Fixed net errors and slight optimizations
Change-Id: Ic4257875764b77e7565271b5d2d5759ef704f6d2
Related-PROD: PROD-28199
diff --git a/cfg_checker/modules/network/mapper.py b/cfg_checker/modules/network/mapper.py
index 03237a6..c3e3b73 100644
--- a/cfg_checker/modules/network/mapper.py
+++ b/cfg_checker/modules/network/mapper.py
@@ -305,9 +305,18 @@
_if_name = _runtime[network][hostname][0]["name"]
# get proper reclass
_r = self.interfaces[hostname][_if_name]['reclass']
- _if_rc = "" if _r else "*"
_if_name_suffix = ""
# get the proto value
+ if _r:
+ _if_rc = ""
+ else:
+ self.errors.add_error(
+ self.errors.NET_NODE_UNEXPECTED_IF,
+ host=hostname,
+ if_name=_if_name
+ )
+ _if_rc = "*"
+
if "proto" in _r:
_proto = _r['proto']
else:
@@ -321,14 +330,6 @@
if _if_name_suffix:
_if_name_suffix = "({})".format(_if_name_suffix)
- # check reclass has this interface
- if _proto != "-" and not _r:
- self.errors.add_error(
- self.errors.NET_NODE_UNEXPECTED_IF,
- host=hostname,
- if_name=_if_name
- )
-
# get gate and routes if proto is static
if _proto == 'static':
# get the gateway for current net
@@ -371,32 +372,32 @@
# if values not match, put *
if _gate != _r_gate and _d_gate_str != _r_gate:
# if values not match, check if default match
+ self.errors.add_error(
+ self.errors.NET_UNEXPECTED_GATEWAY,
+ host=hostname,
+ if_name=_if_name,
+ ip=_ip_str,
+ gateway=_gate
+ )
_gate_error = "*"
# IF status in reclass
_e = "enabled"
if _e not in _r:
+ self.errors.add_error(
+ self.errors.NET_NO_RC_IF_STATUS,
+ host=hostname,
+ if_name=_if_name
+ )
_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)
- elif _host['mtu'] == "1500" \
- or _proto == "-" \
- or _proto == "dhcp":
- # 1500 is a default value => reclass not have it
- # or this is a fancy network
- pass
- else:
- # this is an error
- _mtu_error = "*"
-
# check if this is a VIP address
# no checks needed if yes.
if _host['vip'] != _ip_str:
if _rc_mtu:
+ _rc_mtu_s = str(_rc_mtu)
# if there is an MTU value, match it
if _host['mtu'] != _rc_mtu_s:
self.errors.add_error(
@@ -412,7 +413,8 @@
else:
# empty the matched value
_rc_mtu_s = ""
- elif _host['mtu'] != '1500':
+ elif _host['mtu'] != '1500' and \
+ _proto not in ["-", "dhcp"]:
# there is no MTU value in reclass
# and runtime value is not default
self.errors.add_error(
diff --git a/cfg_checker/modules/network/network_errors.py b/cfg_checker/modules/network/network_errors.py
index 276c4ab..6c41021 100644
--- a/cfg_checker/modules/network/network_errors.py
+++ b/cfg_checker/modules/network/network_errors.py
@@ -10,12 +10,14 @@
# error type codes here
NET_MTU_MISMATCH = next(_c)
NET_MTU_EMPTY = next(_c)
+ NET_NO_RC_IF_STATUS = next(_c)
NET_DUPLICATE_IF = next(_c)
NET_SUBNET_INTERSECT = next(_c)
NET_MASK_MISMATCH = next(_c)
NET_NODE_NON_RESPONSIVE = next(_c)
NET_NODE_UNEXPECTED_IF = next(_c)
NET_NO_RUNTIME_NETWORK = next(_c)
+ NET_UNEXPECTED_GATEWAY = next(_c)
NET_PING_SUCCESS = next(_c)
NET_PING_TIMEOUT = next(_c)
NET_PING_ERROR = next(_c)
@@ -33,6 +35,10 @@
"MTU value is not 1500 on runtime and empty in reclass"
)
self.add_error_type(
+ self.NET_NO_RC_IF_STATUS,
+ "Reclass has no IF 'enable' status value"
+ )
+ self.add_error_type(
self.NET_DUPLICATE_IF,
"Duplicate interface specified"
)
@@ -57,6 +63,10 @@
"Reclass network not found in Runtime"
)
self.add_error_type(
+ self.NET_UNEXPECTED_GATEWAY,
+ "Runtime has unexpected gateway set for specific network"
+ )
+ self.add_error_type(
self.NET_PING_SUCCESS,
"Network Ping successfull"
)