blob: f7b55dbc8bc02e1bd5b89f93ff59a739e4eb1eb2 [file] [log] [blame]
Alex3ebc5632019-04-18 16:47:18 -05001from cfg_checker.common import logger_cli
Alex205546c2020-12-30 19:22:30 -06002from cfg_checker.modules.network.mapper import SaltNetworkMapper, \
3 KubeNetworkMapper
Alex3ebc5632019-04-18 16:47:18 -05004from cfg_checker.modules.network.network_errors import NetworkErrors
Alex Savatieievf526dc02019-03-06 10:11:32 -06005from cfg_checker.reports import reporter
Alex Savatieiev9b2f6512019-02-20 18:05:00 -06006
7
Alexe0c5b9e2019-04-23 18:51:23 -05008class NetworkChecker(object):
Alex205546c2020-12-30 19:22:30 -06009 def __init__(self):
Alexe0c5b9e2019-04-23 18:51:23 -050010 logger_cli.debug("... init error logs folder")
Alex3ebc5632019-04-18 16:47:18 -050011 self.errors = NetworkErrors()
12
Alex836fac82019-08-22 13:36:16 -050013 def check_networks(self, map=True):
Alexe0c5b9e2019-04-23 18:51:23 -050014 self.mapper.map_network(self.mapper.RECLASS)
15 self.mapper.map_network(self.mapper.RUNTIME)
Alex3ebc5632019-04-18 16:47:18 -050016
Alex836fac82019-08-22 13:36:16 -050017 self.mapper.create_map()
18 if map:
19 self.mapper.print_map()
Alex Savatieiev42b89fa2019-03-07 18:45:26 -060020
Alex3ebc5632019-04-18 16:47:18 -050021 def print_summary(self):
Alex3ebc5632019-04-18 16:47:18 -050022 logger_cli.info(self.errors.get_summary(print_zeros=False))
Alex3ebc5632019-04-18 16:47:18 -050023
24 def print_error_details(self):
25 # Detailed errors
Alexb151fbe2019-04-22 16:53:30 -050026 logger_cli.info(
27 "\n{}\n".format(
28 self.errors.get_errors()
29 )
30 )
Alex3ebc5632019-04-18 16:47:18 -050031
Alex Savatieiev9b2f6512019-02-20 18:05:00 -060032 def create_html_report(self, filename):
33 """
34 Create static html showing network schema-like report
35
36 :return: none
37 """
38 logger_cli.info("### Generating report to '{}'".format(filename))
39 _report = reporter.ReportToFile(
Alex205546c2020-12-30 19:22:30 -060040 reporter.HTMLNetworkReport(self.mapper.master),
Alex Savatieiev9b2f6512019-02-20 18:05:00 -060041 filename
42 )
Alex9a4ad212020-10-01 18:04:25 -050043 _report(
44 {
45 "domain": self.mapper.domain,
46 "nodes": self.mapper.nodes,
47 "map": self.mapper.map,
48 "mcp_release": self.mapper.cluster['mcp_release'],
49 "openstack_release": self.mapper.cluster['openstack_release']
50 }
51 )
Alex Savatieiev9b2f6512019-02-20 18:05:00 -060052 logger_cli.info("-> Done")
Alex205546c2020-12-30 19:22:30 -060053
54
55class SaltNetworkChecker(NetworkChecker):
56 def __init__(
57 self,
58 config,
59 skip_list=None,
60 skip_list_file=None
61 ):
62 super(SaltNetworkChecker, self).__init__()
63 self.mapper = SaltNetworkMapper(
64 config,
65 errors_class=self.errors,
66 skip_list=skip_list,
67 skip_list_file=skip_list_file
68 )
69
70class KubeNetworkChecker(NetworkChecker):
71 def __init__(
72 self,
73 config,
74 skip_list=None,
75 skip_list_file=None
76 ):
77 super(SaltNetworkChecker, self).__init__()
78 self.mapper = KubeNetworkMapper(
79 config,
80 errors_class=self.errors,
81 skip_list=skip_list,
82 skip_list_file=skip_list_file
83 )