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/modules/reclass/__init__.py b/cfg_checker/modules/reclass/__init__.py
index 2546ec3..adae6df 100644
--- a/cfg_checker/modules/reclass/__init__.py
+++ b/cfg_checker/modules/reclass/__init__.py
@@ -1,21 +1,22 @@
import os
-import comparer
-import validator
-
from cfg_checker.common import logger_cli
from cfg_checker.helpers import args_utils
from cfg_checker.reports import reporter
+import comparer
+
+import validator
+
def do_list(args):
logger_cli.info("# Reclass list")
_arg_path = args_utils.get_arg(args, 'models_path')
logger_cli.info("-> Current path is: {}".format(_arg_path))
_path = args_utils.get_path_arg(_arg_path)
-
- logger_cli.info("# ...models path is '{}'".format(args.models_path))
-
+
+ logger_cli.info("# ...models path is '{}'".format(_path))
+
models = {}
for _folder in os.listdir(args.models_path):
# validate item as a model
@@ -24,15 +25,15 @@
_folder
)
_validated = validator.basic_model_validation_by_path(_model_path)
-
+
if not _validated:
logger_cli.info("-> '{}' not a valid model".format(_folder))
continue
else:
models[_folder] = _model_path
-
+
logger_cli.info("-> '{}' at '{}'".format(_folder, _model_path))
-
+
# TODO: collect info about the model
return
@@ -44,7 +45,7 @@
# checking folder params
_model1 = args_utils.get_path_arg(args.model1)
_model2 = args_utils.get_path_arg(args.model2)
-
+
# Do actual compare using hardcoded model names
mComparer = comparer.ModelComparer()
@@ -52,7 +53,7 @@
mComparer.model_path_1 = _model1
mComparer.model_name_2 = os.path.split(_model2)[1]
mComparer.model_path_2 = _model2
-
+
mComparer.load_model_tree(
mComparer.model_name_1,
mComparer.model_path_1
diff --git a/cfg_checker/modules/reclass/comparer.py b/cfg_checker/modules/reclass/comparer.py
index b0b7b37..6591d16 100644
--- a/cfg_checker/modules/reclass/comparer.py
+++ b/cfg_checker/modules/reclass/comparer.py
@@ -4,13 +4,14 @@
"""
import itertools
import os
+
+from cfg_checker.common import logger, logger_cli
+from cfg_checker.reports import reporter
+
import yaml
-from cfg_checker.reports import reporter
-from cfg_checker.common import logger, logger_cli
-
-def get_element(element_path, input_data):
+def get_element(element_path, input_data):
paths = element_path.split(":")
data = input_data
for i in range(0, len(paths)):
@@ -18,7 +19,7 @@
return data
-def pop_element(element_path, input_data):
+def pop_element(element_path, input_data):
paths = element_path.split(":")
data = input_data
# Search for last dict
@@ -38,7 +39,7 @@
"03_cluster": "classes:cluster",
"04_other": "classes"
}
-
+
models = {}
models_path = "/srv/salt/reclass"
model_name_1 = "source"
@@ -123,7 +124,7 @@
# creating dict structure out of folder list. Pure python magic
parent = reduce(dict.get, folders[:-1], raw_tree)
parent[folders[-1]] = subdir
-
+
self.models[name] = {}
# Brake in according to pathes
_parts = self._model_parts.keys()
@@ -133,7 +134,7 @@
self._model_parts[_parts[ii]],
raw_tree[root_key]
)
-
+
# save it as a single data object
self.models[name]["rc_diffs"] = raw_tree[root_key]
return True
@@ -223,8 +224,7 @@
if _removed or _added:
_removed_str_lst = ["- {}".format(item)
for item in _removed]
- _added_str_lst = ["+ {}".format(item)
- for item in _added]
+ _added_str_lst = ["+ {}".format(i) for i in _added]
_report[_new_path] = {
"type": "list",
"raw_values": [
@@ -287,7 +287,6 @@
))
return _report
-
def generate_model_report_tree(self):
"""Use two loaded models to generate comparison table with
values are groupped by YAML files
diff --git a/cfg_checker/modules/reclass/validator.py b/cfg_checker/modules/reclass/validator.py
index e7d7f06..8fc65a5 100644
--- a/cfg_checker/modules/reclass/validator.py
+++ b/cfg_checker/modules/reclass/validator.py
@@ -2,6 +2,7 @@
from cfg_checker.common import logger_cli
+
def basic_model_validation_by_path(path):
logger_cli.debug("\t...validating '{}' as a model".format(path))
_checks = []
@@ -20,7 +21,7 @@
_has_nodes = os.path.isdir(os.path.join(path, "nodes"))
logger_cli.debug("\t- has nodes? -> {}".format(_has_nodes))
_checks.append(_has_nodes)
-
+
logger_cli.debug("\t-> {}".format(
all(_checks)
))