Skip to content

Commit f3f722d

Browse files
Addressed PR review comments
1 parent fc8f08a commit f3f722d

2 files changed

Lines changed: 36 additions & 14 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6418,6 +6418,9 @@ def wred_affected_model_check(tversion, fabric_nodes, **kwargs):
64186418
recommended_action = "Disable WRED in fabric or upgrade to a release newer than 6.1(5e) or 6.2(1g)."
64196419
doc_url = "https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#wred-with-affected-fm-models"
64206420

6421+
if not tversion:
6422+
return Result(result=MANUAL, msg=TVER_MISSING)
6423+
64216424
version_affected = (
64226425
(tversion.major1 == "6" and tversion.major2 == "1" and (tversion.older_than("6.1(5e)") or tversion.same_as("6.1(5e)")))
64236426
or (tversion.major1 == "6" and tversion.major2 == "2" and (tversion.older_than("6.2(1g)") or tversion.same_as("6.2(1g)")))
@@ -6432,6 +6435,12 @@ def wred_affected_model_check(tversion, fabric_nodes, **kwargs):
64326435
for node in fabric_nodes
64336436
}
64346437

6438+
for cong in icurl("class", "qosCong.json"):
6439+
if cong.get("qosCong", {}).get("attributes", {}).get("algo") == "wred":
6440+
break
6441+
else:
6442+
return Result(result=PASS, msg="WRED not enabled.")
6443+
64356444
for obj in icurl("class", "eqptFC.json"):
64366445
attr = obj["eqptFC"]["attributes"]
64376446
model = attr.get("model", "")
@@ -6446,17 +6455,8 @@ def wred_affected_model_check(tversion, fabric_nodes, **kwargs):
64466455
if not data:
64476456
return Result(result=NA, msg="No affected Fabric module found.")
64486457

6449-
wred_enabled = False
6450-
for cong in icurl("class", "qosCong.json"):
6451-
if cong.get("qosCong", {}).get("attributes", {}).get("algo") == "wred":
6452-
wred_enabled = True
6453-
break
6454-
6455-
if wred_enabled:
6456-
data.sort(key=lambda row: (int(row[0]) if row[0].isdigit() else row[0], row[3]))
6457-
result = FAIL_O
6458-
else:
6459-
data = []
6458+
data.sort(key=lambda row: (int(row[0]) if row[0].isdigit() else row[0], row[3]))
6459+
result = FAIL_O
64606460

64616461
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
64626462

tests/checks/wred_affected_model_check/test_wred_affected_model_check.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@
1717
@pytest.mark.parametrize(
1818
"tversion, fabric_nodes, icurl_outputs, expected_result, expected_data",
1919
[
20-
# Case 1: Target version 6.2(2a) is the first fixed release and not in the affected range.
20+
# Case 1: Target version not supplied. Expected: MANUAL.
21+
(
22+
None,
23+
read_data(dir, "fabricNode_spine.json"),
24+
{},
25+
script.MANUAL,
26+
[],
27+
),
28+
# Case 2: Target version 6.2(2a) is the first fixed release and not in the affected range.
2129
# Version gate fails. Expected: NA without any API calls.
2230
(
2331
"6.2(2a)",
@@ -40,11 +48,13 @@
4048
[["1001", "spine1001", "FM", "N9K-C9508-FM-E"]],
4149
),
4250
# Case 3: Version is affected but no affected FM hardware found.
43-
# Hardware gate fails before WRED is checked. Expected: NA - issue is model-specific.
51+
# WRED is enabled so the script proceeds to the FM check, which finds nothing.
52+
# Hardware gate fails. Expected: NA - issue is model-specific.
4453
(
4554
"6.1(5e)",
4655
read_data(dir, "fabricNode_spine.json"),
4756
{
57+
qosCong_api: read_data(dir, "qosCong_wred.json"),
4858
eqptFC_api: read_data(dir, "eqptFC_empty.json"),
4959
},
5060
script.NA,
@@ -75,11 +85,23 @@
7585
script.FAIL_O,
7686
[["1001", "spine1001", "FM", "N9K-C9508-FM-E"]],
7787
),
88+
# Case 6: Version is affected, WRED is enabled, but no affected FM models found.
89+
# FM gate fails. Expected: NA.
90+
(
91+
"6.2(1g)",
92+
read_data(dir, "fabricNode_spine.json"),
93+
{
94+
qosCong_api: read_data(dir, "qosCong_wred.json"),
95+
eqptFC_api: read_data(dir, "eqptFC_empty.json"),
96+
},
97+
script.NA,
98+
[],
99+
),
78100
],
79101
)
80102
def test_logic(run_check, mock_icurl, tversion, fabric_nodes, expected_result, expected_data):
81103
result = run_check(
82-
tversion=script.AciVersion(tversion),
104+
tversion=script.AciVersion(tversion) if tversion else None,
83105
fabric_nodes=fabric_nodes,
84106
)
85107
assert result.result == expected_result

0 commit comments

Comments
 (0)