Skip to content

Commit

Permalink
Sup hwrev check + v1.6.0 bump (#63)
Browse files Browse the repository at this point in the history
* sup hwrev check + pytests

* ver to v1.6.0
  • Loading branch information
monrog2 authored Aug 3, 2023
1 parent 72ff6c3 commit 828b6ba
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 3 deletions.
43 changes: 40 additions & 3 deletions aci-preupgrade-validation-script.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import os
import re

SCRIPT_VERSION = "v1.5.0"
SCRIPT_VERSION = "v1.6.0"
DONE = 'DONE'
PASS = 'PASS'
FAIL_O = 'FAIL - OUTAGE WARNING!!'
Expand Down Expand Up @@ -2660,7 +2660,6 @@ def fabricdomain_name_check(index, total_checks, cversion=None, tversion=None, *

if tfw.same_as("6.0(2h)"):
controller = icurl('class', 'topSystem.json?query-target-filter=eq(topSystem.role,"controller")')
print(controller)
if not controller:
print_result(title, ERROR, 'topSystem response empty. Is the cluster healthy?')
return ERROR
Expand All @@ -2676,6 +2675,42 @@ def fabricdomain_name_check(index, total_checks, cversion=None, tversion=None, *
return result


def sup_hwrev_check(index, total_checks, cversion=None, tversion=None, **kwargs):
title = 'Spine SUP HW Revision Check'
result = FAIL_O
msg = ''
headers = ["Pod", "Node", "Sup Slot", "Part Number"]
data = []
recommended_action = "Do not upgrade yet, please contact your account team"

print_title(title, index, total_checks)

cfw = AciVersion(cversion)
# tfw = AciVersion(tversion)

if cfw.newer_than("5.2(1a)") and cfw.older_than("6.0(1a)"):
sup_re = r'/.+(?P<supslot>supslot-\d+)'
sups = icurl('class', 'eqptSpCmnBlk.json?&query-target-filter=wcard(eqptSpromSupBlk.dn,"sup")')
if not sups:
print_result(title, ERROR, 'No sups found. This is unlikely.')
return ERROR

for sup in sups:
print(sup)
prtNum = sup['eqptSpCmnBlk']['attributes']['prtNum']
if prtNum in ['73-18562-02', '73-18570-02']:
dn = re.search(node_regex+sup_re, sup['eqptSpCmnBlk']['attributes']['dn'])
pod_id = dn.group("pod")
node_id = dn.group("node")
supslot = dn.group("supslot")
data.append([pod_id, node_id, supslot, prtNum])

if not data:
result = PASS
print_result(title, result, msg, headers, data, recommended_action=recommended_action)
return result


if __name__ == "__main__":
prints(' ==== %s%s, Script Version %s ====\n' % (ts, tz, SCRIPT_VERSION))
prints('!!!! Check https://github.com/datacenter/ACI-Pre-Upgrade-Validation-Script for Latest Release !!!!\n')
Expand Down Expand Up @@ -2750,7 +2785,9 @@ def fabricdomain_name_check(index, total_checks, cversion=None, tversion=None, *
llfc_susceptibility_check,
internal_vlanpool_check,
apic_ca_cert_validation,
fabricdomain_name_check
fabricdomain_name_check,
sup_hwrev_check,

]
summary = {PASS: 0, FAIL_O: 0, FAIL_UF: 0, ERROR: 0, MANUAL: 0, NA: 0, 'TOTAL': len(checks)}
for idx, check in enumerate(checks):
Expand Down
42 changes: 42 additions & 0 deletions tests/sup_hwrev_check/eqptSpCmnBlk_NEG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1201/sys/ch/supslot-1/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-A",
"prtNum": "73-15279-05"
}
}
},
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1201/sys/ch/supslot-2/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-A",
"prtNum": "73-15279-05"
}
}
},
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1202/sys/ch/supslot-1/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-A",
"prtNum": "73-15279-05"
}
}
},
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1202/sys/ch/supslot-1/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-A",
"prtNum": "73-15279-05"
}
}
}
]
42 changes: 42 additions & 0 deletions tests/sup_hwrev_check/eqptSpCmnBlk_POS.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1201/sys/ch/supslot-1/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-A",
"prtNum": "73-18562-02"
}
}
},
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1201/sys/ch/supslot-2/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-A",
"prtNum": "73-18562-02"
}
}
},
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1202/sys/ch/supslot-1/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-B",
"prtNum": "73-18570-02"
}
}
},
{
"eqptSpCmnBlk": {
"attributes": {
"dn": "topology/pod-1/node-1202/sys/ch/supslot-2/sup/spsup/spcmn",
"oem": "Cisco Systems, Inc.",
"pdNum": "N9K-SUP-B",
"prtNum": "73-18570-02"
}
}
}
]
58 changes: 58 additions & 0 deletions tests/sup_hwrev_check/test_sup_hwrev_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import os
import pytest
import logging
import importlib
from helpers.utils import read_data
script = importlib.import_module("aci-preupgrade-validation-script")

log = logging.getLogger(__name__)
dir = os.path.dirname(os.path.abspath(__file__))


# icurl queries
eqptSpCmnBlk = 'eqptSpCmnBlk.json?&query-target-filter=wcard(eqptSpromSupBlk.dn,"sup")'

@pytest.mark.parametrize(
"icurl_outputs, cversion, tversion, expected_result",
[
# Affected Sups and on 5.2
(
{
eqptSpCmnBlk: read_data(dir, "eqptSpCmnBlk_POS.json")
},
"5.2(1g)",
"6.0(2h)",
script.FAIL_O,
),
# Affected sups, no longer on 5.2
(
{
eqptSpCmnBlk: read_data(dir, "eqptSpCmnBlk_POS.json")
},
"6.0(3a)",
"6.0(2h)",
script.PASS,
),
# affected sups, not yet on 5.2
(
{
eqptSpCmnBlk: read_data(dir, "eqptSpCmnBlk_POS.json")
},
"4.2(3g)",
"5.2(2h)",
script.PASS,
),
# no affected sups
(
{
eqptSpCmnBlk: read_data(dir, "eqptSpCmnBlk_NEG.json")
},
"5.2(1g)",
"6.0(2h)",
script.PASS,
)
],
)
def test_logic(mock_icurl, cversion, tversion, expected_result):
result = script.sup_hwrev_check(1, 1, cversion, tversion)
assert result == expected_result

0 comments on commit 828b6ba

Please sign in to comment.