From cff063884dc55628b4e74c43e5e48646d69ffaeb Mon Sep 17 00:00:00 2001 From: sanjanch Date: Mon, 12 Jan 2026 15:01:29 +0000 Subject: [PATCH 1/2] modified the method to check only the 'raised' faults --- aci-preupgrade-validation-script.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index ebe0477..8ef5175 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -2991,27 +2991,30 @@ def apic_disk_space_faults_check(cversion, **kwargs): doc_url = "https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#apic-disk-space-usage" recommended_action = { '/firmware': 'Remove unneeded images', - '/techsupport': 'Remove unneeded techsupports/cores' + '/techsupport': 'Remove unneeded techsupports/cores', + '/data/log': 'Remove unneeded logs in var/log/dme/log' } default_action = 'Contact Cisco TAC.' if cversion.same_as('4.0(1h)') or cversion.older_than('3.2(6i)'): default_action += ' A typical issue is CSCvn13119.' dn_regex = node_regex + r'/.+p-\[(?P.+)\]-f' - desc_regex = r'is (?P\d{2}%) full' - + desc_regex = r'is (?P\d{2,3}%) full' + faultInsts = icurl('class', 'faultInst.json?query-target-filter=or(eq(faultInst.code,"F1527"),eq(faultInst.code,"F1528"),eq(faultInst.code,"F1529"))') for faultInst in faultInsts: - fc = faultInst['faultInst']['attributes']['code'] - dn = re.search(dn_regex, faultInst['faultInst']['attributes']['dn']) - desc = re.search(desc_regex, faultInst['faultInst']['attributes']['descr']) - if dn and desc: - data.append([fc, dn.group('pod'), dn.group('node'), dn.group('mountpoint'), - desc.group('usage'), - recommended_action.get(dn.group('mountpoint'), default_action)]) - else: - unformatted_data.append([fc, faultInst['faultInst']['attributes']['dn'], default_action]) + lc = faultInst['faultInst']['attributes']['lc'] + if lc == "raised": + fc = faultInst['faultInst']['attributes']['code'] + dn = re.search(dn_regex, faultInst['faultInst']['attributes']['dn']) + desc = re.search(desc_regex, faultInst['faultInst']['attributes']['descr']) + if dn and desc: + data.append([fc, dn.group('pod'), dn.group('node'), dn.group('mountpoint'), + desc.group('usage'), + recommended_action.get(dn.group('mountpoint'), default_action)]) + else: + unformatted_data.append([fc, faultInst['faultInst']['attributes']['dn'], default_action]) if not data and not unformatted_data: result = PASS return Result( From 100f3576b412799f99b1bebb7541173192d954b3 Mon Sep 17 00:00:00 2001 From: sanjanch Date: Fri, 16 Jan 2026 07:15:16 +0000 Subject: [PATCH 2/2] added the pytest file for method 'apic_disk_space_faults_check' --- .../Fault_combination.json | 92 +++++++++++++++++++ .../Fault_exists_not_raised.json | 91 ++++++++++++++++++ .../Fault_raised.json | 91 ++++++++++++++++++ .../Fault_unformatted_data.json | 31 +++++++ .../test_apic_disk_space_faults_check.py | 80 ++++++++++++++++ 5 files changed, 385 insertions(+) create mode 100644 tests/checks/apic_disk_space_faults_check/Fault_combination.json create mode 100644 tests/checks/apic_disk_space_faults_check/Fault_exists_not_raised.json create mode 100644 tests/checks/apic_disk_space_faults_check/Fault_raised.json create mode 100644 tests/checks/apic_disk_space_faults_check/Fault_unformatted_data.json create mode 100644 tests/checks/apic_disk_space_faults_check/test_apic_disk_space_faults_check.py diff --git a/tests/checks/apic_disk_space_faults_check/Fault_combination.json b/tests/checks/apic_disk_space_faults_check/Fault_combination.json new file mode 100644 index 0000000..b6312cb --- /dev/null +++ b/tests/checks/apic_disk_space_faults_check/Fault_combination.json @@ -0,0 +1,92 @@ +[ + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1529", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /data/log on Node 1 with hostname fab3-apic1 mounted at /data/log is 94% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/data/log]-f-[tmpfs]/fault-F1529", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "raised", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + }, + + + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /firmware on Node 1 with hostname fab3-apic1 mounted at /firmware is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/firmware]-f-[/dev/mapper/vg_ifc0-firmware]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "soaking", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + }, + + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /techsupport on Node 1 with hostname fab3-apic1 mounted at /techsupport is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/techsupport]-f-[/dev/mapper/vg_ifc0-techsupport]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "raised-clearing", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + } + ] \ No newline at end of file diff --git a/tests/checks/apic_disk_space_faults_check/Fault_exists_not_raised.json b/tests/checks/apic_disk_space_faults_check/Fault_exists_not_raised.json new file mode 100644 index 0000000..aadbc74 --- /dev/null +++ b/tests/checks/apic_disk_space_faults_check/Fault_exists_not_raised.json @@ -0,0 +1,91 @@ +[ + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /data/log on Node 1 with hostname fab3-apic1 mounted at /data/log is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/data/log]-f-[tmpfs]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "retaining", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "cleared", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + }, + + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /firmware on Node 1 with hostname fab3-apic1 mounted at /firmware is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/firmware]-f-[/dev/mapper/vg_ifc0-firmware]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "soaking", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + }, + + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /techsupport on Node 1 with hostname fab3-apic1 mounted at /techsupport is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/techsupport]-f-[/dev/mapper/vg_ifc0-techsupport]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "raised-clearing", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + } + ] \ No newline at end of file diff --git a/tests/checks/apic_disk_space_faults_check/Fault_raised.json b/tests/checks/apic_disk_space_faults_check/Fault_raised.json new file mode 100644 index 0000000..37284ba --- /dev/null +++ b/tests/checks/apic_disk_space_faults_check/Fault_raised.json @@ -0,0 +1,91 @@ +[ + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /data/log on Node 1 with hostname fab3-apic1 mounted at /data/log is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/data/log]-f-[tmpfs]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "raised", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + }, + + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /firmware on Node 1 with hostname fab3-apic1 mounted at /firmware is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/firmware]-f-[/dev/mapper/vg_ifc0-firmware]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "raised", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + }, + + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 1501496, New: 240908), capUtilized (Old: 29, New: 89), inodesFree (Old: 12148991, New: 12148990), inodesUsed (Old: 721, New: 722), used (Old: 595656, New: 1856244)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "descr": "Storage unit /techsupport on Node 1 with hostname fab3-apic1 mounted at /techsupport is 89% full", + "dn": "topology/pod-1/node-1/sys/ch/p-[/techsupport]-f-[/dev/mapper/vg_ifc0-techsupport]/fault-F1528", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:44:26.382+00:00", + "lc": "raised", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + } + ] \ No newline at end of file diff --git a/tests/checks/apic_disk_space_faults_check/Fault_unformatted_data.json b/tests/checks/apic_disk_space_faults_check/Fault_unformatted_data.json new file mode 100644 index 0000000..759c4ed --- /dev/null +++ b/tests/checks/apic_disk_space_faults_check/Fault_unformatted_data.json @@ -0,0 +1,31 @@ +[ + { + "faultInst": { + "attributes": { + "ack": "no", + "alert": "no", + "cause": "equipment-full", + "changeSet": "available (Old: 237936, New: 1495556), capUtilized (Old: 89, New: 29), inodesFree (Old: 12148990, New: 12148991), inodesUsed (Old: 722, New: 721), used (Old: 1859216, New: 601596)", + "childAction": "", + "code": "F1528", + "created": "2026-01-12T06:44:26.382+00:00", + "delegated": "no", + "dn": "topology/pod-1/node-1/sys/ch/p-[/unknown]-f", + "descr": "Partition /unknown is 88% full", + "domain": "infra", + "highestSeverity": "major", + "lastTransition": "2026-01-12T06:49:47.550+00:00", + "lc": "raised", + "occur": "1", + "origSeverity": "major", + "prevSeverity": "major", + "rule": "eqpt-storage-full-major", + "severity": "major", + "status": "", + "subject": "equipment-full", + "title": "", + "type": "operational" + } + } + } + ] \ No newline at end of file diff --git a/tests/checks/apic_disk_space_faults_check/test_apic_disk_space_faults_check.py b/tests/checks/apic_disk_space_faults_check/test_apic_disk_space_faults_check.py new file mode 100644 index 0000000..93ee83f --- /dev/null +++ b/tests/checks/apic_disk_space_faults_check/test_apic_disk_space_faults_check.py @@ -0,0 +1,80 @@ +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__)) + +test_function = "apic_disk_space_faults_check" + +# icurl queries +faultInst = 'faultInst.json?query-target-filter=or(eq(faultInst.code,"F1527"),eq(faultInst.code,"F1528"),eq(faultInst.code,"F1529"))' + + +@pytest.mark.parametrize( + "icurl_outputs, cversion, expected_result", + [ + # PASS - No raised faults + ( + {faultInst: []}, + "4.2(1h)", + script.PASS, + ), + # FAIL - Raised faults with /firmware,/techsupport,/data/log mount points + ( + { + faultInst: read_data(dir, "Fault_raised.json") + }, + "4.2(1h)", + script.FAIL_UF, + ), + + # PASS - Faults exist but not raised (cleared) + ( + { + faultInst: read_data(dir, "Fault_exists_not_raised.json") + }, + "4.2(1h)", + script.PASS, + ), + + # FAIL - Raised faults with multiple status - Cleared and Active + ( + { + faultInst: read_data(dir, "Fault_combination.json") + }, + "4.2(1h)", + script.FAIL_UF, + ), + + # FAIL - Raised faults with unknown mount point (unformatted data) + ( + { + faultInst: read_data(dir, "Fault_unformatted_data.json") + }, + "4.2(1h)", + script.FAIL_UF, + ), + # FAIL - Raised faults with CSCvn13119 affected version + ( + { + faultInst: read_data(dir, "Fault_raised.json") + }, + "4.0(1h)", + script.FAIL_UF, + ), + # PASS - No raised faults with CSCvn13119 affected version + ( + {faultInst: []}, + "4.0(1h)", + script.PASS, + ), + ], +) +def test_logic(run_check, mock_icurl, cversion, expected_result): + result = run_check(cversion=script.AciVersion(cversion)) + assert result.result == expected_result \ No newline at end of file