Refactor working with Networks and Pinger class
- Mapper moved to separate module
- Other modules can use Mapper to get desired networks
- salt_master is now a separate single instance
- Updated file handling on salt
- ping.py, an scripted flexible interface to ping command
multithreaded ping execution, 15 at once
- New commands in network: 'ping' and 'list'
- New error when runtime has no network listed in reclass
Fixes:
- Master node code handling
- Unknown node codes detection
- Proper node code search and handling
- File upload procedures updated
- Packages report fix
Change-Id: I5959210aed53b20b04b05ea880218e93239bb661
Related-PROD: PROD-28199
diff --git a/cfg_checker/modules/packages/checker.py b/cfg_checker/modules/packages/checker.py
index 3225f70..0bcb1a6 100644
--- a/cfg_checker/modules/packages/checker.py
+++ b/cfg_checker/modules/packages/checker.py
@@ -3,13 +3,13 @@
from cfg_checker.common import const, logger_cli
from cfg_checker.common.exception import ConfigException
from cfg_checker.helpers.console_utils import Progress
-from cfg_checker.nodes import SaltNodes
+from cfg_checker.nodes import salt_master
from cfg_checker.reports import reporter
from versions import DebianVersion, PkgVersions, VersionCmpResult
-class CloudPackageChecker(SaltNodes):
+class CloudPackageChecker(object):
@staticmethod
def presort_packages(all_packages, full=None):
logger_cli.info("-> Presorting packages")
@@ -52,14 +52,14 @@
# sort packages
_pn, _val = all_packages.popitem()
_c = _val['desc']['component']
- if full:
+ if not full:
# Check if this packet has errors
# if all is ok -> just skip it
_max_status = max(_val['results'].keys())
if _max_status <= const.VERSION_OK:
_max_action = max(_val['results'][_max_status].keys())
if _max_action == const.ACT_NA:
- # this package do not ha any comments
+ # this package do not has any comments
# ...just skip it from report
continue
@@ -118,9 +118,12 @@
:return: none
"""
logger_cli.info("# Collecting installed packages")
- _result = self.execute_script_on_active_nodes("pkg_versions.py")
+ if not salt_master.nodes:
+ salt_master.nodes = salt_master.get_nodes()
+ salt_master.prepare_script_on_active_nodes("pkg_versions.py")
+ _result = salt_master.execute_script_on_active_nodes("pkg_versions.py")
- for key in self.nodes.keys():
+ for key in salt_master.nodes.keys():
# due to much data to be passed from salt, it is happening in order
if key in _result:
_text = _result[key]
@@ -135,12 +138,12 @@
)
_dict = {}
- self.nodes[key]['packages'] = _dict
+ salt_master.nodes[key]['packages'] = _dict
else:
- self.nodes[key]['packages'] = {}
+ salt_master.nodes[key]['packages'] = {}
logger_cli.debug("... {} has {} packages installed".format(
key,
- len(self.nodes[key]['packages'].keys())
+ len(salt_master.nodes[key]['packages'].keys())
))
logger_cli.info("-> Done")
@@ -156,12 +159,12 @@
logger_cli.info(
"# Cross-comparing: Installed vs Candidates vs Release"
)
- _progress = Progress(len(self.nodes.keys()))
+ _progress = Progress(len(salt_master.nodes.keys()))
_progress_index = 0
_total_processed = 0
# Collect packages from all of the nodes in flat dict
_all_packages = {}
- for node_name, node_value in self.nodes.iteritems():
+ for node_name, node_value in salt_master.nodes.iteritems():
_uniq_len = len(_all_packages.keys())
_progress_index += 1
# progress will jump from node to node
@@ -182,8 +185,8 @@
# All packages list with version and node list
if _name not in _all_packages:
# shortcuts for this cloud values
- _os = self.openstack_release
- _mcp = self.mcp_release
+ _os = salt_master.openstack_release
+ _mcp = salt_master.mcp_release
_pkg_desc = {}
if _desc[_name]:
# shortcut to version library
@@ -256,9 +259,9 @@
filename
)
payload = {
- "nodes": self.nodes,
- "mcp_release": self.mcp_release,
- "openstack_release": self.openstack_release
+ "nodes": salt_master.nodes,
+ "mcp_release": salt_master.mcp_release,
+ "openstack_release": salt_master.openstack_release
}
payload.update(self.presort_packages(self._packages, full))
_report(payload)