Updates to mapper and network check
- support for proto types: DHCP, MANUAL, STATIC
- proper interface mappings reclass/runtime
- updated map
- first step in bridge check support
Change-Id: I2f3293332913df57917be552dcb0ac66fc2c68bc
Related-PROD: PROD-28199
diff --git a/cfg_checker/modules/network/mapper.py b/cfg_checker/modules/network/mapper.py
index e0c3113..fd47918 100644
--- a/cfg_checker/modules/network/mapper.py
+++ b/cfg_checker/modules/network/mapper.py
@@ -300,7 +300,7 @@
_if_name = _runtime[network][hostname][0]["name"]
# get proper reclass
_r = self.interfaces[hostname][_if_name]['reclass']
- _if_rc = "+" if _r else "*"
+ _if_rc = "" if _r else "*"
_if_name_suffix = ""
# get the proto value
if "proto" in _r:
@@ -351,41 +351,40 @@
for _host in _a:
for _if in _host['ifs']:
_ip_str = str(_if.exploded)
+ _gate_error = ""
+ _up_error = ""
+ _mtu_error = ""
# check if node is UP
- if not salt_master.is_node_available(hostname):
- _r_gate = "-"
# get proper network from reclass
- elif _proto == 'static':
+ if _proto == 'static':
# Lookup match for the ip
_r_gate = "-"
if "gateway" in _r:
_r_gate = _r["gateway"]
- # if values match, put + for reclass
- if _gate == _r_gate:
- _r_gate = "+"
- else:
- _r_gate = "*"
+ # if values not match, put *
+ if _gate != _r_gate:
+ _gate_error = "*"
# IF status in reclass
_e = "enabled"
- _enabled = "*"
- if _e in _r:
- _enabled = "+" if _r[_e] else "-"
+ if _e not in _r:
+ _up_error = "*"
_rc_mtu = _r['mtu'] if 'mtu' in _r else None
+ _rc_mtu_s = ""
if _rc_mtu:
# there is a reclass MTU, save it
- _rc_mtu_s = str(_rc_mtu)
+ _rc_mtu_s = "/" + str(_rc_mtu)
elif _host['mtu'] == 1500 \
or _proto == "-" \
or _proto == "dhcp":
# 1500 is a default value => reclass not have it
# or this is a fancy network
- _rc_mtu_s = "-"
+ pass
else:
# this is an error
- _rc_mtu_s = "*"
+ _mtu_error = "*"
# check if this is a VIP address
# no checks needed if yes.
@@ -401,6 +400,10 @@
reclass_mtu=_rc_mtu,
runtime_mtu=_host['mtu']
)
+ _mtu_error = "*"
+ else:
+ # empty the matched value
+ _rc_mtu_s = ""
elif _host['mtu'] != '1500':
# there is no MTU value in reclass
# and runtime value is not default
@@ -411,24 +414,22 @@
if_cidr=_ip_str,
if_mtu=_host['mtu']
)
+ _mtu_error = "*"
else:
# this is a VIP
_if_name = " "*7
- _if_rc = ""
_if_name_suffix = ""
_ip_str += " VIP"
- _enabled = "-"
- _r_gate = "-"
# Host IF IP Proto MTU State Gate Def.Gate
- _text = "{:7} {:18} {:25} {:6} {:10} " \
+ _text = "{:7} {:17} {:25} {:6} {:10} " \
"{:10} {}/{}".format(
_if_name + _if_rc,
_if_name_suffix,
_ip_str,
_proto,
- _host['mtu'] + "/" + _rc_mtu_s,
- _host['state'] + _enabled,
- _gate + _r_gate,
+ _host['mtu'] + _rc_mtu_s + _mtu_error,
+ _host['state'] + _up_error,
+ _gate + _gate_error,
_d_gate_str
)
logger_cli.info(
@@ -447,13 +448,14 @@
for hostname in names:
for _n in _runtime[network][hostname]:
_ifs = [str(ifs.ip) for ifs in _n['ifs']]
- _text = "{0:25}: {1:19} {2:5} {3:4}".format(
+ _text = "{:25} {:25} {:6} {:10} {}".format(
_n['name'],
", ".join(_ifs),
+ "-",
_n['mtu'],
_n['state']
)
logger_cli.info(
- " {0:17} {1}".format(hostname.split('.')[0], _text)
+ " {0:8} {1}".format(hostname.split('.')[0], _text)
)
logger_cli.info("\n")