From 3f9965bb4ce262b7bf21ea39fa417717193bf037 Mon Sep 17 00:00:00 2001 From: ASRAF KHAN NAZAR Date: Fri, 17 Jul 2026 10:03:13 +0000 Subject: [PATCH 1/3] Added Function check for certificate expiration --- aci-preupgrade-validation-script.py | 111 +++++ docs/docs/validations.md | 112 ++++- .../faultInst_F3081.json | 13 + .../faultInst_F3082.json | 13 + .../faultInst_F4501.json | 13 + .../faultInst_F4502.json | 13 + .../faultInst_F4503.json | 13 + .../faultInst_F4617.json | 13 + .../faultInst_F4752.json | 13 + .../faultInst_F4753.json | 13 + .../faultInst_cleared.json | 13 + .../faultInst_mixed.json | 46 ++ .../faultInst_multiple_expired.json | 35 ++ .../faultInst_multiple_expiring.json | 35 ++ .../test_certificate_expiration_check.py | 442 ++++++++++++++++++ 15 files changed, 897 insertions(+), 1 deletion(-) create mode 100644 tests/checks/certificate_expiration_check/faultInst_F3081.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F3082.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F4501.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F4502.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F4503.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F4617.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F4752.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_F4753.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_cleared.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_mixed.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_multiple_expired.json create mode 100644 tests/checks/certificate_expiration_check/faultInst_multiple_expiring.json create mode 100644 tests/checks/certificate_expiration_check/test_certificate_expiration_check.py diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index 5e79f56..d2c53e9 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -6702,6 +6702,116 @@ def stale_dbgacEpgSummaryTask_check(tversion, **kwargs): return Result(result=result, headers=headers, data=data, recommended_action=recommended_action, doc_url=doc_url) +@check_wrapper(check_title='Certificate Expiration Check') +def certificate_expiration_check(cversion, username, password, fabric_nodes, **kwargs): + result = PASS + headers = ["Fault Code", "Severity", "Description"] + data = [] + recommended_action = "" + doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#certificate-expiration-check' + + fault_min_versions = { + "F4501": "6.0(4c)", "F4502": "6.0(4c)", # KeyRing cert expiring/expired + "F4503": "6.1(1e)", "F4617": "6.1(1e)", # TP cert expired/expiring + "F3081": "3.1(2f)", "F3082": "3.1(2f)", # SAML encryption cert expiring/expired + "F4752": "6.1(5e)", "F4753": "6.1(5e)", # Factory certificate expired/expiring + } + FACTORY_CERT_MIN_VERSION = "6.1(5e)" + FACTORY_CERT_EXPIRING_DAYS = 30 + + has_critical = has_major = has_error = False + + applicable_codes = [code for code, ver in fault_min_versions.items() if not cversion.older_than(ver)] + if applicable_codes: + fault_filter = ",".join('eq(faultInst.code,"{}")'.format(code) for code in applicable_codes) + for faultInst in icurl('class', 'faultInst.json?query-target-filter=or({})'.format(fault_filter)): + fault_attrs = faultInst['faultInst']['attributes'] + if fault_attrs['lc'] not in ("raised", "soaking"): + continue + data.append([fault_attrs['code'], fault_attrs['severity'], fault_attrs['descr']]) + if fault_attrs['severity'] == 'critical': + has_critical = True + elif fault_attrs['severity'] == 'major': + has_major = True + + if cversion.older_than(FACTORY_CERT_MIN_VERSION) and username and password: + date_format = "%b %d %H:%M:%S %Y" + current_date_re = re.compile( + r'[A-Z][a-z]{2}\s+(?P[A-Z][a-z]{2})\s+(?P\d+)\s+(?P