Regression fixes for command execution
Change-Id: I8591a206268b7afcb8f561f2eab4fc21b2172fc1
Related-PROD: PROD-28199
diff --git a/cfg_checker/modules/packages/checker.py b/cfg_checker/modules/packages/checker.py
index bf192f9..83ecc94 100644
--- a/cfg_checker/modules/packages/checker.py
+++ b/cfg_checker/modules/packages/checker.py
@@ -188,9 +188,6 @@
_total_processed = 0
# Collect packages from all of the nodes in flat dict
_all_packages = {}
- _all_tags = set([])
- # get env tag's year and major version
- _tag_major = _mcp[:_mcp.find('.', _mcp.find('.')+1)]
for node_name, node_value in salt_master.nodes.iteritems():
_uniq_len = len(_all_packages.keys())
_progress_index += 1
@@ -205,66 +202,54 @@
)
for _name, _value in node_value['packages'].iteritems():
_total_processed += 1
- # Parse versions
+ # Parse versions from nodes
_ver_ins = DebianVersion(_value['installed'])
_ver_can = DebianVersion(_value['candidate'])
- # All packages list with version and node list
+ # Process package description and release version
+ # at a first sight
if _name not in _all_packages:
- # get repo versions list,
+ # get node attributes
_linux = salt_master.nodes[node_name]['linux_codename']
_arch = salt_master.nodes[node_name]['linux_arch']
- if _name == u'qemu-block-extra':
- a = 1
- # omit tag as target versions might be of different tag
+ # get versions for this tag and repo headers
+ # excluding 'nightly' repos
_r = self.rm.get_filtered_versions(
_name,
tag=_mcp,
include=[_os, _linux, _arch],
exclude=["nightly"]
)
- # save versions for matching major tags
+ # repack versions in flat format
_vs = {}
_sections = {}
_apps = {}
- # get all versions for this year
for s, apps in _r.iteritems():
for a, versions in apps.iteritems():
for v, repos in versions.iteritems():
for repo in repos:
- t = repo['tag']
- _major = t[:t.find('.', t.find('.')+1)]
- if _tag_major == _major:
- if v not in _vs:
- _vs[v] = []
- _vs[v].append(repo)
- if v not in _sections:
- _sections[v] = []
- _sections[v].append(s)
- if v not in _apps:
- _apps[v] = []
- _apps[v].append(a)
-
- # check if we have candidate version among found
+ if v not in _vs:
+ _vs[v] = []
+ _vs[v].append(repo)
+ if v not in _sections:
+ _sections[v] = []
+ _sections[v].append(s)
+ if v not in _apps:
+ _apps[v] = []
+ _apps[v].append(a)
+ # search for the newest version among filtered
_r_desc = []
_vs_keys = _vs.keys()
if _vs_keys:
_newest = _newest = DebianVersion(_vs_keys.pop())
else:
_newest = DebianVersion('')
- # if _ver_ins.version in _vs_keys:
- # # exact match, save it
- # _release = _ver_ins
- # else:
- # detect newest version among saved
-
for v in _vs_keys:
_this = DebianVersion(v)
if _this > _newest:
_newest = _this
- # newest version for the YEAR.MAJOR will be the release
_release = _newest
- # save repos list for this version
+ # Get best description for the package
if _release.version != 'n/a':
_r_desc = _vs[_release.version]
# preload special description
@@ -272,6 +257,7 @@
_pkg_desc = _desc[_name]
else:
_pkg_desc = _desc.dummy_desc
+ # Save repos list and desc for this version
# Check if we can provide better from the package
if _release.version != 'n/a':
if not _pkg_desc['section']:
@@ -281,49 +267,7 @@
_pkg_desc['app'] = \
"/".join(_apps[_release.version])
- # get specific set for this OS release if present
- # if not, try search in all repos for this tag
- # _r_desc = _r[_newest.version]
- # if _r:
- # _vs = _r.keys()
- # if len(_vs) > 1:
- # # search best match
- # _release = None
- # for _v in _vs:
- # _deb = DebianVersion(_v)
- # if _ver_can == _deb:
- # _release = _deb
- # _r_desc = _r[_v]
- # break
- # if not _release:
- # _progress.clearline()
- # logger_cli.error(
- # "# ERROR: No release version found "
- # "for '{}'".format(_name)
- # )
- # _release = DebianVersion('')
- # else:
- # _release = DebianVersion(_vs[0])
- # _r_desc = _r[_vs[0]]
- # else:
- # # not found... 99% that it will not happen
- # _release = DebianVersion('')
-
- # Old versions match routine
- # ########
- # if _os in _vers:
- # _v = _vers[_os]
- # elif 'any' in _vers:
- # _v = _vers['any']
- # else:
- # _v = {}
-
- # Finally, get specific version
- # _release = DebianVersion(_v[_mcp] if _mcp in _v else '')
- for repo in _r_desc:
- _all_tags.add(repo['tag'])
-
- # Populate package info
+ # Populate package info, once for package
_m = _r_desc[0]["maintainer"] if _r_desc else 'n/a'
_all_packages[_name] = {
"desc": _pkg_desc,
@@ -331,18 +275,18 @@
"maintainer": _m,
"is_mirantis": self.rm.is_mirantis(
_name,
- tag=_tag_major
+ tag=_mcp
),
"results": {},
"r": _release,
}
-
+ # Cross-compare versions
_cmp = VersionCmpResult(
_ver_ins,
_ver_can,
_all_packages[_name]['r']
)
-
+ # Update results structure
# shortcut to results
_res = _all_packages[_name]['results']
# update status