diff --git a/plugins/action/dtc/map_msd_inventory.py b/plugins/action/dtc/map_msd_inventory.py deleted file mode 100644 index cdf30d56b..000000000 --- a/plugins/action/dtc/map_msd_inventory.py +++ /dev/null @@ -1,85 +0,0 @@ -# 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): - - def run(self, tmp=None, task_vars=None): - results = super(ActionModule, self).run(tmp, task_vars) - results['failed'] = False - - parent_fabric_name = self._task.args['parent_fabric_name'] - data_model_overlay = self._task.args['data_model_overlay'] - - msd_inventory = self._execute_module( - module_name="cisco.dcnm.dcnm_inventory", - module_args={ - "fabric": parent_fabric_name, - "state": "query" - }, - task_vars=task_vars, - tmp=tmp - ) - - response = msd_inventory.get('response', []) - msd_switches = {} - - if isinstance(response, str): - if response == 'The queried switch is not part of the fabric configured': - results['msd_switches'] = msd_switches - return results - - for switch in response: - msd_switches.update({switch['hostName']: switch['ipAddress']}) - msd_switches.update({switch['ipAddress']: switch['ipAddress']}) - msd_switches.update({switch['fabricName']: switch['fabricName']}) - - # Cross reference msd_switches with the switches defined in - # VRF and Network attach list. - # - # Only makes sense to check this if msd_switches actually has switches. - if bool(msd_switches): - results['msg'] = [] - for switch in data_model_overlay['vrf_attach_switches_list']: - if switch not in msd_switches.keys(): - results['failed'] = True - msg = f"Switch ({switch}) defined under vxlan.multisite.overlay.vrf_attach_groups" - msg += f" does not exist under this MSD fabric ({parent_fabric_name})" - results['msg'].append(msg) - for switch in data_model_overlay['network_attach_switches_list']: - if switch not in msd_switches.keys(): - results['failed'] = True - msg = f"Switch ({switch}) defined under vxlan.multisite.overlay.network_attach_groups" - msg += f" does not exist under this MSD fabric ({parent_fabric_name})" - results['msg'].append(msg) - - results['msd_switches'] = msd_switches - return results diff --git a/plugins/action/dtc/prepare_msite_data.py b/plugins/action/dtc/prepare_msite_data.py index 5c369b20c..8d41aa94f 100644 --- a/plugins/action/dtc/prepare_msite_data.py +++ b/plugins/action/dtc/prepare_msite_data.py @@ -121,7 +121,7 @@ def run(self, tmp=None, task_vars=None): ) proxy = '' - if version_compare(nd_major_minor_patch, '3.2.1', '<='): + if version_compare(nd_major_minor_patch, '3.2.2', '<='): proxy = f'/onepath/{fabric_cluster}' elif version_compare(nd_major_minor_patch, '4.1.1', '>='): proxy = f'/fedproxy/{fabric_cluster}' @@ -142,7 +142,9 @@ def run(self, tmp=None, task_vars=None): fabric_switches.append( { 'hostname': fabric_switch['logicalName'], - 'mgmt_ip_address': fabric_switch['ipAddress'] + 'mgmt_ip_address': fabric_switch['ipAddress'], + 'fabric_name': fabric_switch['fabricName'], + 'serial_number': fabric_switch['serialNumber'], } ) diff --git a/roles/dtc/common/tasks/mcfg/ndfc_vrfs.yml b/roles/dtc/common/tasks/mcfg/ndfc_vrfs.yml index 19ff615bb..68e52bbed 100644 --- a/roles/dtc/common/tasks/mcfg/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/mcfg/ndfc_vrfs.yml @@ -93,26 +93,27 @@ - file_diff_result.file_data_changed - check_roles['save_previous'] -- name: Set file_name Var for loopback attachments +- name: Create Empty mcfg_vrf_attach_config Var ansible.builtin.set_fact: - file_name: "{{ data_model_extended.vxlan.fabric.name }}_attach_vrfs_loopbacks.yml" + mcfg_vrf_attach_config: [] delegate_to: localhost -# Check with Matt and Pete on how we want to handle VRF loopbacks for MCFG -# - name: Build VRFs Attach List From Template for loopback -# ansible.builtin.template: -# src: ndfc_attach_vrfs_loopbacks.j2 -# dest: "{{ path_name }}{{ file_name }}" -# delegate_to: localhost +- name: Build VRF Loopback Attachments Data File and Var + when: (data_model_extended.vxlan.multisite.overlay.vrfs | default([])) | length > 0 + block: + - name: Set file_name Var for VRF Loopback Attachments + ansible.builtin.set_fact: + file_name: ndfc_attach_vrfs_loopbacks.yml + delegate_to: localhost -# - name: Create Empty vrf_config Var -# ansible.builtin.set_fact: -# vrf_attach_config: [] -# delegate_to: localhost + - name: Build VRF Loopback Attach List From Template + ansible.builtin.template: + src: "{{ role_path }}/../common/templates/ndfc_vrfs/mcfg_fabric/mcfg_fabric_attach_vrfs_loopbacks.j2" + dest: "{{ path_name }}{{ file_name }}" + mode: '0644' + delegate_to: localhost -# - name: Set vrf_config Var -# ansible.builtin.set_fact: -# vrf_attach_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" -# when: > -# (data_model_extended.vxlan.overlay.vrfs | default([])) | length > 0 -# delegate_to: localhost + - name: Set mcfg_vrf_attach_config Var + ansible.builtin.set_fact: + mcfg_vrf_attach_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" + delegate_to: localhost diff --git a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml index d875f34e3..df4c15e08 100644 --- a/roles/dtc/common/tasks/msd/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/msd/ndfc_vrfs.yml @@ -93,25 +93,27 @@ - file_diff_result.file_data_changed - check_roles['save_previous'] -- name: Set file_name Var for loopback attachments +- name: Create Empty msd_vrf_attach_config Var ansible.builtin.set_fact: - file_name: "ndfc_attach_vrfs_loopbacks.yml" + msd_vrf_attach_config: [] delegate_to: localhost -- name: Build VRFs Loopback Attach List From Template - ansible.builtin.template: - src: "{{ role_path }}/../common/templates/ndfc_vrfs/msd_fabric/msd_attach_vrfs_loopbacks.j2" - dest: "{{ path_name }}{{ file_name }}" - mode: '0644' - delegate_to: localhost +- name: Build VRF Loopback Attachments Data File and Var + when: (data_model_extended.vxlan.multisite.overlay.vrfs | default([])) | length > 0 + block: + - name: Set file_name Var for VRF Loopback Attachments + ansible.builtin.set_fact: + file_name: ndfc_attach_vrfs_loopbacks.yml + delegate_to: localhost -- name: Create Empty vrf_loopbacks Var - ansible.builtin.set_fact: - vrf_attach_config: [] - delegate_to: localhost + - name: Build VRF Loopback Attach List From Template + ansible.builtin.template: + src: "{{ role_path }}/../common/templates/ndfc_vrfs/msd_fabric/msd_fabric_attach_vrfs_loopbacks.j2" + dest: "{{ path_name }}{{ file_name }}" + mode: '0644' + delegate_to: localhost -- name: Set vrf_attach_config Var - ansible.builtin.set_fact: - vrf_attach_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" - when: (data_model_extended.vxlan.multisite.overlay.vrfs | default([])) | length > 0 - delegate_to: localhost + - name: Set msd_vrf_attach_config Var + ansible.builtin.set_fact: + msd_vrf_attach_config: "{{ lookup('file', path_name + file_name) | from_yaml }}" + delegate_to: localhost diff --git a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml index 4911b50fc..d876aafe5 100644 --- a/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml +++ b/roles/dtc/common/tasks/vxlan/ndfc_vrfs.yml @@ -96,12 +96,12 @@ - name: Set file_name Var for loopback attachments ansible.builtin.set_fact: - file_name: "attach_vrfs_loopbacks.yml" + file_name: attach_vrfs_loopbacks.yml delegate_to: localhost - name: Build VRFs Attach List From Template for loopback ansible.builtin.template: - src: ndfc_vrfs/ndfc_attach_vrfs_loopbacks.j2 + src: ndfc_vrfs/dc_vxlan_fabric/dc_vxlan_fabric_attach_vrfs_loopbacks.j2 dest: "{{ path_name }}{{ file_name }}" mode: '0644' delegate_to: localhost diff --git a/roles/dtc/common/templates/ndfc_interfaces/ndfc_interface_breakout.j2 b/roles/dtc/common/templates/ndfc_interfaces/ndfc_interface_breakout.j2 index 9996ff631..20658abc0 100644 --- a/roles/dtc/common/templates/ndfc_interfaces/ndfc_interface_breakout.j2 +++ b/roles/dtc/common/templates/ndfc_interfaces/ndfc_interface_breakout.j2 @@ -2,7 +2,6 @@ # This NDFC breakout interface data structure is auto-generated # DO NOT EDIT MANUALLY # - {% for switch in data_model_extended.vxlan.topology.switches %} {% if switch.interface_breakouts is defined %} {% for breakout in switch.interface_breakouts %} diff --git a/roles/dtc/common/templates/ndfc_vrfs/ndfc_attach_vrfs_loopbacks.j2 b/roles/dtc/common/templates/ndfc_vrfs/dc_vxlan_fabric/dc_vxlan_fabric_attach_vrfs_loopbacks.j2 similarity index 100% rename from roles/dtc/common/templates/ndfc_vrfs/ndfc_attach_vrfs_loopbacks.j2 rename to roles/dtc/common/templates/ndfc_vrfs/dc_vxlan_fabric/dc_vxlan_fabric_attach_vrfs_loopbacks.j2 diff --git a/roles/dtc/common/templates/ndfc_vrfs/mcfg_fabric/mcfg_fabric_attach_vrfs_loopbacks.j2 b/roles/dtc/common/templates/ndfc_vrfs/mcfg_fabric/mcfg_fabric_attach_vrfs_loopbacks.j2 new file mode 100644 index 000000000..9c47b7af8 --- /dev/null +++ b/roles/dtc/common/templates/ndfc_vrfs/mcfg_fabric/mcfg_fabric_attach_vrfs_loopbacks.j2 @@ -0,0 +1,41 @@ +# This NDFC VRF loopback config data structure is auto-generated +# DO NOT EDIT MANUALLY +# +[ +{% for vrf in data_model_extended.vxlan.overlay.vrfs %} +{% if vrf['vrf_attach_group'] is defined %} +{% if runtime_mcfg_data_model.overlay_attach_groups.vrf_attach_groups_dict[vrf['vrf_attach_group']] is defined %} + { + "vrfName": "{{ vrf["name"] }}", + "lanAttachList": + [ +{% for attach in runtime_mcfg_data_model.overlay_attach_groups.vrf_attach_groups_dict[vrf['vrf_attach_group']] %} +{% if attach.loopback_id is defined and attach.loopback_id %} + { + "vrfName": "{{ vrf["name"] }}", +{% for switch in runtime_mcfg_data_model.switches %} +{% if switch["hostname"] == attach["hostname"] %} + "fabric": "{{ switch["fabric_name"] }}", + "serialNumber": "{{ switch["serial_number"] }}", +{% endif %} +{% endfor %} + "freeformConfig": "{{ attach['freeform_config'] | default('') | replace('\n', '\\n') | replace('"', '\\"') }}", + "extensionValues": "", +{% if vrf["vlan_id"] is defined %} + "vlan": {{ vrf["vlan_id"] }}, +{% endif %} + "deployment": true, + "instanceValues": "{\"loopbackId\": \"{{ attach['loopback_id'] | default('')}}\", \"loopbackIpAddress\": \"{{ attach['loopback_ipv4'] | default('') }}\", \"loopbackIpV6Address\":\"{{ attach['loopback_ipv6'] | default('') }}\"}" + }{% if not loop.last %},{% endif %} +{# Empty space needed to prettify and correctly represent the comma in a list continuation #} + +{% endif %} +{% endfor %} + ] + }{% if not loop.last %},{% endif %} +{# Empty space needed to prettify and correctly represent the comma in a list continuation #} + +{% endif %} +{% endif %} +{% endfor %} +] diff --git a/roles/dtc/common/templates/ndfc_vrfs/msd_fabric/msd_attach_vrfs_loopbacks.j2 b/roles/dtc/common/templates/ndfc_vrfs/msd_fabric/msd_attach_vrfs_loopbacks.j2 deleted file mode 100644 index e1f41ea82..000000000 --- a/roles/dtc/common/templates/ndfc_vrfs/msd_fabric/msd_attach_vrfs_loopbacks.j2 +++ /dev/null @@ -1,29 +0,0 @@ -[ - {% for vrf in data_model_extended.vxlan.multisite.overlay.vrfs %} - {% if vrf['vrf_attach_group'] is defined %} - { - "vrfName": "{{ vrf["name"] }}", - "lanAttachList": - [ - {% for attach in data_model_extended.vxlan.multisite.overlay.vrf_attach_groups_dict[vrf["vrf_attach_group"]] %} - { - - "vrfName": "{{ vrf["name"] }}", - {% for switch in runtime_msd_data_model.switches %} - {% if switch.hostname == attach["hostname"] %} - "fabric": "{{ switch.fabric_name }}", - "serialNumber": "{{ switch.serial_number }}", - {% endif %} - {% endfor %} - "freeformConfig": "{{ attach['freeform_config'] | default('') | replace('\n', '\\n') | replace('"', '\\"') }}", - "extensionValues": "", - "vlan": {{ vrf["vlan_id"] }}, - "deployment": true, - "instanceValues": "{\"loopbackId\": \"{{ attach['loopback_id'] | default('') }}\", \"loopbackIpAddress\": \"{{ attach['loopback_ipv4'] | default('') }}\", \"loopbackIpV6Address\":\"{{ attach['loopback_ipv6'] | default('') }}\"}" - }{% if not loop.last %},{% endif %} - {% endfor %} - ] - }{% if not loop.last %},{% endif %} - {% endif %} - {% endfor %} -] diff --git a/roles/dtc/common/templates/ndfc_vrfs/msd_fabric/msd_fabric_attach_vrfs_loopbacks.j2 b/roles/dtc/common/templates/ndfc_vrfs/msd_fabric/msd_fabric_attach_vrfs_loopbacks.j2 new file mode 100644 index 000000000..bd1acb8ae --- /dev/null +++ b/roles/dtc/common/templates/ndfc_vrfs/msd_fabric/msd_fabric_attach_vrfs_loopbacks.j2 @@ -0,0 +1,41 @@ +# This NDFC VRF loopback config data structure is auto-generated +# DO NOT EDIT MANUALLY +# +[ +{% for vrf in data_model_extended.vxlan.overlay.vrfs %} +{% if vrf['vrf_attach_group'] is defined %} +{% if runtime_msd_data_model.overlay_attach_groups.vrf_attach_groups_dict[vrf['vrf_attach_group']] is defined %} + { + "vrfName": "{{ vrf["name"] }}", + "lanAttachList": + [ +{% for attach in runtime_msd_data_model.overlay_attach_groups.vrf_attach_groups_dict[vrf['vrf_attach_group']] %} +{% if attach.loopback_id is defined and attach.loopback_id %} + { + "vrfName": "{{ vrf["name"] }}", +{% for switch in runtime_msd_data_model.switches %} +{% if switch["hostname"] == attach["hostname"] %} + "fabric": "{{ switch["fabric_name"] }}", + "serialNumber": "{{ switch["serial_number"] }}", +{% endif %} +{% endfor %} + "freeformConfig": "{{ attach['freeform_config'] | default('') | replace('\n', '\\n') | replace('"', '\\"') }}", + "extensionValues": "", +{% if vrf["vlan_id"] is defined %} + "vlan": "{{ vrf["vlan_id"] }}", +{% endif %} + "deployment": true, + "instanceValues": "{\"loopbackId\": \"{{ attach['loopback_id'] | default('')}}\", \"loopbackIpAddress\": \"{{ attach['loopback_ipv4'] | default('') }}\", \"loopbackIpV6Address\":\"{{ attach['loopback_ipv6'] | default('') }}\"}" + }{% if not loop.last %},{% endif %} +{# Empty space needed to prettify and correctly represent the comma in a list continuation #} + +{% endif %} +{% endfor %} + ] + }{% if not loop.last %},{% endif %} +{# Empty space needed to prettify and correctly represent the comma in a list continuation #} + +{% endif %} +{% endif %} +{% endfor %} +] diff --git a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml index d78c6a936..0b48d37ae 100644 --- a/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml +++ b/roles/dtc/create/tasks/common_vxlan/vrfs_networks.yml @@ -76,32 +76,37 @@ when: - run_map_read_result.diff_run is true|bool -- name: Manage Fabric VRFs in Nexus Dashboard - cisco.dcnm.dcnm_vrf: - fabric: "{{ data_model_extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vrf_config_list }}" - register: manage_vrf_result - when: - - data_model_extended.vxlan.overlay.vrfs is defined - - data_model_extended.vxlan.overlay.vrfs - - change_flags.changes_detected_vrfs - - vrf_config_list | length > 0 - - not is_active_child_fabric - # -------------------------------------------------------------------- -# Manage Loopback VRF attachments in Nexus Dashboard +# Manage VRF Configuration in Nexus Dashboard # -------------------------------------------------------------------- -- name: Attach Loopbacks to VRFs in Nexus Dashboard - cisco.dcnm.dcnm_rest: - method: POST - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ data_model_extended.vxlan.fabric.name }}/vrfs/attachments" - json_data: "{{ vars_common_local.vrf_attach_config | to_json }}" + +- name: Manage MSD Fabric VRFs and Loopback Attachments in Nexus Dashboard when: - data_model_extended.vxlan.overlay.vrfs is defined - data_model_extended.vxlan.overlay.vrfs - - change_flags.changes_detected_vrfs + - vrf_config_list | length > 0 - not is_active_child_fabric + block: + - name: Manage Fabric VRFs in Nexus Dashboard + cisco.dcnm.dcnm_vrf: + fabric: "{{ data_model_extended.vxlan.fabric.name }}" + state: replaced + config: "{{ vrf_config_list }}" + register: manage_vrf_result + when: + - change_flags.changes_detected_vrfs + + # -------------------------------------------------------------------- + # Manage Loopback VRF Attachments in Nexus Dashboard + # -------------------------------------------------------------------- + + - name: Attach Loopbacks to VRFs in Nexus Dashboard + cisco.dcnm.dcnm_rest: + method: POST + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ data_model_extended.vxlan.fabric.name }}/vrfs/attachments" + json_data: "{{ vars_common_local.vrf_attach_config | to_json }}" + when: + - vars_common_local.vrf_attach_config | length > 0 # -------------------------------------------------------------------- # Manage Network Configuration in Nexus Dashboard diff --git a/roles/dtc/create/tasks/mcfg/vrfs_networks.yml b/roles/dtc/create/tasks/mcfg/vrfs_networks.yml index 43d9dcbc9..e28b1d17d 100644 --- a/roles/dtc/create/tasks/mcfg/vrfs_networks.yml +++ b/roles/dtc/create/tasks/mcfg/vrfs_networks.yml @@ -81,21 +81,21 @@ operation: display delegate_to: localhost -- name: Override Networks List Based On Diff Run Settings +- name: Override VRFs List Based On Diff Run Settings ansible.builtin.set_fact: - net_config: "{{ mcfg_network_diff_result.updated }}" + vrf_config: "{{ mcfg_vrf_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool - - (change_flags_mcfg.changes_detected_networks is defined and change_flags_mcfg.changes_detected_networks) - - (mcfg_network_diff_result is defined and mcfg_network_diff_result.updated | length > 0) + - (change_flags_mcfg.changes_detected_vrfs is defined and change_flags_mcfg.changes_detected_vrfs) + - (mcfg_vrf_diff_result is defined and mcfg_vrf_diff_result.updated | length > 0) - name: Override Networks List Based On Diff Run Settings ansible.builtin.set_fact: - vrf_config: "{{ mcfg_vrf_diff_result.updated }}" + net_config: "{{ mcfg_network_diff_result.updated }}" when: - run_map_read_result.diff_run is true|bool - - (change_flags_mcfg.changes_detected_vrfs is defined and change_flags_mcfg.changes_detected_vrfs) - - (mcfg_vrf_diff_result is defined and mcfg_vrf_diff_result.updated | length > 0) + - (change_flags_mcfg.changes_detected_networks is defined and change_flags_mcfg.changes_detected_networks) + - (mcfg_network_diff_result is defined and mcfg_network_diff_result.updated | length > 0) # ---------------------------------------------------------------------------------- # Likewise, the vrf_config and net_config data is created when the tasks above @@ -113,37 +113,38 @@ # based on the detected changes. This is done in the following tasks. # -------------------------------------------------------------------- -# Manage VRF Configuration on NDFC +# Manage VRF Configuration in Nexus Dashboard # -------------------------------------------------------------------- -- name: Manage MCFG Fabric VRFs in Nexus Dashboard - cisco.dcnm.dcnm_vrf: - fabric: "{{ data_model_extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_mcfg.vrf_config }}" - register: manage_mcfg_vrf_result +- name: Manage MCFG Fabric VRFs and Loopback Attachments in Nexus Dashboard when: - data_model_extended.vxlan.multisite.overlay.vrfs is defined - data_model_extended.vxlan.multisite.overlay.vrfs - - change_flags_mcfg.changes_detected_vrfs - -# -------------------------------------------------------------------- -# Manage Loopback VRF attachments on NDFC -# -------------------------------------------------------------------- - -# Check with Matt and Pete on how we want to handle this for MCFG -# - name: Attach VRF Loopbacks per VRF -# cisco.dcnm.dcnm_rest: -# path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ data_model_extended.vxlan.fabric.name }}/vrfs/attachments" -# method: "POST" -# json_data: "{{ vars_common_mcfg.vrf_attach_config | to_json}}" -# when: -# - data_model_extended.vxlan.overlay.vrfs is defined -# - data_model_extended.vxlan.overlay.vrfs -# - change_flags_mcfg.changes_detected_vrfs + - vars_common_mcfg.vrf_config | length > 0 + block: + - name: Manage MCFG Fabric VRFs in Nexus Dashboard + cisco.dcnm.dcnm_vrf: + fabric: "{{ data_model_extended.vxlan.fabric.name }}" + state: replaced + config: "{{ vars_common_mcfg.vrf_config }}" + register: manage_mcfg_vrf_result + when: + - change_flags_mcfg.changes_detected_vrfs + + # -------------------------------------------------------------------- + # Manage Loopback VRF Attachments in Nexus Dashboard + # -------------------------------------------------------------------- + + - name: Manage MCFG Fabric VRF Loopback Attachments in Nexus Dashboard + cisco.dcnm.dcnm_rest: + path: "/onemanage/appcenter/cisco/ndfc/api/v1/onemanage/top-down/fabrics/{{ data_model_extended.vxlan.fabric.name }}/vrfs/attachments" + method: POST + json_data: "{{ mcfg_vrf_attach_config | to_json }}" + when: + - mcfg_vrf_attach_config | length > 0 # -------------------------------------------------------------------- -# Manage Network Configuration on NDFC +# Manage Network Configuration in Nexus Dashboard # -------------------------------------------------------------------- - name: Manage MCFG Fabric Networks in Nexus Dashboard cisco.dcnm.dcnm_network: @@ -154,4 +155,5 @@ when: - data_model_extended.vxlan.multisite.overlay.networks is defined - data_model_extended.vxlan.multisite.overlay.networks + - vars_common_mcfg.net_config | length > 0 - change_flags_mcfg.changes_detected_networks diff --git a/roles/dtc/create/tasks/msd/vrfs_networks.yml b/roles/dtc/create/tasks/msd/vrfs_networks.yml index b94de91b4..c8872b985 100644 --- a/roles/dtc/create/tasks/msd/vrfs_networks.yml +++ b/roles/dtc/create/tasks/msd/vrfs_networks.yml @@ -123,36 +123,38 @@ # based on the detected changes. This is done in the following tasks. # -------------------------------------------------------------------- -# Manage VRF Configuration on NDFC +# Manage VRF Configuration in Nexus Dashboard # -------------------------------------------------------------------- -- name: Manage MSD Fabric VRFs in Nexus Dashboard - cisco.dcnm.dcnm_vrf: - fabric: "{{ data_model_extended.vxlan.fabric.name }}" - state: replaced - config: "{{ vars_common_msd.vrf_config }}" - register: manage_msd_vrf_result - when: - - data_model_extended.vxlan.multisite.overlay.vrfs is defined - - data_model_extended.vxlan.multisite.overlay.vrfs - - change_flags_msd.changes_detected_vrfs - -# -------------------------------------------------------------------- -# Manage Loopback VRF attachments on NDFC (MSD) -# -------------------------------------------------------------------- - -- name: Manage MSD Fabric VRF Loopback Attachments in Nexus Dashboard - cisco.dcnm.dcnm_rest: - path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ data_model_extended.vxlan.fabric.name }}/vrfs/attachments" - method: POST - json_data: "{{ vrf_attach_config | to_json }}" +- name: Manage MSD Fabric VRFs and Loopback Attachments in Nexus Dashboard when: - data_model_extended.vxlan.multisite.overlay.vrfs is defined - data_model_extended.vxlan.multisite.overlay.vrfs - - change_flags_msd.changes_detected_vrfs + - vars_common_msd.vrf_config | length > 0 + block: + - name: Manage MSD Fabric VRFs in Nexus Dashboard + cisco.dcnm.dcnm_vrf: + fabric: "{{ data_model_extended.vxlan.fabric.name }}" + state: replaced + config: "{{ vars_common_msd.vrf_config }}" + register: manage_msd_vrf_result + when: + - change_flags_msd.changes_detected_vrfs + + # -------------------------------------------------------------------- + # Manage Loopback VRF Attachments in Nexus Dashboard + # -------------------------------------------------------------------- + + - name: Manage MSD Fabric VRF Loopback Attachments in Nexus Dashboard + cisco.dcnm.dcnm_rest: + path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ data_model_extended.vxlan.fabric.name }}/vrfs/attachments" + method: POST + json_data: "{{ msd_vrf_attach_config | to_json }}" + when: + - msd_vrf_attach_config | length > 0 # -------------------------------------------------------------------- -# Manage Network Configuration on NDFC +# Manage Network Configuration in Nexus Dashboard # -------------------------------------------------------------------- - name: Manage MSD Fabric Networks in Nexus Dashboard cisco.dcnm.dcnm_network: @@ -163,4 +165,5 @@ when: - data_model_extended.vxlan.multisite.overlay.networks is defined - data_model_extended.vxlan.multisite.overlay.networks + - vars_common_msd.net_config | length > 0 - change_flags_msd.changes_detected_networks diff --git a/roles/dtc/remove/tasks/mcfg/networks.yml b/roles/dtc/remove/tasks/mcfg/networks.yml index 20b29a8fb..56ad3ba9e 100644 --- a/roles/dtc/remove/tasks/mcfg/networks.yml +++ b/roles/dtc/remove/tasks/mcfg/networks.yml @@ -80,6 +80,8 @@ when: - multisite_network_delete_mode is defined - multisite_network_delete_mode is true | bool + - data_model_extended.vxlan.multisite.child_fabrics is defined + - data_model_extended.vxlan.multisite.child_fabrics | length > 0 - run_map_read_result.diff_run is false | bool or force_run_all is true | bool - name: Skip Remove Unmanaged Fabric Networks Task If multisite_network_delete_mode is False diff --git a/roles/dtc/remove/tasks/mcfg/vrfs.yml b/roles/dtc/remove/tasks/mcfg/vrfs.yml index 69f2aa234..4f6b2f75a 100644 --- a/roles/dtc/remove/tasks/mcfg/vrfs.yml +++ b/roles/dtc/remove/tasks/mcfg/vrfs.yml @@ -80,6 +80,8 @@ when: - multisite_vrf_delete_mode is defined - multisite_vrf_delete_mode is true | bool + - data_model_extended.vxlan.multisite.child_fabrics is defined + - data_model_extended.vxlan.multisite.child_fabrics | length > 0 - run_map_read_result.diff_run is false | bool or force_run_all is true | bool - name: Skip Remove Unmanaged Fabric VRFs Task If multisite_vrf_delete_mode is False diff --git a/roles/dtc/remove/tasks/msd/networks.yml b/roles/dtc/remove/tasks/msd/networks.yml index 65f9d184c..a7f865fa8 100644 --- a/roles/dtc/remove/tasks/msd/networks.yml +++ b/roles/dtc/remove/tasks/msd/networks.yml @@ -80,6 +80,8 @@ when: - multisite_network_delete_mode is defined - multisite_network_delete_mode is true | bool + - data_model_extended.vxlan.multisite.child_fabrics is defined + - data_model_extended.vxlan.multisite.child_fabrics | length > 0 - run_map_read_result.diff_run is false | bool or force_run_all is true | bool - name: Skip Remove Unmanaged Fabric Networks Task If multisite_network_delete_mode is False diff --git a/roles/dtc/remove/tasks/msd/vrfs.yml b/roles/dtc/remove/tasks/msd/vrfs.yml index 6535e8f3f..5a96fddbf 100644 --- a/roles/dtc/remove/tasks/msd/vrfs.yml +++ b/roles/dtc/remove/tasks/msd/vrfs.yml @@ -80,6 +80,8 @@ when: - multisite_vrf_delete_mode is defined - multisite_vrf_delete_mode is true | bool + - data_model_extended.vxlan.multisite.child_fabrics is defined + - data_model_extended.vxlan.multisite.child_fabrics | length > 0 - run_map_read_result.diff_run is false | bool or force_run_all is true | bool - name: Skip Remove Unmanaged Fabric VRFs Task If multisite_vrf_delete_mode is False diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt index 00a8e9075..931adeb1e 100644 --- a/tests/sanity/ignore-2.14.txt +++ b/tests/sanity/ignore-2.14.txt @@ -31,7 +31,6 @@ plugins/action/dtc/links_filter_and_remove.py action-plugin-docs # action plugin plugins/action/dtc/unmanaged_policy.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plugin has no matching module to provide documentation 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/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 diff --git a/tests/sanity/ignore-2.15.txt b/tests/sanity/ignore-2.15.txt index 00a8e9075..931adeb1e 100644 --- a/tests/sanity/ignore-2.15.txt +++ b/tests/sanity/ignore-2.15.txt @@ -31,7 +31,6 @@ plugins/action/dtc/links_filter_and_remove.py action-plugin-docs # action plugin plugins/action/dtc/unmanaged_policy.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plugin has no matching module to provide documentation 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/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 diff --git a/tests/sanity/ignore-2.16.txt b/tests/sanity/ignore-2.16.txt index 00a8e9075..931adeb1e 100644 --- a/tests/sanity/ignore-2.16.txt +++ b/tests/sanity/ignore-2.16.txt @@ -31,7 +31,6 @@ plugins/action/dtc/links_filter_and_remove.py action-plugin-docs # action plugin plugins/action/dtc/unmanaged_policy.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plugin has no matching module to provide documentation 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/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 diff --git a/tests/sanity/ignore-2.17.txt b/tests/sanity/ignore-2.17.txt index 00a8e9075..931adeb1e 100644 --- a/tests/sanity/ignore-2.17.txt +++ b/tests/sanity/ignore-2.17.txt @@ -31,7 +31,6 @@ plugins/action/dtc/links_filter_and_remove.py action-plugin-docs # action plugin plugins/action/dtc/unmanaged_policy.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plugin has no matching module to provide documentation 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/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 diff --git a/tests/sanity/ignore-2.18.txt b/tests/sanity/ignore-2.18.txt index a3a6a655c..5693466a3 100644 --- a/tests/sanity/ignore-2.18.txt +++ b/tests/sanity/ignore-2.18.txt @@ -31,7 +31,6 @@ plugins/action/dtc/links_filter_and_remove.py action-plugin-docs # action plugin plugins/action/dtc/unmanaged_policy.py action-plugin-docs # action plugin has no matching module to provide documentation plugins/action/dtc/unmanaged_edge_connections.py action-plugin-docs # action plugin has no matching module to provide documentation 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/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