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/packages/__init__.py b/cfg_checker/modules/packages/__init__.py
index 774e674..5e717d6 100644
--- a/cfg_checker/modules/packages/__init__.py
+++ b/cfg_checker/modules/packages/__init__.py
@@ -1,7 +1,7 @@
-import checker
-
 from cfg_checker.helpers import args_utils
 
+import checker
+
 
 def do_report(args):
     """Create package versions report, HTML
diff --git a/cfg_checker/modules/packages/checker.py b/cfg_checker/modules/packages/checker.py
index 8a3456d..3225f70 100644
--- a/cfg_checker/modules/packages/checker.py
+++ b/cfg_checker/modules/packages/checker.py
@@ -1,18 +1,12 @@
 import json
-import os
-#import sys
 
-from copy import deepcopy
-
+from cfg_checker.common import const, logger_cli
 from cfg_checker.common.exception import ConfigException
-from cfg_checker.common import utils, const
-from cfg_checker.common import config, logger, logger_cli, pkg_dir
-from cfg_checker.common import salt_utils
 from cfg_checker.helpers.console_utils import Progress
-from cfg_checker.nodes import SaltNodes, node_tmpl
+from cfg_checker.nodes import SaltNodes
 from cfg_checker.reports import reporter
 
-from versions import PkgVersions, DebianVersion, VersionCmpResult
+from versions import DebianVersion, PkgVersions, VersionCmpResult
 
 
 class CloudPackageChecker(SaltNodes):
@@ -99,7 +93,6 @@
                 _eo += _val['results'].keys().count(const.VERSION_ERR)
                 _do += _val['results'].keys().count(const.VERSION_DOWN)
 
-        
         _progress.newline()
 
         _data['errors'] = {
@@ -133,13 +126,15 @@
                 _text = _result[key]
                 try:
                     _dict = json.loads(_text[_text.find('{'):])
-                except ValueError as e:
+                except ValueError:
                     logger_cli.info("... no JSON for '{}'".format(
                         key
                     ))
-                    logger_cli.debug("ERROR:\n{}\n".format(_text[:_text.find('{')]))
+                    logger_cli.debug(
+                        "ERROR:\n{}\n".format(_text[:_text.find('{')])
+                    )
                     _dict = {}
-                
+
                 self.nodes[key]['packages'] = _dict
             else:
                 self.nodes[key]['packages'] = {}
@@ -157,8 +152,10 @@
         """
         # Preload OpenStack release versions
         _desc = PkgVersions()
-        
-        logger_cli.info("# Cross-comparing: Installed vs Candidates vs Release")
+
+        logger_cli.info(
+            "# Cross-comparing: Installed vs Candidates vs Release"
+        )
         _progress = Progress(len(self.nodes.keys()))
         _progress_index = 0
         _total_processed = 0
@@ -196,10 +193,10 @@
                         # no description - no library :)
                         _vers = {}
                         _pkg_desc = _desc.dummy_desc
-                    
+
                     # get specific set for this OS release if present
                     if _os in _vers:
-                        _v = _vers[_os] 
+                        _v = _vers[_os]
                     elif 'any' in _vers:
                         _v = _vers['any']
                     else:
@@ -212,13 +209,13 @@
                         "results": {},
                         "r": _release,
                     }
-                
+
                 _cmp = VersionCmpResult(
                     _ver_ins,
                     _ver_can,
                     _all_packages[_name]['r']
                 )
-                
+
                 # shortcut to results
                 _res = _all_packages[_name]['results']
                 # update status
@@ -240,7 +237,6 @@
 
         self._packages = _all_packages
         _progress.newline()
