Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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') }}"
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/fabric_check_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=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",
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/fabrics_config_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=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",
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/fabrics_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=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",
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/get_poap_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def refresh(self) -> None:
self.refresh_message = None

data = self.execute_module(
module_name="cisco.dcnm.dcnm_rest",
module_name=task_vars['ansible_network_os_rest'],
module_args={
"method": self.poap_get_method,
"path": self.poap_get_path
Expand Down
4 changes: 2 additions & 2 deletions plugins/action/dtc/manage_child_fabric_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=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']}",
Expand Down Expand Up @@ -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=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']}",
Expand Down
4 changes: 2 additions & 2 deletions plugins/action/dtc/manage_child_fabric_vrfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=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']}"
Expand Down Expand Up @@ -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=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']}",
Expand Down
4 changes: 2 additions & 2 deletions plugins/action/dtc/manage_child_fabrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=task_vars['ansible_network_os_rest'],
module_args={
"method": "POST",
"path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdAdd",
Expand Down Expand Up @@ -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=task_vars['ansible_network_os_rest'],
module_args={
"method": "POST",
"path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msdExit",
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/prepare_msite_child_fabrics_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=task_vars['ansible_network_os_rest'],
module_args={
"method": "GET",
"path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations",
Expand Down
2 changes: 1 addition & 1 deletion plugins/action/dtc/prepare_msite_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=task_vars['ansible_network_os_rest'],
module_args={
"method": "GET",
"path": "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/msd/fabric-associations",
Expand Down
4 changes: 2 additions & 2 deletions plugins/plugin_utils/helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=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"
Expand Down Expand Up @@ -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=task_vars['ansible_network_os_rest'],
module_args={
"method": "GET",
"path": f"/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/control/fabrics/{fabric}",
Expand Down
16 changes: 15 additions & 1 deletion roles/dtc/connectivity_check/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,28 @@
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:
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
9 changes: 8 additions & 1 deletion roles/dtc/create/tasks/common/devices_discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@
delegate_to: localhost

- name: Update Switch Hostname Policy in NDFC
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 }}"
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
when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest"
11 changes: 9 additions & 2 deletions roles/dtc/create/tasks/external/devices_discovery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -53,8 +53,15 @@
delegate_to: localhost

- name: Update Switch Hostname Policy in NDFC
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 }}"
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
when: results.policy_update | length > 0 and ansible_network_os_rest == "cisco.dcnm.dcnm_rest"
35 changes: 34 additions & 1 deletion roles/dtc/create/tasks/external/fabric.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,61 @@
- "----------------------------------------------------------------"

- name: Check if fabric External {{ MD_Extended.vxlan.fabric.name }} exists in NDFC
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

- 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.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:
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: >
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
11 changes: 9 additions & 2 deletions roles/dtc/create/tasks/sub_main_vxlan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,20 @@
- 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
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:
Expand Down
25 changes: 23 additions & 2 deletions roles/dtc/create/tasks/vxlan/vrfs_networks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +80,19 @@
# --------------------------------------------------------------------
# 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"
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:
method: POST
path: "/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/top-down/v2/fabrics/{{ MD_Extended.vxlan.fabric.name }}/vrfs/attachments"
Expand All @@ -82,6 +102,7 @@
- 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:
Expand Down
Loading