Skip to content

Commit

Permalink
Used the API 'add_control_plane_device' to add the CONTROL_NODE with …
Browse files Browse the repository at this point in the history
…the distribution protocol
  • Loading branch information
MUTHU-RAKESH-27 committed Oct 29, 2024
1 parent a8b0221 commit 32615c5
Showing 1 changed file with 128 additions and 3 deletions.
131 changes: 128 additions & 3 deletions plugins/modules/sda_fabric_devices_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@
choices: [CONTROL_PLANE_NODE, EDGE_NODE, BORDER_NODE, WIRELESS_CONTROLLER_NODE]
type: list
elements: str
route_distribution_protocol:
description:
- Route Distribution Protocol for Control Plane Device.
- The route distribution protocol manages routing information across network segments.
- Available protocols,
- LISP_BGP - Location/ID Separation Protocol Publish-Subscribe is a control plane model
in which routing information is distributed using a publish-subscribe mechanism.
- LISP_PUB_SUB - Location/ID Separation Protocol with BGP) integrates BGP as the control plane
for LISP networks. Here, BGP advertises and manages routing information.
choices: [LISP_BGP, LISP_PUB_SUB]
type: list
elements: str
borders_settings:
description:
- Effective only when the 'device_roles' contains BORDER_NODE.
Expand Down Expand Up @@ -318,6 +330,7 @@
sda.Sda.get_fabric_devices_layer3_handoffs_with_ip_transit,
sda.Sda.get_fabric_devices,
sda.Sda.add_fabric_devices,
sda.Sda.add_control_plane_device,
sda.Sda.add_fabric_devices_layer2_handoffs,
sda.Sda.add_fabric_devices_layer3_handoffs_with_sda_transit,
sda.Sda.add_fabric_devices_layer3_handoffs_with_ip_transit,
Expand Down Expand Up @@ -345,6 +358,7 @@
get /dna/intent/api/v1/sda/fabricDevices/layer3Handoffs/ipTransits
get /dna/intent/api/v1/sda/fabricDevices
post /dna/intent/api/v1/sda/fabricDevices
post /dna/intent/api/v1/business/sda/control-plane-device
post /dna/intent/api/v1/sda/fabricDevices/layer2Handoffs
post /dna/intent/api/v1/sda/fabricDevices/layer3Handoffs/sdaTransits
post /dna/intent/api/v1/sda/fabricDevices/layer3Handoffs/ipTransits
Expand Down Expand Up @@ -380,6 +394,54 @@
device_config:
- device_ip: 10.0.0.1
device_roles: [CONTROL_PLANE_NODE]
route_distribution_protocol: LISP_PUB_SUB
- name: Create SDA fabric device with device role as CONTROL_PLANE_NODE, EDGE_NODE
cisco.dnac.sda_fabric_devices_workflow_manager:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
dnac_log: True
dnac_log_level: "{{ dnac_log_level }}"
state: merged
config_verify: True
config:
- fabric_devices:
fabric_name: Global/USA/SAN-JOSE
device_config:
- device_ip: 10.0.0.1
device_roles: [CONTROL_PLANE_NODE, EDGE_NODE]
- name: Create SDA fabric device with device role as CONTROL_PLANE_NODE, EDGE_NODE, BORDER_NODE
cisco.dnac.sda_fabric_devices_workflow_manager:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
dnac_log: True
dnac_log_level: "{{ dnac_log_level }}"
state: merged
config_verify: True
config:
- fabric_devices:
fabric_name: Global/USA/SAN-JOSE
device_config:
- device_ip: 10.0.0.1
device_roles: [CONTROL_PLANE_NODE, EDGE_NODE, BORDER_NODE]
borders_settings:
layer3_settings:
local_autonomous_system_number: 1234
is_default_exit: true
import_external_routes: true
border_priority: 1
prepend_autonomous_system_count: 1
- name: Update the SDA fabric device with the device roles with BORDER_NODE and add L2 Handoff
cisco.dnac.sda_fabric_devices_workflow_manager:
Expand Down Expand Up @@ -836,6 +898,25 @@
},
"version": "string"
}
# Case_13: Successful addition of Control Node to the fabric.
response_13:
description: A dictionary or list with the response returned by the Cisco Catalyst Center Python SDK
returned: always
type: dict
sample: >
{
"response": {
"endTime": "integer",
"lastUpdate": "integer",
"status": "string",
"startTime": "integer",
"version": "integer",
"resultLocation": "string",
"id": "string"
},
"version": "string"
}
"""

import time
Expand Down Expand Up @@ -3932,9 +4013,53 @@ def update_fabric_devices(self, fabric_devices):
self.log("Desired fabric device '{ip}' details (want): {requested_state}"
.format(ip=device_ip, requested_state=want_device_details), "DEBUG")
try:
payload = {"payload": [want_device_details]}
task_name = "add_fabric_devices"
task_id = self.get_taskid_post_api_call("sda", task_name, payload)
device_roles = want_device_details.get("deviceRoles")
if device_roles == ["CONTROL_PLANE_NODE"]:
route_distribution_protocol = item.get("route_distribution_protocol")
if route_distribution_protocol is None:
route_distribution_protocol = "LISP_BGP"
else:
route_distribution_protocol_list = ["LISP_BGP", "LISP_PUB_SUB"]
if route_distribution_protocol not in route_distribution_protocol_list:
self.msg = (
"The 'route_distribution_protocol_list' should be in the list {protocol_list}."
.format(protocol_list=route_distribution_protocol_list)
)
self.status = "failed"
return self

payload = {
"payload": {
"deviceManagementIpAddress": device_ip,
"siteNameHierarchy": fabric_name,
"routeDistributionProtocol": route_distribution_protocol
}
}
task_name = "add_control_plane_device"

# Execute the API call
response = self.dnac._exec(
family="sda",
function="add_control_plane_device",
op_modifies=True,
params=payload,
)
self.log(
"Response received from API call to Function: 'add_control_plane_device': {response}"
.format(response=str(response)), "DEBUG"
)

# Update result and extract task ID
task_id = response.get("taskId")
self.log(
"Task ID received from API call to Function: 'add_control_plane_device': {task_id}"
.format(task_id=task_id), "INFO"
)
else:
payload = {"payload": [want_device_details]}
task_name = "add_fabric_devices"
task_id = self.get_taskid_post_api_call("sda", task_name, payload)

if not task_id:
self.msg = (
"Unable to retrive the task_id for the task '{task_name}'."
Expand Down

0 comments on commit 32615c5

Please sign in to comment.