| 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_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" |
| ) |
| |
| 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() |