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/common/const.py b/cfg_checker/common/const.py
index f1f69ae..1ae2bba 100644
--- a/cfg_checker/common/const.py
+++ b/cfg_checker/common/const.py
@@ -43,6 +43,8 @@
VERSION_NA: "no status"
}
+uknown_code = "unk"
+
all_roles_map = {
"apt": "repository",
"bmk": "validation",
@@ -60,5 +62,6 @@
"mtr": "stacklight_metering",
"osd": "storage_node",
"prx": "proxy",
- "rgw": "storage_rados"
+ "rgw": "storage_rados",
+ "unk": "uknown"
}
diff --git a/cfg_checker/common/other.py b/cfg_checker/common/other.py
index 1d34776..d9e434a 100644
--- a/cfg_checker/common/other.py
+++ b/cfg_checker/common/other.py
@@ -2,7 +2,7 @@
import re
import subprocess
-from cfg_checker.common.const import all_roles_map
+from cfg_checker.common.const import all_roles_map, uknown_code
from cfg_checker.common.exception import ConfigException
pkg_dir = os.path.dirname(__file__)
@@ -70,10 +70,27 @@
def get_node_code(self, fqdn):
# validate
_isvalid, _message = self.validate_name(fqdn, message=True)
- _code = re.findall("[a-zA-Z]+", fqdn.split('.')[0])
+ _code = re.findall("[a-zA-Z]+?(?=(?:[0-9]+$)|$)", fqdn.split('.')[0])
# check if it is valid and raise if not
if _isvalid:
- return _code[0]
+ # try to match it with ones in map
+ _c = _code[0]
+ match = any([r in _c for r in all_roles_map.keys()])
+ if match:
+ # no match, try to find it
+ match = False
+ for r in all_roles_map.keys():
+ _idx = _c.find(r)
+ if _idx > -1:
+ _c = _c[_idx:]
+ match = True
+ break
+ if match:
+ return _c
+ else:
+ return uknown_code
+ else:
+ return uknown_code
else:
raise ConfigException(_message)
diff --git a/cfg_checker/common/salt_utils.py b/cfg_checker/common/salt_utils.py
index 2927e28..4dcbd30 100644
--- a/cfg_checker/common/salt_utils.py
+++ b/cfg_checker/common/salt_utils.py
@@ -189,6 +189,8 @@
class SaltRemote(SaltRest):
+ master_node = ""
+
def __init__(self):
super(SaltRemote, self).__init__()
@@ -362,7 +364,7 @@
"makedirs": makedirs
}
salt_output = self.cmd(
- "cfg01*",
+ self.master_node,
"file.touch",
param=path,
kwarg=_kwarg
@@ -376,7 +378,7 @@
_args = [path]
_args.extend(strings_list)
salt_output = self.cmd(
- "cfg01*",
+ self.master_node,
"file.write",
param=_args,
kwarg=_kwarg
@@ -428,7 +430,7 @@
"makedirs": makedirs
}
salt_output = self.cmd(
- "cfg01*",
+ self.master_node,
"file.manage_file",
param=_arg,
kwarg=_kwarg