Skip to content

Commit ebedcf4

Browse files
committed
Addressed the comments
1 parent b258668 commit ebedcf4

4 files changed

Lines changed: 68 additions & 69 deletions

File tree

aci-preupgrade-validation-script.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6055,17 +6055,14 @@ def auto_firmware_update_on_switch_check(cversion, tversion, **kwargs):
60556055

60566056

60576057
@check_wrapper(check_title="Inband Management Policy Misconfiguration")
6058-
def inband_management_policy_misconfig_check(cversion, tversion, **kwargs):
6059-
6058+
def inband_management_policy_misconfig_check(tversion, **kwargs):
60606059
result = PASS
60616060
headers = ["Node_ID", "Address", "Gateway"]
60626061
data = []
6063-
recommended_action = " Contact Cisco TAC to remove any identified misconfigured 'mgmtRsInBStNode' objects"
6062+
recommended_action = "Contact Cisco TAC to remove any identified misconfigured 'mgmtRsInBStNode' objects"
60646063
doc_url = "https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#inband-management-policy-misconfiguration"
6065-
6066-
if not tversion:
6067-
return Result(result=MANUAL, msg=TVER_MISSING)
6068-
if cversion.older_than("6.0(4c)") and (tversion.newer_than("6.0(4c)") or tversion.same_as("6.0(4c)")):
6064+
6065+
if tversion.newer_than("6.0(4c)") or tversion.same_as("6.0(4c)"):
60696066
mgmtRsInBStNodes = icurl('class', 'mgmtRsInBStNode.json?query-target-filter=or(eq(mgmtRsInBStNode.addr,"0.0.0.0"),eq(mgmtRsInBStNode.addr,"0.0.0.0/0"),eq(mgmtRsInBStNode.gw,"0.0.0.0"))')
60706067
for mgmtRsInBStNode in mgmtRsInBStNodes:
60716068
attrs = mgmtRsInBStNode["mgmtRsInBStNode"]["attributes"]
@@ -6076,10 +6073,8 @@ def inband_management_policy_misconfig_check(cversion, tversion, **kwargs):
60766073
data.append([node_id, addr, gw])
60776074
else:
60786075
return Result(result=NA, msg=VER_NOT_AFFECTED)
6079-
60806076
if data:
60816077
result = FAIL_O
6082-
60836078
return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url)
60846079

60856080

docs/docs/validations.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ Items | Defect | This Script
227227
[d29]: #auto-firmware-update-on-switch-discovery
228228
[d30]: #inband-management-policy-misconfiguration
229229

230-
231230
## General Check Details
232231

233232
### Compatibility (Target ACI Version)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]

tests/checks/inband_management_policy_misconfig_check/test_inband_management_policy_misconfig_check.py

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,115 +5,119 @@
55
from helpers.utils import read_data
66

77
script = importlib.import_module("aci-preupgrade-validation-script")
8-
98
log = logging.getLogger(__name__)
109
dir = os.path.dirname(os.path.abspath(__file__))
11-
1210
test_function = "inband_management_policy_misconfig_check"
13-
14-
# icurl query
1511
mgmtRsInBStNode = 'mgmtRsInBStNode.json?query-target-filter=or(eq(mgmtRsInBStNode.addr,"0.0.0.0"),eq(mgmtRsInBStNode.addr,"0.0.0.0/0"),eq(mgmtRsInBStNode.gw,"0.0.0.0"))'
1612