-    
 
     def create_report(self, filename, rtype, full=None):
         """
diff --git a/cfg_checker/modules/packages/versions.py b/cfg_checker/modules/packages/versions.py
index 10f65dc..9352dd6 100644
--- a/cfg_checker/modules/packages/versions.py
+++ b/cfg_checker/modules/packages/versions.py
@@ -1,7 +1,7 @@
 import csv
 import os
 
-from cfg_checker.common import config, logger, logger_cli, pkg_dir, const
+from cfg_checker.common import config, const, logger_cli, pkg_dir
 
 
 class PkgVersions(object):
@@ -33,15 +33,16 @@
                 _app = row[2]
                 _repo = row[3]
                 # if release cell empty - use keyword 'any'
-                _os_release = row[4] if len(row[4]) > 0 else 'any' 
+                _os_release = row[4] if len(row[4]) > 0 else 'any'
 
                 # prepare versions dict
                 _l = self._labels
-                _versions = {_l[i]:row[5+i] for i in range(0, len(row[5:]))}
-                
+                _versions = {_l[i]: row[5+i] for i in range(0, len(row[5:]))}
+
                 if _pkg in self._list:
                     if _os_release in self._list[_pkg]["versions"]:
-                        # all pkg/os_releases should be uniq. If found, latest one used
+                        # all pkg/os_releases should be uniq.
+                        # If found, latest one used
                         logger_cli.info(
                             "-> WARNING: Duplicate package info found "
                             "'{}' (line {})".format(
@@ -59,17 +60,17 @@
                             "versions": {}
                         }
                     })
-                
+
                 # and finally, update the versions for this release
                 self._list[_pkg]["versions"].update({
                     _os_release: _versions
                 })
-    
+
     def __getitem__(self, pkg_name):
-        if pkg_name in self._list:        
+        if pkg_name in self._list:
             return self._list[pkg_name]
         else:
-            #return self._dummy_desc
+            # return self._dummy_desc
             return None
 
 
@@ -95,7 +96,7 @@
         _ord_map = [ord(ch) not in _chars for ch in version_fragment]
         # if there is nothing to extract, return at once
         if not any([_s in version_fragment for _s in _symbols]) \
-            and not any(_ord_map):
+                and not any(_ord_map):
             # no revisions
             return version_fragment, ""
         else:
@@ -114,7 +115,7 @@
             _main = version_fragment[:_indices[0]]
             _rev = version_fragment[_indices[0]:]
             return _main, _rev
-    
+
     def __init__(self, version_string):
         # save
         if len(version_string) < 1:
@@ -139,7 +140,7 @@
             self.upstream, self.upstream_rev = self.split_revision(_m)
             self.debian, self.debian_rev = self.split_revision(_d)
             self.version = version_string
-    
+
     # Following functions is a freestyle python mimic of apt's upstream, enjoy
     # https://github.com/chaos/apt/blob/master/apt/apt-pkg/deb/debversion.cc#L42
     # mimic produced in order not to pull any packages or call external code
@@ -160,7 +161,7 @@
                 return _num
             _li += 1
             _ri += 1
-        
+
         # diff found? lens equal?
         if not _diff and _lL != _rL:
             # lens not equal? Longer - later
@@ -168,7 +169,7 @@
         else:
             # equal
             return 0
-    
+
     def _cmp_num(self, lf, rf):
         # split fragments into lists
         _lhf = lf.split('.') if '.' in lf else list(lf)
@@ -178,14 +179,14 @@
         _rhf = [int(n) for n in _rhf if len(n)]
 
         return self._cmp_fragment(_lhf, _rhf)
-    
+
     def _cmp_lex(self, lf, rf):
         # cast each item into its ORD value
         _lhf = [ord(n) for n in lf]
         _rhf = [ord(n) for n in rf]
 
-        return self._cmp_fragment(_lhf, _rhf)        
-   # end of cmps
+        return self._cmp_fragment(_lhf, _rhf)
+    # end of cmps
 
     # main part compared using splitted numbers
     # if equal, revision is compared using lexical comparizon
@@ -217,7 +218,7 @@
             return True
         else:
             return False
-    
+
     def update_parts(self, target, status):
         # updating parts of version statuses
         if self._cmp_num(self.epoch, target.epoch) != 0:
@@ -226,13 +227,13 @@
             self.epoch_status = const.VERSION_OK
 
         if self._cmp_num(self.upstream, target.upstream) != 0 \
-            or self._cmp_lex(self.upstream_rev, target.upstream_rev) != 0:
+                or self._cmp_lex(self.upstream_rev, target.upstream_rev) != 0:
             self.upstream_status = status
         else:
             self.upstream_status = const.VERSION_OK
 
         if self._cmp_lex(self.debian, target.debian) != 0 \
-            or self._cmp_lex(self.debian_rev, target.debian_rev) != 0:
+                or self._cmp_lex(self.debian_rev, target.debian_rev) != 0:
             self.debian_status = status
         else:
             self.debian_status = const.VERSION_OK
@@ -245,13 +246,12 @@
     source = None
     target = None
 
-
     def __init__(self, i, c, r):
         # compare three versions and write a result
         self.source = i
         self.status = const.VERSION_NA
         self.action = const.ACT_NA
-        
+
         # Check if there is a release version present
         if r and len(r.version) > 0 and r.version != 'n/a':
             # I < C, installed version is older
@@ -333,7 +333,7 @@
             elif i == c:
                 self.status = const.VERSION_OK
                 self.action = const.ACT_NA
-        
+
         # and we need to update per-part status
         self.source.update_parts(self.target, self.status)
 
@@ -342,4 +342,4 @@
         if _t.debian and _t.debian > _s.debian:
             return True
         else:
-            return false
+            return False