From 4c6d67a38e7aedef5b3aad0e235b1ef3c44a287a Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Fri, 30 Aug 2024 14:35:49 -1000 Subject: [PATCH 1/5] fabric_isn: initial commit CODE FUNCTIONAL CHANGES plugins/module_utils/fabric/fabric_types.py - Add changes for ISN fabric DOCUMENTATION dcnm_fabric.py - Update documentation to include ISN fabric type docs/cisco.dcnm.dcnm_fabric_module.rst - Update with ISN fabric type docs/cisco.dcnm.dcnm_maintenance_mode_module.rst - This was missing. Adding it as part of this commit... README.md - Add dcnm_maintenance_mode link INTEGRATION TESTS playbooks/roles/dcnm_fabric/dcnm_tests.yaml - Added IT for ISM delete, merged, replaced tests/integration/targets/dcnm_fabric/tests/*.yaml - Added the following tests - dcnm_fabric_deleted_basic_isn.yaml - dcnm_fabric_merged_baeic_isn.yaml - Modified the following tests (tests were modified to include ISN) - dcnm_fabric_deleted_basic.yaml - Modified the following tests (only comments are modified) - dcnm_fabric_deleted_basic_ipfm.yaml - dcnm_fabric_deleted_basic_lan_classic.yaml - dcnm_fabric_deleted_basic_vxlan.yaml --- README.md | 5 +- docs/cisco.dcnm.dcnm_fabric_module.rst | 941 +++++++++++++++++- ...isco.dcnm.dcnm_maintenance_mode_module.rst | 294 ++++++ playbooks/roles/dcnm_fabric/dcnm_tests.yaml | 7 +- plugins/module_utils/fabric/fabric_types.py | 16 +- plugins/modules/dcnm_fabric.py | 306 +++++- .../tests/dcnm_fabric_deleted_basic.yaml | 149 ++- .../tests/dcnm_fabric_deleted_basic_ipfm.yaml | 1 - .../tests/dcnm_fabric_deleted_basic_isn.yaml | 262 +++++ ...dcnm_fabric_deleted_basic_lan_classic.yaml | 1 - .../tests/dcnm_fabric_deleted_basic_msd.yaml | 1 - .../dcnm_fabric_deleted_basic_vxlan.yaml | 1 - .../tests/dcnm_fabric_merged_basic_isn.yaml | 448 +++++++++ 13 files changed, 2396 insertions(+), 36 deletions(-) create mode 100644 docs/cisco.dcnm.dcnm_maintenance_mode_module.rst create mode 100644 tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_isn.yaml create mode 100644 tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_merged_basic_isn.yaml diff --git a/README.md b/README.md index e631bd7e8..32ef31d0c 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,10 @@ This collection is intended for use with the following release versions: ## Ansible version compatibility -This collection has been tested against following Ansible versions: **>=2.9.10**. +This collection has been tested against following Ansible versions: **>=2.15.0**. +For collections that support Ansible 2.9, please ensure you update your `network_os` to use the +fully qualified collection name (for example, `cisco.ios.ios`). Plugins and modules within a collection may be tested with only specific Ansible versions. A collection may contain metadata that identifies these versions. PEP440 is the schema used to describe the versions of Ansible. @@ -39,6 +41,7 @@ Name | Description [cisco.dcnm.dcnm_interface](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_interface_module.rst)|DCNM Ansible Module for managing interfaces. [cisco.dcnm.dcnm_inventory](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_inventory_module.rst)|Add and remove Switches from a DCNM managed VXLAN fabric. [cisco.dcnm.dcnm_links](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_links_module.rst)|DCNM ansible module for managing Links. +[cisco.dcnm.dcnm_maintenance_mode](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_maintenance_mode_module.rst)|Manage Maintenance Mode Configuration of NX-OS Switches. [cisco.dcnm.dcnm_network](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_network_module.rst)|Add and remove Networks from a DCNM managed VXLAN fabric. [cisco.dcnm.dcnm_policy](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_policy_module.rst)|DCNM Ansible Module for managing policies. [cisco.dcnm.dcnm_resource_manager](https://github.com/CiscoDevNet/ansible-dcnm/blob/main/docs/cisco.dcnm.dcnm_resource_manager_module.rst)|DCNM ansible module for managing resources. diff --git a/docs/cisco.dcnm.dcnm_fabric_module.rst b/docs/cisco.dcnm.dcnm_fabric_module.rst index 8c012612c..453e30966 100644 --- a/docs/cisco.dcnm.dcnm_fabric_module.rst +++ b/docs/cisco.dcnm.dcnm_fabric_module.rst @@ -99,9 +99,11 @@ Parameters @@ -1261,6 +1263,940 @@ Parameters + + + +
+ ISN_FABRIC_PARAMETERS + +
+ - +
+ + + + +
ISN (Inter-site Network) fabric specific parameters.
+
Also known as Multi-Site External Network.
+
The following parameters are specific to ISN fabrics.
+
Network infrastructure attached to Border Gateways to interconnect VXLAN EVPN fabrics for Multi-Site and Multi-Cloud deployments.
+
The indentation of these parameters is meant only to logically group them.
+
They should be at the same YAML level as FABRIC_TYPE and FABRIC_NAME.
+ + + + + + +
+ AAA_REMOTE_IP_ENABLED + +
+ boolean +
+ + + + + +
Enable only, when IP Authorization is enabled in the AAA Server
+ + + + + + +
+ AAA_SERVER_CONF + +
+ string +
+ + + Default:
""
+ + +
AAA Configurations
+ + + + + + +
+ BGP_AS + +
+ string +
+ + + Default:
""
+ + +
1-4294967295 | 1-65535.0-65535 It is a good practice to have a unique ASN for each Fabric.
+ + + + + + +
+ BOOTSTRAP_CONF + +
+ string +
+ + + Default:
""
+ + +
Additional CLIs required during device bootup/login e.g. AAA/Radius
+ + + + + + +
+ BOOTSTRAP_CONF_XE + +
+ string +
+ + + Default:
""
+ + +
Additional CLIs required during device bootup/login e.g. AAA/Radius
+ + + + + + +
+ BOOTSTRAP_ENABLE + +
+ boolean +
+ + + + + +
Automatic IP Assignment For POAP
+ + + + + + +
+ BOOTSTRAP_MULTISUBNET + +
+ string +
+ + + Default:
"#Scope_Start_IP, Scope_End_IP, Scope_Default_Gateway, Scope_Subnet_Prefix"
+ + +
lines with # prefix are ignored here
+ + + + + + +
+ CDP_ENABLE + +
+ boolean +
+ + + + + +
Enable CDP on management interface
+ + + + + + +
+ DHCP_ENABLE + +
+ boolean +
+ + + + + +
Automatic IP Assignment For POAP From Local DHCP Server
+ + + + + + +
+ DHCP_END + +
+ string +
+ + + Default:
""
+ + +
End Address For Switch POAP
+ + + + + + +
+ DHCP_IPV6_ENABLE + +
+ string +
+ + + + + +
No description available
+ + + + + + +
+ DHCP_START + +
+ string +
+ + + Default:
""
+ + +
Start Address For Switch POAP
+ + + + + + +
+ DOMAIN_NAME + +
+ string +
+ + + Default:
""
+ + +
Domain name for DHCP server PnP block
+ + + + + + +
+ ENABLE_AAA + +
+ boolean +
+ + + + + +
Include AAA configs from Advanced tab during device bootup
+ + + + + + +
+ ENABLE_NETFLOW + +
+ boolean +
+ + + + + +
Enable Netflow on VTEPs
+ + + + + + +
+ ENABLE_NXAPI + +
+ boolean +
+ + + + + +
Enable HTTPS NX-API
+ + + + + + +
+ ENABLE_NXAPI_HTTP + +
+ boolean +
+ + + + + +
No description available
+ + + + + + +
+ ENABLE_RT_INTF_STATS + +
+ boolean +
+ + + + + +
Valid for NX-OS only
+ + + + + + +
+ enableRealTimeBackup + +
+ boolean +
+ + + + Default:
""
+ + +
Backup hourly only if there is any config deployment since last backup
+ + + + + + +
+ enableScheduledBackup + +
+ boolean +
+ + + + Default:
""
+ + +
Backup at the specified time
+ + + + + + +
+ FABRIC_FREEFORM + +
+ string +
+ + + Default:
""
+ + +
Additional supported CLIs for all same OS (e.g. all NxOS or IOS-XE, etc) switches
+ + + + + + +
+ FABRIC_NAME + +
+ string +
+ + + Default:
""
+ + +
Please provide the fabric name to create it (Max Size 64)
+ + + + + + +
+ FEATURE_PTP + +
+ boolean +
+ + + + + +
No description available
+ + + + + + +
+ INBAND_ENABLE + +
+ boolean +
+ + + + + +
Enable POAP over Inband Interface (Pre-req: Inband Mgmt Knob should be Enabled)
+ + + + + + +
+ INBAND_MGMT + +
+ boolean +
+ + + + + +
Import switches with inband connectivity
+ + + + + + +
+ INTF_STAT_LOAD_INTERVAL + +
+ integer +
+ + + Default:
10
+ + +
Time in seconds
+ + + + + + +
+ IS_READ_ONLY + +
+ boolean +
+ + + + + +
If enabled, fabric is only monitored. No configuration will be deployed
+ + + + + + +
+ MGMT_GW + +
+ string +
+ + + Default:
""
+ + +
Default Gateway For Management VRF On The Switch
+ + + + + + +
+ MGMT_PREFIX + +
+ integer +
+ + + Default:
24
+ + +
No description available
+ + + + + + +
+ MGMT_V6PREFIX + +
+ integer +
+ + + Default:
64
+ + +
No description available
+ + + + + + +
+ MPLS_HANDOFF + +
+ boolean +
+ + + + + +
No description available
+ + + + + + +
+ MPLS_LB_ID + +
+ integer +
+ + + Default:
101
+ + +
No description available
+ + + + + + +
+ MPLS_LOOPBACK_IP_RANGE + +
+ string +
+ + + Default:
"10.102.0.0/25"
+ + +
MPLS Loopback IP Address Range
+ + + + + + +
+ NETFLOW_EXPORTER_LIST + +
+ list +
+ + + Default:
""
+ + +
One or Multiple Netflow Exporters
+ + + + + + +
+ NETFLOW_MONITOR_LIST + +
+ list +
+ + + Default:
""
+ + +
One or Multiple Netflow Monitors
+ + + + + + +
+ NETFLOW_RECORD_LIST + +
+ list +
+ + + Default:
""
+ + +
One or Multiple Netflow Records
+ + + + + + +
+ NETFLOW_SAMPLER_LIST + +
+ list +
+ + + Default:
""
+ + +
One or multiple netflow samplers. Applicable to N7K only
+ + + + + + +
+ NXAPI_HTTP_PORT + +
+ integer +
+ + + Default:
80
+ + +
No description available
+ + + + + + +
+ NXAPI_HTTPS_PORT + +
+ integer +
+ + + Default:
443
+ + +
No description available
+ + + + + + +
+ PM_ENABLE + +
+ boolean +
+ + + + + +
No description available
+ + + + + + +
+ PNP_ENABLE + +
+ boolean +
+ + + + + +
Enable Plug n Play (Automatic IP Assignment) for Cat9K switches
+ + + + + + +
+ POWER_REDUNDANCY_MODE + +
+ string +
+ + + + + +
Default Power Supply Mode For Bootstrapped NX-OS Switches
+ + + + + + +
+ PTP_DOMAIN_ID + +
+ integer +
+ + + Default:
0
+ + +
Multiple Independent PTP Clocking Subdomains on a Single Network
+ + + + + + +
+ PTP_LB_ID + +
+ integer +
+ + + Default:
0
+ + +
No description available
+ + + + + + +
+ scheduledTime + +
+ string +
+ + + Default:
""
+ + +
Time (UTC) in 24hr format. (00:00 to 23:59)
+ + + + + + +
+ SNMP_SERVER_HOST_TRAP + +
+ boolean +
+ + + + + +
Configure NDFC as a receiver for SNMP traps
+ + + + + + +
+ SUBINTERFACE_RANGE + +
+ string +
+ + + Default:
"2-511"
+ + +
Per Border Dot1q Range For VRF Lite Connectivity
+ + + @@ -6454,6 +7390,9 @@ Examples BGP_AS: 65000 ANYCAST_GW_MAC: 0001.aabb.ccdd UNDERLAY_IS_V6: false + EXTRA_CONF_LEAF: | + interface Ethernet1/1-16 + description managed by NDFC DEPLOY: false - FABRIC_NAME: MSD_Fabric FABRIC_TYPE: VXLAN_EVPN_MSD diff --git a/docs/cisco.dcnm.dcnm_maintenance_mode_module.rst b/docs/cisco.dcnm.dcnm_maintenance_mode_module.rst new file mode 100644 index 000000000..d453f3e5c --- /dev/null +++ b/docs/cisco.dcnm.dcnm_maintenance_mode_module.rst @@ -0,0 +1,294 @@ +.. _cisco.dcnm.dcnm_maintenance_mode_module: + + +******************************** +cisco.dcnm.dcnm_maintenance_mode +******************************** + +**Manage Maintenance Mode Configuration of NX-OS Switches.** + + +Version added: 3.5.0 + +.. contents:: + :local: + :depth: 1 + + +Synopsis +-------- +- Enable Maintenance or Normal Mode. + + + + +Parameters +---------- + +.. raw:: html + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ParameterChoices/DefaultsComments
+
+ config + +
+ dictionary + / required +
+
+ +
A dictionary containing the maintenance mode configuration.
+
+
+ deploy + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Whether to deploy the switch configurations.
+
+
+ mode + +
+ boolean +
+
+
    Choices: +
  • no
  • +
  • yes
  • +
+ Default:
"normal"
+
+
Enable maintenance or normal mode on all switches.
+
+
+ switches + +
+ list + / elements=dictionary + / required +
+
+ +
A list of target switches.
+
Per-switch options override the global options.
+
+
+ deploy + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
Whether to deploy the switch configuration.
+
+
+ ip_address + +
+ string + / required +
+
+ +
The IP address of the switch.
+
+
+ mode + +
+ string +
+
+
    Choices: +
  • maintenance
  • +
  • normal ←
  • +
+
+
Enable maintenance or normal mode for the switch.
+
+
+ wait_for_mode_change + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
If deploy is enabled, whether to wait for NDFC to push the change to the switch. Ignored if deploy is not enabled.
+
+
+ wait_for_mode_change + +
+ boolean +
+
+
    Choices: +
  • no ←
  • +
  • yes
  • +
+
+
If deploy is enabled, whether to wait for NDFC to push the change to the switch. Ignored if deploy is not enabled.
+
+
+ state + +
+ string +
+
+
    Choices: +
  • merged ←
  • +
  • query
  • +
+
+
The state of the feature or object after module completion
+
+
+ + + + +Examples +-------- + +.. code-block:: yaml + + # Enable maintenance mode on all switches. + # Do not deploy the configuration on any switch. + + - name: Configure switch mode + cisco.dcnm.dcnm_maintenance_mode: + state: merged + config: + deploy: true + wait_for_mode_change: true + mode: maintenance + switches: + - ip_address: 192.168.1.2 + - ip_address: 192.160.1.3 + - ip_address: 192.160.1.4 + register: result + - debug: + var: result + + # Enable maintenance mode on two switches. + # Enable normal mode on one switch. + # Deploy the configuration on one switch. + + - name: Configure switch mode + cisco.dcnm.dcnm_maintenance_mode: + state: merged + config: + deploy: false + mode: maintenance + switches: + - ip_address: 192.168.1.2 + mode: normal + - ip_address: 192.160.1.3 + deploy: true + wait_for_mode_change: true + - ip_address: 192.160.1.4 + register: result + - debug: + var: result + + + + +Status +------ + + +Authors +~~~~~~~ + +- Allen Robel (@quantumonion) diff --git a/playbooks/roles/dcnm_fabric/dcnm_tests.yaml b/playbooks/roles/dcnm_fabric/dcnm_tests.yaml index e125309b3..a944d71ab 100644 --- a/playbooks/roles/dcnm_fabric/dcnm_tests.yaml +++ b/playbooks/roles/dcnm_fabric/dcnm_tests.yaml @@ -22,17 +22,20 @@ # Uncomment ONE of the following testcases # testcase: dcnm_fabric_deleted_basic # testcase: dcnm_fabric_deleted_basic_ipfm + # testcase: dcnm_fabric_deleted_basic_isn # testcase: dcnm_fabric_deleted_basic_lan_classic # testcase: dcnm_fabric_deleted_basic_msd # testcase: dcnm_fabric_deleted_basic_vxlan # testcase: dcnm_fabric_merged_basic # testcase: dcnm_fabric_merged_basic_ipfm + # testcase: dcnm_fabric_merged_basic_isn # testcase: dcnm_fabric_merged_save_deploy # testcase: dcnm_fabric_merged_save_deploy_ipfm # testcase: dcnm_fabric_replaced_basic + # testcase: dcnm_fabric_replaced_basic_ipfm + # testcase: dcnm_fabric_replaced_basic_isn # testcase: dcnm_fabric_replaced_basic_vxlan # testcase: dcnm_fabric_replaced_basic_vxlan_site_id - # testcase: dcnm_fabric_replaced_basic_ipfm # testcase: dcnm_fabric_replaced_save_deploy # testcase: dcnm_fabric_replaced_save_deploy_ipfm # testcase: dcnm_fabric_query_basic.yaml @@ -44,6 +47,8 @@ fabric_type_3: LAN_CLASSIC fabric_name_4: IPFM_Fabric fabric_type_4: IPFM + fabric_name_5: ISN_Fabric + fabric_type_5: ISN leaf_1: 172.22.150.103 leaf_2: 172.22.150.104 nxos_username: admin diff --git a/plugins/module_utils/fabric/fabric_types.py b/plugins/module_utils/fabric/fabric_types.py index 4592a1d3a..f96dc41ce 100644 --- a/plugins/module_utils/fabric/fabric_types.py +++ b/plugins/module_utils/fabric/fabric_types.py @@ -24,7 +24,7 @@ class FabricTypes: """ - Fabric type definitions the dcnm_fabric module. + Fabric type definitions for the dcnm_fabric module. Usage @@ -65,13 +65,16 @@ def _init_fabric_types(self) -> None: This is the single place to add new fabric types. Initialize the following: - - fabric_type_to_feature_name_map dict() - fabric_type_to_template_name_map dict() + - fabric_type_to_feature_name_map dict() - _valid_fabric_types - Sorted list() of fabric types - - _mandatory_payload_keys_all_fabrics list() + - _mandatory_parameters_all_fabrics list() + - _mandatory_parameters dict() keyed on fabric type + - Value is a list of mandatory parameters for the fabric type """ self._fabric_type_to_template_name_map = {} self._fabric_type_to_template_name_map["IPFM"] = "Easy_Fabric_IPFM" + self._fabric_type_to_template_name_map["ISN"] = "External_Fabric" self._fabric_type_to_template_name_map["LAN_CLASSIC"] = "LAN_Classic" self._fabric_type_to_template_name_map["VXLAN_EVPN"] = "Easy_Fabric" self._fabric_type_to_template_name_map["VXLAN_EVPN_MSD"] = "MSD_Fabric" @@ -80,6 +83,7 @@ def _init_fabric_types(self) -> None: # on the controller to enable the fabric type. self._fabric_type_to_feature_name_map = {} self._fabric_type_to_feature_name_map["IPFM"] = "pmn" + self._fabric_type_to_feature_name_map["ISN"] = "vxlan" self._fabric_type_to_feature_name_map["LAN_CLASSIC"] = "lan" self._fabric_type_to_feature_name_map["VXLAN_EVPN"] = "vxlan" self._fabric_type_to_feature_name_map["VXLAN_EVPN_MSD"] = "vxlan" @@ -94,17 +98,23 @@ def _init_fabric_types(self) -> None: self._mandatory_parameters["IPFM"] = copy.copy( self._mandatory_parameters_all_fabrics ) + self._mandatory_parameters["ISN"] = copy.copy( + self._mandatory_parameters_all_fabrics + ) self._mandatory_parameters["LAN_CLASSIC"] = copy.copy( self._mandatory_parameters_all_fabrics ) self._mandatory_parameters["VXLAN_EVPN"] = copy.copy( self._mandatory_parameters_all_fabrics ) + self._mandatory_parameters["ISN"].append("BGP_AS") self._mandatory_parameters["VXLAN_EVPN"].append("BGP_AS") self._mandatory_parameters["VXLAN_EVPN_MSD"] = copy.copy( self._mandatory_parameters_all_fabrics ) + self._mandatory_parameters["IPFM"].sort() + self._mandatory_parameters["ISN"].sort() self._mandatory_parameters["LAN_CLASSIC"].sort() self._mandatory_parameters["VXLAN_EVPN"].sort() self._mandatory_parameters["VXLAN_EVPN_MSD"].sort() diff --git a/plugins/modules/dcnm_fabric.py b/plugins/modules/dcnm_fabric.py index 4204986e0..57ad5e241 100644 --- a/plugins/modules/dcnm_fabric.py +++ b/plugins/modules/dcnm_fabric.py @@ -56,9 +56,11 @@ type: str FABRIC_TYPE: choices: + - IPFM + - ISN + - LAN_CLASSIC - VXLAN_EVPN - VXLAN_EVPN_MSD - - LAN_CLASSIC description: - The type of fabric. required: true @@ -1545,6 +1547,308 @@ - Default Overlay VRF Template For Borders required: false type: str + ISN_FABRIC_PARAMETERS: + description: + - ISN (Inter-site Network) fabric specific parameters. + - Also known as Multi-Site External Network. + - The following parameters are specific to ISN fabrics. + - Network infrastructure attached to Border Gateways to interconnect VXLAN EVPN fabrics for Multi-Site and Multi-Cloud deployments. + - The indentation of these parameters is meant only to logically group them. + - They should be at the same YAML level as FABRIC_TYPE and FABRIC_NAME. + suboptions: + AAA_REMOTE_IP_ENABLED: + default: false + description: + - Enable only, when IP Authorization is enabled in the AAA Server + required: false + type: bool + AAA_SERVER_CONF: + default: '' + description: + - AAA Configurations + required: false + type: str + BGP_AS: + default: '' + description: + - 1-4294967295 | 1-65535.0-65535 It is a good practice to have a unique + ASN for each Fabric. + required: false + type: str + BOOTSTRAP_CONF: + default: '' + description: + - Additional CLIs required during device bootup/login e.g. AAA/Radius + required: false + type: str + BOOTSTRAP_CONF_XE: + default: '' + description: + - Additional CLIs required during device bootup/login e.g. AAA/Radius + required: false + type: str + BOOTSTRAP_ENABLE: + default: false + description: + - Automatic IP Assignment For POAP + required: false + type: bool + BOOTSTRAP_MULTISUBNET: + default: '#Scope_Start_IP, Scope_End_IP, Scope_Default_Gateway, Scope_Subnet_Prefix' + description: + - 'lines with # prefix are ignored here' + required: false + type: str + CDP_ENABLE: + default: false + description: + - Enable CDP on management interface + required: false + type: bool + DHCP_ENABLE: + default: false + description: + - Automatic IP Assignment For POAP From Local DHCP Server + required: false + type: bool + DHCP_END: + default: '' + description: + - End Address For Switch POAP + required: false + type: str + DHCP_IPV6_ENABLE: + choices: + - DHCPv4 + - DHCPv6 + default: DHCPv4 + description: + - No description available + required: false + type: str + DHCP_START: + default: '' + description: + - Start Address For Switch POAP + required: false + type: str + DOMAIN_NAME: + default: '' + description: + - Domain name for DHCP server PnP block + required: false + type: str + ENABLE_AAA: + default: false + description: + - Include AAA configs from Advanced tab during device bootup + required: false + type: bool + ENABLE_NETFLOW: + default: false + description: + - Enable Netflow on VTEPs + required: false + type: bool + ENABLE_NXAPI: + default: false + description: + - Enable HTTPS NX-API + required: false + type: bool + ENABLE_NXAPI_HTTP: + default: false + description: + - No description available + required: false + type: bool + ENABLE_RT_INTF_STATS: + default: false + description: + - Valid for NX-OS only + required: false + type: bool + FABRIC_FREEFORM: + default: '' + description: + - Additional supported CLIs for all same OS (e.g. all NxOS or IOS-XE, + etc) switches + required: false + type: str + FABRIC_NAME: + default: '' + description: + - Please provide the fabric name to create it (Max Size 64) + required: false + type: str + FEATURE_PTP: + default: false + description: + - No description available + required: false + type: bool + INBAND_ENABLE: + default: false + description: + - 'Enable POAP over Inband Interface (Pre-req: Inband Mgmt Knob should + be Enabled)' + required: false + type: bool + INBAND_MGMT: + default: false + description: + - Import switches with inband connectivity + required: false + type: bool + INTF_STAT_LOAD_INTERVAL: + default: 10 + description: + - 'Time in seconds ' + required: false + type: int + IS_READ_ONLY: + default: true + description: + - If enabled, fabric is only monitored. No configuration will be deployed + required: false + type: bool + MGMT_GW: + default: '' + description: + - Default Gateway For Management VRF On The Switch + required: false + type: str + MGMT_PREFIX: + default: 24 + description: + - No description available + required: false + type: int + MGMT_V6PREFIX: + default: 64 + description: + - No description available + required: false + type: int + MPLS_HANDOFF: + default: false + description: + - No description available + required: false + type: bool + MPLS_LB_ID: + default: 101 + description: + - No description available + required: false + type: int + MPLS_LOOPBACK_IP_RANGE: + default: 10.102.0.0/25 + description: + - MPLS Loopback IP Address Range + required: false + type: str + NETFLOW_EXPORTER_LIST: + default: '' + description: + - One or Multiple Netflow Exporters + required: false + type: list + NETFLOW_MONITOR_LIST: + default: '' + description: + - One or Multiple Netflow Monitors + required: false + type: list + NETFLOW_RECORD_LIST: + default: '' + description: + - One or Multiple Netflow Records + required: false + type: list + NETFLOW_SAMPLER_LIST: + default: '' + description: + - One or multiple netflow samplers. Applicable to N7K only + required: false + type: list + NXAPI_HTTPS_PORT: + default: 443 + description: + - No description available + required: false + type: int + NXAPI_HTTP_PORT: + default: 80 + description: + - No description available + required: false + type: int + PM_ENABLE: + default: false + description: + - No description available + required: false + type: bool + PNP_ENABLE: + default: false + description: + - Enable Plug n Play (Automatic IP Assignment) for Cat9K switches + required: false + type: bool + POWER_REDUNDANCY_MODE: + choices: + - ps-redundant + - combined + - insrc-redundant + default: ps-redundant + description: + - Default Power Supply Mode For Bootstrapped NX-OS Switches + required: false + type: str + PTP_DOMAIN_ID: + default: 0 + description: + - 'Multiple Independent PTP Clocking Subdomains on a Single Network ' + required: false + type: int + PTP_LB_ID: + default: 0 + description: + - No description available + required: false + type: int + SNMP_SERVER_HOST_TRAP: + default: true + description: + - Configure NDFC as a receiver for SNMP traps + required: false + type: bool + SUBINTERFACE_RANGE: + default: 2-511 + description: + - 'Per Border Dot1q Range For VRF Lite Connectivity ' + required: false + type: str + enableRealTimeBackup: + default: '' + description: + - Backup hourly only if there is any config deployment since last + backup + required: false + type: bool + enableScheduledBackup: + default: '' + description: + - Backup at the specified time + required: false + type: bool + scheduledTime: + default: '' + description: + - Time (UTC) in 24hr format. (00:00 to 23:59) + required: false + type: str IPFM_FABRIC_PARAMETERS: description: - IPFM (IP Fabric for Media) fabric specific parameters. diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml index 0ded0a927..05df6ef78 100644 --- a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml @@ -8,7 +8,6 @@ # # Test basic deletion of fabrics verify results. # - Deletion of populated fabrics not tested here. -# - See dcnm_fabric_deleted_populated.yaml instead. ################################################################################ ################################################################################ # STEPS @@ -22,18 +21,22 @@ # - fabric_type_2 # VXLAN_EVPN_MSD # - fabric_name_3 # - fabric_type_3 # LAN_CLASSIC +# - fabric_name_5 +# - fabric_type_5 # ISN # 2. Delete fabrics under test, if they exist # - fabric_name_1 # - fabric_name_2 # - fabric_name_3 +# - fabric_name_5 # TEST # 3. Create fabrics and verify result # - fabric_name_1 # - fabric_name_2 # - fabric_name_3 +# - fabric_name_5 # 4. Delete fabric_name_1 and fabric_name_2. Verify result -# 5. Delete fabric_name_3. Verify result -# 6. Delete fabric_name_3 again to verify idempotence. +# 5. Delete fabric_name_3 and fabric_name_5. Verify result +# 6. Delete fabric_name_3 and fabric_name_5 again to verify idempotence. # CLEANUP # 7. No cleanup required ################################################################################ @@ -56,6 +59,8 @@ # fabric_type_2: VXLAN_EVPN_MSD # fabric_name_3: LAN_CLASSIC_Fabric # fabric_type_3: LAN_CLASSIC +# fabric_name_5: ISN_Fabric +# fabric_type_5: ISN ################################################################################ # SETUP ################################################################################ @@ -66,6 +71,7 @@ - FABRIC_NAME: "{{ fabric_name_1 }}" - FABRIC_NAME: "{{ fabric_name_2 }}" - FABRIC_NAME: "{{ fabric_name_3 }}" + - FABRIC_NAME: "{{ fabric_name_5 }}" register: result - debug: var: result @@ -193,6 +199,10 @@ BOOTSTRAP_ENABLE: false IS_READ_ONLY: false DEPLOY: true + - FABRIC_NAME: "{{ fabric_name_5 }}" + FABRIC_TYPE: "{{ fabric_type_5 }}" + BGP_AS: "65005" + DEPLOY: true register: result - debug: var: result @@ -200,7 +210,7 @@ that: - result.changed == true - result.failed == false - - (result.diff | length) == 3 + - (result.diff | length) == 4 - result.diff[0].BGP_AS == "65535.65534" - result.diff[0].FABRIC_NAME == fabric_name_1 - result.diff[0].sequence_number == 1 @@ -210,7 +220,27 @@ - result.diff[2].sequence_number == 3 - result.diff[2].BOOTSTRAP_ENABLE == false - result.diff[2].IS_READ_ONLY == false - - (result.response | length) == 3 + - result.diff[3].BGP_AS == "65005" + - result.diff[3].FABRIC_NAME == fabric_name_5 + - result.diff[3].sequence_number == 4 + - (result.metadata | length) == 4 + - result.metadata[0].action == "fabric_create" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "merged" + - result.metadata[1].action == "fabric_create" + - result.metadata[1].check_mode == False + - result.metadata[1].sequence_number == 2 + - result.metadata[1].state == "merged" + - result.metadata[2].action == "fabric_create" + - result.metadata[2].check_mode == False + - result.metadata[2].sequence_number == 3 + - result.metadata[2].state == "merged" + - result.metadata[3].action == "fabric_create" + - result.metadata[3].check_mode == False + - result.metadata[3].sequence_number == 4 + - result.metadata[3].state == "merged" + - (result.response | length) == 4 - result.response[0].sequence_number == 1 - result.response[0].MESSAGE == "OK" - result.response[0].METHOD == "POST" @@ -223,11 +253,29 @@ - result.response[2].MESSAGE == "OK" - result.response[2].METHOD == "POST" - result.response[2].RETURN_CODE == 200 + - result.response[3].sequence_number == 4 + - result.response[3].MESSAGE == "OK" + - result.response[3].METHOD == "POST" + - result.response[3].RETURN_CODE == 200 + - (result.result | length) == 4 + - result.result[0].changed == True + - result.result[0].success == True + - result.result[0].sequence_number == 1 + - result.result[1].changed == True + - result.result[1].success == True + - result.result[1].sequence_number == 2 + - result.result[2].changed == True + - result.result[2].success == True + - result.result[2].sequence_number == 3 + - result.result[3].changed == True + - result.result[3].success == True + - result.result[3].sequence_number == 4 + ############################################################################################### # DELETED - TEST - Delete first two fabrics (fabric_name_1, fabric_name_2) and verify ############################################################################################### # Expected result -# ok: [ndfc1] => { +# ok: [172.22.150.244] => { # "result": { # "changed": true, # "diff": [ @@ -243,13 +291,13 @@ # "failed": false, # "metadata": [ # { -# "action": "delete", +# "action": "fabric_delete", # "check_mode": false, # "sequence_number": 1, # "state": "deleted" # }, # { -# "action": "delete", +# "action": "fabric_delete", # "check_mode": false, # "sequence_number": 2, # "state": "deleted" @@ -257,18 +305,18 @@ # ], # "response": [ # { -# "DATA": "Fabric 'VXLAN_EVPN_Fabric' is deleted successfully!", +# "DATA": "Invalid JSON response: Fabric 'VXLAN_EVPN_Fabric' is deleted successfully!", # "MESSAGE": "OK", # "METHOD": "DELETE", -# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/rest/control/fabrics/VXLAN_EVPN_Fabric", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/VXLAN_EVPN_Fabric", # "RETURN_CODE": 200, # "sequence_number": 1 # }, # { -# "DATA": "Fabric 'VXLAN_EVPN_MSD_Fabric' is deleted successfully!", +# "DATA": "Invalid JSON response: Fabric 'VXLAN_EVPN_MSD_Fabric' is deleted successfully!", # "MESSAGE": "OK", # "METHOD": "DELETE", -# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/rest/control/fabrics/VXLAN_EVPN_MSD_Fabric", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/VXLAN_EVPN_MSD_Fabric", # "RETURN_CODE": 200, # "sequence_number": 2 # } @@ -297,6 +345,8 @@ register: result - debug: var: result +- set_fact: + TEST_PHRASE: "is deleted successfully" - assert: that: - result.changed == true @@ -316,14 +366,19 @@ - result.metadata[1].sequence_number == 2 - result.metadata[1].state == "deleted" - (result.response | length) == 2 + # - '"{{ TEST_PHRASE }}" in result.response[0].DATA' + - TEST_PHRASE in result.response[0].DATA - result.response[0].MESSAGE == "OK" - result.response[0].METHOD == "DELETE" - result.response[0].RETURN_CODE == 200 - result.response[0].sequence_number == 1 + # - "{{ TEST_PHRASE }}" in result.response[1].DATA + - TEST_PHRASE in result.response[1].DATA - result.response[1].MESSAGE == "OK" - result.response[1].METHOD == "DELETE" - result.response[1].RETURN_CODE == 200 - result.response[1].sequence_number == 2 + - (result.result | length) == 2 - result.result[0].changed == true - result.result[0].success == true - result.result[0].sequence_number == 1 @@ -331,35 +386,53 @@ - result.result[1].success == true - result.result[1].sequence_number == 2 ################################################################################ -# DELETED - TEST - Delete third fabric (fabric_name_3) and verify +# DELETED - TEST - Delete remaining fabrics (fabric_name_3, fabric_name_5) and verify ################################################################################ # Expected result -# ok: [ndfc1] => { +# ok: [172.22.150.244] => { # "result": { # "changed": true, # "diff": [ # { # "FABRIC_NAME": "LAN_CLASSIC_Fabric", # "sequence_number": 1 +# }, +# { +# "FABRIC_NAME": "ISN_Fabric", +# "sequence_number": 2 # } # ], # "failed": false, # "metadata": [ # { -# "action": "delete", +# "action": "fabric_delete", # "check_mode": false, # "sequence_number": 1, # "state": "deleted" +# }, +# { +# "action": "fabric_delete", +# "check_mode": false, +# "sequence_number": 2, +# "state": "deleted" # } # ], # "response": [ # { -# "DATA": "Fabric 'LAN_CLASSIC_Fabric' is deleted successfully!", +# "DATA": "Invalid JSON response: Fabric 'LAN_CLASSIC_Fabric' is deleted successfully!", # "MESSAGE": "OK", # "METHOD": "DELETE", -# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/rest/control/fabrics/LAN_CLASSIC_Fabric", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/LAN_CLASSIC_Fabric", # "RETURN_CODE": 200, # "sequence_number": 1 +# }, +# { +# "DATA": "Invalid JSON response: Fabric 'ISN_Fabric' is deleted successfully!", +# "MESSAGE": "OK", +# "METHOD": "DELETE", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 2 # } # ], # "result": [ @@ -367,44 +440,70 @@ # "changed": true, # "sequence_number": 1, # "success": true +# }, +# { +# "changed": true, +# "sequence_number": 2, +# "success": true # } # ] # } # } ################################################################################ -- name: DELETED - TEST - Delete third fabric (fabric_name_3) and verify +- name: DELETED - TEST - Delete remaining fabrics (fabric_name_3, fabric_name_5) and verify cisco.dcnm.dcnm_fabric: &fabric_deleted state: deleted config: - FABRIC_NAME: "{{ fabric_name_3 }}" + - FABRIC_NAME: "{{ fabric_name_5 }}" register: result - debug: var: result +- set_fact: + TEST_PHRASE: "is deleted successfully" - assert: that: - result.changed == true - result.failed == false - - (result.diff | length) == 1 + - (result.diff | length) == 2 - result.diff[0].FABRIC_NAME == fabric_name_3 - result.diff[0].sequence_number == 1 - - (result.metadata | length) == 1 + - result.diff[1].FABRIC_NAME == fabric_name_5 + - result.diff[1].sequence_number == 2 + - (result.metadata | length) == 2 - result.metadata[0].action == "fabric_delete" - result.metadata[0].check_mode == False - result.metadata[0].sequence_number == 1 - result.metadata[0].state == "deleted" - - (result.response | length) == 1 + - result.metadata[1].action == "fabric_delete" + - result.metadata[1].check_mode == False + - result.metadata[1].sequence_number == 2 + - result.metadata[1].state == "deleted" + - (result.response | length) == 2 + # - "{{ TEST_PHRASE }}" in result.response[0].DATA + - TEST_PHRASE in result.response[0].DATA - result.response[0].MESSAGE == "OK" - result.response[0].METHOD == "DELETE" - result.response[0].RETURN_CODE == 200 - result.response[0].sequence_number == 1 + # - "{{ TEST_PHRASE }}" in result.response[1].DATA + - TEST_PHRASE in result.response[1].DATA + - result.response[1].MESSAGE == "OK" + - result.response[1].METHOD == "DELETE" + - result.response[1].RETURN_CODE == 200 + - result.response[1].sequence_number == 2 + - (result.result | length) == 2 - result.result[0].changed == true - result.result[0].success == true - result.result[0].sequence_number == 1 + - result.result[1].changed == true + - result.result[1].success == true + - result.result[1].sequence_number == 2 ################################################################################ -# DELETED - TEST - Delete third fabric (fabric_name_3) idempotence +# DELETED - TEST - Delete remaining fabrics (fabric_name_3, fabric_name_5) idempotence ################################################################################ # Expected result -# ok: [ndfc1] => { +# ok: [172.22.150.244] => { # "result": { # "changed": false, # "diff": [ @@ -415,7 +514,7 @@ # "failed": false, # "metadata": [ # { -# "action": "delete", +# "action": "fabric_delete", # "check_mode": false, # "sequence_number": 1, # "state": "deleted" @@ -438,7 +537,7 @@ # } # } ################################################################################ -- name: DELETED - TEST - Delete third fabric (fabric_name_3) idempotence +- name: DELETED - TEST - Delete remaining fabrics (fabric_name_3, fabric_name_5) idempotence cisco.dcnm.dcnm_fabric: *fabric_deleted register: result - debug: diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_ipfm.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_ipfm.yaml index 2e95c2dec..2e0afbb71 100644 --- a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_ipfm.yaml +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_ipfm.yaml @@ -8,7 +8,6 @@ # # Test basic deletion of fabrics verify results. # - Deletion of populated fabrics not tested here. -# - See dcnm_fabric_deleted_populated.yaml instead. ################################################################################ ################################################################################ # STEPS diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_isn.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_isn.yaml new file mode 100644 index 000000000..4b682f237 --- /dev/null +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_isn.yaml @@ -0,0 +1,262 @@ +################################################################################ +# RUNTIME +################################################################################ +# Recent run times (MM:SS.ms): +# 00:03.60 +################################################################################ +# DESCRIPTION - BASIC FABRIC DELETED STATE TEST FOR ISN +# +# Test basic deletion of fabrics and verify results. +# - Deletion of populated fabrics not tested here. +################################################################################ +################################################################################ +# STEPS +################################################################################ +# SETUP +# 1. The following fabrics must be empty on the controller +# See vars: section in cisco/dcnm/playbooks/dcnm_tests.yaml +# - fabric_name_5 +# - fabric_type_5 # ISN +# 2. Delete fabrics under test, if they exist +# - fabric_name_5 +# TEST +# 3. Create fabrics and verify result +# - fabric_name_5 +# 4. Delete fabric_name_5. Verify result +# CLEANUP +# 7. No cleanup required +################################################################################ +# REQUIREMENTS +################################################################################ +# Inventory: +# ./playbooks/roles/dcnm_fabric/dcnm_hosts.yaml +# Playbook: +# ./playbooks/roles/dcnm_fabric/dcnm_tests.yaml +# Roles: +# ./tests/integration/targets/dcnm_fabric/tests/*.yaml +# +# Example vars: +# +# vars: +# testcase: dcnm_fabric_deleted_basic_ISN +# fabric_name_5: ISN_Fabric +# fabric_type_5: ISN +################################################################################ +# SETUP +################################################################################ +- name: DELETED - SETUP - Delete fabrics + cisco.dcnm.dcnm_fabric: + state: deleted + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + register: result +- debug: + var: result +################################################################################ +# DELETED - TEST - Create ISN Fabric +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "BGP_AS": 65535, +# "FABRIC_NAME": "ISN_Fabric", +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_create", +# "check_mode": false, +# "sequence_number": 1, +# "state": "merged" +# } +# ], +# "response": [ +# { +# "DATA": { +# "nvPairs": { +# "BGP_AS": "65535", +# "FABRIC_NAME": "ISN_Fabric", +# "FABRIC_TYPE": "External" +# } +# }, +# "MESSAGE": "OK", +# "METHOD": "POST", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric/External_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: DELETED - SETUP - Create ISN Fabric and verify + cisco.dcnm.dcnm_fabric: + state: merged + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + FABRIC_TYPE: "{{ fabric_type_5 }}" + BGP_AS: 65535 + DEPLOY: true + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].FABRIC_NAME == fabric_name_5 + - result.response[0].DATA.nvPairs.BGP_AS == "65535" + - result.response[0].DATA.nvPairs.FABRIC_NAME == fabric_name_5 + - result.response[0].DATA.nvPairs.FABRIC_TYPE == "External" + - (result.response | length) == 1 + - result.response[0].sequence_number == 1 + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "POST" + - result.response[0].RETURN_CODE == 200 +############################################################################################### +# DELETED - TEST - Delete ISN Fabric (fabric_name_5) and verify +############################################################################################### +# Expected result +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "FABRIC_NAME": "ISN_Fabric", +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_delete", +# "check_mode": false, +# "sequence_number": 1, +# "state": "deleted" +# } +# ], +# "response": [ +# { +# "DATA": "Invalid JSON response: Fabric 'ISN_Fabric' is deleted successfully!", +# "MESSAGE": "OK", +# "METHOD": "DELETE", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +############################################################################################### +- name: DELETED - TEST - Delete ISN fabric (fabric_name_5) and verify + cisco.dcnm.dcnm_fabric: &fabric_deleted + state: deleted + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].FABRIC_NAME == fabric_name_5 + - result.diff[0].sequence_number == 1 + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_delete" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "deleted" + - (result.response | length) == 1 + - result.response[0].DATA == "Invalid JSON response: Fabric 'ISN_Fabric' is deleted successfully!" + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "DELETE" + - result.response[0].RETURN_CODE == 200 + - result.response[0].sequence_number == 1 + - result.result[0].changed == true + - result.result[0].success == true + - result.result[0].sequence_number == 1 +################################################################################ +# DELETED - TEST - Delete ISN Fabric (fabric_name_5) and verify idempotence +################################################################################ +# Expected result +# ok: [172.22.150.244] => { +# "result": { +# "changed": false, +# "diff": [ +# { +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_delete", +# "check_mode": false, +# "sequence_number": 1, +# "state": "deleted" +# } +# ], +# "response": [ +# { +# "MESSAGE": "No fabrics to delete", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": false, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: DELETED - TEST - Delete ISN Fabric (fabric_name_5) and verify idempotence + cisco.dcnm.dcnm_fabric: *fabric_deleted + register: result +- debug: + var: result +- assert: + that: + - result.changed == false + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].sequence_number == 1 + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_delete" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "deleted" + - (result.response | length) == 1 + - result.response[0].MESSAGE == "No fabrics to delete" + - result.response[0].RETURN_CODE == 200 + - result.response[0].sequence_number == 1 + - result.result[0].changed == false + - result.result[0].success == true + - result.result[0].sequence_number == 1 diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_lan_classic.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_lan_classic.yaml index 443af166b..00816ca31 100644 --- a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_lan_classic.yaml +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_lan_classic.yaml @@ -8,7 +8,6 @@ # # Test basic deletion of fabrics verify results. # - Deletion of populated fabrics not tested here. -# - See dcnm_fabric_deleted_populated.yaml instead. ################################################################################ ################################################################################ # STEPS diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_msd.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_msd.yaml index 59200f2e3..9a4e21c7e 100644 --- a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_msd.yaml +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_msd.yaml @@ -8,7 +8,6 @@ # # Test basic deletion of fabrics verify results. # - Deletion of populated fabrics not tested here. -# - See dcnm_fabric_deleted_populated.yaml instead. ################################################################################ ################################################################################ # STEPS diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_vxlan.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_vxlan.yaml index a9844b96e..fbcd25be1 100644 --- a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_vxlan.yaml +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic_vxlan.yaml @@ -8,7 +8,6 @@ # # Test basic deletion of fabrics verify results. # - Deletion of populated fabrics not tested here. -# - See dcnm_fabric_deleted_populated.yaml instead. ################################################################################ ################################################################################ # STEPS diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_merged_basic_isn.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_merged_basic_isn.yaml new file mode 100644 index 000000000..dc42832e3 --- /dev/null +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_merged_basic_isn.yaml @@ -0,0 +1,448 @@ +################################################################################ +# RUNTIME +################################################################################ +# Recent run times (MM:SS.ms): +# TODO +################################################################################ +# DESCRIPTION - BASIC FABRIC MERGED STATE TEST for ISN +# +# Test basic merge of new ISN fabric configuration and verify results. +# - config-save and config-deploy not tested here. +# - See dcnm_fabric_merged_save_deploy_ISN.yaml instead. +################################################################################ +# STEPS +################################################################################ +# SETUP +################################################################################ +# 1. The following fabrics must be empty on the controller +# See vars: section in cisco/dcnm/playbooks/dcnm_tests.yaml +# - fabric_name_5 +# - fabric_type_5 # ISN +# 3. Delete fabrics under test, if they exist +# - fabric_name_5 +################################################################################ +# TEST +################################################################################ +# 4. Create fabrics and verify result +# - fabric_name_5 +# 5. Merge additional configs into fabric_5 and verify result +################################################################################ +# CLEANUP +################################################################################ +# 6. Delete fabrics under test +# - fabric_name_5 +################################################################################ +# REQUIREMENTS +################################################################################ +# Inventory: +# ./playbooks/roles/dcnm_fabric/dcnm_hosts.yaml +# Playbook: +# ./playbooks/roles/dcnm_fabric/dcnm_tests.yaml +# Roles: +# ./tests/integration/targets/dcnm_fabric/tests/*.yaml +# +# Example vars: +# +# vars: +# testcase: dcnm_fabric_merged_basic_isn +# fabric_name_5: ISN_Fabric +# fabric_type_5: ISN +################################################################################ +# MERGED - SETUP - Delete fabrics +################################################################################ +- name: MERGED - SETUP - Delete fabrics + cisco.dcnm.dcnm_fabric: + state: deleted + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + register: result +- debug: + var: result +################################################################################ +# MERGED - TEST - Create ISN fabric type with basic config +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "BGP_AS": 65535, +# "FABRIC_NAME": "ISN_Fabric", +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_create", +# "check_mode": false, +# "sequence_number": 1, +# "state": "merged" +# } +# ], +# "response": [ +# { +# "DATA": { +# "nvPairs": { +# "BGP_AS": "65535", +# "DCI_SUBNET_RANGE": "10.10.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "FABRIC_TYPE": "External", +# "LOOPBACK0_IP_RANGE": "10.1.0.0/22", +# }, +# }, +# "MESSAGE": "OK", +# "METHOD": "POST", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric/External_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: MERGED - TEST - Create all supported fabric types with minimal config + cisco.dcnm.dcnm_fabric: + state: merged + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + FABRIC_TYPE: "{{ fabric_type_5 }}" + BGP_AS: 65535 + DEPLOY: true + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].BGP_AS == 65535 + - result.diff[0].FABRIC_NAME == fabric_name_5 + - result.diff[0].sequence_number == 1 + - result.metadata[0].action == "fabric_create" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "merged" + - (result.response | length) == 1 + - result.response[0].sequence_number == 1 + - result.response[0].MESSAGE == "OK" + - result.response[0].DATA.nvPairs.BGP_AS == "65535" + - result.response[0].DATA.nvPairs.DCI_SUBNET_RANGE == "10.10.1.0/24" + - result.response[0].DATA.nvPairs.FABRIC_NAME == fabric_name_5 + - result.response[0].DATA.nvPairs.FABRIC_TYPE == "External" + - result.response[0].DATA.nvPairs.LOOPBACK0_IP_RANGE == "10.1.0.0/22" + - result.response[0].METHOD == "POST" + - result.response[0].RETURN_CODE == 200 +################################################################################ +# MERGED - TEST - Merge additional valid configs into fabric_5 +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "DCI_SUBNET_RANGE": "10.20.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "LOOPBACK0_IP_RANGE": "10.2.0.0/22", +# "sequence_number": 1 +# }, +# { +# "sequence_number": 2 +# }, +# { +# "sequence_number": 3 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_update", +# "check_mode": false, +# "sequence_number": 1, +# "state": "merged" +# }, +# { +# "action": "config_save", +# "check_mode": false, +# "sequence_number": 2, +# "state": "merged" +# }, +# { +# "action": "config_deploy", +# "check_mode": false, +# "sequence_number": 3, +# "state": "merged" +# } +# ], +# "response": [ +# { +# "DATA": { +# "asn": "65535", +# "createdOn": 1725045045386, +# "deviceType": "n9k", +# "fabricId": "FABRIC-6", +# "fabricName": "ISN_Fabric", +# "fabricTechnology": "External", +# "fabricTechnologyFriendly": "Custom", +# "fabricType": "External", +# "fabricTypeFriendly": "External", +# "id": 6, +# "modifiedOn": 1725045053210, +# "nvPairs": { +# "BGP_AS": "65535", +# "DCI_SUBNET_RANGE": "10.20.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "FABRIC_TYPE": "External", +# "LOOPBACK0_IP_RANGE": "10.2.0.0/22" +# } +# }, +# "MESSAGE": "OK", +# "METHOD": "PUT", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric/External_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# }, +# { +# "MESSAGE": "Fabric ISN_Fabric DEPLOY is False or None. Skipping config-save.", +# "RETURN_CODE": 200, +# "sequence_number": 2 +# }, +# { +# "MESSAGE": "FabricConfigDeploy._can_fabric_be_deployed: Fabric ISN_Fabric DEPLOY is False or None. Skipping config-deploy.", +# "RETURN_CODE": 200, +# "sequence_number": 3 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# }, +# { +# "changed": true, +# "sequence_number": 2, +# "success": true +# }, +# { +# "changed": true, +# "sequence_number": 3, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: MERGED - TEST - Merge additional configs into fabric_5 + cisco.dcnm.dcnm_fabric: &merge_fabric_5 + state: merged + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + FABRIC_TYPE: "{{ fabric_type_5 }}" + BGP_AS: 65535 + DCI_SUBNET_RANGE: "10.20.1.0/24" + LOOPBACK0_IP_RANGE: "10.2.0.0/22" + DEPLOY: false + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 3 + - result.diff[0].FABRIC_NAME == fabric_name_5 + - result.diff[0].DCI_SUBNET_RANGE == "10.20.1.0/24" + - result.diff[0].LOOPBACK0_IP_RANGE == "10.2.0.0/22" + - result.diff[0].sequence_number == 1 + - result.diff[1].sequence_number == 2 + - result.diff[2].sequence_number == 3 + - (result.metadata | length) == 3 + - result.metadata[0].action == "fabric_update" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "merged" + - result.metadata[1].action == "config_save" + - result.metadata[1].check_mode == False + - result.metadata[1].sequence_number == 2 + - result.metadata[1].state == "merged" + - result.metadata[2].action == "config_deploy" + - result.metadata[2].check_mode == False + - result.metadata[2].sequence_number == 3 + - result.metadata[2].state == "merged" + - (result.response | length) == 3 + - result.response[0].sequence_number == 1 + - result.response[0].DATA.nvPairs.BGP_AS == "65535" + - result.response[0].DATA.nvPairs.DCI_SUBNET_RANGE == "10.20.1.0/24" + - result.response[0].DATA.nvPairs.FABRIC_NAME == fabric_name_5 + - result.response[0].DATA.nvPairs.FABRIC_TYPE == "External" + - result.response[0].DATA.nvPairs.LOOPBACK0_IP_RANGE == "10.2.0.0/22" + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "PUT" + - result.response[0].RETURN_CODE == 200 + - result.response[1].sequence_number == 2 + - result.response[1].RETURN_CODE == 200 + - result.response[1].MESSAGE is match '.*Skipping config-save.*' + - result.response[2].sequence_number == 3 + - result.response[2].RETURN_CODE == 200 + - result.response[2].MESSAGE is match '.*Skipping config-deploy.*' + - (result.result | length) == 3 + - result.result[0].changed == true + - result.result[0].success == true + - result.result[0].sequence_number == 1 + - result.result[1].changed == true + - result.result[1].success == true + - result.result[1].sequence_number == 2 + - result.result[2].changed == true + - result.result[2].success == true + - result.result[2].sequence_number == 3 +################################################################################ +# MERGED - TEST - Merge additional valid configs into fabric_5 - idempotence +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": false, +# "diff": [ +# { +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_update", +# "check_mode": false, +# "sequence_number": 1, +# "state": "merged" +# } +# ], +# "response": [ +# { +# "MESSAGE": "No fabrics to update for merged state.", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": false, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: MERGED - TEST - Merge additional config into fabric_5 - idempotence + cisco.dcnm.dcnm_fabric: *merge_fabric_5 + register: result +- debug: + var: result +- assert: + that: + - result.changed == false + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].sequence_number == 1 + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_update" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "merged" + - (result.response | length) == 1 + - result.response[0].sequence_number == 1 + - result.response[0].MESSAGE == "No fabrics to update for merged state." + - result.response[0].RETURN_CODE == 200 + - (result.result | length) == 1 + - result.result[0].changed == false + - result.result[0].success == true + - result.result[0].sequence_number == 1 +################################################################################ +# MERGED - CLEANUP - Delete fabric_5 +################################################################################ +# Expected result +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "FABRIC_NAME": "ISN_Fabric", +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_delete", +# "check_mode": false, +# "sequence_number": 1, +# "state": "deleted" +# } +# ], +# "response": [ +# { +# "DATA": "Invalid JSON response: Fabric 'ISN_Fabric' is deleted successfully!", +# "MESSAGE": "OK", +# "METHOD": "DELETE", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: MERGED - CLEANUP - Delete fabric_5 + cisco.dcnm.dcnm_fabric: + state: deleted + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].FABRIC_NAME == fabric_name_5 + - result.diff[0].sequence_number == 1 + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_delete" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "deleted" + - (result.response | length) == 1 + - result.response[0].DATA is match '.*deleted successfully.*' + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "DELETE" + - result.response[0].RETURN_CODE == 200 + - result.response[0].sequence_number == 1 + - (result.result | length) == 1 + - result.result[0].changed == true + - result.result[0].success == true + - result.result[0].sequence_number == 1 From 5ecae78edef62a0cbe6b0f71ed4792d17550dad6 Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Fri, 30 Aug 2024 14:51:49 -1000 Subject: [PATCH 2/5] ISN: dcnm_fabric.py fix NETFLOW_*_LIST parameters Fix sanity test errors. NETFLOW_*_LIST parameters needed "elements: str" --- plugins/modules/dcnm_fabric.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/modules/dcnm_fabric.py b/plugins/modules/dcnm_fabric.py index 57ad5e241..68eb28b76 100644 --- a/plugins/modules/dcnm_fabric.py +++ b/plugins/modules/dcnm_fabric.py @@ -1754,24 +1754,28 @@ - One or Multiple Netflow Exporters required: false type: list + elements: str NETFLOW_MONITOR_LIST: default: '' description: - One or Multiple Netflow Monitors required: false type: list + elements: str NETFLOW_RECORD_LIST: default: '' description: - One or Multiple Netflow Records required: false type: list + elements: str NETFLOW_SAMPLER_LIST: default: '' description: - One or multiple netflow samplers. Applicable to N7K only required: false type: list + elements: str NXAPI_HTTPS_PORT: default: 443 description: From 5e6069e9ed29503abc88ddabbd6ec3420a1a5165 Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Fri, 30 Aug 2024 15:23:03 -1000 Subject: [PATCH 3/5] ISN: Update unit tests to verify ISN fabric type changes --- tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py b/tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py index 30f191e47..8b2f951f6 100644 --- a/tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py +++ b/tests/unit/modules/dcnm/dcnm_fabric/test_fabric_types.py @@ -47,12 +47,13 @@ def test_fabric_types_00010(fabric_types) -> None: assert instance.class_name == "FabricTypes" assert instance._properties["fabric_type"] is None assert instance._properties["template_name"] is None - for fabric_type in ["IPFM", "LAN_CLASSIC", "VXLAN_EVPN", "VXLAN_EVPN_MSD"]: + for fabric_type in ["IPFM", "ISN", "LAN_CLASSIC", "VXLAN_EVPN", "VXLAN_EVPN_MSD"]: assert fabric_type in instance.valid_fabric_types for mandatory_parameter in ["FABRIC_NAME", "FABRIC_TYPE"]: assert mandatory_parameter in instance._mandatory_parameters_all_fabrics for fabric_type in instance.valid_fabric_types: assert fabric_type in instance._mandatory_parameters + assert "BGP_AS" in instance._mandatory_parameters["ISN"] assert "BGP_AS" in instance._mandatory_parameters["VXLAN_EVPN"] @@ -64,6 +65,7 @@ def test_fabric_types_00010(fabric_types) -> None: @pytest.mark.parametrize( "fabric_type, template_name, does_raise, expected", [ + ("ISN", "External_Fabric", False, does_not_raise()), ("IPFM", "Easy_Fabric_IPFM", False, does_not_raise()), ("LAN_CLASSIC", "LAN_Classic", False, does_not_raise()), ("VXLAN_EVPN", "Easy_Fabric", False, does_not_raise()), @@ -120,6 +122,7 @@ def test_fabric_types_00030(fabric_types) -> None: instance.template_name # pylint: disable=pointless-statement +ISN_PARAMETERS = ["BGP_AS", "FABRIC_NAME", "FABRIC_TYPE"] IPFM_PARAMETERS = ["FABRIC_NAME", "FABRIC_TYPE"] LAN_CLASSIC_PARAMETERS = ["FABRIC_NAME", "FABRIC_TYPE"] VXLAN_EVPN_PARAMETERS = ["BGP_AS", "FABRIC_NAME", "FABRIC_TYPE"] @@ -131,6 +134,7 @@ def test_fabric_types_00030(fabric_types) -> None: @pytest.mark.parametrize( "fabric_type, parameters, does_raise, expected", [ + ("ISN", ISN_PARAMETERS, False, does_not_raise()), ("IPFM", IPFM_PARAMETERS, False, does_not_raise()), ("LAN_CLASSIC", LAN_CLASSIC_PARAMETERS, False, does_not_raise()), ("VXLAN_EVPN", VXLAN_EVPN_PARAMETERS, False, does_not_raise()), From 02253c5b994b39c2c1a2fa46d576277ac5abb6cf Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Fri, 30 Aug 2024 15:32:30 -1000 Subject: [PATCH 4/5] ISN: Remove commented assert from IT tests. --- .../targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml index 05df6ef78..df600cb30 100644 --- a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_deleted_basic.yaml @@ -366,13 +366,11 @@ - result.metadata[1].sequence_number == 2 - result.metadata[1].state == "deleted" - (result.response | length) == 2 - # - '"{{ TEST_PHRASE }}" in result.response[0].DATA' - TEST_PHRASE in result.response[0].DATA - result.response[0].MESSAGE == "OK" - result.response[0].METHOD == "DELETE" - result.response[0].RETURN_CODE == 200 - result.response[0].sequence_number == 1 - # - "{{ TEST_PHRASE }}" in result.response[1].DATA - TEST_PHRASE in result.response[1].DATA - result.response[1].MESSAGE == "OK" - result.response[1].METHOD == "DELETE" @@ -480,13 +478,11 @@ - result.metadata[1].sequence_number == 2 - result.metadata[1].state == "deleted" - (result.response | length) == 2 - # - "{{ TEST_PHRASE }}" in result.response[0].DATA - TEST_PHRASE in result.response[0].DATA - result.response[0].MESSAGE == "OK" - result.response[0].METHOD == "DELETE" - result.response[0].RETURN_CODE == 200 - result.response[0].sequence_number == 1 - # - "{{ TEST_PHRASE }}" in result.response[1].DATA - TEST_PHRASE in result.response[1].DATA - result.response[1].MESSAGE == "OK" - result.response[1].METHOD == "DELETE" From 1ac1255cdc0b7a0c6da1ff43831d55f0b0d08488 Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Fri, 30 Aug 2024 15:54:55 -1000 Subject: [PATCH 5/5] IT: ISN Add replaced-state integration test. --- .../tests/dcnm_fabric_replaced_basic_isn.yaml | 462 ++++++++++++++++++ 1 file changed, 462 insertions(+) create mode 100644 tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_replaced_basic_isn.yaml diff --git a/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_replaced_basic_isn.yaml b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_replaced_basic_isn.yaml new file mode 100644 index 000000000..044abcfec --- /dev/null +++ b/tests/integration/targets/dcnm_fabric/tests/dcnm_fabric_replaced_basic_isn.yaml @@ -0,0 +1,462 @@ +################################################################################ +# RUNTIME +################################################################################ +# Recent run times (MM:SS.ms): +# 00:39.188 +# 00:32.893 +################################################################################ +# DESCRIPTION - BASIC FABRIC REPLACED STATE TEST for ISN +# +# Test basic replace of new fabric configurations and verify results. +# - config-save and config-deploy not tested here. +# - See dcnm_fabric_replaced_save_deploy_isn.yaml instead. +################################################################################ +# STEPS +################################################################################ +# SETUP +# 1. The following fabrics must be empty on the controller +# See vars: section in cisco/dcnm/playbooks/dcnm_tests.yaml +# - fabric_name_5 +# - fabric_type_5 # ISN +# 3. Delete fabrics under test, if they exist +# - fabric_name_5 +# TEST +# 4. Create fabrics with non-default configs and verify result +# - fabric_name_5 +# 5. Replace configs for fabric_5 verify result +# CLEANUP +# 7. Delete fabrics under test +# - fabric_name_5 +################################################################################ +# REQUIREMENTS +################################################################################ +# Inventory: +# ./playbooks/roles/dcnm_fabric/dcnm_hosts.yaml +# Playbook: +# ./playbooks/roles/dcnm_fabric/dcnm_tests.yaml +# Roles: +# ./tests/integration/targets/dcnm_fabric/tests/*.yaml +# +# Example vars: +# +# vars: +# testcase: dcnm_fabric_replaced_basic_isn +# fabric_name_5: ISN_Fabric +# fabric_type_5: ISN +################################################################################ +# REPLACED - SETUP - Delete fabrics +################################################################################ +- name: REPLACED - SETUP - Delete fabrics + cisco.dcnm.dcnm_fabric: + state: deleted + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + register: result +- debug: + var: result +################################################################################ +# REPLACED - TEST - Create ISN Fabric with non-default configs +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "BGP_AS": 65005, +# "DCI_SUBNET_RANGE": "10.20.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "LOOPBACK0_IP_RANGE": "10.2.0.0/22", +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_create", +# "check_mode": false, +# "sequence_number": 1, +# "state": "merged" +# } +# ], +# "response": [ +# { +# "DATA": { +# "asn": "65005", +# "deviceType": "n9k", +# "fabricId": "FABRIC-4", +# "fabricName": "ISN_Fabric", +# "fabricTechnology": "External", +# "fabricTechnologyFriendly": "Custom", +# "fabricType": "External", +# "fabricTypeFriendly": "External", +# "id": 4, +# "nvPairs": { +# "BGP_AS": "65005", +# "DCI_SUBNET_RANGE": "10.20.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "FABRIC_TYPE": "External", +# "LOOPBACK0_IP_RANGE": "10.2.0.0/22" +# } +# }, +# "MESSAGE": "OK", +# "METHOD": "POST", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric/External_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: REPLACED - TEST - Create ISN fabric with non-default config. + cisco.dcnm.dcnm_fabric: + state: merged + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + FABRIC_TYPE: "{{ fabric_type_5 }}" + BGP_AS: 65005 + DCI_SUBNET_RANGE: "10.20.1.0/24" + LOOPBACK0_IP_RANGE: "10.2.0.0/22" + DEPLOY: true + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].sequence_number == 1 + - result.diff[0].BGP_AS == 65005 + - result.diff[0].FABRIC_NAME == "ISN_Fabric" + - result.diff[0].DCI_SUBNET_RANGE == "10.20.1.0/24" + - result.diff[0].LOOPBACK0_IP_RANGE == "10.2.0.0/22" + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_create" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "merged" + - (result.response | length) == 1 + - result.response[0].sequence_number == 1 + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "POST" + - result.response[0].RETURN_CODE == 200 + - result.response[0].DATA.nvPairs.BGP_AS == "65005" + - result.response[0].DATA.nvPairs.DCI_SUBNET_RANGE == "10.20.1.0/24" + - result.response[0].DATA.nvPairs.FABRIC_NAME == fabric_name_5 + - result.response[0].DATA.nvPairs.FABRIC_TYPE == "External" + - result.response[0].DATA.nvPairs.LOOPBACK0_IP_RANGE == "10.2.0.0/22" + - (result.result | length) == 1 + - result.result[0].changed == true + - result.result[0].success == true + - result.result[0].sequence_number == 1 +################################################################################ +# REPLACED - TEST - Replace configs for fabric_5 with default config +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "DCI_SUBNET_RANGE": "10.10.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "LOOPBACK0_IP_RANGE": "10.1.0.0/22", +# "sequence_number": 1 +# }, +# { +# "sequence_number": 2 +# }, +# { +# "sequence_number": 3 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_replace", +# "check_mode": false, +# "sequence_number": 1, +# "state": "replaced" +# }, +# { +# "action": "config_save", +# "check_mode": false, +# "sequence_number": 2, +# "state": "replaced" +# }, +# { +# "action": "config_deploy", +# "check_mode": false, +# "sequence_number": 3, +# "state": "replaced" +# } +# ], +# "response": [ +# { +# "DATA": { +# "asn": "65005", +# "createdOn": 1725068607212, +# "deviceType": "n9k", +# "fabricId": "FABRIC-4", +# "fabricName": "ISN_Fabric", +# "fabricTechnology": "External", +# "fabricTechnologyFriendly": "Custom", +# "fabricType": "External", +# "fabricTypeFriendly": "External", +# "id": 4, +# "modifiedOn": 1725068615299, +# "nvPairs": { +# "BGP_AS": "65005", +# "DCI_SUBNET_RANGE": "10.10.1.0/24", +# "FABRIC_NAME": "ISN_Fabric", +# "FABRIC_TYPE": "External", +# "LOOPBACK0_IP_RANGE": "10.1.0.0/22" +# } +# } +# "MESSAGE": "OK", +# "METHOD": "PUT", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric/External_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# }, +# { +# "MESSAGE": "Fabric ISN_Fabric DEPLOY is False or None. Skipping config-save.", +# "RETURN_CODE": 200, +# "sequence_number": 2 +# }, +# { +# "MESSAGE": "FabricConfigDeploy._can_fabric_be_deployed: Fabric ISN_Fabric DEPLOY is False or None. Skipping config-deploy.", +# "RETURN_CODE": 200, +# "sequence_number": 3 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# }, +# { +# "changed": true, +# "sequence_number": 2, +# "success": true +# }, +# { +# "changed": true, +# "sequence_number": 3, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: REPLACED - TEST - Replace configs for fabric_5 with default config + cisco.dcnm.dcnm_fabric: &replace_fabric_5 + state: replaced + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + FABRIC_TYPE: "{{ fabric_type_5 }}" + BGP_AS: 65005 + DEPLOY: false + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 3 + - result.diff[0].sequence_number == 1 + - result.diff[0].DCI_SUBNET_RANGE == "10.10.1.0/24" + - result.diff[0].FABRIC_NAME == "ISN_Fabric" + - result.diff[0].LOOPBACK0_IP_RANGE == "10.1.0.0/22" + - result.diff[1].sequence_number == 2 + - result.diff[2].sequence_number == 3 + - (result.metadata | length) == 3 + - result.metadata[0].action == "fabric_replace" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "replaced" + - result.metadata[1].action == "config_save" + - result.metadata[1].check_mode == False + - result.metadata[1].sequence_number == 2 + - result.metadata[1].state == "replaced" + - result.metadata[2].action == "config_deploy" + - result.metadata[2].check_mode == False + - result.metadata[2].sequence_number == 3 + - result.metadata[2].state == "replaced" + - (result.response | length) == 3 + - result.response[0].sequence_number == 1 + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "PUT" + - result.response[0].RETURN_CODE == 200 + - result.response[0].DATA.nvPairs.BGP_AS == "65005" + - result.response[0].DATA.nvPairs.DCI_SUBNET_RANGE == "10.10.1.0/24" + - result.response[0].DATA.nvPairs.FABRIC_NAME == fabric_name_5 + - result.response[0].DATA.nvPairs.FABRIC_TYPE == "External" + - result.response[0].DATA.nvPairs.LOOPBACK0_IP_RANGE == "10.1.0.0/22" + - result.response[1].sequence_number == 2 + - result.response[1].MESSAGE is match '.*Skipping config-save.*' + - result.response[1].RETURN_CODE == 200 + - result.response[2].sequence_number == 3 + - result.response[2].MESSAGE is match '.*Skipping config-deploy.*' + - result.response[2].RETURN_CODE == 200 + - (result.result | length) == 3 + - result.result[0].changed == true + - result.result[0].success == true + - result.result[0].sequence_number == 1 + - result.result[1].changed == true + - result.result[1].success == true + - result.result[1].sequence_number == 2 + - result.result[2].changed == true + - result.result[2].success == true + - result.result[2].sequence_number == 3 +################################################################################ +# REPLACED - TEST - Replace config for fabric_5 with default config omnipotence +################################################################################ +# Expected result +# - All untested nvPairs removed for brevity. +# - Fabric global keys in DATA removed for brevity. +# ok: [172.22.150.244] => { +# "result": { +# "changed": false, +# "diff": [ +# { +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_replace", +# "check_mode": false, +# "sequence_number": 1, +# "state": "replaced" +# } +# ], +# "response": [ +# { +# "MESSAGE": "No fabrics to update for replaced state.", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": false, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: REPLACED - TEST - Replace config for fabric_5 with default config omnipotence + cisco.dcnm.dcnm_fabric: *replace_fabric_5 + register: result +- debug: + var: result +- assert: + that: + - result.changed == false + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].sequence_number == 1 + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_replace" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "replaced" + - (result.response | length) == 1 + - result.response[0].sequence_number == 1 + - result.response[0].MESSAGE == "No fabrics to update for replaced state." + - result.response[0].RETURN_CODE == 200 + - (result.result | length) == 1 + - result.result[0].changed == false + - result.result[0].success == true + - result.result[0].sequence_number == 1 +################################################################################ +# REPLACED - CLEANUP - Delete the fabrics +################################################################################ +# Expected result +# ok: [172.22.150.244] => { +# "result": { +# "changed": true, +# "diff": [ +# { +# "FABRIC_NAME": "ISN_Fabric", +# "sequence_number": 1 +# } +# ], +# "failed": false, +# "metadata": [ +# { +# "action": "fabric_delete", +# "check_mode": false, +# "sequence_number": 1, +# "state": "deleted" +# } +# ], +# "response": [ +# { +# "DATA": "Invalid JSON response: Fabric 'ISN_Fabric' is deleted successfully!", +# "MESSAGE": "OK", +# "METHOD": "DELETE", +# "REQUEST_PATH": "https://172.22.150.244:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/ISN_Fabric", +# "RETURN_CODE": 200, +# "sequence_number": 1 +# } +# ], +# "result": [ +# { +# "changed": true, +# "sequence_number": 1, +# "success": true +# } +# ] +# } +# } +################################################################################ +- name: MERGED - CLEANUP - Delete the fabrics + cisco.dcnm.dcnm_fabric: + state: deleted + config: + - FABRIC_NAME: "{{ fabric_name_5 }}" + register: result +- debug: + var: result +- assert: + that: + - result.changed == true + - result.failed == false + - (result.diff | length) == 1 + - result.diff[0].FABRIC_NAME == fabric_name_5 + - result.diff[0].sequence_number == 1 + - (result.metadata | length) == 1 + - result.metadata[0].action == "fabric_delete" + - result.metadata[0].check_mode == False + - result.metadata[0].sequence_number == 1 + - result.metadata[0].state == "deleted" + - (result.response | length) == 1 + - result.response[0].DATA is match '.*deleted successfully.*' + - result.response[0].MESSAGE == "OK" + - result.response[0].METHOD == "DELETE" + - result.response[0].RETURN_CODE == 200 + - result.response[0].sequence_number == 1 + - (result.result | length) == 1 + - result.result[0].changed == true + - result.result[0].success == true + - result.result[0].sequence_number == 1