Skip to content

Commit 3bd442b

Browse files
committed
updating rule
1 parent 124115d commit 3bd442b

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

roles/validate/files/rules/common/312_topology_interface_storm_control.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Rule:
22
id = "312"
3-
description = "Verify either percentage or PPS is configured for storm-control"
3+
description = "Verify either percentage or PPS is configured on the switch for storm-control"
44
severity = "HIGH"
55

66
@classmethod
@@ -19,16 +19,20 @@ def match(cls, data_model):
1919
for switch in switches:
2020
check = cls.data_model_key_check(switch, ['interfaces'])
2121
if 'interfaces' in check['keys_data']:
22-
interfaces = switch.get('interfaces')
23-
for interface in interfaces:
24-
pct = {k for k in pct_keys if interface.get(k) is not None}
25-
pps = {k for k in pps_keys if interface.get(k) is not None}
26-
if pct and pps:
27-
results.append(
28-
f"switch {switch.get('name')} interface {interface.get('name')}: "
29-
f"storm_control percent and pps are mutually exclusive; "
30-
f"got {sorted(pct)} and {sorted(pps)}"
31-
)
22+
pct_ifaces = []
23+
pps_ifaces = []
24+
for interface in switch.get('interfaces'):
25+
if any(interface.get(k) is not None for k in pct_keys):
26+
pct_ifaces.append(interface.get('name'))
27+
if any(interface.get(k) is not None for k in pps_keys):
28+
pps_ifaces.append(interface.get('name'))
29+
30+
if pct_ifaces and pps_ifaces:
31+
results.append(
32+
f"switch {switch.get('name')}: storm_control mode must be consistent "
33+
f"across all interfaces; percent-mode interfaces: {pct_ifaces}; "
34+
f"pps-mode interfaces: {pps_ifaces}"
35+
)
3236

3337
return results
3438

0 commit comments

Comments
 (0)