From 1d7c0a056236844d0333272f5924fcf6df1ffed5 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Thu, 24 Jul 2025 16:24:34 +0530 Subject: [PATCH 01/11] Changes in ansible-dc-vxlan to support nd_rest --- README.md | 2 +- plugins/action/dtc/fabric_check_sync.py | 2 +- plugins/action/dtc/fabrics_config_save.py | 2 +- plugins/action/dtc/fabrics_deploy.py | 2 +- plugins/action/dtc/get_poap_data.py | 2 +- plugins/action/dtc/manage_child_fabric_networks.py | 4 ++-- plugins/action/dtc/manage_child_fabric_vrfs.py | 4 ++-- plugins/action/dtc/manage_child_fabrics.py | 6 +++--- plugins/action/dtc/prepare_msite_child_fabrics_data.py | 2 +- plugins/action/dtc/prepare_msite_data.py | 2 +- plugins/plugin_utils/helper_functions.py | 4 ++-- roles/dtc/connectivity_check/tasks/main.yml | 2 +- roles/dtc/create/tasks/common/devices_discovery.yml | 4 ++-- roles/dtc/create/tasks/external/devices_discovery.yml | 4 ++-- roles/dtc/create/tasks/external/fabric.yml | 6 +++--- roles/dtc/create/tasks/msd/vrfs_networks.yml | 2 +- roles/dtc/create/tasks/sub_main_vxlan.yml | 2 +- roles/dtc/create/tasks/vxlan/vrfs_networks.yml | 4 ++-- roles/dtc/deploy/tasks/sub_main_external.yml | 4 ++-- roles/dtc/deploy/tasks/sub_main_isn.yml | 4 ++-- roles/dtc/deploy/tasks/sub_main_msd.yml | 4 ++-- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 8 ++++---- roles/dtc/remove/tasks/common/edge_connections.yml | 2 +- roles/dtc/remove/tasks/common/interfaces.yml | 4 ++-- roles/dtc/remove/tasks/common/links.yml | 2 +- roles/dtc/remove/tasks/common/policy.yml | 2 +- roles/dtc/remove/tasks/sub_main_external.yml | 2 +- roles/dtc/remove/tasks/sub_main_isn.yml | 2 +- roles/dtc/remove/tasks/sub_main_vxlan.yml | 2 +- roles/dtc/remove/tasks/vxlan/networks.yml | 2 +- roles/dtc/remove/tasks/vxlan/vrfs.yml | 2 +- tests/integration/group_vars/ndfc/examples/main.yml | 2 +- 32 files changed, 49 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 44051119f..a62507aaf 100644 --- a/README.md +++ b/README.md @@ -256,7 +256,7 @@ ansible_connection: ansible.netcommon.httpapi ansible_httpapi_port: 443 ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false -ansible_network_os: cisco.dcnm.dcnm +ansible_network_os: cisco.nd.nd # NDFC API Credentials ansible_user: "{{ lookup('env', 'ND_USERNAME') }}" ansible_password: "{{ lookup('env', 'ND_PASSWORD') }}" diff --git a/plugins/action/dtc/fabric_check_sync.py b/plugins/action/dtc/fabric_check_sync.py index daa2daa5c..865b8af95 100644 --- a/plugins/action/dtc/fabric_check_sync.py +++ b/plugins/action/dtc/fabric_check_sync.py @@ -41,7 +41,7 @@ def run(self, tmp=None, task_vars=None): fabric = self._task.args["fabric"] ndfc_response = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/inventory/switchesByFabric", diff --git a/plugins/action/dtc/fabrics_config_save.py b/plugins/action/dtc/fabrics_config_save.py index 048d55ec9..a14f7f06f 100644 --- a/plugins/action/dtc/fabrics_config_save.py +++ b/plugins/action/dtc/fabrics_config_save.py @@ -43,7 +43,7 @@ def run(self, tmp=None, task_vars=None): for fabric in fabrics: display.display(f"Executing config-save on Fabric: {fabric}") ndfc_config_save = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "POST", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/config-save", diff --git a/plugins/action/dtc/fabrics_deploy.py b/plugins/action/dtc/fabrics_deploy.py index 5e956defc..ccd3efa77 100644 --- a/plugins/action/dtc/fabrics_deploy.py +++ b/plugins/action/dtc/fabrics_deploy.py @@ -43,7 +43,7 @@ def run(self, tmp=None, task_vars=None): for fabric in fabrics: display.display(f"Executing config-deploy on Fabric: {fabric}") ndfc_deploy = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "POST", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/config-deploy?forceShowRun=false", diff --git a/plugins/action/dtc/get_poap_data.py b/plugins/action/dtc/get_poap_data.py index dcf60bf6d..4f3783509 100644 --- a/plugins/action/dtc/get_poap_data.py +++ b/plugins/action/dtc/get_poap_data.py @@ -149,7 +149,7 @@ def refresh(self) -> None: self.refresh_message = None data = self.execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": self.poap_get_method, "path": self.poap_get_path diff --git a/plugins/action/dtc/manage_child_fabric_networks.py b/plugins/action/dtc/manage_child_fabric_networks.py index b536127e3..df0ede86f 100644 --- a/plugins/action/dtc/manage_child_fabric_networks.py +++ b/plugins/action/dtc/manage_child_fabric_networks.py @@ -130,7 +130,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_net = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/networks/{network['name']}", @@ -184,7 +184,7 @@ def run(self, tmp=None, task_vars=None): rendered_to_nice_json = templar.environment.filters['to_nice_json'](rendered_content) ndfc_net_update = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "PUT", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/networks/{network['name']}", diff --git a/plugins/action/dtc/manage_child_fabric_vrfs.py b/plugins/action/dtc/manage_child_fabric_vrfs.py index 6ee32c1c9..3b6825a6b 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -130,7 +130,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_vrf = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/vrfs/{vrf['name']}" @@ -195,7 +195,7 @@ def run(self, tmp=None, task_vars=None): rendered_to_nice_json = templar.environment.filters['to_nice_json'](rendered_content) ndfc_vrf_update = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "PUT", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/vrfs/{vrf['name']}", diff --git a/plugins/action/dtc/manage_child_fabrics.py b/plugins/action/dtc/manage_child_fabrics.py index 6ad5a9917..9f4feadd7 100644 --- a/plugins/action/dtc/manage_child_fabrics.py +++ b/plugins/action/dtc/manage_child_fabrics.py @@ -46,7 +46,7 @@ def run(self, tmp=None, task_vars=None): for fabric in child_fabrics: json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric, fabric) add_fabric_result = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd", @@ -75,7 +75,7 @@ def run(self, tmp=None, task_vars=None): for fabric in child_fabrics: json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric, fabric) remove_fabric_result = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdExit", @@ -95,7 +95,7 @@ def run(self, tmp=None, task_vars=None): return results -# cisco.dcnm.dcnm_rest: +# cisco.nd.nd_rest: # method: POST # path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd # json_data: '{"destFabric":"nac-msd","sourceFabric":"nac-ndfc1"}' diff --git a/plugins/action/dtc/prepare_msite_child_fabrics_data.py b/plugins/action/dtc/prepare_msite_child_fabrics_data.py index 315d0c3a7..3c58e9a75 100644 --- a/plugins/action/dtc/prepare_msite_child_fabrics_data.py +++ b/plugins/action/dtc/prepare_msite_child_fabrics_data.py @@ -45,7 +45,7 @@ def run(self, tmp=None, task_vars=None): # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD) msd_fabric_associations = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations", diff --git a/plugins/action/dtc/prepare_msite_data.py b/plugins/action/dtc/prepare_msite_data.py index fb26150a4..e2af792ae 100644 --- a/plugins/action/dtc/prepare_msite_data.py +++ b/plugins/action/dtc/prepare_msite_data.py @@ -47,7 +47,7 @@ def run(self, tmp=None, task_vars=None): # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD) msd_fabric_associations = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations", diff --git a/plugins/plugin_utils/helper_functions.py b/plugins/plugin_utils/helper_functions.py index 475335e8a..0101b2df5 100644 --- a/plugins/plugin_utils/helper_functions.py +++ b/plugins/plugin_utils/helper_functions.py @@ -97,7 +97,7 @@ def ndfc_get_switch_policy(self, task_vars, tmp, switch_serial_number): N/A """ policy_data = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/switches/{switch_serial_number}/SWITCH/SWITCH" @@ -183,7 +183,7 @@ def ndfc_get_fabric_attributes(self, task_vars, tmp, fabric): N/A """ fabric_response = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name="cisco.nd.nd_rest", module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}", diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index aa27fbdb6..b374a9f7a 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -47,7 +47,7 @@ tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml - name: Get Cisco NDFC Version - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/about/version register: ndfc_version diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index b08b81086..c837e53e7 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -82,7 +82,7 @@ switch_serial_numbers: "{{ md_serial_numbers }}" template_name: host_11_1 register: results -# do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest +# do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest - name: Join List of Switch Hostname Policy IDs from NDFC ansible.builtin.set_fact: @@ -91,7 +91,7 @@ delegate_to: localhost - name: Update Switch Hostname Policy in NDFC - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml index e606c63f4..dcebed3c2 100644 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ b/roles/dtc/create/tasks/external/devices_discovery.yml @@ -44,7 +44,7 @@ switch_serial_numbers: "{{ md_serial_numbers }}" template_name: host_11_1 register: results -# do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest +# do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest - name: Join List of Switch Hostname Policy IDs from NDFC ansible.builtin.set_fact: @@ -53,7 +53,7 @@ delegate_to: localhost - name: Update Switch Hostname Policy in NDFC - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" diff --git a/roles/dtc/create/tasks/external/fabric.yml b/roles/dtc/create/tasks/external/fabric.yml index 170370a41..0bfd3d048 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -29,14 +29,14 @@ - "----------------------------------------------------------------" - name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists in NDFC - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" register: get_result failed_when: false - name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (PUT) - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: PUT path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' json_data: '{{ fabric_config | to_json }}' @@ -46,7 +46,7 @@ register: put_result - name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (POST) - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' json_data: '{{ fabric_config | to_json }}' diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index 3d8389492..a7eb076df 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -113,7 +113,7 @@ # Check with Matt and Pete on how we want to handle this for MSD # - name: Attach VRF Loopbacks per VRF -# cisco.dcnm.dcnm_rest: +# cisco.nd.nd_rest: # path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" # method: "POST" # json_data: "{{ vars_common_msd.vrf_attach_config | to_json}}" diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index 9307faeb6..463188c54 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -58,7 +58,7 @@ - name: Config-Save block to propagate vPC changes to the fabric block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" when: MD_Extended.vxlan.topology.switches | length > 0 diff --git a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml index 0860d8f1a..a66c7bb9e 100644 --- a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml @@ -31,7 +31,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations @@ -73,7 +73,7 @@ # Manage Loopback VRF attachments on NDFC # -------------------------------------------------------------------- - name: Attach Loopbacks to VRFs - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" json_data: "{{ vars_common_vxlan.vrf_attach_config | to_json}}" diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index 39d3fff6f..426548b89 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -47,7 +47,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index f8582bbfa..813d0f312 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -48,7 +48,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index 7e38f8115..8475a27b2 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -48,7 +48,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index ffc8f6fb6..e1f705b8d 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -47,7 +47,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: @@ -67,7 +67,7 @@ - name: Retrying Config-Save Block block: - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -83,7 +83,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Retrying Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/remove/tasks/common/edge_connections.yml b/roles/dtc/remove/tasks/common/edge_connections.yml index 72ed3a0eb..e372fec8c 100644 --- a/roles/dtc/remove/tasks/common/edge_connections.yml +++ b/roles/dtc/remove/tasks/common/edge_connections.yml @@ -42,7 +42,7 @@ switch_data: "{{ switch_list.response.DATA }}" edge_connections: "{{ edge_connections }}" register: unmanaged_edge_connections_config - # do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest + # do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest - name: Remove Unmanaged NDFC Edge Connections cisco.dcnm.dcnm_policy: diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 3f375ce6a..80ee1b831 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -54,7 +54,7 @@ - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) # - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces -# cisco.dcnm.dcnm_rest: +# cisco.nd.nd_rest: # method: POST # path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" # when: @@ -63,7 +63,7 @@ # - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) # - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces -# cisco.dcnm.dcnm_rest: +# cisco.nd.nd_rest: # path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" # method: POST # vars: diff --git a/roles/dtc/remove/tasks/common/links.yml b/roles/dtc/remove/tasks/common/links.yml index a9667d854..2956dab82 100644 --- a/roles/dtc/remove/tasks/common/links.yml +++ b/roles/dtc/remove/tasks/common/links.yml @@ -58,7 +58,7 @@ register: links_to_be_removed when: result_links.response is defined - # do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest + # do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest - name: Set not_required_links if result_links.response is not defined ansible.builtin.set_fact: links_to_be_removed: [] diff --git a/roles/dtc/remove/tasks/common/policy.yml b/roles/dtc/remove/tasks/common/policy.yml index 09dbc73bd..c0d808ce9 100644 --- a/roles/dtc/remove/tasks/common/policy.yml +++ b/roles/dtc/remove/tasks/common/policy.yml @@ -47,7 +47,7 @@ switch_serial_numbers: "{{ switch_serial_numbers }}" model_data: "{{ MD_Extended }}" register: unmanaged_policy_config - # do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest + # do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest - name: Remove Unmanaged NDFC Fabric Policy cisco.dcnm.dcnm_policy: diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index 7f0371cf5..be74933b0 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -32,7 +32,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of Fabric Switches from NDFC - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" register: switch_list diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index 1bee03c94..15c3dd4cd 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -32,7 +32,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of Fabric Switches from NDFC - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" register: switch_list diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index 474cce2a5..9fb2c5844 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -32,7 +32,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of Fabric Switches from NDFC - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" register: switch_list diff --git a/roles/dtc/remove/tasks/vxlan/networks.yml b/roles/dtc/remove/tasks/vxlan/networks.yml index 587d31736..1494fc864 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -23,7 +23,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations diff --git a/roles/dtc/remove/tasks/vxlan/vrfs.yml b/roles/dtc/remove/tasks/vxlan/vrfs.yml index d21e24e03..f5ba83b2b 100644 --- a/roles/dtc/remove/tasks/vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/vxlan/vrfs.yml @@ -23,7 +23,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations - cisco.dcnm.dcnm_rest: + cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations diff --git a/tests/integration/group_vars/ndfc/examples/main.yml b/tests/integration/group_vars/ndfc/examples/main.yml index 2c484e92c..6eb3c95d8 100644 --- a/tests/integration/group_vars/ndfc/examples/main.yml +++ b/tests/integration/group_vars/ndfc/examples/main.yml @@ -27,7 +27,7 @@ ansible_connection: ansible.netcommon.httpapi ansible_httpapi_port: 443 ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false -ansible_network_os: cisco.dcnm.dcnm +ansible_network_os: cisco.nd.nd # NDFC API Credentials ansible_user: admin ansible_password: password From 4e9c9677b37da58cefbb883cc1de47868f8578ff Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Mon, 4 Aug 2025 23:04:58 +0530 Subject: [PATCH 02/11] Changes to support dynamic selection of rest modules --- plugins/action/dtc/fabric_check_sync.py | 2 +- plugins/action/dtc/fabrics_config_save.py | 2 +- plugins/action/dtc/fabrics_deploy.py | 2 +- plugins/action/dtc/get_poap_data.py | 2 +- .../dtc/manage_child_fabric_networks.py | 4 +- .../action/dtc/manage_child_fabric_vrfs.py | 4 +- plugins/action/dtc/manage_child_fabrics.py | 6 +- .../dtc/prepare_msite_child_fabrics_data.py | 2 +- plugins/action/dtc/prepare_msite_data.py | 2 +- plugins/plugin_utils/helper_functions.py | 4 +- roles/dtc/connectivity_check/tasks/main.yml | 11 +++- .../create/tasks/common/devices_discovery.yml | 11 +++- .../tasks/external/devices_discovery.yml | 9 ++- roles/dtc/create/tasks/external/fabric.yml | 14 ++++- roles/dtc/create/tasks/msd/vrfs_networks.yml | 2 +- roles/dtc/create/tasks/sub_main_vxlan.yml | 9 ++- .../dtc/create/tasks/vxlan/vrfs_networks.yml | 25 +++++++- roles/dtc/deploy/tasks/sub_main_external.yml | 39 ++++++++++-- roles/dtc/deploy/tasks/sub_main_isn.yml | 33 +++++++++- roles/dtc/deploy/tasks/sub_main_msd.yml | 39 ++++++++++-- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 61 +++++++++++++++++-- .../remove/tasks/common/edge_connections.yml | 2 +- roles/dtc/remove/tasks/common/interfaces.yml | 4 +- roles/dtc/remove/tasks/common/links.yml | 2 +- roles/dtc/remove/tasks/common/policy.yml | 2 +- roles/dtc/remove/tasks/sub_main_external.yml | 14 ++++- roles/dtc/remove/tasks/sub_main_isn.yml | 12 +++- roles/dtc/remove/tasks/sub_main_vxlan.yml | 12 +++- roles/dtc/remove/tasks/vxlan/networks.yml | 10 ++- roles/dtc/remove/tasks/vxlan/vrfs.yml | 9 ++- .../group_vars/ndfc/examples/main.yml | 4 +- 31 files changed, 299 insertions(+), 55 deletions(-) diff --git a/plugins/action/dtc/fabric_check_sync.py b/plugins/action/dtc/fabric_check_sync.py index 865b8af95..676542fe3 100644 --- a/plugins/action/dtc/fabric_check_sync.py +++ b/plugins/action/dtc/fabric_check_sync.py @@ -41,7 +41,7 @@ def run(self, tmp=None, task_vars=None): fabric = self._task.args["fabric"] ndfc_response = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/inventory/switchesByFabric", diff --git a/plugins/action/dtc/fabrics_config_save.py b/plugins/action/dtc/fabrics_config_save.py index a14f7f06f..3343d305e 100644 --- a/plugins/action/dtc/fabrics_config_save.py +++ b/plugins/action/dtc/fabrics_config_save.py @@ -43,7 +43,7 @@ def run(self, tmp=None, task_vars=None): for fabric in fabrics: display.display(f"Executing config-save on Fabric: {fabric}") ndfc_config_save = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "POST", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/config-save", diff --git a/plugins/action/dtc/fabrics_deploy.py b/plugins/action/dtc/fabrics_deploy.py index ccd3efa77..a1ab33495 100644 --- a/plugins/action/dtc/fabrics_deploy.py +++ b/plugins/action/dtc/fabrics_deploy.py @@ -43,7 +43,7 @@ def run(self, tmp=None, task_vars=None): for fabric in fabrics: display.display(f"Executing config-deploy on Fabric: {fabric}") ndfc_deploy = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "POST", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/config-deploy?forceShowRun=false", diff --git a/plugins/action/dtc/get_poap_data.py b/plugins/action/dtc/get_poap_data.py index 4f3783509..a43167fda 100644 --- a/plugins/action/dtc/get_poap_data.py +++ b/plugins/action/dtc/get_poap_data.py @@ -149,7 +149,7 @@ def refresh(self) -> None: self.refresh_message = None data = self.execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": self.poap_get_method, "path": self.poap_get_path diff --git a/plugins/action/dtc/manage_child_fabric_networks.py b/plugins/action/dtc/manage_child_fabric_networks.py index df0ede86f..668f0db4c 100644 --- a/plugins/action/dtc/manage_child_fabric_networks.py +++ b/plugins/action/dtc/manage_child_fabric_networks.py @@ -130,7 +130,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_net = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/networks/{network['name']}", @@ -184,7 +184,7 @@ def run(self, tmp=None, task_vars=None): rendered_to_nice_json = templar.environment.filters['to_nice_json'](rendered_content) ndfc_net_update = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "PUT", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/networks/{network['name']}", diff --git a/plugins/action/dtc/manage_child_fabric_vrfs.py b/plugins/action/dtc/manage_child_fabric_vrfs.py index 3b6825a6b..60bb8f2ea 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -130,7 +130,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_vrf = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/vrfs/{vrf['name']}" @@ -195,7 +195,7 @@ def run(self, tmp=None, task_vars=None): rendered_to_nice_json = templar.environment.filters['to_nice_json'](rendered_content) ndfc_vrf_update = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "PUT", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/vrfs/{vrf['name']}", diff --git a/plugins/action/dtc/manage_child_fabrics.py b/plugins/action/dtc/manage_child_fabrics.py index 9f4feadd7..a5d2453fe 100644 --- a/plugins/action/dtc/manage_child_fabrics.py +++ b/plugins/action/dtc/manage_child_fabrics.py @@ -46,7 +46,7 @@ def run(self, tmp=None, task_vars=None): for fabric in child_fabrics: json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric, fabric) add_fabric_result = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd", @@ -75,7 +75,7 @@ def run(self, tmp=None, task_vars=None): for fabric in child_fabrics: json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric, fabric) remove_fabric_result = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdExit", @@ -95,7 +95,7 @@ def run(self, tmp=None, task_vars=None): return results -# cisco.nd.nd_rest: +# cisco.dcnm.dcnm_rest: # method: POST # path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd # json_data: '{"destFabric":"nac-msd","sourceFabric":"nac-ndfc1"}' diff --git a/plugins/action/dtc/prepare_msite_child_fabrics_data.py b/plugins/action/dtc/prepare_msite_child_fabrics_data.py index 3c58e9a75..e3d965a99 100644 --- a/plugins/action/dtc/prepare_msite_child_fabrics_data.py +++ b/plugins/action/dtc/prepare_msite_child_fabrics_data.py @@ -45,7 +45,7 @@ def run(self, tmp=None, task_vars=None): # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD) msd_fabric_associations = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations", diff --git a/plugins/action/dtc/prepare_msite_data.py b/plugins/action/dtc/prepare_msite_data.py index e2af792ae..2cf989076 100644 --- a/plugins/action/dtc/prepare_msite_data.py +++ b/plugins/action/dtc/prepare_msite_data.py @@ -47,7 +47,7 @@ def run(self, tmp=None, task_vars=None): # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD) msd_fabric_associations = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations", diff --git a/plugins/plugin_utils/helper_functions.py b/plugins/plugin_utils/helper_functions.py index 0101b2df5..3e3f3b51c 100644 --- a/plugins/plugin_utils/helper_functions.py +++ b/plugins/plugin_utils/helper_functions.py @@ -97,7 +97,7 @@ def ndfc_get_switch_policy(self, task_vars, tmp, switch_serial_number): N/A """ policy_data = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/switches/{switch_serial_number}/SWITCH/SWITCH" @@ -183,7 +183,7 @@ def ndfc_get_fabric_attributes(self, task_vars, tmp, fabric): N/A """ fabric_response = self._execute_module( - module_name="cisco.nd.nd_rest", + module_name=task_vars['ansible_network_os_rest'], module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}", diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index b374a9f7a..2c10b859e 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -46,12 +46,21 @@ nd_version: "{{ nd_version_response.json.major }}.{{ nd_version_response.json.minor }}.{{ nd_version_response.json.maintenance }}{{ nd_version_response.json.patch }}" tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml -- name: Get Cisco NDFC Version +- name: Get Cisco NDFC Version for ND cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/about/version register: ndfc_version tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml + when: ansible_network_os_rest == "cisco.nd.nd_rest" + +- name: Get Cisco NDFC Version for DCNM + cisco.dcnm.dcnm_rest: + method: GET + path: /appcenter/cisco/ndfc/api/about/version + register: ndfc_version + tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - name: Set Cisco NDFC Version Var ansible.builtin.set_fact: diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index c837e53e7..88d2df90a 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -82,7 +82,7 @@ switch_serial_numbers: "{{ md_serial_numbers }}" template_name: host_11_1 register: results -# do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest +# do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest - name: Join List of Switch Hostname Policy IDs from NDFC ansible.builtin.set_fact: @@ -95,4 +95,11 @@ method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 \ No newline at end of file + when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.nd.nd_rest" + +- name: Update Switch Hostname Policy in DCNM + cisco.dcnm.dcnm_rest: + method: PUT + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" + json_data: "{{ results.policy_update.values() | list | to_json }}" + when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml index dcebed3c2..28618e654 100644 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ b/roles/dtc/create/tasks/external/devices_discovery.yml @@ -57,4 +57,11 @@ method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 \ No newline at end of file + when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.nd.nd_rest" + +- name: Update Switch Hostname Policy in DCNM + cisco.dcnm.dcnm_rest: + method: PUT + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" + json_data: "{{ results.policy_update.values() | list | to_json }}" + when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" \ No newline at end of file diff --git a/roles/dtc/create/tasks/external/fabric.yml b/roles/dtc/create/tasks/external/fabric.yml index 0bfd3d048..e1a734832 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -32,6 +32,15 @@ cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" + when: ansible_network_os_rest == "cisco.nd.nd_rest" + register: get_result + failed_when: false + +- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists in DCNM + cisco.dcnm.dcnm_rest: + method: GET + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: get_result failed_when: false @@ -40,7 +49,7 @@ method: PUT path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' json_data: '{{ fabric_config | to_json }}' - when: + when: ansible_network_os_rest == "cisco.nd.nd_rest" - get_result.response.DATA is defined - get_result.response.DATA register: put_result @@ -50,7 +59,8 @@ method: POST path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' json_data: '{{ fabric_config | to_json }}' - when: > + when: > (get_result.response.DATA is not defined) or (get_result.response.DATA is defined and not get_result.get('response', false) and not get_result.get('response').get('DATA')) + and ansible_network_os_rest == "cisco.nd.nd_rest" register: post_result diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index a7eb076df..3d8389492 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -113,7 +113,7 @@ # Check with Matt and Pete on how we want to handle this for MSD # - name: Attach VRF Loopbacks per VRF -# cisco.nd.nd_rest: +# cisco.dcnm.dcnm_rest: # path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" # method: "POST" # json_data: "{{ vars_common_msd.vrf_attach_config | to_json}}" diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index 463188c54..5c8880ed9 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -61,10 +61,17 @@ cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - when: MD_Extended.vxlan.topology.switches | length > 0 + when: MD_Extended.vxlan.topology.switches | length > 0 and ansible_network_os_rest == "cisco.nd.nd_rest" register: config_save # TODO: Need to add logic to only save if changes are made + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" + when: MD_Extended.vxlan.topology.switches | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + register: config_save + rescue: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed ansible.builtin.debug: diff --git a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml index a66c7bb9e..028d4a4b7 100644 --- a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml @@ -30,10 +30,18 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - - name: Get Multisite Fabric Associations + - name: Get Multisite Fabric Associations for nd cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations + when: ansible_network_os_rest == "cisco.nd.nd_rest" + register: ndfc_msd_fabric_associations + + - name: Get Multisite Fabric Associations for dcnm + cisco.dcnm.dcnm_rest: + method: GET + path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: ndfc_msd_fabric_associations - name: Find Current Fabric by Name In Multisite Associations @@ -72,7 +80,7 @@ # -------------------------------------------------------------------- # Manage Loopback VRF attachments on NDFC # -------------------------------------------------------------------- -- name: Attach Loopbacks to VRFs +- name: Attach Loopbacks to VRFs for nd cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" @@ -82,6 +90,19 @@ - MD_Extended.vxlan.overlay.vrfs - vars_common_vxlan.changes_detected_vrfs - not is_active_child_fabric + - ansible_network_os_rest == "cisco.nd.nd_rest" + +- name: Attach Loopbacks to VRFs for dcnm + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" + json_data: "{{ vars_common_vxlan.vrf_attach_config | to_json}}" + when: + - MD_Extended.vxlan.overlay.vrfs is defined + - MD_Extended.vxlan.overlay.vrfs + - vars_common_vxlan.changes_detected_vrfs + - not is_active_child_fabric + - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - name: Fail If Current Fabric is Part of Multisite And Attempting to Manage Networks ansible.builtin.fail: diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index 426548b89..4c4f5c51c 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -30,7 +30,7 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block +- name: Config-Save block for nd block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} cisco.nd.nd_rest: @@ -38,7 +38,8 @@ path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.nd.nd_rest" # TODO: Need to add logic to only save if changes are made rescue: @@ -46,7 +47,24 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} +- name: Config-Save block for dcnm + block: + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" + register: config_save + when: > + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + # TODO: Need to add logic to only save if changes are made + + rescue: + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed + ansible.builtin.debug: + msg: "{{ config_save.msg.DATA }}" + +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" @@ -54,5 +72,18 @@ ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.nd.nd_rest" + # TODO: Need to add logic to only deploy if changes are made + +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for dcnm + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: > + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 1) and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only deploy if changes are made diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index 813d0f312..8180b5b9a 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -30,7 +30,7 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block +- name: Config-Save block for nd block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} cisco.nd.nd_rest: @@ -39,7 +39,21 @@ register: config_save when: > (MD_Extended.vxlan.fabric.type == 'ISN' and - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) and + ansible_network_os_rest == "cisco.nd.nd_rest" + # TODO: Need to add logic to only save if changes are made + +- name: Config-Save block for dcnm + block: + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" + register: config_save + when: > + (MD_Extended.vxlan.fabric.type == 'ISN' and + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 1)) and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only save if changes are made rescue: @@ -47,7 +61,7 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" @@ -57,4 +71,17 @@ when: > (MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) + ansible_network_os_rest == "cisco.nd.nd_rest" + +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for dcnm + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: > + (MD_Extended.vxlan.fabric.type == 'ISN' and + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only deploy if changes are made diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index 8475a27b2..b3d010f66 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -30,7 +30,7 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block +- name: Config-Save block for nd block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} cisco.nd.nd_rest: @@ -38,8 +38,22 @@ path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > - (MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) or - MD_Extended.vxlan.fabric.type == 'MSD' + ((MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) or + MD_Extended.vxlan.fabric.type == 'MSD') and + ansible_network_os_rest == "cisco.nd.nd_rest" + # TODO: Need to add logic to only save if changes are made + +- name: Config-Save block for dcnm + block: + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" + register: config_save + when: > + ((MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) or + MD_Extended.vxlan.fabric.type == 'MSD') and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only save if changes are made rescue: @@ -47,7 +61,7 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" @@ -57,7 +71,22 @@ when: > (MD_Extended.vxlan.fabric.type == 'MSD' and MD_Extended.vxlan.topology.child_fabrics is defined and - MD_Extended.vxlan.topology.child_fabrics | length > 0) + MD_Extended.vxlan.topology.child_fabrics | length > 0) and + ansible_network_os_rest == "cisco.nd.nd_rest" + # TODO: Need to add logic to only deploy if changes are made + +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for dcnm + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: > + (MD_Extended.vxlan.fabric.type == 'MSD' and + MD_Extended.vxlan.topology.child_fabrics is defined and + MD_Extended.vxlan.topology.child_fabrics | length > 0) and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only deploy if changes are made - name: Config-Save For Child Fabrics diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index e1f705b8d..76f659f3b 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -30,7 +30,7 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block +- name: Config-Save block for nd block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} cisco.nd.nd_rest: @@ -38,7 +38,8 @@ path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.nd.nd_rest" # TODO: Need to add logic to only save if changes are made rescue: @@ -46,7 +47,24 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} +- name: Config-Save block for dcnm + block: + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" + register: config_save + when: > + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + # TODO: Need to add logic to only save if changes are made + + rescue: + - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed + ansible.builtin.debug: + msg: "{{ config_save.msg.DATA }}" + +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd cisco.nd.nd_rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" @@ -54,7 +72,20 @@ ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.nd.nd_rest" + # TODO: Need to add logic to only deploy if changes are made + +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} dcnm + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" + vars: + ansible_command_timeout: 3000 + ansible_connect_timeout: 3000 + when: > + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only deploy if changes are made - name: Check Switch Sync in Fabric {{ MD_Extended.vxlan.fabric.name }} @@ -64,7 +95,7 @@ when: > (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) -- name: Retrying Config-Save Block +- name: Retrying Config-Save Block for nd block: - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} cisco.nd.nd_rest: @@ -75,6 +106,26 @@ - MD_Extended.vxlan.topology.switches is defined - MD_Extended.vxlan.topology.switches | length > 0 - results.changed + - ansible_network_os_rest == "cisco.nd.nd_rest" + # TODO: Need to add logic to only save if changes are made + + rescue: + - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed + ansible.builtin.debug: + msg: "{{ config_save.msg.DATA }}" + +- name: Retrying Config-Save Block for dcnm + block: + - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" + register: config_save + when: + - MD_Extended.vxlan.topology.switches is defined + - MD_Extended.vxlan.topology.switches | length > 0 + - results.changed + - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only save if changes are made rescue: diff --git a/roles/dtc/remove/tasks/common/edge_connections.yml b/roles/dtc/remove/tasks/common/edge_connections.yml index e372fec8c..72ed3a0eb 100644 --- a/roles/dtc/remove/tasks/common/edge_connections.yml +++ b/roles/dtc/remove/tasks/common/edge_connections.yml @@ -42,7 +42,7 @@ switch_data: "{{ switch_list.response.DATA }}" edge_connections: "{{ edge_connections }}" register: unmanaged_edge_connections_config - # do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest + # do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest - name: Remove Unmanaged NDFC Edge Connections cisco.dcnm.dcnm_policy: diff --git a/roles/dtc/remove/tasks/common/interfaces.yml b/roles/dtc/remove/tasks/common/interfaces.yml index 80ee1b831..3f375ce6a 100644 --- a/roles/dtc/remove/tasks/common/interfaces.yml +++ b/roles/dtc/remove/tasks/common/interfaces.yml @@ -54,7 +54,7 @@ - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) # - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces -# cisco.nd.nd_rest: +# cisco.dcnm.dcnm_rest: # method: POST # path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" # when: @@ -63,7 +63,7 @@ # - (interface_delete_mode is defined) and (interface_delete_mode is true|bool) # - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} after removing or defaulting interfaces -# cisco.nd.nd_rest: +# cisco.dcnm.dcnm_rest: # path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" # method: POST # vars: diff --git a/roles/dtc/remove/tasks/common/links.yml b/roles/dtc/remove/tasks/common/links.yml index 2956dab82..a9667d854 100644 --- a/roles/dtc/remove/tasks/common/links.yml +++ b/roles/dtc/remove/tasks/common/links.yml @@ -58,7 +58,7 @@ register: links_to_be_removed when: result_links.response is defined - # do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest + # do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest - name: Set not_required_links if result_links.response is not defined ansible.builtin.set_fact: links_to_be_removed: [] diff --git a/roles/dtc/remove/tasks/common/policy.yml b/roles/dtc/remove/tasks/common/policy.yml index c0d808ce9..09dbc73bd 100644 --- a/roles/dtc/remove/tasks/common/policy.yml +++ b/roles/dtc/remove/tasks/common/policy.yml @@ -47,7 +47,7 @@ switch_serial_numbers: "{{ switch_serial_numbers }}" model_data: "{{ MD_Extended }}" register: unmanaged_policy_config - # do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest + # do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest - name: Remove Unmanaged NDFC Fabric Policy cisco.dcnm.dcnm_policy: diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index be74933b0..1c1fffa12 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -31,10 +31,20 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of Fabric Switches from NDFC - cisco.nd.nd_rest: +- name: Get List of Fabric Switches from NDFC for nd + cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" + when: ansible_network_os_rest == "cisco.nd.nd_rest" + register: switch_list + tags: "{{ nac_tags.remove }}" + +- name: Get List of Fabric Switches from NDFC for dcnm + cisco.dcnm.dcnm_rest: + method: GET + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric +" + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: switch_list tags: "{{ nac_tags.remove }}" diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index 15c3dd4cd..ce642c3c9 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -31,10 +31,20 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of Fabric Switches from NDFC +- name: Get List of Fabric Switches from NDFC for nd cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" + when: ansible_network_os_rest == "cisco.nd.nd_rest" + register: switch_list + tags: "{{ nac_tags.remove }}" + +- name: Get List of Fabric Switches from NDFC for dcnm + cisco.dcnm.dcnm_rest: + method: GET + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric +" + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: switch_list tags: "{{ nac_tags.remove }}" diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index 9fb2c5844..b998401d5 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -31,10 +31,20 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of Fabric Switches from NDFC +- name: Get List of Fabric Switches from NDFC for nd cisco.nd.nd_rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" + when: ansible_network_os_rest == "cisco.nd.nd_rest" + register: switch_list + tags: "{{ nac_tags.remove }}" + +- name: Get List of Fabric Switches from NDFC for dcnm + cisco.dcnm.dcnm_rest: + method: GET + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric +" + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: switch_list tags: "{{ nac_tags.remove }}" diff --git a/roles/dtc/remove/tasks/vxlan/networks.yml b/roles/dtc/remove/tasks/vxlan/networks.yml index 1494fc864..dcda0a4a2 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -22,10 +22,18 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - - name: Get Multisite Fabric Associations + - name: Get Multisite Fabric Associations for nd cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations + ansible_network_os_rest == "cisco.nd.nd_rest" + register: ndfc_msd_fabric_associations + + - name: Get Multisite Fabric Associations for dcnm + cisco.dcnm.dcnm_rest: + method: GET + path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations + ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: ndfc_msd_fabric_associations - name: Find Current Fabric by Name In Multisite Associations diff --git a/roles/dtc/remove/tasks/vxlan/vrfs.yml b/roles/dtc/remove/tasks/vxlan/vrfs.yml index f5ba83b2b..e053f435c 100644 --- a/roles/dtc/remove/tasks/vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/vxlan/vrfs.yml @@ -22,12 +22,19 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - - name: Get Multisite Fabric Associations + - name: Get Multisite Fabric Associations for nd cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations + - name: Get Multisite Fabric Associations for dcnm + cisco.dcnm.dcnm_rest: + method: GET + path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + register: ndfc_msd_fabric_associations + - name: Find Current Fabric by Name In Multisite Associations ansible.builtin.set_fact: selected_fabric: "{{ ndfc_msd_fabric_associations['response']['DATA'] | json_query(query) }}" diff --git a/tests/integration/group_vars/ndfc/examples/main.yml b/tests/integration/group_vars/ndfc/examples/main.yml index 6eb3c95d8..0748f6962 100644 --- a/tests/integration/group_vars/ndfc/examples/main.yml +++ b/tests/integration/group_vars/ndfc/examples/main.yml @@ -27,7 +27,7 @@ ansible_connection: ansible.netcommon.httpapi ansible_httpapi_port: 443 ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false -ansible_network_os: cisco.nd.nd +ansible_network_os: ansible_network_os_rest # NDFC API Credentials ansible_user: admin ansible_password: password @@ -62,4 +62,4 @@ inventory_delete_mode: True # 66393864666137613534636231663062393838323130616338646261373633356533376338643932 # 3130376133383030620a353866303634323133616266303631353265383166366664643033393732 # 6537 -# Replace line 10 above with the encrypted string. \ No newline at end of file +# Replace line 10 above with the encrypted string. From 4cb496d88e6cbc8011e203d4e2a0c2e7fd13e8d6 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Wed, 6 Aug 2025 14:53:42 +0530 Subject: [PATCH 03/11] Changes in tasks file --- README.md | 2 +- roles/dtc/connectivity_check/tasks/main.yml | 5 ++++ roles/dtc/create/tasks/external/fabric.yml | 31 ++++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a62507aaf..16d752d9a 100644 --- a/README.md +++ b/README.md @@ -256,7 +256,7 @@ ansible_connection: ansible.netcommon.httpapi ansible_httpapi_port: 443 ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false -ansible_network_os: cisco.nd.nd +ansible_network_os: cisco.nd.nd #Change as per ansible_network_os # NDFC API Credentials ansible_user: "{{ lookup('env', 'ND_USERNAME') }}" ansible_password: "{{ lookup('env', 'ND_PASSWORD') }}" diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index 2c10b859e..a2f50f4cc 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -65,4 +65,9 @@ - name: Set Cisco NDFC Version Var ansible.builtin.set_fact: ndfc_version: "{{ ndfc_version.response.DATA.version }}" + when: + - ndfc_version is defined + - ndfc_version.response is defined + - ndfc_version.response.DATA is defined + - ndfc_version.response.DATA.version is defined tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml diff --git a/roles/dtc/create/tasks/external/fabric.yml b/roles/dtc/create/tasks/external/fabric.yml index e1a734832..7f40ee92e 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -44,23 +44,46 @@ register: get_result failed_when: false -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (PUT) +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in ND (PUT) cisco.nd.nd_rest: + method: PUT + path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' + payload: '{{ fabric_config }}' + when: + - ansible_network_os_rest == "cisco.nd.nd_rest" + - get_result.response.DATA is defined + - get_result.response.DATA + register: put_result + +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (PUT) + cisco.dcnm.dcnm_rest: method: PUT path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' json_data: '{{ fabric_config | to_json }}' - when: ansible_network_os_rest == "cisco.nd.nd_rest" + when: + - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - get_result.response.DATA is defined - get_result.response.DATA register: put_result -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (POST) +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in ND (POST) cisco.nd.nd_rest: method: POST path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' - json_data: '{{ fabric_config | to_json }}' + payload: '{{ fabric_config }}' when: > (get_result.response.DATA is not defined) or (get_result.response.DATA is defined and not get_result.get('response', false) and not get_result.get('response').get('DATA')) and ansible_network_os_rest == "cisco.nd.nd_rest" register: post_result + +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (POST) + cisco.dcnm.dcnm_rest: + method: POST + path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' + json_data: '{{ fabric_config | to_json }}' + when: > + (get_result.response.DATA is not defined) or + (get_result.response.DATA is defined and not get_result.get('response', false) and not get_result.get('response').get('DATA')) + and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + register: post_result From 772b28122bc119dedfaa71dc8c8878c0a2231f24 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Wed, 6 Aug 2025 17:49:02 +0530 Subject: [PATCH 04/11] Fixing networks.yml changes --- roles/dtc/remove/tasks/vxlan/networks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/dtc/remove/tasks/vxlan/networks.yml b/roles/dtc/remove/tasks/vxlan/networks.yml index dcda0a4a2..ad43fc1e9 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -26,14 +26,14 @@ cisco.nd.nd_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - ansible_network_os_rest == "cisco.nd.nd_rest" + when: ansible_network_os_rest == "cisco.nd.nd_rest" register: ndfc_msd_fabric_associations - name: Get Multisite Fabric Associations for dcnm cisco.dcnm.dcnm_rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: ndfc_msd_fabric_associations - name: Find Current Fabric by Name In Multisite Associations From 73df40164901dfbf06480fcde64724d61bb93dcd Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Fri, 8 Aug 2025 14:38:03 +0530 Subject: [PATCH 05/11] plugin introduced to select dcnm_rest or nd_rest --- plugins/action/dtc/rest_selector.py | 101 ++++++++++++++++++ roles/dtc/connectivity_check/tasks/main.yml | 13 +-- .../create/tasks/common/devices_discovery.yml | 13 +-- .../tasks/external/devices_discovery.yml | 13 +-- roles/dtc/create/tasks/external/fabric.yml | 45 ++------ roles/dtc/create/tasks/sub_main_vxlan.yml | 11 +- .../dtc/create/tasks/vxlan/vrfs_networks.yml | 27 +---- roles/dtc/deploy/tasks/sub_main_external.yml | 43 ++------ roles/dtc/deploy/tasks/sub_main_isn.yml | 38 +------ roles/dtc/deploy/tasks/sub_main_msd.yml | 41 ++----- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 69 ++---------- roles/dtc/remove/tasks/sub_main_external.yml | 14 +-- roles/dtc/remove/tasks/sub_main_isn.yml | 14 +-- roles/dtc/remove/tasks/sub_main_vxlan.yml | 14 +-- roles/dtc/remove/tasks/vxlan/networks.yml | 10 +- roles/dtc/remove/tasks/vxlan/vrfs.yml | 2 +- 16 files changed, 154 insertions(+), 314 deletions(-) create mode 100644 plugins/action/dtc/rest_selector.py diff --git a/plugins/action/dtc/rest_selector.py b/plugins/action/dtc/rest_selector.py new file mode 100644 index 000000000..39286d4ca --- /dev/null +++ b/plugins/action/dtc/rest_selector.py @@ -0,0 +1,101 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Copyright (c) 2024 Cisco Systems, Inc. and its affiliates +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of +# this software and associated documentation files (the "Software"), to deal in +# the Software without restriction, including without limitation the rights to +# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +# the Software, and to permit persons to whom the Software is furnished to do so, +# subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# SPDX-License-Identifier: MIT + +from __future__ import absolute_import, division, print_function + +__metaclass__ = type + +from ansible.utils.display import Display +from ansible.plugins.action import ActionBase + + +display = Display() + + +class ActionModule(ActionBase): + """ + Action plugin to dynamically select between cisco.nac_dc_vxlan.dtc.rest_selector and cisco.dcnm.dcnm_rest + based on the ansible_network_os variable. + """ + + def run(self, tmp=None, task_vars=None): + """ + Execute the action plugin. + + Args: + tmp (str, optional): Temporary directory. Defaults to None. + task_vars (dict, optional): Dictionary of task variables. Defaults to None. + + Returns: + dict: Results of the REST API call + """ + # Initialize results dictionary + results = super(ActionModule, self).run(tmp, task_vars) + results['changed'] = False + results['failed'] = False + + # Get task arguments + module_args = self._task.args.copy() + + # Get the network OS from task variables or module arguments + network_os = task_vars.get('ansible_network_os') \ + or module_args.pop('ansible_network_os', None) + + # Determine which module to use based on network_os + if network_os == 'cisco.nd.nd': + rest_module = 'cisco.nac_dc_vxlan.dtc.rest_selector' + elif network_os == 'cisco.dcnm.dcnm': + rest_module = 'cisco.dcnm.dcnm_rest' + else: + results['failed'] = True + results['msg'] = ( + f"Unsupported network_os: {network_os}. " + "Must be 'cisco.nd.nd' or 'cisco.dcnm.dcnm'" + ) + return results + + display.vvvv(f"Using REST module: {rest_module}") + + try: + # Execute the appropriate REST module + result = self._execute_module( + module_name=rest_module, + module_args=module_args, + task_vars=task_vars, + tmp=tmp + ) + + # Update results with the module's results + if result.get('failed'): + results.update(result) + else: + results['changed'] = result.get('changed', False) + results.update(result) + + except Exception as e: + results['failed'] = True + results['msg'] = f"Failed to execute {rest_module}: {str(e)}" + display.error(results['msg'], wrap_text=False) + + return results diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index a2f50f4cc..0514635ea 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -46,21 +46,12 @@ nd_version: "{{ nd_version_response.json.major }}.{{ nd_version_response.json.minor }}.{{ nd_version_response.json.maintenance }}{{ nd_version_response.json.patch }}" tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml -- name: Get Cisco NDFC Version for ND - cisco.nd.nd_rest: +- name: Get Cisco NDFC Version + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: /appcenter/cisco/ndfc/api/about/version register: ndfc_version tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml - when: ansible_network_os_rest == "cisco.nd.nd_rest" - -- name: Get Cisco NDFC Version for DCNM - cisco.dcnm.dcnm_rest: - method: GET - path: /appcenter/cisco/ndfc/api/about/version - register: ndfc_version - tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - name: Set Cisco NDFC Version Var ansible.builtin.set_fact: diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index 88d2df90a..cb2db936f 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -90,16 +90,9 @@ when: results.policy_update | length > 0 delegate_to: localhost -- name: Update Switch Hostname Policy in NDFC - cisco.nd.nd_rest: +- name: Update Switch Hostname Policy + cisco.nac_dc_vxlan.dtc.rest_selector: method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.nd.nd_rest" - -- name: Update Switch Hostname Policy in DCNM - cisco.dcnm.dcnm_rest: - method: PUT - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" - json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + when: results.policy_update | length > 0 diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml index 28618e654..856d36024 100644 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ b/roles/dtc/create/tasks/external/devices_discovery.yml @@ -52,16 +52,9 @@ when: results.policy_update | length > 0 delegate_to: localhost -- name: Update Switch Hostname Policy in NDFC - cisco.nd.nd_rest: +- name: Update Switch Hostname Policy + cisco.nac_dc_vxlan.dtc.rest_selector: method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.nd.nd_rest" - -- name: Update Switch Hostname Policy in DCNM - cisco.dcnm.dcnm_rest: - method: PUT - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" - json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" \ No newline at end of file + when: results.policy_update | length > 1 diff --git a/roles/dtc/create/tasks/external/fabric.yml b/roles/dtc/create/tasks/external/fabric.yml index 7f40ee92e..8e16dfc94 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -28,62 +28,29 @@ - "+ Manage Fabric External {{ MD_Extended.vxlan.fabric.name }}" - "----------------------------------------------------------------" -- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists in NDFC - cisco.nd.nd_rest: +- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" - when: ansible_network_os_rest == "cisco.nd.nd_rest" register: get_result failed_when: false -- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists in DCNM - cisco.dcnm.dcnm_rest: - method: GET - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - register: get_result - failed_when: false - -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in ND (PUT) - cisco.nd.nd_rest: +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} (PUT) + cisco.nac_dc_vxlan.dtc.rest_selector: method: PUT path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' payload: '{{ fabric_config }}' when: - - ansible_network_os_rest == "cisco.nd.nd_rest" - get_result.response.DATA is defined - get_result.response.DATA register: put_result -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (PUT) - cisco.dcnm.dcnm_rest: - method: PUT - path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' - json_data: '{{ fabric_config | to_json }}' - when: - - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - - get_result.response.DATA is defined - - get_result.response.DATA - register: put_result - -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in ND (POST) - cisco.nd.nd_rest: +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} (POST) + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' payload: '{{ fabric_config }}' when: > (get_result.response.DATA is not defined) or (get_result.response.DATA is defined and not get_result.get('response', false) and not get_result.get('response').get('DATA')) - and ansible_network_os_rest == "cisco.nd.nd_rest" - register: post_result - -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (POST) - cisco.dcnm.dcnm_rest: - method: POST - path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' - json_data: '{{ fabric_config | to_json }}' - when: > - (get_result.response.DATA is not defined) or - (get_result.response.DATA is defined and not get_result.get('response', false) and not get_result.get('response').get('DATA')) - and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: post_result diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index 5c8880ed9..bdf6e626a 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -58,20 +58,13 @@ - name: Config-Save block to propagate vPC changes to the fabric block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - when: MD_Extended.vxlan.topology.switches | length > 0 and ansible_network_os_rest == "cisco.nd.nd_rest" + when: MD_Extended.vxlan.topology.switches | length > 0 register: config_save # TODO: Need to add logic to only save if changes are made - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - when: MD_Extended.vxlan.topology.switches | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - register: config_save - rescue: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed ansible.builtin.debug: diff --git a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml index 028d4a4b7..b79319039 100644 --- a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml @@ -30,18 +30,10 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - - name: Get Multisite Fabric Associations for nd - cisco.nd.nd_rest: + - name: Get Multisite Fabric Associations + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - when: ansible_network_os_rest == "cisco.nd.nd_rest" - register: ndfc_msd_fabric_associations - - - name: Get Multisite Fabric Associations for dcnm - cisco.dcnm.dcnm_rest: - method: GET - path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: ndfc_msd_fabric_associations - name: Find Current Fabric by Name In Multisite Associations @@ -81,19 +73,7 @@ # Manage Loopback VRF attachments on NDFC # -------------------------------------------------------------------- - name: Attach Loopbacks to VRFs for nd - cisco.nd.nd_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" - json_data: "{{ vars_common_vxlan.vrf_attach_config | to_json}}" - when: - - MD_Extended.vxlan.overlay.vrfs is defined - - MD_Extended.vxlan.overlay.vrfs - - vars_common_vxlan.changes_detected_vrfs - - not is_active_child_fabric - - ansible_network_os_rest == "cisco.nd.nd_rest" - -- name: Attach Loopbacks to VRFs for dcnm - cisco.dcnm.dcnm_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" json_data: "{{ vars_common_vxlan.vrf_attach_config | to_json}}" @@ -102,7 +82,6 @@ - MD_Extended.vxlan.overlay.vrfs - vars_common_vxlan.changes_detected_vrfs - not is_active_child_fabric - - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - name: Fail If Current Fabric is Part of Multisite And Attempting to Manage Networks ansible.builtin.fail: diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index 4c4f5c51c..8d4eb725b 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -30,16 +30,15 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block for nd +- name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.nd.nd_rest" + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) # TODO: Need to add logic to only save if changes are made rescue: @@ -47,43 +46,13 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Config-Save block for dcnm - block: - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - # TODO: Need to add logic to only save if changes are made - - rescue: - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd - cisco.nd.nd_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.nd.nd_rest" - # TODO: Need to add logic to only deploy if changes are made - -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for dcnm - cisco.dcnm.dcnm_rest: +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 1) and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) # TODO: Need to add logic to only deploy if changes are made diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index 8180b5b9a..0ccd5f9b3 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -30,30 +30,16 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block for nd +- name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > (MD_Extended.vxlan.fabric.type == 'ISN' and - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) and - ansible_network_os_rest == "cisco.nd.nd_rest" - # TODO: Need to add logic to only save if changes are made - -- name: Config-Save block for dcnm - block: - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.fabric.type == 'ISN' and - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 1)) and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) # TODO: Need to add logic to only save if changes are made rescue: @@ -61,20 +47,8 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd - cisco.nd.nd_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.fabric.type == 'ISN' and - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) - ansible_network_os_rest == "cisco.nd.nd_rest" - -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for dcnm - cisco.dcnm.dcnm_rest: +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: @@ -83,5 +57,3 @@ when: > (MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - # TODO: Need to add logic to only deploy if changes are made diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index b3d010f66..80ff9ffda 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -30,30 +30,16 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block for nd +- name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > ((MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) or - MD_Extended.vxlan.fabric.type == 'MSD') and - ansible_network_os_rest == "cisco.nd.nd_rest" - # TODO: Need to add logic to only save if changes are made - -- name: Config-Save block for dcnm - block: - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - ((MD_Extended.vxlan.fabric.type == 'ISN' and (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0)) or - MD_Extended.vxlan.fabric.type == 'MSD') and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + MD_Extended.vxlan.fabric.type == 'MSD') # TODO: Need to add logic to only save if changes are made rescue: @@ -61,22 +47,8 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd - cisco.nd.nd_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.fabric.type == 'MSD' and - MD_Extended.vxlan.topology.child_fabrics is defined and - MD_Extended.vxlan.topology.child_fabrics | length > 0) and - ansible_network_os_rest == "cisco.nd.nd_rest" - # TODO: Need to add logic to only deploy if changes are made - -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for dcnm - cisco.dcnm.dcnm_rest: +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: @@ -85,8 +57,7 @@ when: > (MD_Extended.vxlan.fabric.type == 'MSD' and MD_Extended.vxlan.topology.child_fabrics is defined and - MD_Extended.vxlan.topology.child_fabrics | length > 0) and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + MD_Extended.vxlan.topology.child_fabrics | length > 0) # TODO: Need to add logic to only deploy if changes are made - name: Config-Save For Child Fabrics diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index 76f659f3b..b3661c095 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -30,16 +30,15 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" -- name: Config-Save block for nd +- name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.nd.nd_rest" + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) # TODO: Need to add logic to only save if changes are made rescue: @@ -47,45 +46,15 @@ ansible.builtin.debug: msg: "{{ config_save.msg.DATA }}" -- name: Config-Save block for dcnm - block: - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - # TODO: Need to add logic to only save if changes are made - - rescue: - - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} for nd - cisco.nd.nd_rest: +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: ansible_command_timeout: 3000 ansible_connect_timeout: 3000 when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.nd.nd_rest" - # TODO: Need to add logic to only deploy if changes are made - -- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} dcnm - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" - vars: - ansible_command_timeout: 3000 - ansible_connect_timeout: 3000 - when: > - (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) and - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" + (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) # TODO: Need to add logic to only deploy if changes are made - name: Check Switch Sync in Fabric {{ MD_Extended.vxlan.fabric.name }} @@ -95,10 +64,10 @@ when: > (MD_Extended.vxlan.topology.switches is defined and MD_Extended.vxlan.topology.switches | length > 0) -- name: Retrying Config-Save Block for nd +- name: Retrying Config-Save Block block: - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -106,26 +75,6 @@ - MD_Extended.vxlan.topology.switches is defined - MD_Extended.vxlan.topology.switches | length > 0 - results.changed - - ansible_network_os_rest == "cisco.nd.nd_rest" - # TODO: Need to add logic to only save if changes are made - - rescue: - - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - Failed - ansible.builtin.debug: - msg: "{{ config_save.msg.DATA }}" - -- name: Retrying Config-Save Block for dcnm - block: - - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" - register: config_save - when: - - MD_Extended.vxlan.topology.switches is defined - - MD_Extended.vxlan.topology.switches | length > 0 - - results.changed - - ansible_network_os_rest == "cisco.dcnm.dcnm_rest" # TODO: Need to add logic to only save if changes are made rescue: @@ -134,7 +83,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Retrying Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index 1c1fffa12..41ea30dbf 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -31,20 +31,10 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of Fabric Switches from NDFC for nd - cisco.nd.nd_rest: +- name: Get List of Fabric Switches from NDFC + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" - when: ansible_network_os_rest == "cisco.nd.nd_rest" - register: switch_list - tags: "{{ nac_tags.remove }}" - -- name: Get List of Fabric Switches from NDFC for dcnm - cisco.dcnm.dcnm_rest: - method: GET - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric -" - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: switch_list tags: "{{ nac_tags.remove }}" diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index ce642c3c9..5e33434ce 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -31,20 +31,10 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of Fabric Switches from NDFC for nd - cisco.nd.nd_rest: +- name: Get List of Fabric Switches from NDFC + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" - when: ansible_network_os_rest == "cisco.nd.nd_rest" - register: switch_list - tags: "{{ nac_tags.remove }}" - -- name: Get List of Fabric Switches from NDFC for dcnm - cisco.dcnm.dcnm_rest: - method: GET - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric -" - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: switch_list tags: "{{ nac_tags.remove }}" diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index b998401d5..a839cf9cc 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -31,20 +31,10 @@ - ansible.builtin.debug: msg="Configuring NXOS Devices using NDFC (Direct to Controller)" tags: "{{ nac_tags.remove }}" -- name: Get List of Fabric Switches from NDFC for nd - cisco.nd.nd_rest: +- name: Get List of Fabric Switches from NDFC + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" - when: ansible_network_os_rest == "cisco.nd.nd_rest" - register: switch_list - tags: "{{ nac_tags.remove }}" - -- name: Get List of Fabric Switches from NDFC for dcnm - cisco.dcnm.dcnm_rest: - method: GET - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric -" - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: switch_list tags: "{{ nac_tags.remove }}" diff --git a/roles/dtc/remove/tasks/vxlan/networks.yml b/roles/dtc/remove/tasks/vxlan/networks.yml index ad43fc1e9..bb014e8be 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -23,17 +23,9 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations for nd - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - when: ansible_network_os_rest == "cisco.nd.nd_rest" - register: ndfc_msd_fabric_associations - - - name: Get Multisite Fabric Associations for dcnm - cisco.dcnm.dcnm_rest: - method: GET - path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" register: ndfc_msd_fabric_associations - name: Find Current Fabric by Name In Multisite Associations diff --git a/roles/dtc/remove/tasks/vxlan/vrfs.yml b/roles/dtc/remove/tasks/vxlan/vrfs.yml index e053f435c..ce31b16ca 100644 --- a/roles/dtc/remove/tasks/vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/vxlan/vrfs.yml @@ -23,7 +23,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations for nd - cisco.nd.nd_rest: + cisco.nac_dc_vxlan.dtc.rest_selector: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations From 478765f4c683cb1b28809ac6ddb1d4894ccd8e69 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Tue, 12 Aug 2025 16:56:33 +0530 Subject: [PATCH 06/11] Changes to rest module to choose from the OS using utils and action plugin --- plugins/action/dtc/fabric_check_sync.py | 10 ++++- plugins/action/dtc/fabrics_config_save.py | 10 ++++- plugins/action/dtc/fabrics_deploy.py | 12 +++++- plugins/action/dtc/get_poap_data.py | 10 ++++- .../dtc/manage_child_fabric_networks.py | 13 +++++- .../action/dtc/manage_child_fabric_vrfs.py | 2 + plugins/action/dtc/manage_child_fabrics.py | 2 + .../dtc/prepare_msite_child_fabrics_data.py | 2 + plugins/action/dtc/prepare_msite_data.py | 5 ++- .../action/dtc/{rest_selector.py => rest.py} | 43 ++++++++++++++----- plugins/action/dtc/rest_module_utils.py | 9 ++++ roles/dtc/connectivity_check/tasks/main.yml | 2 +- .../create/tasks/common/devices_discovery.yml | 5 ++- .../tasks/external/devices_discovery.yml | 9 ++-- roles/dtc/create/tasks/external/fabric.yml | 6 +-- roles/dtc/create/tasks/sub_main_vxlan.yml | 2 +- .../dtc/create/tasks/vxlan/vrfs_networks.yml | 4 +- roles/dtc/deploy/tasks/sub_main_external.yml | 4 +- roles/dtc/deploy/tasks/sub_main_isn.yml | 4 +- roles/dtc/deploy/tasks/sub_main_msd.yml | 4 +- roles/dtc/deploy/tasks/sub_main_vxlan.yml | 8 ++-- roles/dtc/remove/tasks/sub_main_external.yml | 2 +- roles/dtc/remove/tasks/sub_main_isn.yml | 2 +- roles/dtc/remove/tasks/sub_main_vxlan.yml | 2 +- roles/dtc/remove/tasks/vxlan/networks.yml | 2 +- roles/dtc/remove/tasks/vxlan/vrfs.yml | 2 +- 26 files changed, 128 insertions(+), 48 deletions(-) rename plugins/action/dtc/{rest_selector.py => rest.py} (69%) create mode 100644 plugins/action/dtc/rest_module_utils.py diff --git a/plugins/action/dtc/fabric_check_sync.py b/plugins/action/dtc/fabric_check_sync.py index 676542fe3..f4f20114d 100644 --- a/plugins/action/dtc/fabric_check_sync.py +++ b/plugins/action/dtc/fabric_check_sync.py @@ -26,6 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from .rest_module_utils import get_rest_module display = Display() @@ -40,8 +41,15 @@ def run(self, tmp=None, task_vars=None): fabric = self._task.args["fabric"] + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + ndfc_response = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/inventory/switchesByFabric", diff --git a/plugins/action/dtc/fabrics_config_save.py b/plugins/action/dtc/fabrics_config_save.py index 3343d305e..203f60f38 100644 --- a/plugins/action/dtc/fabrics_config_save.py +++ b/plugins/action/dtc/fabrics_config_save.py @@ -24,8 +24,10 @@ __metaclass__ = type + from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from .rest_module_utils import get_rest_module display = Display() @@ -42,8 +44,14 @@ def run(self, tmp=None, task_vars=None): for fabric in fabrics: display.display(f"Executing config-save on Fabric: {fabric}") + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results ndfc_config_save = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "POST", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/config-save", diff --git a/plugins/action/dtc/fabrics_deploy.py b/plugins/action/dtc/fabrics_deploy.py index a1ab33495..24c395090 100644 --- a/plugins/action/dtc/fabrics_deploy.py +++ b/plugins/action/dtc/fabrics_deploy.py @@ -24,8 +24,10 @@ __metaclass__ = type + from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from .rest_module_utils import get_rest_module display = Display() @@ -39,11 +41,17 @@ def run(self, tmp=None, task_vars=None): results['failed'] = False fabrics = self._task.args["fabrics"] - for fabric in fabrics: display.display(f"Executing config-deploy on Fabric: {fabric}") + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + ndfc_deploy = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "POST", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}/config-deploy?forceShowRun=false", diff --git a/plugins/action/dtc/get_poap_data.py b/plugins/action/dtc/get_poap_data.py index a43167fda..2891d76f2 100644 --- a/plugins/action/dtc/get_poap_data.py +++ b/plugins/action/dtc/get_poap_data.py @@ -139,17 +139,23 @@ def _get_discovered(self, ip, role, hostname): return discovered + def refresh(self) -> None: """ ### Summary Refresh POAP data from NDFC - """ self.refresh_succeeded = False self.refresh_message = None + from .rest_module_utils import get_rest_module + network_os = self.task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + self.refresh_message = f"Unsupported network_os: {network_os}" + return data = self.execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": self.poap_get_method, "path": self.poap_get_path diff --git a/plugins/action/dtc/manage_child_fabric_networks.py b/plugins/action/dtc/manage_child_fabric_networks.py index 668f0db4c..6c85ace6c 100644 --- a/plugins/action/dtc/manage_child_fabric_networks.py +++ b/plugins/action/dtc/manage_child_fabric_networks.py @@ -24,10 +24,12 @@ __metaclass__ = type + from ansible.utils.display import Display from ansible.plugins.action import ActionBase from ansible.template import Templar from ansible.errors import AnsibleFileNotFound +from .rest_module_utils import get_rest_module import json @@ -53,6 +55,13 @@ def run(self, tmp=None, task_vars=None): child_fabrics = msite_data['child_fabrics_data'] + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + for network in networks: network_attach_group_switches = [ network_attach_groups_dict['switches'] @@ -130,7 +139,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_net = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/networks/{network['name']}", @@ -184,7 +193,7 @@ def run(self, tmp=None, task_vars=None): rendered_to_nice_json = templar.environment.filters['to_nice_json'](rendered_content) ndfc_net_update = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "PUT", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/networks/{network['name']}", diff --git a/plugins/action/dtc/manage_child_fabric_vrfs.py b/plugins/action/dtc/manage_child_fabric_vrfs.py index 60bb8f2ea..e5691f66d 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -24,10 +24,12 @@ __metaclass__ = type + from ansible.utils.display import Display from ansible.plugins.action import ActionBase from ansible.template import Templar from ansible.errors import AnsibleFileNotFound +from .rest_module_utils import get_rest_module import json diff --git a/plugins/action/dtc/manage_child_fabrics.py b/plugins/action/dtc/manage_child_fabrics.py index a5d2453fe..7133a2275 100644 --- a/plugins/action/dtc/manage_child_fabrics.py +++ b/plugins/action/dtc/manage_child_fabrics.py @@ -24,8 +24,10 @@ __metaclass__ = type + from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from .rest_module_utils import get_rest_module display = Display() diff --git a/plugins/action/dtc/prepare_msite_child_fabrics_data.py b/plugins/action/dtc/prepare_msite_child_fabrics_data.py index e3d965a99..1700499bb 100644 --- a/plugins/action/dtc/prepare_msite_child_fabrics_data.py +++ b/plugins/action/dtc/prepare_msite_child_fabrics_data.py @@ -24,8 +24,10 @@ __metaclass__ = type + from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from .rest_module_utils import get_rest_module display = Display() diff --git a/plugins/action/dtc/prepare_msite_data.py b/plugins/action/dtc/prepare_msite_data.py index 2cf989076..c9a0adfc1 100644 --- a/plugins/action/dtc/prepare_msite_data.py +++ b/plugins/action/dtc/prepare_msite_data.py @@ -26,8 +26,9 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from ...plugin_utils.helper_functions import ndfc_get_fabric_attributes -from ...plugin_utils.helper_functions import ndfc_get_fabric_switches +from .rest_module_utils import get_rest_module +from ...plugin_utils/helper_functions import ndfc_get_fabric_attributes +from ...plugin_utils/helper_functions import ndfc_get_fabric_switches import re display = Display() diff --git a/plugins/action/dtc/rest_selector.py b/plugins/action/dtc/rest.py similarity index 69% rename from plugins/action/dtc/rest_selector.py rename to plugins/action/dtc/rest.py index 39286d4ca..76e27e263 100644 --- a/plugins/action/dtc/rest_selector.py +++ b/plugins/action/dtc/rest.py @@ -35,9 +35,21 @@ class ActionModule(ActionBase): """ - Action plugin to dynamically select between cisco.nac_dc_vxlan.dtc.rest_selector and cisco.dcnm.dcnm_rest + Action plugin to dynamically select between cisco.nd.nd_rest and cisco.dcnm.dcnm_rest based on the ansible_network_os variable. """ + REST_MODULES = { + 'cisco.nd.nd': 'cisco.nd.nd_rest', + 'cisco.dcnm.dcnm': 'cisco.dcnm.dcnm_rest' + } + + def get_rest_module(self, network_os): + if not network_os: + results['failed'] = True + results['msg'] = "ansible_network_os is not defined in task_vars" + else: + results = self.REST_MODULES.get(network_os) + return results def run(self, tmp=None, task_vars=None): """ @@ -59,14 +71,12 @@ def run(self, tmp=None, task_vars=None): module_args = self._task.args.copy() # Get the network OS from task variables or module arguments - network_os = task_vars.get('ansible_network_os') \ - or module_args.pop('ansible_network_os', None) + network_os = task_vars.get('ansible_network_os') + display.vvvv(f"Using OS module: {network_os}") # Determine which module to use based on network_os - if network_os == 'cisco.nd.nd': - rest_module = 'cisco.nac_dc_vxlan.dtc.rest_selector' - elif network_os == 'cisco.dcnm.dcnm': - rest_module = 'cisco.dcnm.dcnm_rest' + if network_os in self.REST_MODULES: + rest_module = self.get_rest_module(network_os) else: results['failed'] = True results['msg'] = ( @@ -75,27 +85,40 @@ def run(self, tmp=None, task_vars=None): ) return results - display.vvvv(f"Using REST module: {rest_module}") + display.vvvv(f"Using ----------REST------------- module: {rest_module}") try: + display.vvvv(f"Executing module: {rest_module} with args: {module_args}") + + self._task.vars['ansible_rest_os_module'] = rest_module + + # Set the connection to httpapi + if 'connection' not in task_vars: + task_vars['connection'] = 'httpapi' + # Execute the appropriate REST module result = self._execute_module( module_name=rest_module, module_args=module_args, task_vars=task_vars, - tmp=tmp + tmp=tmp, + wrap_async=False ) # Update results with the module's results if result.get('failed'): results.update(result) + display.error(f"Module execution failed: {result.get('msg')}") else: results['changed'] = result.get('changed', False) results.update(result) + display.vvvv(f"Module execution successful: {result}") except Exception as e: + import traceback + error_trace = traceback.format_exc() results['failed'] = True - results['msg'] = f"Failed to execute {rest_module}: {str(e)}" + results['msg'] = f"Failed to execute {rest_module}: {str(e)}\n{error_trace}" display.error(results['msg'], wrap_text=False) return results diff --git a/plugins/action/dtc/rest_module_utils.py b/plugins/action/dtc/rest_module_utils.py new file mode 100644 index 000000000..f11bc825f --- /dev/null +++ b/plugins/action/dtc/rest_module_utils.py @@ -0,0 +1,9 @@ +# Utility to select the correct REST module based on network_os + +def get_rest_module(network_os): + if network_os == 'cisco.dcnm.dcnm': + return 'cisco.dcnm.dcnm_rest' + elif network_os == 'cisco.nd.nd': + return 'cisco.nd.nd_rest' + else: + return None diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index 0514635ea..f6d50e8fd 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -47,7 +47,7 @@ tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml - name: Get Cisco NDFC Version - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/about/version register: ndfc_version diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index cb2db936f..c5c5acf4f 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -90,9 +90,10 @@ when: results.policy_update | length > 0 delegate_to: localhost -- name: Update Switch Hostname Policy - cisco.nac_dc_vxlan.dtc.rest_selector: +- name: Update Switch Hostname Policy in NDFC + cisco.nac_dc_vxlan.dtc.rest: method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" when: results.policy_update | length > 0 + diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml index 856d36024..feeebebc6 100644 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ b/roles/dtc/create/tasks/external/devices_discovery.yml @@ -44,7 +44,7 @@ switch_serial_numbers: "{{ md_serial_numbers }}" template_name: host_11_1 register: results -# do not delegate_to: localhost as this action plugin uses Python to execute cisco.nd.nd_rest +# do not delegate_to: localhost as this action plugin uses Python to execute cisco.dcnm.dcnm_rest - name: Join List of Switch Hostname Policy IDs from NDFC ansible.builtin.set_fact: @@ -52,9 +52,10 @@ when: results.policy_update | length > 0 delegate_to: localhost -- name: Update Switch Hostname Policy - cisco.nac_dc_vxlan.dtc.rest_selector: +- name: Update Switch Hostname Policy in NDFC + cisco.nac_dc_vxlan.dtc.rest: method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 1 + when: results.policy_update | length > 0 + diff --git a/roles/dtc/create/tasks/external/fabric.yml b/roles/dtc/create/tasks/external/fabric.yml index 8e16dfc94..c8aac5da1 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -29,14 +29,14 @@ - "----------------------------------------------------------------" - name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" register: get_result failed_when: false - name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} (PUT) - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: PUT path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' payload: '{{ fabric_config }}' @@ -46,7 +46,7 @@ register: put_result - name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} (POST) - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' payload: '{{ fabric_config }}' diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index bdf6e626a..9e99c9553 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -58,7 +58,7 @@ - name: Config-Save block to propagate vPC changes to the fabric block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" when: MD_Extended.vxlan.topology.switches | length > 0 diff --git a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml index b79319039..ee3a7e5e2 100644 --- a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml @@ -31,7 +31,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations @@ -73,7 +73,7 @@ # Manage Loopback VRF attachments on NDFC # -------------------------------------------------------------------- - name: Attach Loopbacks to VRFs for nd - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" json_data: "{{ vars_common_vxlan.vrf_attach_config | to_json}}" diff --git a/roles/dtc/deploy/tasks/sub_main_external.yml b/roles/dtc/deploy/tasks/sub_main_external.yml index 8d4eb725b..60ff2c2de 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -47,7 +47,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/deploy/tasks/sub_main_isn.yml b/roles/dtc/deploy/tasks/sub_main_isn.yml index 0ccd5f9b3..d775039f4 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -48,7 +48,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/deploy/tasks/sub_main_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index 80ff9ffda..080bb6688 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -48,7 +48,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/deploy/tasks/sub_main_vxlan.yml b/roles/dtc/deploy/tasks/sub_main_vxlan.yml index b3661c095..c9c007c46 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -33,7 +33,7 @@ - name: Config-Save block block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -47,7 +47,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: @@ -67,7 +67,7 @@ - name: Retrying Config-Save Block block: - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-save" register: config_save @@ -83,7 +83,7 @@ msg: "{{ config_save.msg.DATA }}" - name: Retrying Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/config-deploy?forceShowRun=false" vars: diff --git a/roles/dtc/remove/tasks/sub_main_external.yml b/roles/dtc/remove/tasks/sub_main_external.yml index 41ea30dbf..0a8a9baa6 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -32,7 +32,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of Fabric Switches from NDFC - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" register: switch_list diff --git a/roles/dtc/remove/tasks/sub_main_isn.yml b/roles/dtc/remove/tasks/sub_main_isn.yml index 5e33434ce..97244c271 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -32,7 +32,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of Fabric Switches from NDFC - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" register: switch_list diff --git a/roles/dtc/remove/tasks/sub_main_vxlan.yml b/roles/dtc/remove/tasks/sub_main_vxlan.yml index a839cf9cc..cc2385bc5 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -32,7 +32,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of Fabric Switches from NDFC - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/inventory/switchesByFabric" register: switch_list diff --git a/roles/dtc/remove/tasks/vxlan/networks.yml b/roles/dtc/remove/tasks/vxlan/networks.yml index bb014e8be..08e683f0f 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -23,7 +23,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations for nd - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations diff --git a/roles/dtc/remove/tasks/vxlan/vrfs.yml b/roles/dtc/remove/tasks/vxlan/vrfs.yml index ce31b16ca..aea164a98 100644 --- a/roles/dtc/remove/tasks/vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/vxlan/vrfs.yml @@ -23,7 +23,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - name: Get Multisite Fabric Associations for nd - cisco.nac_dc_vxlan.dtc.rest_selector: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations From 0f32945afadac9cdca728284a5fca56932743a92 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Wed, 13 Aug 2025 14:12:19 +0530 Subject: [PATCH 07/11] More changes to previous commit --- plugins/action/dtc/fabrics_config_save.py | 1 - plugins/action/dtc/fabrics_deploy.py | 1 - plugins/action/dtc/get_poap_data.py | 3 ++- .../dtc/manage_child_fabric_networks.py | 1 - .../action/dtc/manage_child_fabric_vrfs.py | 13 +++++++--- plugins/action/dtc/manage_child_fabrics.py | 12 +++++++--- .../dtc/prepare_msite_child_fabrics_data.py | 10 ++++++-- plugins/action/dtc/rest.py | 24 ++++--------------- plugins/plugin_utils/helper_functions.py | 19 +++++++++++++-- roles/dtc/create/tasks/external/fabric.yml | 6 ++--- .../dtc/create/tasks/vxlan/vrfs_networks.yml | 2 +- roles/dtc/remove/tasks/vxlan/networks.yml | 2 +- roles/dtc/remove/tasks/vxlan/vrfs.yml | 9 +------ 13 files changed, 56 insertions(+), 47 deletions(-) diff --git a/plugins/action/dtc/fabrics_config_save.py b/plugins/action/dtc/fabrics_config_save.py index 203f60f38..146de47dd 100644 --- a/plugins/action/dtc/fabrics_config_save.py +++ b/plugins/action/dtc/fabrics_config_save.py @@ -24,7 +24,6 @@ __metaclass__ = type - from ansible.utils.display import Display from ansible.plugins.action import ActionBase from .rest_module_utils import get_rest_module diff --git a/plugins/action/dtc/fabrics_deploy.py b/plugins/action/dtc/fabrics_deploy.py index 24c395090..bd7779062 100644 --- a/plugins/action/dtc/fabrics_deploy.py +++ b/plugins/action/dtc/fabrics_deploy.py @@ -24,7 +24,6 @@ __metaclass__ = type - from ansible.utils.display import Display from ansible.plugins.action import ActionBase from .rest_module_utils import get_rest_module diff --git a/plugins/action/dtc/get_poap_data.py b/plugins/action/dtc/get_poap_data.py index 2891d76f2..975b412fc 100644 --- a/plugins/action/dtc/get_poap_data.py +++ b/plugins/action/dtc/get_poap_data.py @@ -25,6 +25,7 @@ __metaclass__ = type from ansible.plugins.action import ActionBase +from .rest_module_utils import get_rest_module import json import re import inspect @@ -139,11 +140,11 @@ def _get_discovered(self, ip, role, hostname): return discovered - def refresh(self) -> None: """ ### Summary Refresh POAP data from NDFC + """ self.refresh_succeeded = False self.refresh_message = None diff --git a/plugins/action/dtc/manage_child_fabric_networks.py b/plugins/action/dtc/manage_child_fabric_networks.py index 6c85ace6c..bc59ec413 100644 --- a/plugins/action/dtc/manage_child_fabric_networks.py +++ b/plugins/action/dtc/manage_child_fabric_networks.py @@ -24,7 +24,6 @@ __metaclass__ = type - from ansible.utils.display import Display from ansible.plugins.action import ActionBase from ansible.template import Templar diff --git a/plugins/action/dtc/manage_child_fabric_vrfs.py b/plugins/action/dtc/manage_child_fabric_vrfs.py index e5691f66d..71f1ef28d 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -24,7 +24,6 @@ __metaclass__ = type - from ansible.utils.display import Display from ansible.plugins.action import ActionBase from ansible.template import Templar @@ -55,6 +54,14 @@ def run(self, tmp=None, task_vars=None): child_fabrics = msite_data['child_fabrics_data'] + + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + for vrf in vrfs: vrf_attach_group_switches = [ vrf_attach_group_dict['switches'] @@ -132,7 +139,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_vrf = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/vrfs/{vrf['name']}" @@ -197,7 +204,7 @@ def run(self, tmp=None, task_vars=None): rendered_to_nice_json = templar.environment.filters['to_nice_json'](rendered_content) ndfc_vrf_update = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "PUT", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/fabrics/{child_fabric}/vrfs/{vrf['name']}", diff --git a/plugins/action/dtc/manage_child_fabrics.py b/plugins/action/dtc/manage_child_fabrics.py index 7133a2275..827cdbc72 100644 --- a/plugins/action/dtc/manage_child_fabrics.py +++ b/plugins/action/dtc/manage_child_fabrics.py @@ -24,7 +24,6 @@ __metaclass__ = type - from ansible.utils.display import Display from ansible.plugins.action import ActionBase from .rest_module_utils import get_rest_module @@ -44,11 +43,18 @@ def run(self, tmp=None, task_vars=None): child_fabrics = self._task.args['child_fabrics'] state = self._task.args['state'] + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + if state == 'present': for fabric in child_fabrics: json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric, fabric) add_fabric_result = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd", @@ -77,7 +83,7 @@ def run(self, tmp=None, task_vars=None): for fabric in child_fabrics: json_data = '{"destFabric":"%s","sourceFabric":"%s"}' % (parent_fabric, fabric) remove_fabric_result = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdExit", diff --git a/plugins/action/dtc/prepare_msite_child_fabrics_data.py b/plugins/action/dtc/prepare_msite_child_fabrics_data.py index 1700499bb..3ff0eef49 100644 --- a/plugins/action/dtc/prepare_msite_child_fabrics_data.py +++ b/plugins/action/dtc/prepare_msite_child_fabrics_data.py @@ -24,7 +24,6 @@ __metaclass__ = type - from ansible.utils.display import Display from ansible.plugins.action import ActionBase from .rest_module_utils import get_rest_module @@ -44,10 +43,17 @@ def run(self, tmp=None, task_vars=None): parent_fabric = self._task.args["parent_fabric"] child_fabrics = self._task.args["child_fabrics"] + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD) msd_fabric_associations = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations", diff --git a/plugins/action/dtc/rest.py b/plugins/action/dtc/rest.py index 76e27e263..4c1807536 100644 --- a/plugins/action/dtc/rest.py +++ b/plugins/action/dtc/rest.py @@ -28,7 +28,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase - +from .rest_module_utils import get_rest_module display = Display() @@ -38,18 +38,6 @@ class ActionModule(ActionBase): Action plugin to dynamically select between cisco.nd.nd_rest and cisco.dcnm.dcnm_rest based on the ansible_network_os variable. """ - REST_MODULES = { - 'cisco.nd.nd': 'cisco.nd.nd_rest', - 'cisco.dcnm.dcnm': 'cisco.dcnm.dcnm_rest' - } - - def get_rest_module(self, network_os): - if not network_os: - results['failed'] = True - results['msg'] = "ansible_network_os is not defined in task_vars" - else: - results = self.REST_MODULES.get(network_os) - return results def run(self, tmp=None, task_vars=None): """ @@ -75,14 +63,10 @@ def run(self, tmp=None, task_vars=None): display.vvvv(f"Using OS module: {network_os}") # Determine which module to use based on network_os - if network_os in self.REST_MODULES: - rest_module = self.get_rest_module(network_os) - else: + rest_module = get_rest_module(network_os) + if not rest_module: results['failed'] = True - results['msg'] = ( - f"Unsupported network_os: {network_os}. " - "Must be 'cisco.nd.nd' or 'cisco.dcnm.dcnm'" - ) + results['msg'] = f"Unsupported network_os: {network_os}" return results display.vvvv(f"Using ----------REST------------- module: {rest_module}") diff --git a/plugins/plugin_utils/helper_functions.py b/plugins/plugin_utils/helper_functions.py index 3e3f3b51c..8dd433ef0 100644 --- a/plugins/plugin_utils/helper_functions.py +++ b/plugins/plugin_utils/helper_functions.py @@ -25,6 +25,7 @@ # For example in prepare_serice_model.py we can do the following: # from ..helper_functions import do_something +from .rest_module_utils import get_rest_module def data_model_key_check(tested_object, keys): """ @@ -96,8 +97,15 @@ def ndfc_get_switch_policy(self, task_vars, tmp, switch_serial_number): :Raises: N/A """ + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + policy_data = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/switches/{switch_serial_number}/SWITCH/SWITCH" @@ -182,8 +190,15 @@ def ndfc_get_fabric_attributes(self, task_vars, tmp, fabric): :Raises: N/A """ + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + fabric_response = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}", diff --git a/roles/dtc/create/tasks/external/fabric.yml b/roles/dtc/create/tasks/external/fabric.yml index c8aac5da1..e734592c7 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -28,14 +28,14 @@ - "+ Manage Fabric External {{ MD_Extended.vxlan.fabric.name }}" - "----------------------------------------------------------------" -- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists +- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists in NDFC cisco.nac_dc_vxlan.dtc.rest: method: GET path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}" register: get_result failed_when: false -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} (PUT) +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (PUT) cisco.nac_dc_vxlan.dtc.rest: method: PUT path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' @@ -45,7 +45,7 @@ - get_result.response.DATA register: put_result -- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} (POST) +- name: Manage fabric External {{ MD_Extended.vxlan.fabric.name }} in NDFC (POST) cisco.nac_dc_vxlan.dtc.rest: method: POST path: '/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{{ MD_Extended.vxlan.fabric.name }}/External_Fabric' diff --git a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml index ee3a7e5e2..b63006b6b 100644 --- a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml @@ -72,7 +72,7 @@ # -------------------------------------------------------------------- # Manage Loopback VRF attachments on NDFC # -------------------------------------------------------------------- -- name: Attach Loopbacks to VRFs for nd +- name: Attach Loopbacks to VRFs cisco.nac_dc_vxlan.dtc.rest: method: POST path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments" diff --git a/roles/dtc/remove/tasks/vxlan/networks.yml b/roles/dtc/remove/tasks/vxlan/networks.yml index 08e683f0f..9e18b5f11 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -22,7 +22,7 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - - name: Get Multisite Fabric Associations for nd + - name: Get Multisite Fabric Associations cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations diff --git a/roles/dtc/remove/tasks/vxlan/vrfs.yml b/roles/dtc/remove/tasks/vxlan/vrfs.yml index aea164a98..7c4644a94 100644 --- a/roles/dtc/remove/tasks/vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/vxlan/vrfs.yml @@ -22,19 +22,12 @@ - name: Check If Current Fabric Is An Active Multisite Fabric block: - - name: Get Multisite Fabric Associations for nd + - name: Get Multisite Fabric Associations cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations register: ndfc_msd_fabric_associations - - name: Get Multisite Fabric Associations for dcnm - cisco.dcnm.dcnm_rest: - method: GET - path: /appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations - when: ansible_network_os_rest == "cisco.dcnm.dcnm_rest" - register: ndfc_msd_fabric_associations - - name: Find Current Fabric by Name In Multisite Associations ansible.builtin.set_fact: selected_fabric: "{{ ndfc_msd_fabric_associations['response']['DATA'] | json_query(query) }}" From f3d293d1a0f070675dccb6793128524ee6300b1f Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Thu, 14 Aug 2025 20:24:49 +0530 Subject: [PATCH 08/11] intermediatory changes --- roles/dtc/create/tasks/common/devices_discovery.yml | 1 - tests/integration/group_vars/ndfc/examples/main.yml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index c5c5acf4f..1dd261a5d 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -20,7 +20,6 @@ # SPDX-License-Identifier: MIT --- - - name: Choose vars_common Based On Fabric Type ansible.builtin.set_fact: vars_common_local: "{{ vars_common_vxlan }}" diff --git a/tests/integration/group_vars/ndfc/examples/main.yml b/tests/integration/group_vars/ndfc/examples/main.yml index 0748f6962..965892124 100644 --- a/tests/integration/group_vars/ndfc/examples/main.yml +++ b/tests/integration/group_vars/ndfc/examples/main.yml @@ -27,7 +27,7 @@ ansible_connection: ansible.netcommon.httpapi ansible_httpapi_port: 443 ansible_httpapi_use_ssl: true ansible_httpapi_validate_certs: false -ansible_network_os: ansible_network_os_rest +ansible_network_os: cisco.dcnm.dcnm # NDFC API Credentials ansible_user: admin ansible_password: password From fd26e1c72196061fdeb52642e94b44c7ebf574a2 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Wed, 20 Aug 2025 11:04:58 +0530 Subject: [PATCH 09/11] moving get_rest_module to common helper function --- plugins/action/dtc/fabric_check_sync.py | 2 +- plugins/action/dtc/fabrics_config_save.py | 2 +- plugins/action/dtc/fabrics_deploy.py | 3 ++- plugins/action/dtc/get_poap_data.py | 2 +- .../action/dtc/manage_child_fabric_networks.py | 2 +- plugins/action/dtc/manage_child_fabric_vrfs.py | 2 +- plugins/action/dtc/manage_child_fabrics.py | 2 +- .../dtc/prepare_msite_child_fabrics_data.py | 2 +- plugins/action/dtc/prepare_msite_data.py | 15 +++++++++++---- plugins/action/dtc/rest.py | 2 +- plugins/action/dtc/rest_module_utils.py | 9 --------- plugins/plugin_utils/helper_functions.py | 9 ++++++++- 12 files changed, 29 insertions(+), 23 deletions(-) delete mode 100644 plugins/action/dtc/rest_module_utils.py diff --git a/plugins/action/dtc/fabric_check_sync.py b/plugins/action/dtc/fabric_check_sync.py index f4f20114d..55b7b7011 100644 --- a/plugins/action/dtc/fabric_check_sync.py +++ b/plugins/action/dtc/fabric_check_sync.py @@ -26,7 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module display = Display() diff --git a/plugins/action/dtc/fabrics_config_save.py b/plugins/action/dtc/fabrics_config_save.py index 146de47dd..be728a7ca 100644 --- a/plugins/action/dtc/fabrics_config_save.py +++ b/plugins/action/dtc/fabrics_config_save.py @@ -26,7 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module display = Display() diff --git a/plugins/action/dtc/fabrics_deploy.py b/plugins/action/dtc/fabrics_deploy.py index bd7779062..983e59962 100644 --- a/plugins/action/dtc/fabrics_deploy.py +++ b/plugins/action/dtc/fabrics_deploy.py @@ -26,7 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module display = Display() @@ -40,6 +40,7 @@ def run(self, tmp=None, task_vars=None): results['failed'] = False fabrics = self._task.args["fabrics"] + for fabric in fabrics: display.display(f"Executing config-deploy on Fabric: {fabric}") network_os = task_vars['ansible_network_os'] diff --git a/plugins/action/dtc/get_poap_data.py b/plugins/action/dtc/get_poap_data.py index 975b412fc..276143ece 100644 --- a/plugins/action/dtc/get_poap_data.py +++ b/plugins/action/dtc/get_poap_data.py @@ -25,7 +25,7 @@ __metaclass__ = type from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module import json import re import inspect diff --git a/plugins/action/dtc/manage_child_fabric_networks.py b/plugins/action/dtc/manage_child_fabric_networks.py index bc59ec413..074fd0b2f 100644 --- a/plugins/action/dtc/manage_child_fabric_networks.py +++ b/plugins/action/dtc/manage_child_fabric_networks.py @@ -28,7 +28,7 @@ from ansible.plugins.action import ActionBase from ansible.template import Templar from ansible.errors import AnsibleFileNotFound -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module import json diff --git a/plugins/action/dtc/manage_child_fabric_vrfs.py b/plugins/action/dtc/manage_child_fabric_vrfs.py index 71f1ef28d..7de34c7c2 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -28,7 +28,7 @@ from ansible.plugins.action import ActionBase from ansible.template import Templar from ansible.errors import AnsibleFileNotFound -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module import json diff --git a/plugins/action/dtc/manage_child_fabrics.py b/plugins/action/dtc/manage_child_fabrics.py index 827cdbc72..f49b1d238 100644 --- a/plugins/action/dtc/manage_child_fabrics.py +++ b/plugins/action/dtc/manage_child_fabrics.py @@ -26,7 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module display = Display() diff --git a/plugins/action/dtc/prepare_msite_child_fabrics_data.py b/plugins/action/dtc/prepare_msite_child_fabrics_data.py index 3ff0eef49..234428fd5 100644 --- a/plugins/action/dtc/prepare_msite_child_fabrics_data.py +++ b/plugins/action/dtc/prepare_msite_child_fabrics_data.py @@ -26,7 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module display = Display() diff --git a/plugins/action/dtc/prepare_msite_data.py b/plugins/action/dtc/prepare_msite_data.py index c9a0adfc1..2cc5f775e 100644 --- a/plugins/action/dtc/prepare_msite_data.py +++ b/plugins/action/dtc/prepare_msite_data.py @@ -26,9 +26,9 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module -from ...plugin_utils/helper_functions import ndfc_get_fabric_attributes -from ...plugin_utils/helper_functions import ndfc_get_fabric_switches +from ...plugin_utils.helper_functions import ndfc_get_fabric_attributes +from ...plugin_utils.helper_functions import ndfc_get_fabric_switches +from ...plugin_utils.helper_functions import get_rest_module import re display = Display() @@ -45,10 +45,17 @@ def run(self, tmp=None, task_vars=None): model_data = self._task.args["model_data"] parent_fabric = self._task.args["parent_fabric"] + network_os = task_vars['ansible_network_os'] + rest_module = get_rest_module(network_os) + if not rest_module: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + # This is actaully not an accurrate API endpoint as it returns all fabrics in NDFC, not just the fabrics associated with MSD # Therefore, we need to get the fabric associations response and filter out the fabrics that are not associated with the parent fabric (MSD) msd_fabric_associations = self._execute_module( - module_name=task_vars['ansible_network_os_rest'], + module_name=rest_module, module_args={ "method": "GET", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations", diff --git a/plugins/action/dtc/rest.py b/plugins/action/dtc/rest.py index 4c1807536..af5a68231 100644 --- a/plugins/action/dtc/rest.py +++ b/plugins/action/dtc/rest.py @@ -28,7 +28,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase -from .rest_module_utils import get_rest_module +from ...plugin_utils.helper_functions import get_rest_module display = Display() diff --git a/plugins/action/dtc/rest_module_utils.py b/plugins/action/dtc/rest_module_utils.py deleted file mode 100644 index f11bc825f..000000000 --- a/plugins/action/dtc/rest_module_utils.py +++ /dev/null @@ -1,9 +0,0 @@ -# Utility to select the correct REST module based on network_os - -def get_rest_module(network_os): - if network_os == 'cisco.dcnm.dcnm': - return 'cisco.dcnm.dcnm_rest' - elif network_os == 'cisco.nd.nd': - return 'cisco.nd.nd_rest' - else: - return None diff --git a/plugins/plugin_utils/helper_functions.py b/plugins/plugin_utils/helper_functions.py index 8dd433ef0..d1d8880c2 100644 --- a/plugins/plugin_utils/helper_functions.py +++ b/plugins/plugin_utils/helper_functions.py @@ -25,7 +25,6 @@ # For example in prepare_serice_model.py we can do the following: # from ..helper_functions import do_something -from .rest_module_utils import get_rest_module def data_model_key_check(tested_object, keys): """ @@ -249,3 +248,11 @@ def ndfc_get_fabric_switches(self, task_vars, tmp, fabric): ) return fabric_switches + +def get_rest_module(network_os): + if network_os == 'cisco.dcnm.dcnm': + return 'cisco.dcnm.dcnm_rest' + elif network_os == 'cisco.nd.nd': + return 'cisco.nd.nd_rest' + else: + return None From fdad3c45e3e8fedd21f5ca1dc62864117d010453 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Wed, 20 Aug 2025 23:58:43 +0530 Subject: [PATCH 10/11] Resolving sanity errors --- plugins/action/dtc/get_poap_data.py | 1 - plugins/action/dtc/manage_child_fabric_vrfs.py | 1 - plugins/action/dtc/rest.py | 13 +++++-------- plugins/plugin_utils/helper_functions.py | 11 +++++------ roles/dtc/create/tasks/common/devices_discovery.yml | 2 -- .../dtc/create/tasks/external/devices_discovery.yml | 4 +--- tests/sanity/ignore-2.14.txt | 1 + tests/sanity/ignore-2.15.txt | 1 + tests/sanity/ignore-2.16.txt | 1 + tests/sanity/ignore-2.17.txt | 1 + 10 files changed, 15 insertions(+), 21 deletions(-) diff --git a/plugins/action/dtc/get_poap_data.py b/plugins/action/dtc/get_poap_data.py index 543d7da09..4f16b794a 100644 --- a/plugins/action/dtc/get_poap_data.py +++ b/plugins/action/dtc/get_poap_data.py @@ -152,7 +152,6 @@ def refresh(self) -> None: self.refresh_succeeded = False self.refresh_message = None - from .rest_module_utils import get_rest_module network_os = self.task_vars['ansible_network_os'] rest_module = get_rest_module(network_os) if not rest_module: diff --git a/plugins/action/dtc/manage_child_fabric_vrfs.py b/plugins/action/dtc/manage_child_fabric_vrfs.py index 47c557eee..191a7d2b4 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -90,7 +90,6 @@ def run(self, tmp=None, task_vars=None): child_fabrics = msite_data['child_fabrics_data'] - network_os = task_vars['ansible_network_os'] rest_module = get_rest_module(network_os) if not rest_module: diff --git a/plugins/action/dtc/rest.py b/plugins/action/dtc/rest.py index af5a68231..60f9a0a8c 100644 --- a/plugins/action/dtc/rest.py +++ b/plugins/action/dtc/rest.py @@ -1,6 +1,3 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - # Copyright (c) 2024 Cisco Systems, Inc. and its affiliates # # Permission is hereby granted, free of charge, to any person obtaining a copy of @@ -57,11 +54,11 @@ def run(self, tmp=None, task_vars=None): # Get task arguments module_args = self._task.args.copy() - + # Get the network OS from task variables or module arguments network_os = task_vars.get('ansible_network_os') display.vvvv(f"Using OS module: {network_os}") - + # Determine which module to use based on network_os rest_module = get_rest_module(network_os) if not rest_module: @@ -79,7 +76,7 @@ def run(self, tmp=None, task_vars=None): # Set the connection to httpapi if 'connection' not in task_vars: task_vars['connection'] = 'httpapi' - + # Execute the appropriate REST module result = self._execute_module( module_name=rest_module, @@ -88,7 +85,7 @@ def run(self, tmp=None, task_vars=None): tmp=tmp, wrap_async=False ) - + # Update results with the module's results if result.get('failed'): results.update(result) @@ -97,7 +94,7 @@ def run(self, tmp=None, task_vars=None): results['changed'] = result.get('changed', False) results.update(result) display.vvvv(f"Module execution successful: {result}") - + except Exception as e: import traceback error_trace = traceback.format_exc() diff --git a/plugins/plugin_utils/helper_functions.py b/plugins/plugin_utils/helper_functions.py index d1d8880c2..9536e7284 100644 --- a/plugins/plugin_utils/helper_functions.py +++ b/plugins/plugin_utils/helper_functions.py @@ -99,9 +99,8 @@ def ndfc_get_switch_policy(self, task_vars, tmp, switch_serial_number): network_os = task_vars['ansible_network_os'] rest_module = get_rest_module(network_os) if not rest_module: - results['failed'] = True - results['msg'] = f"Unsupported network_os: {network_os}" - return results + err_msg = f"Unsupported network_os: {network_os}" + raise Exception(err_msg) policy_data = self._execute_module( module_name=rest_module, @@ -192,9 +191,8 @@ def ndfc_get_fabric_attributes(self, task_vars, tmp, fabric): network_os = task_vars['ansible_network_os'] rest_module = get_rest_module(network_os) if not rest_module: - results['failed'] = True - results['msg'] = f"Unsupported network_os: {network_os}" - return results + err_msg = f"Unsupported network_os: {network_os}" + raise Exception(err_msg) fabric_response = self._execute_module( module_name=rest_module, @@ -249,6 +247,7 @@ def ndfc_get_fabric_switches(self, task_vars, tmp, fabric): return fabric_switches + def get_rest_module(network_os): if network_os == 'cisco.dcnm.dcnm': return 'cisco.dcnm.dcnm_rest' diff --git a/roles/dtc/create/tasks/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index d332e16df..844a5920e 100644 --- a/roles/dtc/create/tasks/common/devices_discovery.yml +++ b/roles/dtc/create/tasks/common/devices_discovery.yml @@ -100,5 +100,3 @@ path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" when: results.policy_update | length > 0 - - diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml index 1f5c06d01..7659b2fb3 100644 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ b/roles/dtc/create/tasks/external/devices_discovery.yml @@ -57,6 +57,4 @@ method: PUT path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/policies/{{ policy_ids }}/bulk" json_data: "{{ results.policy_update.values() | list | to_json }}" - when: results.policy_update | length > 0 - - + when: results.policy_update | length > 0 \ No newline at end of file diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index a35fe069a..57f788e74 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -36,6 +36,7 @@ plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plu plugins/action/dtc/get_poap_data.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/map_msd_inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/existing_links_check.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/rest.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtd/prepare_service_model.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/test/inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/nac_dc_validate.py import-3.10!skip diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index a35fe069a..57f788e74 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -36,6 +36,7 @@ plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plu plugins/action/dtc/get_poap_data.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/map_msd_inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/existing_links_check.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/rest.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtd/prepare_service_model.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/test/inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/nac_dc_validate.py import-3.10!skip diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index a35fe069a..57f788e74 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -36,6 +36,7 @@ plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plu plugins/action/dtc/get_poap_data.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/map_msd_inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/existing_links_check.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/rest.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtd/prepare_service_model.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/test/inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/nac_dc_validate.py import-3.10!skip diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index a35fe069a..57f788e74 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -36,6 +36,7 @@ plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plu plugins/action/dtc/get_poap_data.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/map_msd_inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/existing_links_check.py action-plugin-docs # action plugin has no matching module to provide documentation +plugins/action/dtc/rest.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtd/prepare_service_model.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/test/inventory.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/common/nac_dc_validate.py import-3.10!skip From 264394a1a3d5720c8bb453d6dab08c7ed87fb929 Mon Sep 17 00:00:00 2001 From: Sivakami S Date: Fri, 22 Aug 2025 11:44:03 +0530 Subject: [PATCH 11/11] Removed debugs --- plugins/action/dtc/rest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/action/dtc/rest.py b/plugins/action/dtc/rest.py index 60f9a0a8c..a7c8d106d 100644 --- a/plugins/action/dtc/rest.py +++ b/plugins/action/dtc/rest.py @@ -66,7 +66,7 @@ def run(self, tmp=None, task_vars=None): results['msg'] = f"Unsupported network_os: {network_os}" return results - display.vvvv(f"Using ----------REST------------- module: {rest_module}") + display.vvvv(f"Using REST module: {rest_module}") try: display.vvvv(f"Executing module: {rest_module} with args: {module_args}")