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
Change-Id: I10bc973776595779b563b84548d46367bcd0886f
Related-PROD: PROD-28199
diff --git a/cfg_checker/cli/reclass.py b/cfg_checker/cli/reclass.py
index 2959bf3..fc5961a 100644
--- a/cfg_checker/cli/reclass.py
+++ b/cfg_checker/cli/reclass.py
@@ -1,6 +1,67 @@
-from cfg_checker.modules.reclass.comparer import ModelComparer
+import sys
+
+from cfg_checker.common import config, logger, logger_cli
+from cfg_checker.helpers.args_utils import MyParser
+
+from command import execute_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"
+ )
+ 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__":
- # Execute the comparison using argv params
-
- pass
+ cli_reclass()