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/cfg_check.py b/cfg_checker/cfg_check.py
index 6b64804..00e40d2 100644
--- a/cfg_checker/cfg_check.py
+++ b/cfg_checker/cfg_check.py
@@ -2,11 +2,10 @@
import os
import sys
import traceback
+from logging import DEBUG, INFO
-from logging import INFO, DEBUG
-
-from cfg_checker.common.exception import CheckerException
from cfg_checker.common import config, logger, logger_cli
+from cfg_checker.common.exception import CheckerException
pkg_dir = os.path.dirname(__file__)
@@ -18,6 +17,7 @@
'reclass': ['list', 'diff']
}
+
class MyParser(argparse.ArgumentParser):
def error(self, message):
sys.stderr.write('Error: {0}\n\n'.format(message))
@@ -36,14 +36,14 @@
def config_check_entrypoint():
"""
- Main entry point. Uses nested parsers structure
+ Main entry point. Uses nested parsers structure
with a default function to execute the comand
:return: - no return value
"""
# Main entrypoint
parser = MyParser(prog="# Mirantis Cloud configuration checker")
-
+
# Parsers (each parser can have own arguments)
# - subparsers (command)
# |- pkg_parser
@@ -109,6 +109,12 @@
help="Do network check and print the result"
)
+ net_check_parser.add_argument(
+ '--detailed',
+ action="store_true", default=False,
+ help="Print error details after summary"
+ )
+
net_report_parser = net_subparsers.add_parser(
'report',
help="Generate network check report"
@@ -119,7 +125,7 @@
metavar='network_html_filename',
help="HTML filename to save report"
)
-
+
# reclass
reclass_parser = subparsers.add_parser(
'reclass',
@@ -157,18 +163,16 @@
help="HTML filename to save report"
)
-
-
- #parse arguments
+ # parse arguments
try:
args = parser.parse_args()
- except TypeError as e:
+ except TypeError:
logger_cli.info("\n# Please, check arguments")
return
# Pass externally configured values
config.ssh_uses_sudo = args.sudo
-
+
# Handle options
if args.debug:
logger_cli.setLevel(DEBUG)
@@ -191,14 +195,18 @@
else:
# form function name to call
_method_name = "do_" + args.type
- _target_module = __import__("cfg_checker.modules."+args.command, fromlist=[""])
+ _target_module = __import__(
+ "cfg_checker.modules."+args.command,
+ fromlist=[""]
+ )
_method = getattr(_target_module, _method_name)
-
+
# Execute the command
result = _method(args)
logger.debug(result)
+
def cli_main():
try:
config_check_entrypoint()
@@ -216,5 +224,6 @@
))
))
+
if __name__ == '__main__':
cli_main()