savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 1 | import json |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 2 | |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 3 | from cfg_checker.common import const, logger_cli |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 4 | from cfg_checker.common.exception import ConfigException |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 5 | from cfg_checker.helpers.console_utils import Progress |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 6 | from cfg_checker.modules.packages.repos import RepoManager |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 7 | from cfg_checker.nodes import salt_master |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 8 | from cfg_checker.reports import reporter |
| 9 | |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 10 | from versions import DebianVersion, PkgVersions, VersionCmpResult |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 11 | |
| 12 | |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 13 | class CloudPackageChecker(object): |
Alex | e9547d8 | 2019-06-03 15:22:50 -0500 | [diff] [blame^] | 14 | def __init__(self, force_tag=None, exclude_keywords=[]): |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 15 | # Init salt master info |
| 16 | if not salt_master.nodes: |
| 17 | salt_master.nodes = salt_master.get_nodes() |
| 18 | |
| 19 | # check that this env tag is present in Manager |
Alex | 571bf15 | 2019-05-31 16:28:30 -0500 | [diff] [blame] | 20 | self.rm = RepoManager() |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 21 | _tags = self.rm.get_available_tags(tag=salt_master.mcp_release) |
| 22 | if not _tags: |
| 23 | logger_cli.warning( |
| 24 | "\n# hWARNING: '{0}' is not listed in repo index. " |
| 25 | "Consider running:\n\t{1}\nto add info on this tag's " |
| 26 | "release package versions".format( |
| 27 | salt_master.mcp_release, |
| 28 | "mcp-checker packages versions --tag {0}" |
| 29 | ) |
| 30 | ) |
| 31 | |
Alex | e9547d8 | 2019-06-03 15:22:50 -0500 | [diff] [blame^] | 32 | self.force_tag = force_tag |
| 33 | self.exclude_repos_keywords = exclude_keywords |
| 34 | |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 35 | @staticmethod |
| 36 | def presort_packages(all_packages, full=None): |
| 37 | logger_cli.info("-> Presorting packages") |
| 38 | # labels |
| 39 | _data = {} |
| 40 | _data = { |
| 41 | "cs": { |
| 42 | "ok": const.VERSION_OK, |
| 43 | "up": const.VERSION_UP, |
| 44 | "down": const.VERSION_DOWN, |
| 45 | "err": const.VERSION_ERR |
| 46 | }, |
| 47 | "ca": { |
| 48 | "na": const.ACT_NA, |
| 49 | "up": const.ACT_UPGRADE, |
| 50 | "need_up": const.ACT_NEED_UP, |
| 51 | "need_down": const.ACT_NEED_DOWN, |
| 52 | "repo": const.ACT_REPO |
| 53 | } |
| 54 | } |
| 55 | _data['status_err'] = const.VERSION_ERR |
| 56 | _data['status_down'] = const.VERSION_DOWN |
| 57 | |
| 58 | # Presort packages |
| 59 | _data['critical'] = {} |
| 60 | _data['system'] = {} |
| 61 | _data['other'] = {} |
| 62 | _data['unlisted'] = {} |
| 63 | |
| 64 | _l = len(all_packages) |
| 65 | _progress = Progress(_l) |
| 66 | _progress_index = 0 |
| 67 | # counters |
| 68 | _ec = _es = _eo = _eu = 0 |
| 69 | _dc = _ds = _do = _du = 0 |
| 70 | while _progress_index < _l: |
| 71 | # progress bar |
| 72 | _progress_index += 1 |
| 73 | _progress.write_progress(_progress_index) |
| 74 | # sort packages |
| 75 | _pn, _val = all_packages.popitem() |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 76 | _c = _val['desc']['section'] |
| 77 | |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 78 | if not full: |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 79 | # Check if this packet has errors |
| 80 | # if all is ok -> just skip it |
| 81 | _max_status = max(_val['results'].keys()) |
| 82 | if _max_status <= const.VERSION_OK: |
| 83 | _max_action = max(_val['results'][_max_status].keys()) |
| 84 | if _max_action == const.ACT_NA: |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 85 | # this package does not have any comments |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 86 | # ...just skip it from report |
| 87 | continue |
| 88 | |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 89 | if len(_c) > 0 and _val['is_mirantis'] is None: |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 90 | # not listed package in version lib |
| 91 | _data['unlisted'].update({ |
| 92 | _pn: _val |
| 93 | }) |
| 94 | _eu += _val['results'].keys().count(const.VERSION_ERR) |
| 95 | _du += _val['results'].keys().count(const.VERSION_DOWN) |
| 96 | # mirantis/critical |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 97 | # elif len(_c) > 0 and _c != 'System': |
| 98 | elif _val['is_mirantis']: |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 99 | # not blank and not system |
| 100 | _data['critical'].update({ |
| 101 | _pn: _val |
| 102 | }) |
| 103 | _ec += _val['results'].keys().count(const.VERSION_ERR) |
| 104 | _dc += _val['results'].keys().count(const.VERSION_DOWN) |
| 105 | # system |
| 106 | elif _c == 'System': |
| 107 | _data['system'].update({ |
| 108 | _pn: _val |
| 109 | }) |
| 110 | _es += _val['results'].keys().count(const.VERSION_ERR) |
| 111 | _ds += _val['results'].keys().count(const.VERSION_DOWN) |
| 112 | # rest |
| 113 | else: |
| 114 | _data['other'].update({ |
| 115 | _pn: _val |
| 116 | }) |
| 117 | _eo += _val['results'].keys().count(const.VERSION_ERR) |
| 118 | _do += _val['results'].keys().count(const.VERSION_DOWN) |
| 119 | |
Alex | d9fd85e | 2019-05-16 16:58:24 -0500 | [diff] [blame] | 120 | _progress.end() |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 121 | |
| 122 | _data['errors'] = { |
| 123 | 'mirantis': _ec, |
| 124 | 'system': _es, |
| 125 | 'other': _eo, |
| 126 | 'unlisted': _eu |
| 127 | } |
| 128 | _data['downgrades'] = { |
| 129 | 'mirantis': _dc, |
| 130 | 'system': _ds, |
| 131 | 'other': _do, |
| 132 | 'unlisted': _du |
| 133 | } |
| 134 | |
| 135 | return _data |
| 136 | |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 137 | def collect_installed_packages(self): |
| 138 | """ |
| 139 | Collect installed packages on each node |
| 140 | sets 'installed' dict property in the class |
| 141 | |
| 142 | :return: none |
| 143 | """ |
Alex Savatieiev | 42b89fa | 2019-03-07 18:45:26 -0600 | [diff] [blame] | 144 | logger_cli.info("# Collecting installed packages") |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 145 | salt_master.prepare_script_on_active_nodes("pkg_versions.py") |
| 146 | _result = salt_master.execute_script_on_active_nodes("pkg_versions.py") |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 147 | |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 148 | for key in salt_master.nodes.keys(): |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 149 | # due to much data to be passed from salt, it is happening in order |
Alex | e9547d8 | 2019-06-03 15:22:50 -0500 | [diff] [blame^] | 150 | if key in _result and _result[key]: |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 151 | _text = _result[key] |
Alex Savatieiev | fa5910a | 2019-03-18 18:12:24 -0500 | [diff] [blame] | 152 | try: |
| 153 | _dict = json.loads(_text[_text.find('{'):]) |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 154 | except ValueError: |
Alex Savatieiev | fa5910a | 2019-03-18 18:12:24 -0500 | [diff] [blame] | 155 | logger_cli.info("... no JSON for '{}'".format( |
| 156 | key |
| 157 | )) |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 158 | logger_cli.debug( |
| 159 | "ERROR:\n{}\n".format(_text[:_text.find('{')]) |
| 160 | ) |
Alex Savatieiev | fa5910a | 2019-03-18 18:12:24 -0500 | [diff] [blame] | 161 | _dict = {} |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 162 | |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 163 | salt_master.nodes[key]['packages'] = _dict |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 164 | else: |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 165 | salt_master.nodes[key]['packages'] = {} |
Alex Savatieiev | 42b89fa | 2019-03-07 18:45:26 -0600 | [diff] [blame] | 166 | logger_cli.debug("... {} has {} packages installed".format( |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 167 | key, |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 168 | len(salt_master.nodes[key]['packages'].keys()) |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 169 | )) |
Alex Savatieiev | 799bee3 | 2019-02-20 17:19:26 -0600 | [diff] [blame] | 170 | logger_cli.info("-> Done") |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 171 | |
| 172 | def collect_packages(self): |
| 173 | """ |
| 174 | Check package versions in repos vs installed |
| 175 | |
| 176 | :return: no return values, all date put to dict in place |
| 177 | """ |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 178 | # Preload OpenStack release versions |
| 179 | _desc = PkgVersions() |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 180 | logger_cli.info( |
| 181 | "# Cross-comparing: Installed vs Candidates vs Release" |
| 182 | ) |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 183 | # shortcuts for this cloud values |
| 184 | _os = salt_master.openstack_release |
| 185 | _mcp = salt_master.mcp_release |
Alex | e9547d8 | 2019-06-03 15:22:50 -0500 | [diff] [blame^] | 186 | _t = [self.force_tag] if self.force_tag else [] |
| 187 | _t.append(_mcp) |
| 188 | |
| 189 | logger_cli.info("# Tag search list: {}".format(", ".join(_t))) |
| 190 | logger_cli.info("# Openstack version: {}".format(_os)) |
| 191 | logger_cli.info( |
| 192 | "# Release versions repos keyword exclude list: {}".format( |
| 193 | ", ".join(self.exclude_repos_keywords) |
| 194 | ) |
| 195 | ) |
| 196 | |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 197 | # Progress class |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 198 | _progress = Progress(len(salt_master.nodes.keys())) |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 199 | _progress_index = 0 |
| 200 | _total_processed = 0 |
Alex Savatieiev | 3db12a7 | 2019-03-22 16:32:31 -0500 | [diff] [blame] | 201 | # Collect packages from all of the nodes in flat dict |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 202 | _all_packages = {} |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 203 | for node_name, node_value in salt_master.nodes.iteritems(): |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 204 | _uniq_len = len(_all_packages.keys()) |
| 205 | _progress_index += 1 |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 206 | # progress updates shown before next node only |
| 207 | # it is costly operation to do it for each of the 150k packages |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 208 | _progress.write_progress( |
| 209 | _progress_index, |
| 210 | note="/ {} uniq out of {} packages found".format( |
| 211 | _uniq_len, |
| 212 | _total_processed |
| 213 | ) |
| 214 | ) |
Alex Savatieiev | 3db12a7 | 2019-03-22 16:32:31 -0500 | [diff] [blame] | 215 | for _name, _value in node_value['packages'].iteritems(): |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 216 | _total_processed += 1 |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 217 | # Parse versions from nodes |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 218 | _ver_ins = DebianVersion(_value['installed']) |
| 219 | _ver_can = DebianVersion(_value['candidate']) |
| 220 | |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 221 | # Process package description and release version |
| 222 | # at a first sight |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 223 | if _name not in _all_packages: |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 224 | # get node attributes |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 225 | _linux = salt_master.nodes[node_name]['linux_codename'] |
| 226 | _arch = salt_master.nodes[node_name]['linux_arch'] |
Alex | e9547d8 | 2019-06-03 15:22:50 -0500 | [diff] [blame^] | 227 | # get versions for tag, Openstack release and repo headers |
| 228 | # excluding 'nightly' repos by default |
| 229 | _r = {} |
| 230 | # if there is a forced tag = use it |
| 231 | if self.force_tag: |
| 232 | _r = self.rm.get_filtered_versions( |
| 233 | _name, |
| 234 | tag=self.force_tag, |
| 235 | include=[_os, _linux, _arch], |
| 236 | exclude=self.exclude_repos_keywords |
| 237 | ) |
| 238 | # if nothing found, look everywhere |
| 239 | if not _r: |
| 240 | _r = self.rm.get_filtered_versions( |
| 241 | _name, |
| 242 | tag=self.force_tag, |
| 243 | include=[_linux, _arch], |
| 244 | exclude=self.exclude_repos_keywords |
| 245 | ) |
| 246 | # if nothing is found at this point, |
| 247 | # repeat search using normal tags |
| 248 | if not _r: |
| 249 | _r = self.rm.get_filtered_versions( |
| 250 | _name, |
| 251 | tag=_mcp, |
| 252 | include=[_os, _linux, _arch], |
| 253 | exclude=self.exclude_repos_keywords |
| 254 | ) |
| 255 | # Once again, if nothing found, look everywhere |
| 256 | if not _r: |
| 257 | _r = self.rm.get_filtered_versions( |
| 258 | _name, |
| 259 | tag=_mcp, |
| 260 | include=[_linux, _arch], |
| 261 | exclude=self.exclude_repos_keywords |
| 262 | ) |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 263 | # repack versions in flat format |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 264 | _vs = {} |
| 265 | _sections = {} |
| 266 | _apps = {} |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 267 | for s, apps in _r.iteritems(): |
| 268 | for a, versions in apps.iteritems(): |
| 269 | for v, repos in versions.iteritems(): |
| 270 | for repo in repos: |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 271 | if v not in _vs: |
| 272 | _vs[v] = [] |
| 273 | _vs[v].append(repo) |
| 274 | if v not in _sections: |
| 275 | _sections[v] = [] |
| 276 | _sections[v].append(s) |
| 277 | if v not in _apps: |
| 278 | _apps[v] = [] |
| 279 | _apps[v].append(a) |
| 280 | # search for the newest version among filtered |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 281 | _r_desc = [] |
| 282 | _vs_keys = _vs.keys() |
| 283 | if _vs_keys: |
| 284 | _newest = _newest = DebianVersion(_vs_keys.pop()) |
| 285 | else: |
| 286 | _newest = DebianVersion('') |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 287 | for v in _vs_keys: |
| 288 | _this = DebianVersion(v) |
| 289 | if _this > _newest: |
| 290 | _newest = _this |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 291 | _release = _newest |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 292 | # Get best description for the package |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 293 | if _release.version != 'n/a': |
| 294 | _r_desc = _vs[_release.version] |
| 295 | # preload special description |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 296 | if _desc[_name]: |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 297 | _pkg_desc = _desc[_name] |
| 298 | else: |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 299 | _pkg_desc = _desc.dummy_desc |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 300 | # Save repos list and desc for this version |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 301 | # Check if we can provide better from the package |
| 302 | if _release.version != 'n/a': |
| 303 | if not _pkg_desc['section']: |
| 304 | _pkg_desc['section'] = \ |
| 305 | "/".join(_sections[_release.version]) |
| 306 | if not _pkg_desc['app']: |
| 307 | _pkg_desc['app'] = \ |
| 308 | "/".join(_apps[_release.version]) |
Alex | 3ebc563 | 2019-04-18 16:47:18 -0500 | [diff] [blame] | 309 | |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 310 | # Populate package info, once for package |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 311 | _m = _r_desc[0]["maintainer"] if _r_desc else 'n/a' |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 312 | _all_packages[_name] = { |
| 313 | "desc": _pkg_desc, |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 314 | "repos": _r_desc, |
| 315 | "maintainer": _m, |
| 316 | "is_mirantis": self.rm.is_mirantis( |
| 317 | _name, |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 318 | tag=_mcp |
Alex | d0391d4 | 2019-05-21 18:48:55 -0500 | [diff] [blame] | 319 | ), |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 320 | "results": {}, |
| 321 | "r": _release, |
Alex Savatieiev | 3db12a7 | 2019-03-22 16:32:31 -0500 | [diff] [blame] | 322 | } |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 323 | # Cross-compare versions |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 324 | _cmp = VersionCmpResult( |
| 325 | _ver_ins, |
| 326 | _ver_can, |
| 327 | _all_packages[_name]['r'] |
| 328 | ) |
Alex | cf91b18 | 2019-05-31 11:57:07 -0500 | [diff] [blame] | 329 | # Update results structure |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 330 | # shortcut to results |
| 331 | _res = _all_packages[_name]['results'] |
| 332 | # update status |
| 333 | if _cmp.status not in _res: |
| 334 | _res[_cmp.status] = {} |
| 335 | # update action |
| 336 | if _cmp.action not in _res[_cmp.status]: |
| 337 | _res[_cmp.status][_cmp.action] = {} |
| 338 | # update node |
| 339 | if node_name not in _res[_cmp.status][_cmp.action]: |
| 340 | _res[_cmp.status][_cmp.action][node_name] = {} |
| 341 | # put result |
| 342 | _res[_cmp.status][_cmp.action][node_name] = { |
| 343 | 'i': _ver_ins, |
| 344 | 'c': _ver_can, |
| 345 | 'res': _cmp, |
| 346 | 'raw': _value['raw'] |
| 347 | } |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 348 | |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 349 | self._packages = _all_packages |
Alex | d9fd85e | 2019-05-16 16:58:24 -0500 | [diff] [blame] | 350 | _progress.end() |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 351 | |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 352 | def create_report(self, filename, rtype, full=None): |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 353 | """ |
| 354 | Create static html showing packages diff per node |
| 355 | |
| 356 | :return: buff with html |
| 357 | """ |
Alex Savatieiev | 42b89fa | 2019-03-07 18:45:26 -0600 | [diff] [blame] | 358 | logger_cli.info("# Generating report to '{}'".format(filename)) |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 359 | if rtype == 'html': |
| 360 | _type = reporter.HTMLPackageCandidates() |
| 361 | elif rtype == 'csv': |
| 362 | _type = reporter.CSVAllPackages() |
| 363 | else: |
| 364 | raise ConfigException("Report type not set") |
Alex Savatieiev | d48994d | 2018-12-13 12:13:00 +0100 | [diff] [blame] | 365 | _report = reporter.ReportToFile( |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 366 | _type, |
savex | 4448e13 | 2018-04-25 15:51:14 +0200 | [diff] [blame] | 367 | filename |
| 368 | ) |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 369 | payload = { |
Alex | e0c5b9e | 2019-04-23 18:51:23 -0500 | [diff] [blame] | 370 | "nodes": salt_master.nodes, |
| 371 | "mcp_release": salt_master.mcp_release, |
| 372 | "openstack_release": salt_master.openstack_release |
Alex | 4148552 | 2019-04-12 17:26:18 -0500 | [diff] [blame] | 373 | } |
| 374 | payload.update(self.presort_packages(self._packages, full)) |
| 375 | _report(payload) |
Alex Savatieiev | 799bee3 | 2019-02-20 17:19:26 -0600 | [diff] [blame] | 376 | logger_cli.info("-> Done") |