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/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)