Alex Savatieiev | c905571 | 2019-03-01 14:43:56 -0600 | [diff] [blame] | 1 | from cfg_checker.helpers import args_utils |
| 2 | |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 3 | import checker |
| 4 | |
Alex | bab1efe | 2019-04-23 18:51:23 -0500 | [diff] [blame^] | 5 | command_help = "Package versions check (Candidate vs Installed)" |
| 6 | |
| 7 | |
| 8 | def 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 Savatieiev | c905571 | 2019-03-01 14:43:56 -0600 | [diff] [blame] | 34 | |
| 35 | def do_report(args): |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 36 | """Create package versions report, HTML |
Alex Savatieiev | c905571 | 2019-03-01 14:43:56 -0600 | [diff] [blame] | 37 | |
| 38 | :args: - parser arguments |
| 39 | :return: - no return value |
| 40 | """ |
Alex | bab1efe | 2019-04-23 18:51:23 -0500 | [diff] [blame^] | 41 | _type, _filename = args_utils.get_package_report_type_and_filename(args) |
Alex Savatieiev | c905571 | 2019-03-01 14:43:56 -0600 | [diff] [blame] | 42 | |
| 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 Savatieiev | 3db12a7 | 2019-03-22 16:32:31 -0500 | [diff] [blame] | 48 | pChecker.collect_packages() |
Alex Savatieiev | c905571 | 2019-03-01 14:43:56 -0600 | [diff] [blame] | 49 | # report it |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 50 | pChecker.create_report(_filename, rtype=_type, full=args.full) |