365 lines
13 KiB
Diff
365 lines
13 KiB
Diff
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
|