From 6cfd45bbc8e25485ac01edb931cd821e6f9b6853 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 22 Apr 2025 12:21:34 -0400 Subject: [PATCH 1/4] missing sw_cversion = ERR --- aci-preupgrade-validation-script.py | 32 ++++++++++++------- ..._unsupported_fec_configuration_ex_check.py | 16 ++++++++-- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index cc02e286..ce881b62 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -1171,7 +1171,6 @@ def get_switch_version(**kwargs): """ Returns lowest switch version as AciVersion instance """ prints("Gathering Lowest Switch Version from Firmware Repository...", end='') firmwares = icurl('class', 'firmwareRunning.json') - lowest_sw_ver = None versions = set() for firmware in firmwares: @@ -1184,7 +1183,10 @@ def get_switch_version(**kwargs): if lowest_sw_ver.newer_than(str(version)): lowest_sw_ver = version prints('%s\n' % lowest_sw_ver) - return lowest_sw_ver + return lowest_sw_ver + else: + prints("No Switches Detected! Join switches to the fabric then re-run this script.\n") + return None def apic_cluster_health_check(index, total_checks, cversion, **kwargs): @@ -3281,7 +3283,11 @@ def telemetryStatsServerP_object_check(index, total_checks, sw_cversion=None, tv doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#telemetrystatserverp-object' print_title(title, index, total_checks) - if not sw_cversion or not tversion: + if not sw_cversion: + print_result(title, ERROR, "Current switch version not found. Check switch health.") + return ERROR + + if not tversion: print_result(title, MANUAL, 'Current or target Switch version not supplied. Skipping.') return MANUAL @@ -4205,10 +4211,14 @@ def unsupported_fec_configuration_ex_check(index, total_checks, sw_cversion, tve doc_url = 'https://datacenter.github.io/ACI-Pre-Upgrade-Validation-Script/validations/#unsupported-fec-configuration-for-n9k-c93180yc-ex' print_title(title, index, total_checks) - if not sw_cversion or not tversion: - print_result(title, MANUAL, "Current or Target switch version not supplied. Skipping.") + if not sw_cversion: + print_result(title, ERROR, "Current switch version not found. Check switch health") + return ERROR + + if not tversion: + print_result(title, MANUAL, "Target switch version not supplied. Skipping.") return MANUAL - + if sw_cversion.older_than('5.0(1a)') and tversion.newer_than("5.0(1a)"): api = 'topSystem.json' api += '?rsp-subtree=children&rsp-subtree-class=l1PhysIf,eqptCh' @@ -4224,12 +4234,12 @@ def unsupported_fec_configuration_ex_check(index, total_checks, sw_cversion, tve elif child.get("l1PhysIf"): interface = child['l1PhysIf']['attributes']['id'] fecMode = child['l1PhysIf']['attributes']['fecMode'] - l1PhysIfs.append({"interface":interface,"fecMode":fecMode}) + l1PhysIfs.append({"interface": interface, "fecMode": fecMode}) if model and l1PhysIfs: pod_id = topSystem['topSystem']['attributes']['podId'] node_id = topSystem['topSystem']['attributes']['id'] for l1PhysIf in l1PhysIfs: - data.append([pod_id,node_id,model,l1PhysIf['interface'],l1PhysIf['fecMode']]) + data.append([pod_id, node_id, model, l1PhysIf['interface'], l1PhysIf['fecMode']]) if data: result = FAIL_O @@ -5111,10 +5121,10 @@ def ave_eol_check(index, total_checks, tversion, **kwargs): sys.exit() inputs = {'username': username, 'password': password, 'cversion': cversion, 'tversion': tversion, - 'vpc_node_ids': vpc_nodes, 'sw_cversion':sw_cversion} + 'vpc_node_ids': vpc_nodes, 'sw_cversion': sw_cversion} json_log = {"name": "PreupgradeCheck", "method": "standalone script", "datetime": ts + tz, - "script_version": str(SCRIPT_VERSION), "check_details": [], - 'cversion': str(cversion), 'tversion': str(tversion)} + "script_version": str(SCRIPT_VERSION), "check_details": [], + 'cversion': str(cversion), 'tversion': str(tversion), 'sw_cversion': sw_cversion} checks = [ # General Checks apic_version_md5_check, diff --git a/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py b/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py index 50d9035c..8b7827b3 100644 --- a/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py +++ b/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py @@ -49,13 +49,25 @@ "5.2(5c)", script.PASS, ), + ( + {topSystems: []}, + None, + "5.2(5c)", + script.ERROR, + ), + ( + {topSystems: []}, + "4.2(7f)", + None, + script.MANUAL, + ), ], ) def test_logic(mock_icurl, sw_cversion, tversion, expected_result): result = script.unsupported_fec_configuration_ex_check( 1, 1, - script.AciVersion(sw_cversion), - script.AciVersion(tversion), + script.AciVersion(sw_cversion) if sw_cversion else None, + script.AciVersion(tversion) if tversion else None, ) assert result == expected_result \ No newline at end of file From 3bf09d1d0b12d96225b5d41737b8847281f6148e Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 22 Apr 2025 12:23:06 -0400 Subject: [PATCH 2/4] consistency --- aci-preupgrade-validation-script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index ce881b62..b6310028 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -4212,7 +4212,7 @@ def unsupported_fec_configuration_ex_check(index, total_checks, sw_cversion, tve print_title(title, index, total_checks) if not sw_cversion: - print_result(title, ERROR, "Current switch version not found. Check switch health") + print_result(title, ERROR, "Current switch version not found. Check switch health.") return ERROR if not tversion: From 104d35a982040783e44590b3d697eb415e88461b Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 22 Apr 2025 12:27:10 -0400 Subject: [PATCH 3/4] lo as str --- aci-preupgrade-validation-script.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index b6310028..3aa8964a 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -5124,7 +5124,7 @@ def ave_eol_check(index, total_checks, tversion, **kwargs): 'vpc_node_ids': vpc_nodes, 'sw_cversion': sw_cversion} json_log = {"name": "PreupgradeCheck", "method": "standalone script", "datetime": ts + tz, "script_version": str(SCRIPT_VERSION), "check_details": [], - 'cversion': str(cversion), 'tversion': str(tversion), 'sw_cversion': sw_cversion} + 'cversion': str(cversion), 'tversion': str(tversion), 'sw_cversion': str(sw_cversion)} checks = [ # General Checks apic_version_md5_check, From a79fce50b0332075c9d250fd6f740ad0764569d6 Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 22 Apr 2025 12:38:05 -0400 Subject: [PATCH 4/4] ERR to MANUAL --- aci-preupgrade-validation-script.py | 8 ++++---- .../test_unsupported_fec_configuration_ex_check.py | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index 3aa8964a..32613588 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -3284,8 +3284,8 @@ def telemetryStatsServerP_object_check(index, total_checks, sw_cversion=None, tv print_title(title, index, total_checks) if not sw_cversion: - print_result(title, ERROR, "Current switch version not found. Check switch health.") - return ERROR + print_result(title, MANUAL, "Current switch version not found. Check switch health.") + return MANUAL if not tversion: print_result(title, MANUAL, 'Current or target Switch version not supplied. Skipping.') @@ -4212,8 +4212,8 @@ def unsupported_fec_configuration_ex_check(index, total_checks, sw_cversion, tve print_title(title, index, total_checks) if not sw_cversion: - print_result(title, ERROR, "Current switch version not found. Check switch health.") - return ERROR + print_result(title, MANUAL, "Current switch version not found. Check switch health.") + return MANUAL if not tversion: print_result(title, MANUAL, "Target switch version not supplied. Skipping.") diff --git a/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py b/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py index 8b7827b3..0990c762 100644 --- a/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py +++ b/tests/unsupported_fec_configuration_ex_check/test_unsupported_fec_configuration_ex_check.py @@ -53,7 +53,7 @@ {topSystems: []}, None, "5.2(5c)", - script.ERROR, + script.MANUAL, ), ( {topSystems: []},