Network check fixes
- Proper network mapping
- Proper reclass lookup
- VIP detection
- Simple error gathering
- IP shown as 'exploded', i.e. in CIDR format
- MTU matching and detection
- Errors class for handling errors, including codes and indices
- Summary and detailed errors view
- Flake8 refactoring
Change-Id: I8ee37d345bdc21c7ad930bf8305acd28f8c121c8
Related-PROD: PROD-28199
diff --git a/cfg_checker/common/salt_utils.py b/cfg_checker/common/salt_utils.py
index b913531..8b1b47f 100644
--- a/cfg_checker/common/salt_utils.py
+++ b/cfg_checker/common/salt_utils.py
@@ -3,12 +3,13 @@
"""
import json
import os
-import requests
import time
-from cfg_checker.common import logger, logger_cli, config
+from cfg_checker.common import config, logger, logger_cli
+from cfg_checker.common.exception import InvalidReturnException, SaltException
from cfg_checker.common.other import shell
-from cfg_checker.common.exception import SaltException, InvalidReturnException
+
+import requests
def _extract_password(_raw):
@@ -17,11 +18,11 @@
else:
try:
_json = json.loads(_raw)
- except ValueError as e:
+ except ValueError:
raise SaltException(
"# Return value is not a json: '{}'".format(_raw)
)
-
+
return _json["local"]
@@ -41,7 +42,7 @@
_ssh_cmd.append(config.ssh_host)
if config.ssh_uses_sudo:
_ssh_cmd.append("sudo")
-
+
_ssh_cmd.append(_salt_cmd)
_ssh_cmd = " ".join(_ssh_cmd)
logger_cli.debug("...calling salt: '{}'".format(_ssh_cmd))
@@ -53,6 +54,7 @@
else:
return _extract_password(_result)
+
def get_local_password():
"""Calls salt locally to get password from the pillar
@@ -86,7 +88,13 @@
self._token = self._login()
self.last_response = None
- def get(self, path='', headers=default_headers, cookies=None, timeout=None):
+ def get(
+ self,
+ path='',
+ headers=default_headers,
+ cookies=None,
+ timeout=None
+ ):
_path = os.path.join(self.uri, path)
logger.debug("# GET '{}'\nHeaders: '{}'\nCookies: {}".format(
_path,
@@ -108,12 +116,14 @@
_data = str(data).replace(self._pass, "*****")
else:
_data = data
- logger.debug("# POST '{}'\nHeaders: '{}'\nCookies: {}\nBody: {}".format(
- _path,
- headers,
- cookies,
- _data
- ))
+ logger.debug(
+ "# POST '{}'\nHeaders: '{}'\nCookies: {}\nBody: {}".format(
+ _path,
+ headers,
+ cookies,
+ _data
+ )
+ )
return requests.post(
os.path.join(self.uri, path),
headers=headers,
@@ -289,7 +299,7 @@
"""
try:
_r = self.salt_request('get', 'minions', timeout=10)
- except requests.exceptions.ReadTimeout as e:
+ except requests.exceptions.ReadTimeout:
logger_cli.debug("... timeout waiting list minions from Salt API")
_r = None
return _r[0] if _r else None
@@ -322,7 +332,7 @@
def get_active_nodes(self):
"""Used when other minion list metods fail
-
+
:return: json result from salt test.ping
"""
if config.skip_nodes:
@@ -336,7 +346,7 @@
expr_form='compound')
else:
_r = self.cmd('*', 'test.ping')
- # Return all nodes that responded
+ # Return all nodes that responded
return [node for node in _r.keys() if _r[node]]
def get_monitoring_ip(self, param_name):
@@ -391,7 +401,7 @@
"""
REST variation of file.get_managed
CLI execution goes like this (10 agrs):
- salt cfg01\* file.manage_file /root/test_scripts/pkg_versions.py
+ salt cfg01\\* file.manage_file /root/test_scripts/pkg_versions.py
'' '{}' /root/diff_pkg_version.py
'{hash_type: 'md5', 'hsum': <md5sum>}' root root '755' base ''
makedirs=True