Unified command execution and unit tests
- All arguments inits moved to own clases
- Added unified way to execute commands
- Unit test structure and very basic tests
- Command line script to test coverage
- Argument parsers moved to corresponding commands
- Automatic parsers and command mapping
Change-Id: Id099d14702d9590729583dfd9574bd57022efac5
Related-PROD: PROD-28199
diff --git a/cfg_checker/modules/network/checker.py b/cfg_checker/modules/network/checker.py
index 48e7acb..7e6a239 100644
--- a/cfg_checker/modules/network/checker.py
+++ b/cfg_checker/modules/network/checker.py
@@ -115,6 +115,11 @@
for _ip_str in _ip4s:
# create interface class
_if = ipaddress.IPv4Interface(_ip_str)
+ # check if this is a VIP
+ # ...all those will have /32 mask
+ net_data['vip'] = None
+ if _if.network.prefixlen == 32:
+ net_data['vip'] = str(_if.exploded)
if 'name' not in net_data:
net_data['name'] = net_name
if 'ifs' not in net_data:
@@ -303,47 +308,44 @@
_name = _host['name']
_rc_mtu = _r['mtu'] if 'mtu' in _r else None
-
- # Check if this is a VIP
- if _if.network.prefixlen == 32:
- _name = " "*20
- _ip_str += " VIP"
- _rc_mtu = "(-)"
- _enabled = "(-)"
- _r_gate = "-"
-
- # Check if this is a default MTU
- elif _host['mtu'] == '1500':
- # reclass is empty if MTU is untended to be 1500
- _rc_mtu = "(-)"
- elif _rc_mtu:
- _rc_mtu_s = str(_rc_mtu)
- # if there is an MTU value, match it
- if _host['mtu'] != _rc_mtu_s:
+ _rc_mtu_s = str(_rc_mtu) if _rc_mtu else '(-)'
+ # check if this is a VIP address
+ # no checks needed if yes.
+ if _host['vip'] != _ip_str:
+ if _rc_mtu:
+ # if there is an MTU value, match it
+ if _host['mtu'] != _rc_mtu_s:
+ self.errors.add_error(
+ self.errors.NET_MTU_MISMATCH,
+ host=hostname,
+ if_name=_name,
+ if_cidr=_ip_str,
+ reclass_mtu=_rc_mtu,
+ runtime_mtu=_host['mtu']
+ )
+ elif _host['mtu'] != '1500':
+ # there is no MTU value in reclass
+ # and runtime value is not default
self.errors.add_error(
- self.errors.NET_MTU_MISMATCH,
+ self.errors.NET_MTU_EMPTY,
host=hostname,
if_name=_name,
if_cidr=_ip_str,
- reclass_mtu=_rc_mtu,
- runtime_mtu=_host['mtu']
+ if_mtu=_host['mtu']
)
else:
- # there is no MTU value in reclass
- self.errors.add_error(
- self.errors.NET_MTU_EMPTY,
- host=hostname,
- if_name=_name,
- if_cidr=_ip_str,
- if_mtu=_host['mtu']
- )
+ # this is a VIP
+ _name = " "*20
+ _ip_str += " VIP"
+ _enabled = "(-)"
+ _r_gate = "-"
_text = "{0:25} {1:19} {2:5}{3:10} {4:4}{5:10} " \
"{6} / {7} / {8}".format(
_name,
_ip_str,
_host['mtu'],
- "("+_rc_mtu_s+")" if _rc_mtu else "(No!)",
+ _rc_mtu_s,
_host['state'],
_enabled,
_gate,