Skip to content

Commit

Permalink
Merge pull request #190 from cisco-en-programmability/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
bvargasre authored Oct 3, 2024
2 parents 3717ed2 + bdf34b0 commit 444910c
Show file tree
Hide file tree
Showing 25 changed files with 26,320 additions and 3,594 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/release-prep.yml

This file was deleted.

16 changes: 0 additions & 16 deletions .github/workflows/release.yml

This file was deleted.

13 changes: 13 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1002,3 +1002,16 @@ releases:
- fabric_sites_zones_workflow_manager.py: removed attribute 'site_type'.
- swim_workflow_manager.py: added attribute 'cco_image_details'.
- user_role_workflow_manager: added attribute 'password_update'.
6.20.0:
release_date: "2024-10-03"
changes:
release_summary: Code changes in workflow manager modules.
minor_changes:
- Removing git release workflows.
- Removed sda_extranet_policies_workflow_manager.py module.
- Changes in network_compliance_workflow_manager module.
- Changes in user_role_workflow_manager module.
- Changes in inventory_workflow_manager module.
- network_settings_workflow_manager.py: added attributes 'wired_data_collection', 'wireless_telemetry', and 'netflow_collector'.
- provision_workflow_manager.py: added attribute 'force_provisioning'.
- accesspoint_workflow_manager.py: added attribute 'reboot_aps'.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: cisco
name: dnac
version: 6.19.0
version: 6.20.0
readme: README.md
authors:
- Rafael Campos <[email protected]>
Expand Down
25 changes: 25 additions & 0 deletions playbooks/provision_workflow_manager.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
- name: Configure device credentials on Cisco Catalyst Center
hosts: localhost
connection: local
gather_facts: no
vars_files:
- "credentials.yml"
tasks:
- name: Provision a wired device to a site
cisco.dnac.provision_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: DEBUG
config_verify: true
dnac_api_task_timeout: 1000
dnac_task_poll_interval: 1
state: merged
config:
- site_name_hierarchy: Global/Chennai/LTTS/FLOOR1
management_ip_address: 1.1.1.1
86 changes: 86 additions & 0 deletions plugins/module_utils/dnac.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,41 @@ def get_device_ip_from_device_id(self, site_id):

return mgmt_ip_to_instance_id_map

def get_sites_type(self, site_name):
"""
Get the type of a site in Cisco Catalyst Center.
Parameters:
self (object): An instance of a class used for interacting with Cisco Catalyst Center.
site_name (str): The name of the site for which to retrieve the type.
Returns:
site_type (str or None): The type of the specified site, or None if the site is not found.
Description:
This function queries Cisco Catalyst Center to retrieve the type of a specified site. It uses the
get_site API with the provided site name, extracts the site type from the response, and returns it.
If the specified site is not found, the function returns None, and an appropriate log message is generated.
"""

try:
response = self.get_site(site_name)
if self.get_ccc_version_as_integer() <= self.get_ccc_version_as_int_from_str("2.3.5.3"):
site = response.get("response")
site_additional_info = site[0].get("additionalInfo")

for item in site_additional_info:
if item["nameSpace"] == "Location":
site_type = item.get("attributes").get("type")
else:
self.log("Received API response from 'get_sites': {0}".format(str(response)), "DEBUG")
site = response.get("response")
site_type = site[0].get("type")

except Exception as e:
self.msg = "Error while fetching the site '{0}' and the specified site was not found in Cisco Catalyst Center.".format(site_name)
self.log(self.msg, "ERROR")
self.module.fail_json(msg=self.msg, response=[self.msg])

return site_type

def get_device_ids_from_site(self, site_id):
"""
Retrieve device IDs associated with a specific site in Cisco Catalyst Center.
Expand Down Expand Up @@ -749,6 +784,57 @@ def get_site(self, site_name):
self.log("An error occurred in 'get_sites':{0}".format(e), "ERROR")
return None

def assign_device_to_site(self, device_ids, site_name, site_id):
"""
Assign devices to the specified site.
Parameters:
self (object): An instance of a class used for interacting with Cisco Catalyst Center.
device_ids (list): A list of device IDs to assign to the specified site.
site_name (str): The complete path of the site location.
site_id (str): The ID of the specified site location.
Returns:
bool: True if the devices are successfully assigned to the site, otherwise False.
Description:
Assigns the specified devices to the site. If the assignment is successful, returns True.
Otherwise, logs an error and returns False along with error details.
"""
assign_network_device_to_site = {
'deviceIds': device_ids,
'siteId': site_id,
}
self.log("Assigning devices to site before update: {0}, {1}".
format(site_name, str(assign_network_device_to_site)), "INFO")
try:
response = self.dnac._exec(
family="site_design",
function='assign_network_devices_to_a_site',
op_modifies=True,
params=assign_network_device_to_site
)
self.log("Response from assigning devices to site: {0}, {1}, {2} .".format(
site_name, str(assign_network_device_to_site), str(response["response"])), "INFO")

self.check_tasks_response_status(response, api_name='assign_device_to_site')
if self.result["changed"]:
return True
else:
self.msg = "Failed to receive a valid response from site assignment API: {0}, {1}".format(site_name,
str(assign_network_device_to_site))
self.log(self.msg, "ERROR")
self.status = "failed"
self.module.fail_json(msg=self.msg)

except Exception as e:
msg = "Failed to assign devices to site: {0}, {1}.".format(site_name,
str(assign_network_device_to_site))
self.log(msg + str(e), "ERROR")
site_assgin_details = str(e)
self.status = "failed"
self.module.fail_json(msg=msg, response=site_assgin_details)

def generate_key(self):
"""
Generate a new encryption key using Fernet.
Expand Down
Loading

0 comments on commit 444910c

Please sign in to comment.