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/network.py b/cfg_checker/cli/network.py
index b53311d..5c5a4e2 100644
--- a/cfg_checker/cli/network.py
+++ b/cfg_checker/cli/network.py
@@ -1,59 +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_network_parser(_parser):
- # network subparser
- net_subparsers = _parser.add_subparsers(dest='type')
-
- net_check_parser = net_subparsers.add_parser(
- 'check',
- help="Do network check and print the result"
+def entrypoint():
+ cli_command(
+ "# Mirantis Cloud Network checker",
+ 'network'
)
- net_check_parser.add_argument(
- '--detailed',
- action="store_true", default=False,
- help="Print error details after summary"
- )
-
- net_report_parser = net_subparsers.add_parser(
- 'report',
- help="Generate network check report"
- )
-
- net_report_parser.add_argument(
- '--html',
- metavar='network_html_filename',
- help="HTML filename to save report"
- )
-
- return _parser
-
-
-def cli_network():
- net_parser = MyParser("# Mirantis Cloud Network checker")
- init_network_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, 'network')
- logger.debug(result)
- sys.exit(result)
-
if __name__ == '__main__':
- cli_network()
+ entrypoint()