@@ -1,15 +1,7 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
(python3.withPackages (
|
||||
python-pkgs: with python-pkgs; [
|
||||
pip
|
||||
numpy
|
||||
pandas
|
||||
python-dotenv
|
||||
requests
|
||||
]
|
||||
))
|
||||
(python3.withPackages (python-pkgs: with python-pkgs; [ pip ]))
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
|
@@ -0,0 +1,8 @@
|
||||
{
|
||||
user ? throw "user argument is required",
|
||||
home ? throw "home argument is required",
|
||||
}:
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
home-manager.users.${user}.home.packages = [ (pkgs.callPackage ./package.nix { }) ];
|
||||
}
|
@@ -0,0 +1,364 @@
|
||||
diff --git a/.gitignore b/.gitignore
|
||||
index 07ae204..28e5e8a 100644
|
||||
--- a/.gitignore
|
||||
+++ b/.gitignore
|
||||
@@ -11,6 +11,8 @@
|
||||
*.pyo
|
||||
*.sa
|
||||
*.so
|
||||
+*.eggs
|
||||
+*.__pycache__/
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
@@ -43,4 +45,4 @@ Thumbs.db
|
||||
/bin/
|
||||
build
|
||||
docker
|
||||
-/**/.pytest_cache/
|
||||
\ No newline at end of file
|
||||
+/**/.pytest_cache/
|
||||
diff --git a/deployment_report/templates/__init__.py b/deployment_report/templates/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/ldap_validator/library/__init__.py b/ldap_validator/library/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/ldap_validator/library/utils/__init__.py b/ldap_validator/library/utils/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/pre_install_report/templates/__init__.py b/pre_install_report/templates/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
||||
diff --git a/setup.cfg b/setup.cfg
|
||||
index 1c80cb2..4ffdef1 100644
|
||||
--- a/setup.cfg
|
||||
+++ b/setup.cfg
|
||||
@@ -2,7 +2,11 @@
|
||||
name = viya4-ark
|
||||
author = SAS Institute Inc.
|
||||
summary = The SAS Viya Administration Resource Kit (SAS Viya ARK) provides tools and utilities to help SAS customers prepare for and gather information about a SAS Viya platform deployment.
|
||||
-description-file = README.md
|
||||
-description-content-type = text/markdown
|
||||
-home-page = https://github.com/sassoftware/viya4-ark
|
||||
+description_file = README.md
|
||||
+description_content_type = text/markdown
|
||||
+home_page = https://github.com/sassoftware/viya4-ark
|
||||
license = Apache-2.0
|
||||
+
|
||||
+[options.entry_points]
|
||||
+console_scripts =
|
||||
+ viya4-ark = viya4_ark:main
|
||||
diff --git a/setup.py b/setup.py
|
||||
index d3dd4f5..05cbeb7 100644
|
||||
--- a/setup.py
|
||||
+++ b/setup.py
|
||||
@@ -14,10 +14,14 @@
|
||||
|
||||
from setuptools import find_packages, setup
|
||||
|
||||
+packages = find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"])
|
||||
+
|
||||
setup(
|
||||
- setup_requires=["pbr"],
|
||||
- pbr=True,
|
||||
- licenses_files=["LICENSE"],
|
||||
- packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
|
||||
+ setup_requires=[],
|
||||
+ license_files=["LICENSE"],
|
||||
+ py_modules=["viya4_ark"],
|
||||
+ packages=packages,
|
||||
+ include_package_data=True,
|
||||
+ package_data={package: ["*"] for package in packages},
|
||||
python_requires=">=3.6",
|
||||
)
|
||||
diff --git a/viya-ark.py b/viya-ark.py
|
||||
deleted file mode 100644
|
||||
index 7626a89..0000000
|
||||
--- a/viya-ark.py
|
||||
+++ /dev/null
|
||||
@@ -1,139 +0,0 @@
|
||||
-####################################################################
|
||||
-# ### viya-ark.py ###
|
||||
-####################################################################
|
||||
-# ### Author: SAS Institute Inc. ###
|
||||
-####################################################################
|
||||
-# ###
|
||||
-# Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA. ###
|
||||
-# All Rights Reserved. ###
|
||||
-# SPDX-License-Identifier: Apache-2.0 ###
|
||||
-# ###
|
||||
-####################################################################
|
||||
-
|
||||
-import importlib
|
||||
-import inspect
|
||||
-import os
|
||||
-import pkgutil
|
||||
-import sys
|
||||
-
|
||||
-from viya_ark_library.command import Command
|
||||
-
|
||||
-# command line options #
|
||||
-_HELP_SHORT_OPT_ = "h"
|
||||
-_HELP_LONG_OPT_ = "help"
|
||||
-
|
||||
-# return codes #
|
||||
-_SUCCESS_RC_ = 0
|
||||
-_BAD_OPT_RC_ = 1
|
||||
-
|
||||
-
|
||||
-################
|
||||
-# Main #
|
||||
-################
|
||||
-def main(argv: list):
|
||||
- """
|
||||
- The main executable method for the viya-ark launcher script.
|
||||
-
|
||||
- :param argv: The list of arguments passed at invocation.
|
||||
- """
|
||||
- try:
|
||||
- # get the requested command value #
|
||||
- command_name = argv[0]
|
||||
-
|
||||
- # print the usage and exit, if requested #
|
||||
- if command_name in (f"-{_HELP_SHORT_OPT_}", f"--{_HELP_LONG_OPT_}"):
|
||||
- usage(_SUCCESS_RC_)
|
||||
-
|
||||
- # convert any dashes in the given command to underscores to align with Pythonic package/module standards #
|
||||
- command_module_name = command_name.replace("-", "_")
|
||||
-
|
||||
- # attempt to import the requested command module #
|
||||
- imported_module = None
|
||||
- try:
|
||||
- imported_module = importlib.import_module(f"{command_module_name}.{command_module_name}")
|
||||
- except ModuleNotFoundError:
|
||||
- print()
|
||||
- print(f"ERROR: Command [{command_name}] not found.")
|
||||
- usage(_BAD_OPT_RC_)
|
||||
-
|
||||
- # find any attributes in the module that implement the Command class using reflection #
|
||||
- command = None
|
||||
- for attribute_name in dir(imported_module):
|
||||
- # get the current module attribute by name #
|
||||
- attribute = getattr(imported_module, attribute_name)
|
||||
-
|
||||
- # if the attribute is: #
|
||||
- # (1) a class -AND- #
|
||||
- # (2) a subclass of Command -AND- #
|
||||
- # (3) not abstract #
|
||||
- # then the attribute defines a command for the project. #
|
||||
- if inspect.isclass(attribute) and issubclass(attribute, Command) and not inspect.isabstract(attribute):
|
||||
- command = attribute
|
||||
- # the Command implementation was found, the loop can break #
|
||||
- break
|
||||
-
|
||||
- if command is not None:
|
||||
- # call the Command's run() method to delegate execution to the module, pass all relevant arguments #
|
||||
- command.run(argv[1:])
|
||||
- else:
|
||||
- # if a Command implementation wasn't found, print the usage message #
|
||||
- print()
|
||||
- print(f"ERROR: Command [{command_name}] not found.")
|
||||
- usage(_BAD_OPT_RC_)
|
||||
-
|
||||
- except IndexError:
|
||||
- # if the launcher script wasn't given enough args, print the usage #
|
||||
- print()
|
||||
- print("ERROR: A command must be provided.")
|
||||
- usage(_BAD_OPT_RC_)
|
||||
-
|
||||
-
|
||||
-#################
|
||||
-# Usage #
|
||||
-#################
|
||||
-def usage(exit_code: int):
|
||||
- """
|
||||
- Prints the usage statement for the viya-ark launcher script and exits with the provided exit_code.
|
||||
-
|
||||
- :param exit_code: The code to return upon exit.
|
||||
- """
|
||||
- commands = list()
|
||||
-
|
||||
- # walk through all packages parallel to this script #
|
||||
- paths = [os.path.realpath(os.path.dirname(__file__))]
|
||||
- for importer, name, is_package in pkgutil.walk_packages(path=paths):
|
||||
- # skip any objects that are packages (i.e. not modules) #
|
||||
- if not is_package:
|
||||
- # import the current module #
|
||||
- try:
|
||||
- importlib.import_module(name)
|
||||
- except ModuleNotFoundError as e:
|
||||
- # ignore any issues importing pytest, raise any other module import errors
|
||||
- if e.name != "pytest":
|
||||
- raise e
|
||||
-
|
||||
- for subclass in Command.__subclasses__():
|
||||
- # create a tuple of command details by calling the command_name() and command_desc() methods #
|
||||
- command_details = (subclass().command_name(), subclass().command_desc())
|
||||
- # add the command details to the list of discovered commands #
|
||||
- commands.append(command_details)
|
||||
-
|
||||
- # print the commands as well as the static help command to stdout #
|
||||
- print()
|
||||
- print(f"Usage: {os.path.basename(__file__)} <command> [options]")
|
||||
- print()
|
||||
- print("Commands:")
|
||||
- for command in commands:
|
||||
- print(" {:<30} {}".format(command[0], command[1]))
|
||||
- help_cmd_display = f"-{_HELP_SHORT_OPT_}, --{_HELP_LONG_OPT_}"
|
||||
- print(" {:<30} {}".format(help_cmd_display, "Display usage for viya-ark."))
|
||||
- print()
|
||||
-
|
||||
- sys.exit(exit_code)
|
||||
-
|
||||
-
|
||||
-##################
|
||||
-# __main__ #
|
||||
-##################
|
||||
-if __name__ == "__main__":
|
||||
- main(sys.argv[1:])
|
||||
diff --git a/viya4_ark.py b/viya4_ark.py
|
||||
new file mode 100644
|
||||
index 0000000..1af3b79
|
||||
--- /dev/null
|
||||
+++ b/viya4_ark.py
|
||||
@@ -0,0 +1,136 @@
|
||||
+####################################################################
|
||||
+# ### main.py ###
|
||||
+####################################################################
|
||||
+# ### Author: SAS Institute Inc. ###
|
||||
+####################################################################
|
||||
+# ###
|
||||
+# Copyright (c) 2020, SAS Institute Inc., Cary, NC, USA. ###
|
||||
+# All Rights Reserved. ###
|
||||
+# SPDX-License-Identifier: Apache-2.0 ###
|
||||
+# ###
|
||||
+####################################################################
|
||||
+
|
||||
+import importlib
|
||||
+import inspect
|
||||
+import os
|
||||
+import pkgutil
|
||||
+import sys
|
||||
+
|
||||
+from viya_ark_library.command import Command
|
||||
+
|
||||
+# command line options #
|
||||
+_HELP_SHORT_OPT_ = "h"
|
||||
+_HELP_LONG_OPT_ = "help"
|
||||
+
|
||||
+# return codes #
|
||||
+_SUCCESS_RC_ = 0
|
||||
+_BAD_OPT_RC_ = 1
|
||||
+
|
||||
+
|
||||
+################
|
||||
+# Main #
|
||||
+################
|
||||
+def main():
|
||||
+ """
|
||||
+ The main executable method for the viya-ark launcher script.
|
||||
+ """
|
||||
+ argv = sys.argv[1:]
|
||||
+
|
||||
+ if len(argv) == 0:
|
||||
+ print("ERROR: A command must be provided.")
|
||||
+ usage(_BAD_OPT_RC_)
|
||||
+
|
||||
+ command_name = argv[0]
|
||||
+
|
||||
+ # print the usage and exit, if requested #
|
||||
+ if command_name in (f"-{_HELP_SHORT_OPT_}", f"--{_HELP_LONG_OPT_}"):
|
||||
+ usage(_SUCCESS_RC_)
|
||||
+
|
||||
+ # convert any dashes in the given command to underscores to align with Pythonic package/module standards #
|
||||
+ command_module_name = command_name.replace("-", "_")
|
||||
+
|
||||
+ # attempt to import the requested command module #
|
||||
+ imported_module = None
|
||||
+ try:
|
||||
+ imported_module = importlib.import_module(f"{command_module_name}.{command_module_name}")
|
||||
+ except ModuleNotFoundError:
|
||||
+ print()
|
||||
+ print(f"ERROR: Command [{command_name}] not found.")
|
||||
+ usage(_BAD_OPT_RC_)
|
||||
+
|
||||
+ # find any attributes in the module that implement the Command class using reflection #
|
||||
+ command = None
|
||||
+ for attribute_name in dir(imported_module):
|
||||
+ # get the current module attribute by name #
|
||||
+ attribute = getattr(imported_module, attribute_name)
|
||||
+
|
||||
+ # if the attribute is: #
|
||||
+ # (1) a class -AND- #
|
||||
+ # (2) a subclass of Command -AND- #
|
||||
+ # (3) not abstract #
|
||||
+ # then the attribute defines a command for the project. #
|
||||
+ if inspect.isclass(attribute) and issubclass(attribute, Command) and not inspect.isabstract(attribute):
|
||||
+ command = attribute
|
||||
+ # the Command implementation was found, the loop can break #
|
||||
+ break
|
||||
+
|
||||
+ if command is not None:
|
||||
+ # call the Command's run() method to delegate execution to the module, pass all relevant arguments #
|
||||
+ command.run(argv[1:])
|
||||
+ else:
|
||||
+ # if a Command implementation wasn't found, print the usage message #
|
||||
+ print()
|
||||
+ print(f"ERROR: Command [{command_name}] not found.")
|
||||
+ usage(_BAD_OPT_RC_)
|
||||
+
|
||||
+
|
||||
+#################
|
||||
+# Usage #
|
||||
+#################
|
||||
+def usage(exit_code: int):
|
||||
+ """
|
||||
+ Prints the usage statement for the viya-ark launcher script and exits with the provided exit_code.
|
||||
+
|
||||
+ :param exit_code: The code to return upon exit.
|
||||
+ """
|
||||
+ commands = list()
|
||||
+
|
||||
+ # walk through all packages parallel to this script #
|
||||
+ paths = [os.path.realpath(os.path.dirname(__file__))]
|
||||
+ for importer, name, is_package in pkgutil.walk_packages(path=paths):
|
||||
+ # skip any objects that are packages (i.e. not modules) #
|
||||
+ if is_package:
|
||||
+ continue
|
||||
+
|
||||
+ try:
|
||||
+ importlib.import_module(name)
|
||||
+ except ModuleNotFoundError as e:
|
||||
+ # ignore any issues importing pytest, raise any other module import errors
|
||||
+ if e.name != "pytest":
|
||||
+ raise e
|
||||
+
|
||||
+ for subclass in Command.__subclasses__():
|
||||
+ # create a tuple of command details by calling the command_name() and command_desc() methods #
|
||||
+ command_details = (subclass().command_name(), subclass().command_desc())
|
||||
+ # add the command details to the list of discovered commands #
|
||||
+ commands.append(command_details)
|
||||
+
|
||||
+ # print the commands as well as the static help command to stdout #
|
||||
+ print()
|
||||
+ print(f"Usage: {os.path.basename(__file__)} <command> [options]")
|
||||
+ print()
|
||||
+ print("Commands:")
|
||||
+ for command in commands:
|
||||
+ print(" {:<30} {}".format(command[0], command[1]))
|
||||
+ help_cmd_display = f"-{_HELP_SHORT_OPT_}, --{_HELP_LONG_OPT_}"
|
||||
+ print(" {:<30} {}".format(help_cmd_display, "Display usage for viya-ark."))
|
||||
+ print()
|
||||
+
|
||||
+ sys.exit(exit_code)
|
||||
+
|
||||
+
|
||||
+##################
|
||||
+# __main__ #
|
||||
+##################
|
||||
+if __name__ == "__main__":
|
||||
+ main()
|
||||
diff --git a/viya_ark_library/templates/__init__.py b/viya_ark_library/templates/__init__.py
|
||||
new file mode 100644
|
||||
index 0000000..e69de29
|
@@ -0,0 +1,25 @@
|
||||
{ pkgs, ... }:
|
||||
pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "viya4-ark";
|
||||
version = "2.0.2";
|
||||
|
||||
src = fetchGit {
|
||||
url = "git@github.com:sassoftware/viya4-ark.git";
|
||||
ref = "main";
|
||||
rev = "6a7864cd25c39c2ba1e06adbbd94ecebf9a5e3bf";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./fix-setup.patch
|
||||
./remove-kubeconfig-check.patch
|
||||
];
|
||||
|
||||
propagatedBuildInputs = with pkgs.python3Packages; [
|
||||
jinja2
|
||||
pint
|
||||
requests
|
||||
pyyaml
|
||||
ldap3
|
||||
semantic-version
|
||||
];
|
||||
}
|
@@ -0,0 +1,96 @@
|
||||
diff --git a/pre_install_report/library/pre_install_check.py b/pre_install_report/library/pre_install_check.py
|
||||
index 31b66d8..88a2d96 100644
|
||||
--- a/pre_install_report/library/pre_install_check.py
|
||||
+++ b/pre_install_report/library/pre_install_check.py
|
||||
@@ -218,21 +218,6 @@ class ViyaPreInstallCheck():
|
||||
output_dir)
|
||||
return
|
||||
|
||||
- def _read_environment_var(self, env_var):
|
||||
- """
|
||||
- This method verifies that the KUBECONFIG environment variable is set.
|
||||
-
|
||||
- :param env_var: Environment variable to check
|
||||
- """
|
||||
- try:
|
||||
- value_env_var = os.environ[env_var]
|
||||
- except Exception:
|
||||
- self.logger.exception("CalledProcessorError")
|
||||
- print(viya_messages.KUBECONF_ERROR)
|
||||
- sys.exit(viya_messages.BAD_ENV_RC_)
|
||||
-
|
||||
- return value_env_var
|
||||
-
|
||||
def _get_nested_info(self, nested_nodes, extracted_nodes, search_key):
|
||||
|
||||
try:
|
||||
diff --git a/pre_install_report/pre_install_report.py b/pre_install_report/pre_install_report.py
|
||||
index 1379c43..54fbc7e 100644
|
||||
--- a/pre_install_report/pre_install_report.py
|
||||
+++ b/pre_install_report/pre_install_report.py
|
||||
@@ -74,24 +74,6 @@ def _read_config_file(filename):
|
||||
sys.exit(viya_messages.SET_LIMTS_ERROR_RC_)
|
||||
|
||||
|
||||
-def read_environment_var(env_var):
|
||||
- """
|
||||
- This method verifies that the KUBECONFIG environment variable is set.
|
||||
-
|
||||
- :param env_var: Environment variable to check
|
||||
- """
|
||||
- try:
|
||||
- value_env_var = os.environ[env_var]
|
||||
- # Check if specified file exists
|
||||
- if not os.path.exists(value_env_var):
|
||||
- print(viya_messages.KUBECONF_FILE_ERROR.format(value_env_var))
|
||||
- sys.exit(viya_messages.BAD_ENV_RC_)
|
||||
- except Exception:
|
||||
- print(viya_messages.KUBECONF_ERROR)
|
||||
- sys.exit(viya_messages.BAD_ENV_RC_)
|
||||
- return value_env_var
|
||||
-
|
||||
-
|
||||
class PreInstallReportCommand(Command):
|
||||
"""
|
||||
Command implementation for the pre-install command to register
|
||||
@@ -198,7 +180,6 @@ def main(argv):
|
||||
|
||||
sas_logger = ViyaARKLogger(report_log_path, logging_level=logging_level, logger_name="pre_install_logger")
|
||||
logger = sas_logger.get_logger()
|
||||
- read_environment_var('KUBECONFIG')
|
||||
|
||||
try:
|
||||
kubectl = Kubectl(namespace=name_space)
|
||||
diff --git a/pre_install_report/test/test_pre_install_report.py b/pre_install_report/test/test_pre_install_report.py
|
||||
index ed805ec..f93ec58 100644
|
||||
--- a/pre_install_report/test/test_pre_install_report.py
|
||||
+++ b/pre_install_report/test/test_pre_install_report.py
|
||||
@@ -25,7 +25,6 @@ from pre_install_report.library.pre_install_check import ViyaPreInstallCheck
|
||||
from pre_install_report.library.pre_install_check_permissions import PreCheckPermissions
|
||||
from viya_ark_library.jinja2.sas_jinja2 import Jinja2TemplateRenderer
|
||||
from viya_ark_library.logging import ViyaARKLogger
|
||||
-from pre_install_report.pre_install_report import read_environment_var
|
||||
from pre_install_report.library.utils import viya_messages
|
||||
|
||||
_SUCCESS_RC_ = 0
|
||||
@@ -548,20 +547,6 @@ def test_get_calculated_aggregate_memory():
|
||||
assert str(round(total_calc_memoryGi.to('Gi'), 13)) == '62.5229606628418 Gi'
|
||||
|
||||
|
||||
-def test_kubconfig_file():
|
||||
- old_kubeconfig = os.environ.get('KUBECONFIG') # /Users/cat/doc
|
||||
- os.environ['KUBECONFIG'] = 'blah_nonexistentfile_blah'
|
||||
- new_kubeconfig = os.environ.get('KUBECONFIG') # /Users/cat/doc
|
||||
- assert new_kubeconfig == 'blah_nonexistentfile_blah'
|
||||
- try:
|
||||
- read_environment_var('KUBECONFIG')
|
||||
- except SystemExit as exc:
|
||||
- assert exc.code == viya_messages.BAD_ENV_RC_
|
||||
- pass
|
||||
- finally:
|
||||
- os.environ['KUBECONFIG'] = str(old_kubeconfig)
|
||||
-
|
||||
-
|
||||
def test_validated_k8s_server_version():
|
||||
|
||||
vpc = createViyaPreInstallCheck(viya_k8s_version_min,
|
@@ -83,6 +83,7 @@ in
|
||||
(import ./configs/gui/vscode { inherit user home; })
|
||||
|
||||
# Private Imports
|
||||
(import ./configs/console/viya-ark { inherit user home; })
|
||||
(import ./configs/console/viya-orders-cli { inherit user home; })
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user