Alex | 265f45e | 2019-04-23 18:51:23 -0500 | [diff] [blame^] | 1 | import sys |
| 2 | |
| 3 | from cfg_checker.common import config, logger, logger_cli |
| 4 | from cfg_checker.helpers.args_utils import MyParser |
| 5 | |
| 6 | from command import execute_command |
| 7 | |
| 8 | |
| 9 | def init_reclass_parser(_parser): |
| 10 | # reclass subparsers |
| 11 | reclass_subparsers = _parser.add_subparsers(dest='type') |
| 12 | reclass_list_parser = reclass_subparsers.add_parser( |
| 13 | 'list', |
| 14 | help="List models available to compare" |
| 15 | ) |
| 16 | reclass_list_parser.add_argument( |
| 17 | "-p", |
| 18 | "--models-path", |
| 19 | default="/srv/salt/", |
| 20 | help="Global path to search models in" |
| 21 | ) |
| 22 | |
| 23 | reclass_diff_parser = reclass_subparsers.add_parser( |
| 24 | 'diff', |
| 25 | help="List models available to compare" |
| 26 | ) |
| 27 | reclass_diff_parser.add_argument( |
| 28 | "--model1", |
| 29 | required=True, |
| 30 | help="Model A <path>. Model name is the folder name" |
| 31 | ) |
| 32 | reclass_diff_parser.add_argument( |
| 33 | "--model2", |
| 34 | required=True, |
| 35 | help="Model B <path>. Model name is the folder name" |
| 36 | ) |
| 37 | reclass_diff_parser.add_argument( |
| 38 | '--html', |
| 39 | metavar='reclass_html_filename', |
| 40 | help="HTML filename to save report" |
| 41 | ) |
| 42 | |
| 43 | return _parser |
| 44 | |
| 45 | |
| 46 | def cli_reclass(): |
| 47 | net_parser = MyParser("# Mirantis Cloud Reclass comparer") |
| 48 | init_reclass_parser(net_parser) |
| 49 | |
| 50 | # parse arguments |
| 51 | try: |
| 52 | args = net_parser.parse_args() |
| 53 | except TypeError: |
| 54 | logger_cli.info("\n# Please, check arguments") |
| 55 | sys.exit(0) |
| 56 | |
| 57 | # force use of sudo |
| 58 | config.ssh_uses_sudo = True |
| 59 | |
| 60 | # Execute the command |
| 61 | result = execute_command(args, 'reclass') |
| 62 | logger.debug(result) |
| 63 | sys.exit(result) |
| 64 | |
Alex Savatieiev | c905571 | 2019-03-01 14:43:56 -0600 | [diff] [blame] | 65 | |
| 66 | if __name__ == "__main__": |
Alex | 265f45e | 2019-04-23 18:51:23 -0500 | [diff] [blame^] | 67 | cli_reclass() |