blob: a4a81bd6ca87bd7f737f9f9d25673727d48e2e89 [file] [log] [blame]
Alex Savatieievc9055712019-03-01 14:43:56 -06001from cfg_checker.helpers import args_utils
2
Alex3ebc5632019-04-18 16:47:18 -05003import checker
4
Alexbab1efe2019-04-23 18:51:23 -05005command_help = "Package versions check (Candidate vs Installed)"
6
7
8def init_parser(_parser):
9 # packages subparser
10 pkg_subparsers = _parser.add_subparsers(dest='type')
11
12 pkg_report_parser = pkg_subparsers.add_parser(
13 'report',
14 help="Report package versions to HTML file"
15 )
16 pkg_report_parser.add_argument(
17 '--full',
18 action="store_true", default=False,
19 help="HTML report will have all of the packages, not just errors"
20 )
21 pkg_report_parser.add_argument(
22 '--html',
23 metavar='packages_html_filename',
24 help="HTML filename to save report"
25 )
26 pkg_report_parser.add_argument(
27 '--csv',
28 metavar='packages_csv_filename',
29 help="CSV filename to save report"
30 )
31
32 return _parser
33
Alex Savatieievc9055712019-03-01 14:43:56 -060034
35def do_report(args):
Alex41485522019-04-12 17:26:18 -050036 """Create package versions report, HTML
Alex Savatieievc9055712019-03-01 14:43:56 -060037
38 :args: - parser arguments
39 :return: - no return value
40 """
Alexbab1efe2019-04-23 18:51:23 -050041 _type, _filename = args_utils.get_package_report_type_and_filename(args)
Alex Savatieievc9055712019-03-01 14:43:56 -060042
43 # init connection to salt and collect minion data
44 pChecker = checker.CloudPackageChecker()
45 # collect data on installed packages
46 pChecker.collect_installed_packages()
47 # diff installed and candidates
Alex Savatieiev3db12a72019-03-22 16:32:31 -050048 pChecker.collect_packages()
Alex Savatieievc9055712019-03-01 14:43:56 -060049 # report it
Alex41485522019-04-12 17:26:18 -050050 pChecker.create_report(_filename, rtype=_type, full=args.full)