| 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_package_parser(_parser): |
| # packages subparser |
| pkg_subparsers = _parser.add_subparsers(dest='type') |
| |
| pkg_report_parser = pkg_subparsers.add_parser( |
| 'report', |
| help="Report package versions to HTML file" |
| ) |
| pkg_report_parser.add_argument( |
| '--full', |
| action="store_true", default=False, |
| help="HTML report will have all of the packages, not just errors" |
| ) |
| pkg_report_parser.add_argument( |
| '--html', |
| metavar='packages_html_filename', |
| help="HTML filename to save report" |
| ) |
| pkg_report_parser.add_argument( |
| '--csv', |
| metavar='packages_csv_filename', |
| help="CSV filename to save report" |
| ) |
| |
| return _parser |
| |
| |
| def cli_package(): |
| pkg_parser = MyParser("# Mirantis Cloud Package checker") |
| init_package_parser(pkg_parser) |
| |
| # parse arguments |
| try: |
| args = pkg_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, 'packages') |
| logger.debug(result) |
| sys.exit(result) |
| |
| |
| if __name__ == '__main__': |
| cli_package() |