Unified command execution and unit tests
- All arguments inits moved to own clases
- Added unified way to execute commands
- Unit test structure and very basic tests
- Command line script to test coverage
- Argument parsers moved to corresponding commands
- Automatic parsers and command mapping
Change-Id: Id099d14702d9590729583dfd9574bd57022efac5
Related-PROD: PROD-28199
diff --git a/cfg_checker/cli/reclass.py b/cfg_checker/cli/reclass.py
index fc5961a..24eb8e2 100644
--- a/cfg_checker/cli/reclass.py
+++ b/cfg_checker/cli/reclass.py
@@ -1,67 +1,12 @@
-import sys
-
-from cfg_checker.common import config, logger, logger_cli
-from cfg_checker.helpers.args_utils import MyParser
-
-from command import execute_command
+from command import cli_command
-def init_reclass_parser(_parser):
- # reclass subparsers
- reclass_subparsers = _parser.add_subparsers(dest='type')
- reclass_list_parser = reclass_subparsers.add_parser(
- 'list',
- help="List models available to compare"
+def entrypoint():
+ cli_command(
+ '# Mirantis Cloud Reclass comparer"',
+ 'packages'
)
- reclass_list_parser.add_argument(
- "-p",
- "--models-path",
- default="/srv/salt/",
- help="Global path to search models in"
- )
-
- reclass_diff_parser = reclass_subparsers.add_parser(
- 'diff',
- help="List models available to compare"
- )
- reclass_diff_parser.add_argument(
- "--model1",
- required=True,
- help="Model A <path>. Model name is the folder name"
- )
- reclass_diff_parser.add_argument(
- "--model2",
- required=True,
- help="Model B <path>. Model name is the folder name"
- )
- reclass_diff_parser.add_argument(
- '--html',
- metavar='reclass_html_filename',
- help="HTML filename to save report"
- )
-
- return _parser
-
-
-def cli_reclass():
- net_parser = MyParser("# Mirantis Cloud Reclass comparer")
- init_reclass_parser(net_parser)
-
- # parse arguments
- try:
- args = net_parser.parse_args()
- except TypeError:
- logger_cli.info("\n# Please, check arguments")
- sys.exit(0)
-
- # force use of sudo
- config.ssh_uses_sudo = True
-
- # Execute the command
- result = execute_command(args, 'reclass')
- logger.debug(result)
- sys.exit(result)
if __name__ == "__main__":
- cli_reclass()
+ entrypoint()