Skip to content

Commit

Permalink
fix empty imdata result + add empty imdata test (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
monrog2 authored Aug 13, 2024
1 parent 8a616a7 commit 6d0c6f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
24 changes: 11 additions & 13 deletions aci-preupgrade-validation-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -2944,19 +2944,17 @@ def uplink_limit_check(index, total_checks, cversion, tversion, **kwargs):

if cversion.older_than("6.0(1a)") and tversion.newer_than("6.0(1a)"):
port_profiles = icurl('class', 'eqptPortP.json?query-target-filter=eq(eqptPortP.ctrl,"uplink")')
if not port_profiles or (len(port_profiles) < 57):
return result

node_count = {}
for pp in port_profiles:
dn = re.search(node_regex, pp['eqptPortP']['attributes']['dn'])
node_id = dn.group("node")
node_count.setdefault(node_id, 0)
node_count[node_id] += 1

for node, count in node_count.items():
if count > 56:
data.append([node, count])
if len(port_profiles) > 56:
node_count = {}
for pp in port_profiles:
dn = re.search(node_regex, pp['eqptPortP']['attributes']['dn'])
node_id = dn.group("node")
node_count.setdefault(node_id, 0)
node_count[node_id] += 1

for node, count in node_count.items():
if count > 56:
data.append([node, count])

if data:
result = FAIL_O
Expand Down
1 change: 1 addition & 0 deletions tests/uplink_limit_check/eqptPortP_empty.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
8 changes: 8 additions & 0 deletions tests/uplink_limit_check/test_uplink_limit_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@
"6.0(2h)",
script.FAIL_O,
),
(
{
eqptPortP: read_data(dir, "eqptPortP_empty.json")
},
"5.2(3g)",
"6.0(2h)",
script.PASS,
),
(
{
eqptPortP: read_data(dir, "eqptPortP_POS.json")
Expand Down

0 comments on commit 6d0c6f3

Please sign in to comment.