diff --git a/README.md b/README.md index 44051119f..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.dcnm.dcnm +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/plugins/action/dtc/fabric_check_sync.py b/plugins/action/dtc/fabric_check_sync.py index daa2daa5c..55b7b7011 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 ...plugin_utils.helper_functions 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="cisco.dcnm.dcnm_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 048d55ec9..be728a7ca 100644 --- a/plugins/action/dtc/fabrics_config_save.py +++ b/plugins/action/dtc/fabrics_config_save.py @@ -26,6 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from ...plugin_utils.helper_functions import get_rest_module display = Display() @@ -42,8 +43,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="cisco.dcnm.dcnm_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 85f2b6e87..633094845 100644 --- a/plugins/action/dtc/fabrics_deploy.py +++ b/plugins/action/dtc/fabrics_deploy.py @@ -26,6 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from ...plugin_utils.helper_functions import get_rest_module display = Display() @@ -42,8 +43,15 @@ def run(self, tmp=None, task_vars=None): 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="cisco.dcnm.dcnm_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 2d3ecc1a5..4f16b794a 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 ...plugin_utils.helper_functions import get_rest_module import json import re import inspect @@ -151,8 +152,13 @@ def refresh(self) -> None: self.refresh_succeeded = False self.refresh_message = None + 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="cisco.dcnm.dcnm_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 8d2f5426d..bafc01ec4 100644 --- a/plugins/action/dtc/manage_child_fabric_networks.py +++ b/plugins/action/dtc/manage_child_fabric_networks.py @@ -29,6 +29,7 @@ from ansible.template import Templar from ansible.errors import AnsibleFileNotFound from ansible_collections.cisco.nac_dc_vxlan.plugins.filter.version_compare import version_compare +from ...plugin_utils.helper_functions import get_rest_module import re @@ -79,6 +80,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'] @@ -157,7 +165,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_net = self._execute_module( - module_name="cisco.dcnm.dcnm_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']}", @@ -222,7 +230,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=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 3500c644e..191a7d2b4 100644 --- a/plugins/action/dtc/manage_child_fabric_vrfs.py +++ b/plugins/action/dtc/manage_child_fabric_vrfs.py @@ -29,6 +29,7 @@ from ansible.template import Templar from ansible.errors import AnsibleFileNotFound from ansible_collections.cisco.nac_dc_vxlan.plugins.filter.version_compare import version_compare +from ...plugin_utils.helper_functions import get_rest_module import re @@ -89,6 +90,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 vrf in vrfs: vrf_attach_group_switches = [ vrf_attach_group_dict['switches'] @@ -167,7 +175,7 @@ def run(self, tmp=None, task_vars=None): # return results ndfc_vrf = self._execute_module( - module_name="cisco.dcnm.dcnm_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']}" @@ -233,7 +241,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=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 6ad5a9917..f49b1d238 100644 --- a/plugins/action/dtc/manage_child_fabrics.py +++ b/plugins/action/dtc/manage_child_fabrics.py @@ -26,6 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from ...plugin_utils.helper_functions import get_rest_module display = Display() @@ -42,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="cisco.dcnm.dcnm_rest", + module_name=rest_module, module_args={ "method": "POST", "path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd", @@ -75,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="cisco.dcnm.dcnm_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 315d0c3a7..234428fd5 100644 --- a/plugins/action/dtc/prepare_msite_child_fabrics_data.py +++ b/plugins/action/dtc/prepare_msite_child_fabrics_data.py @@ -26,6 +26,7 @@ from ansible.utils.display import Display from ansible.plugins.action import ActionBase +from ...plugin_utils.helper_functions import get_rest_module display = Display() @@ -42,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="cisco.dcnm.dcnm_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/prepare_msite_data.py b/plugins/action/dtc/prepare_msite_data.py index f40083426..eaca05935 100644 --- a/plugins/action/dtc/prepare_msite_data.py +++ b/plugins/action/dtc/prepare_msite_data.py @@ -28,6 +28,7 @@ from ansible.plugins.action import ActionBase from ansible_collections.cisco.nac_dc_vxlan.plugins.plugin_utils.helper_functions import ndfc_get_fabric_attributes from ansible_collections.cisco.nac_dc_vxlan.plugins.plugin_utils.helper_functions import ndfc_get_fabric_switches +from ...plugin_utils.helper_functions import get_rest_module import re display = Display() @@ -44,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="cisco.dcnm.dcnm_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 new file mode 100644 index 000000000..a7c8d106d --- /dev/null +++ b/plugins/action/dtc/rest.py @@ -0,0 +1,105 @@ +# 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 +from ...plugin_utils.helper_functions import get_rest_module + +display = Display() + + +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. + """ + + 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') + 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: + results['failed'] = True + results['msg'] = f"Unsupported network_os: {network_os}" + return results + + 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, + 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)}\n{error_trace}" + display.error(results['msg'], wrap_text=False) + + return results diff --git a/plugins/plugin_utils/helper_functions.py b/plugins/plugin_utils/helper_functions.py index 475335e8a..9536e7284 100644 --- a/plugins/plugin_utils/helper_functions.py +++ b/plugins/plugin_utils/helper_functions.py @@ -96,8 +96,14 @@ 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: + err_msg = f"Unsupported network_os: {network_os}" + raise Exception(err_msg) + policy_data = self._execute_module( - module_name="cisco.dcnm.dcnm_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 +188,14 @@ 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: + err_msg = f"Unsupported network_os: {network_os}" + raise Exception(err_msg) + fabric_response = self._execute_module( - module_name="cisco.dcnm.dcnm_rest", + module_name=rest_module, module_args={ "method": "GET", "path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}", @@ -234,3 +246,12 @@ 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 diff --git a/roles/dtc/connectivity_check/tasks/main.yml b/roles/dtc/connectivity_check/tasks/main.yml index 5cc1c0399..bd792dd23 100644 --- a/roles/dtc/connectivity_check/tasks/main.yml +++ b/roles/dtc/connectivity_check/tasks/main.yml @@ -52,7 +52,7 @@ tags: "{{ nac_tags.connectivity_check }}" # Tags defined in roles/common_global/vars/main.yml - name: Get Cisco Nexus Dashboard Fabric Controller Version - cisco.dcnm.dcnm_rest: + cisco.nac_dc_vxlan.dtc.rest: method: GET path: /appcenter/cisco/ndfc/api/about/version register: ndfc_version @@ -61,4 +61,9 @@ - name: Set Cisco Nexus Dashboard Fabric Controller 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/common/devices_discovery.yml b/roles/dtc/create/tasks/common/devices_discovery.yml index cf4ea85f4..844a5920e 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 - VXLAN_EVPN/iBGP_VXLAN ansible.builtin.set_fact: vars_common_local: "{{ vars_common_vxlan }}" @@ -96,7 +95,7 @@ delegate_to: localhost - name: Update Switch Hostname Policy in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 }}" diff --git a/roles/dtc/create/tasks/external/devices_discovery.yml b/roles/dtc/create/tasks/external/devices_discovery.yml index c131ac6fe..7659b2fb3 100644 --- a/roles/dtc/create/tasks/external/devices_discovery.yml +++ b/roles/dtc/create/tasks/external/devices_discovery.yml @@ -53,8 +53,8 @@ delegate_to: localhost - name: Update Switch Hostname Policy in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 + when: results.policy_update | length > 0 \ 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 cab031251..d290ea883 100644 --- a/roles/dtc/create/tasks/external/fabric.yml +++ b/roles/dtc/create/tasks/external/fabric.yml @@ -29,27 +29,27 @@ - "----------------------------------------------------------------" - name: Check Fabric Exists in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 in Nexus Dashboard (PUT) - cisco.dcnm.dcnm_rest: + 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' - json_data: '{{ fabric_config | to_json }}' + payload: '{{ fabric_config }}' when: - get_result.response.DATA is defined - get_result.response.DATA register: put_result - name: Manage Fabric in Nexus Dashboard (POST) - cisco.dcnm.dcnm_rest: + 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' - 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')) diff --git a/roles/dtc/create/tasks/sub_main_vxlan.yml b/roles/dtc/create/tasks/sub_main_vxlan.yml index 920e050ca..254b9691d 100644 --- a/roles/dtc/create/tasks/sub_main_vxlan.yml +++ b/roles/dtc/create/tasks/sub_main_vxlan.yml @@ -60,7 +60,7 @@ - name: Config-Save Block to Propagate vPC Changes to iBGP VXLAN Fabric in Nexus Dashboard block: - name: Config-Save for iBGP VXLAN Fabric in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 4c3cc5494..9fe48c6db 100644 --- a/roles/dtc/create/tasks/vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/vxlan/vrfs_networks.yml @@ -32,7 +32,7 @@ when: is_active_child_fabric is not defined block: - name: Get Multisite Fabric Associations in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 in Nexus Dashboard # -------------------------------------------------------------------- - name: Attach Loopbacks to VRFs in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 bfaf1ba43..2470a7d68 100644 --- a/roles/dtc/deploy/tasks/sub_main_external.yml +++ b/roles/dtc/deploy/tasks/sub_main_external.yml @@ -35,7 +35,7 @@ - name: Config-Save Block for External Fabric block: - name: Config-Save for External Fabric - cisco.dcnm.dcnm_rest: + 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 @@ -49,8 +49,8 @@ msg: "{{ config_save.msg.DATA }}" when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 -- name: Deploy for External Fabric - cisco.dcnm.dcnm_rest: +- name: Deploy for Fabric {{ MD_Extended.vxlan.fabric.name }} + 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 8ca70399b..c203a19e4 100644 --- a/roles/dtc/deploy/tasks/sub_main_isn.yml +++ b/roles/dtc/deploy/tasks/sub_main_isn.yml @@ -35,7 +35,7 @@ - name: Config-Save Block for ISN Fabric block: - name: Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + 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 @@ -51,7 +51,7 @@ when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - name: Deploy for ISN Fabric - cisco.dcnm.dcnm_rest: + 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: @@ -60,4 +60,3 @@ when: > (MD_Extended.vxlan.fabric.type == 'ISN' and (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_msd.yml b/roles/dtc/deploy/tasks/sub_main_msd.yml index 87306cf4b..92b0d6f53 100644 --- a/roles/dtc/deploy/tasks/sub_main_msd.yml +++ b/roles/dtc/deploy/tasks/sub_main_msd.yml @@ -35,7 +35,7 @@ - name: Config-Save Block for MSD Fabric block: - name: Config-Save for MSD Fabric - cisco.dcnm.dcnm_rest: + 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 @@ when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - name: Deploy for MSD Fabric - cisco.dcnm.dcnm_rest: + 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 a3652c5f1..fbd9fea82 100644 --- a/roles/dtc/deploy/tasks/sub_main_vxlan.yml +++ b/roles/dtc/deploy/tasks/sub_main_vxlan.yml @@ -35,7 +35,7 @@ - name: Config-Save Block for iBGP VXLAN Fabric block: - name: Config-Save for iBGP VXLAN Fabric - cisco.dcnm.dcnm_rest: + 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 @@ -50,7 +50,7 @@ when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - name: Deploy for iBGP VXLAN Fabric - cisco.dcnm.dcnm_rest: + 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: @@ -70,7 +70,7 @@ - name: Retrying Config-Save Block for iBGP VXLAN Fabric block: - name: Retrying Config-Save for Fabric {{ MD_Extended.vxlan.fabric.name }} - cisco.dcnm.dcnm_rest: + 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 @@ -87,7 +87,7 @@ when: config_save.msg.RETURN_CODE is defined and config_save.msg.RETURN_CODE == 500 - name: Retrying Deploy for iBGP VXLAN Fabric - cisco.dcnm.dcnm_rest: + 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 147d49093..672a5abf5 100644 --- a/roles/dtc/remove/tasks/sub_main_external.yml +++ b/roles/dtc/remove/tasks/sub_main_external.yml @@ -34,7 +34,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of External Fabric Switches from Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 2a15e1b34..f4ef8fcbe 100644 --- a/roles/dtc/remove/tasks/sub_main_isn.yml +++ b/roles/dtc/remove/tasks/sub_main_isn.yml @@ -34,7 +34,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of ISN Fabric Switches from Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 fbfff7f96..8fc749247 100644 --- a/roles/dtc/remove/tasks/sub_main_vxlan.yml +++ b/roles/dtc/remove/tasks/sub_main_vxlan.yml @@ -34,7 +34,7 @@ tags: "{{ nac_tags.remove }}" - name: Get List of iBGP VXLAN Fabric Switches from Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 bb712bfef..922de0d96 100644 --- a/roles/dtc/remove/tasks/vxlan/networks.yml +++ b/roles/dtc/remove/tasks/vxlan/networks.yml @@ -24,7 +24,7 @@ when: is_active_child_fabric is not defined block: - name: Get Multisite Fabric Associations in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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 780eca49a..9b37b04d2 100644 --- a/roles/dtc/remove/tasks/vxlan/vrfs.yml +++ b/roles/dtc/remove/tasks/vxlan/vrfs.yml @@ -24,7 +24,7 @@ when: is_active_child_fabric is not defined block: - name: Get Multisite Fabric Associations in Nexus Dashboard - cisco.dcnm.dcnm_rest: + 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/tests/integration/group_vars/ndfc/examples/main.yml b/tests/integration/group_vars/ndfc/examples/main.yml index 2c484e92c..965892124 100644 --- a/tests/integration/group_vars/ndfc/examples/main.yml +++ b/tests/integration/group_vars/ndfc/examples/main.yml @@ -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. 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