From 72ff6c374ae573cf777f2ee5abdb21932926c9fb Mon Sep 17 00:00:00 2001 From: GM Date: Fri, 28 Jul 2023 16:56:08 -0400 Subject: [PATCH] #57 fabricName check - v1.5.0 (#62) * issue 57 fabricName check + pytests * bump to v1.5.0 --- README.md | 191 +++++++++--------- aci-preupgrade-validation-script.py | 39 +++- .../test_fabricdomain_name_check.py | 91 +++++++++ .../topSystem_1POS.json | 38 ++++ .../topSystem_2POS.json | 38 ++++ .../topSystem_NEG.json | 38 ++++ 6 files changed, 339 insertions(+), 96 deletions(-) create mode 100644 tests/fabricdomain_name_check/test_fabricdomain_name_check.py create mode 100644 tests/fabricdomain_name_check/topSystem_1POS.json create mode 100644 tests/fabricdomain_name_check/topSystem_2POS.json create mode 100644 tests/fabricdomain_name_check/topSystem_NEG.json diff --git a/README.md b/README.md index a09304a..c8a15cf 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,37 @@ -Table of Contents -================= - -* [Table of Contents](#table-of-contents) -* [Quick Start](#quick-start) -* [Introduction](#introduction) -* [Preparation](#preparation) - * [ssh copy/paste and vi](#ssh-copypaste-and-vi) - * [local file transfer client](#local-file-transfer-client) -* [Usage](#usage) -* [Details](#details) - * [Results](#results) - * [General Checks](#general-checks) - * [Fault Checks](#fault-checks) - * [Configuration Checks](#configuration-checks) - * [Defect Condition Checks](#defect-condition-checks) - * [Log Files](#log-files) -* [Example run output](#example-run-output) - - +# Table of Contents + +- [Table of Contents](#table-of-contents) +- [Quick Start](#quick-start) +- [Introduction](#introduction) +- [Preparation](#preparation) + - [ssh copy/paste and vi](#ssh-copypaste-and-vi) + - [local file transfer client](#local-file-transfer-client) +- [Usage](#usage) +- [Details](#details) + - [Results](#results) + - [General Checks](#general-checks) + - [Fault Checks](#fault-checks) + - [Configuration Checks](#configuration-checks) + - [Defect Condition Checks](#defect-condition-checks) + - [Log Files](#log-files) +- [Example run output](#example-run-output) + # Quick Start 1. copy `aci-preupgrade-validation-script.py` ([link](https://raw.githubusercontent.com/datacenter/ACI-Pre-Upgrade-Validation-Script/master/aci-preupgrade-validation-script.py?token=AJD5RRLZ5LVFDIW6Z6ZDIMTBBW5X6)) on your APIC (`/data/techsupport`) 2. `cd /data/techsupport` -3. `python aci-preupgrade-validation-script.py` +3. `python aci-preupgrade-validation-script.py` 4. follow recommendations for all checks that have been flagged as `FAIL` or `MANUAL CHECK REQUIRED` - # Introduction -The Goal of this script is to provide you with an automated list of proactive checks before performing an ACI fabric upgrade. Each check is documented in the "Cisco ACI Upgrade guide - Pre-upgrade CheckLists" with a detailed explanation of the importance to resolve each issue before upgrading. +The Goal of this script is to provide you with an automated list of proactive checks before performing an ACI fabric upgrade. Each check is documented in the "Cisco ACI Upgrade guide - Pre-upgrade CheckLists" with a detailed explanation of the importance to resolve each issue before upgrading. [ACI Upgrade Documentation](https://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/all/apic-installation-upgrade-downgrade/Cisco-APIC-Installation-Upgrade-Downgrade-Guide.html) Failure to address an affected issue before an upgrade is known to cause challenges during or post upgrade. -For every check that has been flagged as `FAIL`, a general recommended action has been provided to guide next steps. There is also a summary with the number of checks that matched a given status. - +For every check that has been flagged as `FAIL`, a general recommended action has been provided to guide next steps. There is also a summary with the number of checks that matched a given status. # Preparation @@ -64,27 +60,28 @@ Download the script from here: [aci-preupgrade-validation-script.py](https://raw When run, the script will prompt for user credentials. -The script will then present a list of firmware from the APIC firmware repository and ask which one is the target -version for the next -planned upgrade. Ensure you have the desired ACI Firmware uploaded to the APIC Firmware Repository before +The script will then present a list of firmware from the APIC firmware repository and ask which one is the target +version for the next +planned upgrade. Ensure you have the desired ACI Firmware uploaded to the APIC Firmware Repository before running this script. Notes: -1. If the APIC FIrmware Repository is empty, the script will proceed but will mark checks that required the target version as -`MANUAL CHECK REQUIRED` -2. `admin` level privileges are recommended. User permissions are important as most of these checks rely on API query responses. -Non-admin remote user credentials can result in RBAC causing queries to return empty responses. -This can result in inconsistent script results. +1. If the APIC FIrmware Repository is empty, the script will proceed but will mark checks that required the target version as + `MANUAL CHECK REQUIRED` -3. This script only performs read operations and will not modify any config or filesystem properties. +2. `admin` level privileges are recommended. User permissions are important as most of these checks rely on API query responses. + Non-admin remote user credentials can result in RBAC causing queries to return empty responses. + This can result in inconsistent script results. + +3. This script only performs read operations and will not modify any config or filesystem properties. ``` -admin@f2-apic1:techsupport> python aci-preupgrade-validation-script.py +admin@f2-apic1:techsupport> python aci-preupgrade-validation-script.py ==== 2021-07-30T13-28-25-0700 ==== Enter username for APIC login : admin -Enter password for corresponding User : +Enter password for corresponding User : Checking current APIC version (switch nodes are assumed to be on the same version)...5.0(1g) @@ -97,7 +94,7 @@ What is the Target Version? : 1 You have chosen version "aci-apic-dk9.5.2.1d.bin" -[Check 1/36] APIC Target version image and MD5 hash... +[Check 1/36] APIC Target version image and MD5 hash... Checking f2-apic1...... DONE PASS [Check 2/36] Target version compatibility... PASS @@ -107,7 +104,7 @@ You have chosen version "aci-apic-dk9.5.2.1d.bin" ## Results -Each check has a unique result which will help determine how to proceed. The results are explained as follows: +Each check has a unique result which will help determine how to proceed. The results are explained as follows: - **PASS** - The check has completed, and the ACI Fabric is not affected by the issue. - **FAIL - OUTAGE WARNING** - The check has completed, and the ACI Fabric is currently affected by an issue which may cause an outage. @@ -121,71 +118,74 @@ Each check has a unique result which will help determine how to proceed. The re aci-preupgrade-validation-script.py currently performs the following checks: Key: + - **CREDS** = credentials; uname/pw supplied on script run - **CVER** = current version; Version on APIC during run - **TVER** = Target Version; selected on run if found -| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | -|-------------------------------------------------------|------------------------------------------------------------------------------------------------|-------------------------------| -| APIC Target version image and MD5 hash | Requires CREDS and TVER.
Logs into each APIC and checks image md5 file | MD5Sum Check for APIC and Switch Firmware + APIC Firmware Synchronization Across APICs | -| Target version compatibility | Requires TVER. Checks catalogue objects for TVER compatibility given CVER | Compatibility (Target ACI Version) | -| Gen 1 switch compatibility | Checks for gen1 hardware and flags incompatibility if TVER >= 5.0 | Compatibility (Switch Hardware) | -| Remote Leaf Compatibility | Checks for "Direct Traffic Forwarding" requirement | Compatibility (Remote Leaf Switch) | -| APIC CIMC Compatibility | Checks running CIMC against minimum recommended CIMC from CApability catalogue given TVER | Compatibility (CIMC Version) | -| APIC Cluster is Fully-Fit | -- | All Your APICs Are In a Fully Fit State | -| Switches are all in Active state | -- | All Your Switches Are In an Active State | -| NTP Status | Checks that NTP is running on the fabric, and that all nodes synchronized to configured NTP server | NTP (Clocks are synchronized Across the Fabric) | -| Firmware/Maintenance Groups when crossing 4.0 Release | Checks for existing FW/maint groups | Implementation Change for Firmware Update Groups on APICs from Release 4.0(1) | -| Features that need to be Disabled prior to Upgrade | See Pre-Upgrade Checklist | Configurations That Must Be Disabled Prior To Upgrades | -| Switch Upgrade Group Guidelines | See Pre-Upgrade Checklist | Grouping Rules 1, 2 and 3 + Switch Graceful Upgrade Guidelines | +| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | +| ----------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| APIC Target version image and MD5 hash | Requires CREDS and TVER.
Logs into each APIC and checks image md5 file | MD5Sum Check for APIC and Switch Firmware + APIC Firmware Synchronization Across APICs | +| Target version compatibility | Requires TVER. Checks catalogue objects for TVER compatibility given CVER | Compatibility (Target ACI Version) | +| Gen 1 switch compatibility | Checks for gen1 hardware and flags incompatibility if TVER >= 5.0 | Compatibility (Switch Hardware) | +| Remote Leaf Compatibility | Checks for "Direct Traffic Forwarding" requirement | Compatibility (Remote Leaf Switch) | +| APIC CIMC Compatibility | Checks running CIMC against minimum recommended CIMC from CApability catalogue given TVER | Compatibility (CIMC Version) | +| APIC Cluster is Fully-Fit | -- | All Your APICs Are In a Fully Fit State | +| Switches are all in Active state | -- | All Your Switches Are In an Active State | +| NTP Status | Checks that NTP is running on the fabric, and that all nodes synchronized to configured NTP server | NTP (Clocks are synchronized Across the Fabric) | +| Firmware/Maintenance Groups when crossing 4.0 Release | Checks for existing FW/maint groups | Implementation Change for Firmware Update Groups on APICs from Release 4.0(1) | +| Features that need to be Disabled prior to Upgrade | See Pre-Upgrade Checklist | Configurations That Must Be Disabled Prior To Upgrades | +| Switch Upgrade Group Guidelines | See Pre-Upgrade Checklist | Grouping Rules 1, 2 and 3 + Switch Graceful Upgrade Guidelines | ## Fault Checks -| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | -|--------------------------------------------------------------------------------------------|-------------------------------------------|-------------------------------| -| APIC Disk Space Usage (F1527, F1528, F1529 equipment-full) | -- | APIC DIsk Space Usage (F1527, F1528, F1529) | -| Switch Node /bootflash usage | Checks /bootflash usage object, flags if over 50% | ACI Switch bootflash Usage | -| Standby APIC Disk Space Usage | Login to Standby APICs and checks `df -h` | Filesystem on Standby APICs | -| APIC SSD Health | Check F2731, if not found, for version earlier than 4.2(7f) and 5.2(1g), get SSD lifetime from AE log | SSD health status on APICs | -| Switch SSD Health (F3073, F3074 equipment-flash-warning) | -- | SSD health status on ACI switches | -| Config On APIC Connected Port (F0467 port-configured-for-apic) | --| EPG config on ports connected to APICs | -| L3 Port Config (F0467 port-configured-as-l2) | -- | Conflicting interface L2/L3 mode| -| L2 Port Config (F0467 port-configured-as-l3) | -- | Conflicting interface L2/L3 mode | -| L3Out Subnets (F0467 prefix-entry-already-in-use) | -- | Conflicting L3Out subnets for contracts | -| BD Subnets (F1425 subnet-overlap) | -- | Overlapping BD subnets in the same VRF | -| BD Subnets (F0469 duplicate-subnets-within-ctx) | -- | Overlapping BD subnets in the same VRF| -| VMM Domain Controller Status | -- | VMM Controller Connectivity | -| VMM Domain LLDP/CDP Adjacency Status | -- | Missing LLDP/CDP adjacency between leaf nodes and VMM hypervisors | -| Different infra VLAN via LLDP (F0454 infra-vlan-mismatch) | -- | Different infra VLAN being injected via LLDP | -| HW Programming Failure (F3544 L3Out Prefixes, F3545 Contracts, actrl-resource-unavailable) | -- | Policy CAM + L3Out Subnets programming for contracts | -| Scalability (faults related to Capacity Dashboard) | -- | General Scalability Limits | +| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | +| ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | +| APIC Disk Space Usage (F1527, F1528, F1529 equipment-full) | -- | APIC DIsk Space Usage (F1527, F1528, F1529) | +| Switch Node /bootflash usage | Checks /bootflash usage object, flags if over 50% | ACI Switch bootflash Usage | +| Standby APIC Disk Space Usage | Login to Standby APICs and checks `df -h` | Filesystem on Standby APICs | +| APIC SSD Health | Check F2731, if not found, for version earlier than 4.2(7f) and 5.2(1g), get SSD lifetime from AE log | SSD health status on APICs | +| Switch SSD Health (F3073, F3074 equipment-flash-warning) | -- | SSD health status on ACI switches | +| Config On APIC Connected Port (F0467 port-configured-for-apic) | -- | EPG config on ports connected to APICs | +| L3 Port Config (F0467 port-configured-as-l2) | -- | Conflicting interface L2/L3 mode | +| L2 Port Config (F0467 port-configured-as-l3) | -- | Conflicting interface L2/L3 mode | +| L3Out Subnets (F0467 prefix-entry-already-in-use) | -- | Conflicting L3Out subnets for contracts | +| BD Subnets (F1425 subnet-overlap) | -- | Overlapping BD subnets in the same VRF | +| BD Subnets (F0469 duplicate-subnets-within-ctx) | -- | Overlapping BD subnets in the same VRF | +| VMM Domain Controller Status | -- | VMM Controller Connectivity | +| VMM Domain LLDP/CDP Adjacency Status | -- | Missing LLDP/CDP adjacency between leaf nodes and VMM hypervisors | +| Different infra VLAN via LLDP (F0454 infra-vlan-mismatch) | -- | Different infra VLAN being injected via LLDP | +| HW Programming Failure (F3544 L3Out Prefixes, F3545 Contracts, actrl-resource-unavailable) | -- | Policy CAM + L3Out Subnets programming for contracts | +| Scalability (faults related to Capacity Dashboard) | -- | General Scalability Limits | ## Configuration Checks -| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | -|-------------------------------------------------|------------------------------------------------------------------|-------------------------------| -| VPC-paired Leaf switches | Flags any Leaf switches not in a VPC| All Switch Nodes In vPC | -| Overlapping VLAN Pools | Checks for multiple domains attached to EPGs, then looks up the corresponding VLAN pools for VLAN overlap | Overlapping VLAN Pool | -| VNID Mismatch | For a given VLAN, flags the VLAN if found to have different VNIDS across different leaves | Overlapping VLAN Pool | -| L3Out MTU | Grabs all MTU defined on L3outs for manual peer MTU verification | L3Out MTU mismatch | -| BGP Peer Profile at node level without Loopback | See Pre-Upgrade Checklist| L3Out BGP Peer Connectivity Profile under a node profile without a loopback | -| L3Out Route Map import/export direction | See Pre-Upgrade Checklist | L3Out incorrect route map direction | -| Intersight Device Connector upgrade status | Flags if APIC Intersight Connector is upgrading| Intersight Device Connector is upgrading | -| ISIS Redistribution Metric for MPOD/Msite | For multi-pod/multi-site deployment, whether isis redistribute metric is less than 63 |Switch Graceful Upgrade Guidelines| -| BGP Route-target Type for GOLF over L2EVPN | For GOLF deployment, whether BGP route-target type starts with route-target: |Switch Graceful Upgrade Guidelines| -| APIC Container Bridge IP Overlap with APIC TEP | Checks if the container bridge IP (docker0) for appCenter on APICs is overlapping with APIC TEP IP | TBD | +| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | +| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| VPC-paired Leaf switches | Flags any Leaf switches not in a VPC | All Switch Nodes In vPC | +| Overlapping VLAN Pools | Checks for multiple domains attached to EPGs, then looks up the corresponding VLAN pools for VLAN overlap | Overlapping VLAN Pool | +| VNID Mismatch | For a given VLAN, flags the VLAN if found to have different VNIDS across different leaves | Overlapping VLAN Pool | +| L3Out MTU | Grabs all MTU defined on L3outs for manual peer MTU verification | L3Out MTU mismatch | +| BGP Peer Profile at node level without Loopback | See Pre-Upgrade Checklist | L3Out BGP Peer Connectivity Profile under a node profile without a loopback | +| L3Out Route Map import/export direction | See Pre-Upgrade Checklist | L3Out incorrect route map direction | +| Intersight Device Connector upgrade status | Flags if APIC Intersight Connector is upgrading | Intersight Device Connector is upgrading | +| ISIS Redistribution Metric for MPOD/Msite | For multi-pod/multi-site deployment, whether isis redistribute metric is less than 63 | Switch Graceful Upgrade Guidelines | +| BGP Route-target Type for GOLF over L2EVPN | For GOLF deployment, whether BGP route-target type starts with route-target: | Switch Graceful Upgrade Guidelines | +| APIC Container Bridge IP Overlap with APIC TEP | Checks if the container bridge IP (docker0) for appCenter on APICs is overlapping with APIC TEP IP | TBD | ## Defect Condition Checks -| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | -|----------------------------------------|-----------------------------------------------------------|-------------------------------| -| EP Announce Compatibility | Checks if TVER and CVER are affected by CSCvi76161 | EP Announce version mismatch | -| Eventmgr DB size defect susceptibility | Check if CVER is affected by CSCvn20175 | None, Contact TAC for verification | -| Contract Port 22 defect susceptibility | Check if TVER is affected by CSCvz65560 | None | -| telemetryStatsServerP defect susceptibility | Check for CVER, TVER and object in CSCvt47850 | None | -| Link Level Flow Control defect susceptibility | Check if CVER and TVER are susceptible to CSCvv33100 and CSCwd37387 | None | -| Non-AVE VLAN Blocks set to "Internal" | Check if CVER, TVER and VLAN Blocks are susceptible to CSCvw33061 | None | -| APIC CA Certificate Validation | Check if pkiFabricSelfCAEp was corrupted by CSCvy35257 | None +| Check Name | What is this check doing | Pre-upgrade Checklist Mapping | +| --------------------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------- | +| EP Announce Compatibility | Checks if TVER and CVER are affected by CSCvi76161 | EP Announce version mismatch | +| Eventmgr DB size defect susceptibility | Check if CVER is affected by CSCvn20175 | None, Contact TAC for verification | +| Contract Port 22 defect susceptibility | Check if TVER is affected by CSCvz65560 | None | +| telemetryStatsServerP defect susceptibility | Check for CVER, TVER and object in CSCvt47850 | None | +| Link Level Flow Control defect susceptibility | Check if CVER and TVER are susceptible to CSCvv33100 and CSCwd37387 | None | +| Non-AVE VLAN Blocks set to "Internal" | Check if CVER, TVER and VLAN Blocks are susceptible to CSCvw33061 | None | +| APIC CA Certificate Validation | Check if pkiFabricSelfCAEp was corrupted by CSCvy35257 | None | +| FabricDomain Name check | Check if fabricDomain name contains a special character which triggers CSCwf80352 | None | + ## Log Files A single log bundle will be generated with each run of the script @@ -193,7 +193,9 @@ A single log bundle will be generated with each run of the script ``` Result Bundle: /data/techsupport/preupgrade_validator_2021-07-27T17-13-12+0000.tgz ``` + This bundle contains 3 inner files; debug.log, .json and .txt. + ``` admin@APIC-1:techsupport> tar -xvf preupgrade_validator_2021-07-27T17-13-12+0000.tgz preupgrade_validator_logs/ @@ -204,17 +206,17 @@ preupgrade_validator_logs/preupgrade_validator_2021-07-27T17-13-12+0000.txt the `preupgrade_validator_*.txt` file contains a dump of the resulting output which can be referenced for check results post-run. -If there are any issues with the script or run results which require TAC assistance, open a proactive TAC case for the +If there are any issues with the script or run results which require TAC assistance, open a proactive TAC case for the upgrade and upload the result bundle for analysis. # Example run output ``` -admin@f2-apic1:techsupport> python aci-preupgrade-validation-script.py +admin@f2-apic1:techsupport> python aci-preupgrade-validation-script.py ==== 2021-07-30T13-28-25-0700 ==== Enter username for APIC login : admin -Enter password for corresponding User : +Enter password for corresponding User : Checking current APIC version (switch nodes are assumed to be on the same version)...5.0(1g) @@ -227,7 +229,7 @@ What is the Target Version? : 1 You have chosen version "aci-apic-dk9.5.2.1d.bin" -[Check 1/36] APIC Target version image and MD5 hash... +[Check 1/36] APIC Target version image and MD5 hash... Checking f2-apic1...... DONE PASS [Check 2/36] Target version compatibility... PASS @@ -329,4 +331,3 @@ TOTAL : 36 Result Bundle: /data/techsupport/preupgrade_validator_2021-07-30T13-28-25-0700.tgz ``` - diff --git a/aci-preupgrade-validation-script.py b/aci-preupgrade-validation-script.py index f76ad99..fc494b2 100644 --- a/aci-preupgrade-validation-script.py +++ b/aci-preupgrade-validation-script.py @@ -15,7 +15,7 @@ import os import re -SCRIPT_VERSION = "v1.4.0" +SCRIPT_VERSION = "v1.5.0" DONE = 'DONE' PASS = 'PASS' FAIL_O = 'FAIL - OUTAGE WARNING!!' @@ -2640,6 +2640,42 @@ def apic_ca_cert_validation(index, total_checks, **kwargs): return result +def fabricdomain_name_check(index, total_checks, cversion=None, tversion=None, **kwargs): + title = 'FabricDomain Name Check' + result = FAIL_O + msg = '' + headers = ["FabricDomain", "Reason"] + data = [] + recommended_action = "Do not upgrade to 6.0(2)" + doc_url = 'https://bst.cloudapps.cisco.com/bugsearch/bug/CSCwf80352' + + print_title(title, index, total_checks) + + if not tversion: + print_result(title, MANUAL, 'Target version not supplied. Skipping.') + return MANUAL + + cfw = AciVersion(cversion) + tfw = AciVersion(tversion) + + 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 + + fabricDomain = controller['imdata'][0]['topSystem']['attributes']['fabricDomain'] + if re.search(r'#|;', fabricDomain): + data.append([fabricDomain, "Contains a special character"]) + + + if not data: + result = PASS + print_result(title, result, msg, headers, data, recommended_action=recommended_action, doc_url=doc_url) + 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') @@ -2714,6 +2750,7 @@ def apic_ca_cert_validation(index, total_checks, **kwargs): llfc_susceptibility_check, internal_vlanpool_check, apic_ca_cert_validation, + fabricdomain_name_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): diff --git a/tests/fabricdomain_name_check/test_fabricdomain_name_check.py b/tests/fabricdomain_name_check/test_fabricdomain_name_check.py new file mode 100644 index 0000000..044593f --- /dev/null +++ b/tests/fabricdomain_name_check/test_fabricdomain_name_check.py @@ -0,0 +1,91 @@ +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 +topSystem = 'topSystem.json?query-target-filter=eq(topSystem.role,"controller")' + +@pytest.mark.parametrize( + "icurl_outputs, cversion, tversion, expected_result", + [ + # # char test + ( + { + topSystem: read_data(dir, "topSystem_1POS.json") + }, + "5.2(3g)", + "6.0(2h)", + script.FAIL_O, + ), + ( + { + topSystem: read_data(dir, "topSystem_1POS.json") + }, + "6.0(3a)", + "6.0(2h)", + script.FAIL_O, + ), + # ; char test + ( + { + topSystem: read_data(dir, "topSystem_2POS.json") + }, + "5.2(3g)", + "6.0(2h)", + script.FAIL_O, + ), + ( + { + topSystem: read_data(dir, "topSystem_2POS.json") + }, + "6.0(3a)", + "6.0(2h)", + script.FAIL_O, + ), + # Neither ; or # in fabricDomain + ( + { + topSystem: read_data(dir, "topSystem_NEG.json") + }, + "5.2(3g)", + "6.0(2h)", + script.PASS, + ), + # only affected 6.0(2h), regardless of special chars + ( + { + topSystem: read_data(dir, "topSystem_1POS.json") + }, + "5.2(3g)", + "6.0(1j)", + script.PASS, + ), + # Eventual 6.0(3) has fix + ( + { + topSystem: read_data(dir, "topSystem_1POS.json") + }, + "5.2(3g)", + "6.0(3a)", + script.PASS, + ), + ( + { + topSystem: read_data(dir, "topSystem_1POS.json") + }, + "6.0(3a)", + "6.0(4a)", + script.PASS, + ), + ], +) +def test_logic(mock_icurl, cversion, tversion, expected_result): + result = script.fabricdomain_name_check(1, 1, cversion, tversion) + assert result == expected_result diff --git a/tests/fabricdomain_name_check/topSystem_1POS.json b/tests/fabricdomain_name_check/topSystem_1POS.json new file mode 100644 index 0000000..982b27e --- /dev/null +++ b/tests/fabricdomain_name_check/topSystem_1POS.json @@ -0,0 +1,38 @@ +{ + "totalCount": "3", + "imdata": [ + { + "topSystem": { + "attributes": { + "address": "10.0.0.1", + "fabricId": "1", + "id": "1", + "fabricDomain": "fabric;4", + "role": "controller" + } + } + }, + { + "topSystem": { + "attributes": { + "address": "10.0.0.2", + "fabricId": "1", + "id": "2", + "fabricDomain": "fabric;4", + "role": "controller" + } + } + }, + { + "topSystem": { + "attributes": { + "address": "10.0.0.3", + "fabricId": "1", + "id": "3", + "fabricDomain": "fabric;4", + "role": "controller" + } + } + } + ] +} diff --git a/tests/fabricdomain_name_check/topSystem_2POS.json b/tests/fabricdomain_name_check/topSystem_2POS.json new file mode 100644 index 0000000..524cdb5 --- /dev/null +++ b/tests/fabricdomain_name_check/topSystem_2POS.json @@ -0,0 +1,38 @@ +{ + "totalCount": "3", + "imdata": [ + { + "topSystem": { + "attributes": { + "address": "10.0.0.1", + "fabricId": "1", + "id": "1", + "fabricDomain": "fabric#4", + "role": "controller" + } + } + }, + { + "topSystem": { + "attributes": { + "address": "10.0.0.2", + "fabricId": "1", + "id": "2", + "fabricDomain": "fabric#4", + "role": "controller" + } + } + }, + { + "topSystem": { + "attributes": { + "address": "10.0.0.3", + "fabricId": "1", + "id": "3", + "fabricDomain": "fabric#4", + "role": "controller" + } + } + } + ] +} diff --git a/tests/fabricdomain_name_check/topSystem_NEG.json b/tests/fabricdomain_name_check/topSystem_NEG.json new file mode 100644 index 0000000..cd260ff --- /dev/null +++ b/tests/fabricdomain_name_check/topSystem_NEG.json @@ -0,0 +1,38 @@ +{ + "totalCount": "3", + "imdata": [ + { + "topSystem": { + "attributes": { + "address": "10.0.0.1", + "fabricId": "1", + "id": "1", + "fabricDomain": "fabric4", + "role": "controller" + } + } + }, + { + "topSystem": { + "attributes": { + "address": "10.0.0.2", + "fabricId": "1", + "id": "2", + "fabricDomain": "fabric4", + "role": "controller" + } + } + }, + { + "topSystem": { + "attributes": { + "address": "10.0.0.3", + "fabricId": "1", + "id": "3", + "fabricDomain": "fabric4", + "role": "controller" + } + } + } + ] +}