17-
1813
@pytest.mark.parametrize(
19-
"icurl_outputs, cversion, tversion, expected_result",
14+
"icurl_outputs, tversion, expected_result, expected_data",
2015
[
21-
# Target version missing
16+
# Target version = 6.0(4c), valid data
2217
(
2318
{
24-
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_addr_and_gw_config.json"),
19+
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_valid_config.json")
2520
},
26-
"5.2(5c)",
27-
None,
28-
script.MANUAL,
29-
),
30-
# Current version < 6.0(4c), target version = 6.0(4c), valid data
31-
(
32-
{
33-
mgmtRsInBStNode: [],
34-
},
35-
"6.0(3g)",
3621
"6.0(4c)",
3722
script.PASS,
23+
[]
3824
),
39-
# Current version < 6.0(4c), target version > 6.0(4c), valid data
40-
(
41-
{
42-
mgmtRsInBStNode: [],
43-
},
44-
"6.0(3e)",
45-
"6.0(8f)",
46-
script.PASS,
47-
),
48-
# Current version > 6.0(4c), target version >= 6.0(4c), invalid address
25+
# Target version = 6.0(4c), invalid address
4926
(
5027
{
5128
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_address_config.json"),
5229
},
5330
"6.0(4c)",
54-
"6.0(5h)",
55-
script.NA,
31+
script.FAIL_O,
32+
[
33+
["103", "0.0.0.0", "191.1.1.1"],
34+
]
5635
),
57-
58-
# Current version > 6.0(4c), target version >= 6.0(4c), invalid gateway
36+
# Target version = 6.0(4c), invalid gateway
5937
(
6038
{
6139
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_gateway_config.json"),
6240
},
63-
"6.0(5h)",
64-
"6.0(5j)",
65-
script.NA,
41+
"6.0(4c)",
42+
script.FAIL_O,
43+
[
44+
["103", "191.1.1.153/24", "0.0.0.0"],
45+
]
6646
),
67-
# Current version > 6.0(4c), target version >= 6.0(4c), invalid both data
47+
# Target version = 6.0(4c), invalid both data
6848
(
6949
{
7050
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_addr_and_gw_config.json"),
7151
},
72-
"6.0(5j)",
73-
"6.0(6c)",
74-
script.NA,
52+
"6.0(4c)",
53+
script.FAIL_O,
54+
[
55+
["103", "0.0.0.0", "0.0.0.0"],
56+
]
7557
),
76-
# Current version < 6.0(4c), target version < 6.0(4c), invalid both data
58+
# Target version > 6.0(4c), valid data
7759
(
7860
{
79-
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_addr_and_gw_config.json"),
61+
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_valid_config.json"),
8062
},
81-
"6.0(3g)",
82-
"6.0(3f)",
83-
script.NA,
63+
"6.0(8f)",
64+
script.PASS,
65+
[]
8466
),
85-
# Current version < 6.0(4c), target version >= 6.0(4c), invalid address
67+
# Target version > 6.0(4c), invalid address
8668
(
8769
{
8870
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_address_config.json"),
8971
},
90-
"6.0(3g)",
91-
"6.0(4c)",
72+
"6.0(5h)",
9273
script.FAIL_O,
74+
[
75+
["103", "0.0.0.0", "191.1.1.1"],
76+
]
9377
),
94-
# Current version < 6.0(4c), target version >= 6.0(4c), invalid gateway
78+
# Target version > 6.0(4c), invalid gateway
9579
(
9680
{
9781
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_gateway_config.json"),
9882
},
99-
"5.3(2c)",
100-
"6.1(4h)",
83+
"6.0(5j)",
10184
script.FAIL_O,
85+
[
86+
["103", "191.1.1.153/24", "0.0.0.0"],
87+
]
10288
),
103-
# Current version < 6.0(4c), target version >= 6.0(4c), invalid both data
89+
# Target version > 6.0(4c), invalid both data
10490
(
10591
{
10692
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_addr_and_gw_config.json"),
10793
},
108-
"5.2(8h)",
109-
"6.1(3f)",
94+
"6.0(6c)",
11095
script.FAIL_O,
96+
[
97+
["103", "0.0.0.0", "0.0.0.0"],
98+
]
11199
),
100+
# Target version < 6.0(4c), invalid both data
101+
(
102+
{
103+
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_invalid_addr_and_gw_config.json"),
104+
},
105+
"6.0(3f)",
106+
script.NA,
107+
[]
108+
),
109+
# Target version < 6.0(4c), valid both data
110+
(
111+
{
112+
mgmtRsInBStNode: read_data(dir, "mgmtRsInBStNode_valid_config.json"),
113+
},
114+
"6.0(3f)",
115+
script.NA,
116+
[]
117+
)
112118
],
113119
)
114-
def test_logic(run_check, mock_icurl, cversion, tversion, expected_result):
115-
result = run_check(
116-
cversion = script.AciVersion(cversion),
117-
tversion = script.AciVersion(tversion) if tversion else None,
118-
)
119-
assert result.result == expected_result
120+
def test_logic(run_check, mock_icurl, tversion, expected_result, expected_data):
121+
result = run_check(tversion=script.AciVersion(tversion))
122+
assert result.result == expected_result
123+
assert result.data == expected_data

0 commit comments

Comments
 (0)