From b50fde8ade826886488cc1230517c745948af28f Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Wed, 20 Nov 2024 19:25:00 +0530 Subject: [PATCH 01/17] Fix the issue of verifying the deletion of template or project --- plugins/modules/template_workflow_manager.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 2f2820567..ec1b97375 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -3371,7 +3371,7 @@ def delete_project_or_template(self, config, is_delete_project=False): template_params = self.want.get("template_params") params_key = {"template_id": self.have_template.get("id")} deletion_value = "deletes_the_template" - name = "templateName: {0}".format(template_params.get('templateName')) + name = "templateName: {0}".format(template_params.get('name')) response = self.dnac_apply['exec']( family="configuration_templates", @@ -3474,8 +3474,7 @@ def get_diff_deleted(self, config): ).format(template_name) self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() - self.msg = "Successfully completed delete state execution" - self.status = "success" + self.log("Successfully completed delete state execution", "DEBUG") return self def verify_diff_merged(self, config): @@ -3570,15 +3569,11 @@ def verify_diff_deleted(self, config): "name", templateName) if template_info: - self.msg = "Configuration Template config is not applied to the Cisco Catalyst Center." - self.status = "failed" + self.log("Configuration Template config is not applied to the Cisco Catalyst Center.", "WARNING") return self - self.log("Successfully validated absence of template in the Catalyst Center.", "INFO") - self.result['response'][0].get("configurationTemplate").get("response").update({"Validation": "Success"}) + self.log("Successfully validated the absence of Template in the Cisco Catalyst Center.", "INFO") - self.msg = "Successfully validated the absence of Template in the Cisco Catalyst Center." - self.status = "success" return self def reset_values(self): From f4bb5d7af490e20fd403a80b46bf9fd487c2c002 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 21 Nov 2024 16:00:15 +0530 Subject: [PATCH 02/17] address review comments --- plugins/modules/template_workflow_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index ec1b97375..0835b7220 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -3464,6 +3464,7 @@ def get_diff_deleted(self, config): self.msg = "Project is not deletable" self.status = "failed" return self + self.log("Successfully completed the delete operation for the template {0}".format(templateName), "DEBUG") deploy_temp_details = config.get("deploy_template") if deploy_temp_details: @@ -3474,7 +3475,6 @@ def get_diff_deleted(self, config): ).format(template_name) self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status() - self.log("Successfully completed delete state execution", "DEBUG") return self def verify_diff_merged(self, config): @@ -3572,7 +3572,7 @@ def verify_diff_deleted(self, config): self.log("Configuration Template config is not applied to the Cisco Catalyst Center.", "WARNING") return self - self.log("Successfully validated the absence of Template in the Cisco Catalyst Center.", "INFO") + self.log("Successfully validated the absence of Template {0} in the Cisco Catalyst Center.".format(templateName), "INFO") return self From 7d856533d4a002fa45abc7a9946fd5f5ec84caa4 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 21 Nov 2024 17:11:55 +0530 Subject: [PATCH 03/17] revert the version in galaxy.yml --- galaxy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galaxy.yml b/galaxy.yml index 935f754c0..c08001f0a 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -1,7 +1,7 @@ --- namespace: cisco name: dnac -version: 6.24.0 +version: 6.25.1 readme: README.md authors: - Rafael Campos From becc28443c0ccff54d44d2c9b72497b6222430a9 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 21 Nov 2024 17:21:16 +0530 Subject: [PATCH 04/17] revert the import statements after documentation --- plugins/modules/template_workflow_manager.py | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 55e8f3d46..df0bd7b62 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -6,17 +6,6 @@ """Ansible module to perform operations on project and templates in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) -from ansible.module_utils.basic import AnsibleModule -import time -import json -import copy - __metaclass__ = type __author__ = [ 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] @@ -1186,6 +1175,17 @@ """ +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import time +import json +import copy + class Template(DnacBase): """Class containing member attributes for template_workflow_manager module""" From 9287475f5c21e248a647ed4dad2057c798344d52 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Mon, 25 Nov 2024 11:12:35 +0530 Subject: [PATCH 05/17] moved import to the top of the module --- plugins/modules/template_workflow_manager.py | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index df0bd7b62..5f05c132e 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -6,6 +6,16 @@ """Ansible module to perform operations on project and templates in Cisco Catalyst Center.""" from __future__ import absolute_import, division, print_function +from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( + DnacBase, + validate_list_of_dicts, + get_dict_result, + dnac_compare_equality, +) +from ansible.module_utils.basic import AnsibleModule +import time +import json +import copy __metaclass__ = type __author__ = [ 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] @@ -1175,17 +1185,6 @@ """ -from ansible_collections.cisco.dnac.plugins.module_utils.dnac import ( - DnacBase, - validate_list_of_dicts, - get_dict_result, - dnac_compare_equality, -) -from ansible.module_utils.basic import AnsibleModule -import time -import json -import copy - class Template(DnacBase): """Class containing member attributes for template_workflow_manager module""" From b54365cf6a5c1ad9c2ebeee631ed1aa4395419aa Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Mon, 25 Nov 2024 11:14:38 +0530 Subject: [PATCH 06/17] add new line after import statements --- plugins/modules/template_workflow_manager.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 5f05c132e..55e8f3d46 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -16,6 +16,7 @@ import time import json import copy + __metaclass__ = type __author__ = [ 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] From af9895f1d6d8af554f5b49cda0e3d86d05231e67 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Mon, 25 Nov 2024 12:52:23 +0530 Subject: [PATCH 07/17] add quotes to the variable --- plugins/modules/template_workflow_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 55e8f3d46..8eca38311 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -2927,7 +2927,7 @@ def filter_devices_with_family_role( filtered_device_list = [] self.log( - "Filtering devices from the provided site-assigned device IDs: {0}, device_family='{1}', " + "Filtering devices from the provided site-assigned device IDs: '{0}', device_family='{1}', " "and device_role='{2}'".format( site_assign_device_ids, device_family, From 24d5b76e88b2ac484d3613de425720d0e3353ed8 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Mon, 25 Nov 2024 12:54:14 +0530 Subject: [PATCH 08/17] Revert "add new line after import statements" This reverts commit b54365cf6a5c1ad9c2ebeee631ed1aa4395419aa. --- plugins/modules/template_workflow_manager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 8eca38311..037568fa3 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -16,7 +16,6 @@ import time import json import copy - __metaclass__ = type __author__ = [ 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] From 358c7c6e7f4668ccd807dfafa437c0d0b5cc7ea1 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Mon, 25 Nov 2024 12:57:23 +0530 Subject: [PATCH 09/17] revert 2 commits before --- plugins/modules/template_workflow_manager.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 037568fa3..55e8f3d46 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -16,6 +16,7 @@ import time import json import copy + __metaclass__ = type __author__ = [ 'Madhan Sankaranarayanan, Rishita Chowdhary, Akash Bhaskaran, Muthu Rakesh, Abhishek Maheshwari'] @@ -2926,7 +2927,7 @@ def filter_devices_with_family_role( filtered_device_list = [] self.log( - "Filtering devices from the provided site-assigned device IDs: '{0}', device_family='{1}', " + "Filtering devices from the provided site-assigned device IDs: {0}, device_family='{1}', " "and device_role='{2}'".format( site_assign_device_ids, device_family, From 52d6207c569fece4404c8d7276fa77cef399a1d6 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Wed, 27 Nov 2024 10:13:34 +0530 Subject: [PATCH 10/17] Fix the issue of creating fabric sites/zones in single go --- .../sda_fabric_sites_zones_workflow_manager.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py index 50e6fb4de..040b13585 100644 --- a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py +++ b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py @@ -1449,11 +1449,15 @@ def get_diff_merged(self, config): # Create/Update Fabric sites/zones in Cisco Catalyst Center raw_fabric_sites = self.want.get('fabric_sites') - # Convert each dictionary to a sorted tuple of key-value pairs - unique_fabric_sites = {tuple(sorted(d.items())) - for d in raw_fabric_sites} - # Convert each unique tuple back into a dictionary - fabric_sites = [dict(t) for t in unique_fabric_sites] + # Preserve the order of input while deduplicating + unique_fabric_site_set = set() + fabric_sites = [] + for fabric_site_dict in raw_fabric_sites: + # Convert dictionary to a frozenset - immutable set + site_zone = frozenset(fabric_site_dict.items()) + if site_zone not in unique_fabric_site_set: + unique_fabric_site_set.add(site_zone) + fabric_sites.append(fabric_site_dict) for site in fabric_sites: site_name = site.get("site_name_hierarchy") From b63863043ed43b65b7927cc621e6f31b17b752db Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 14:41:32 +0530 Subject: [PATCH 11/17] Add space after - to fix sanity errors --- plugins/modules/template_workflow_manager.py | 72 ++++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 0835b7220..32ab9c9ae 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -14,14 +14,14 @@ module: template_workflow_manager short_description: Resource module for Template functions description: -- Manage operations create, update and delete of the resource Configuration Template. -- API to create a template by project name and template name. -- API to update a template by template name and project name. -- API to delete a template by template name and project name. -- API to export the projects for given projectNames. -- API to export the templates for given templateIds. -- API to manage operation create of the resource Configuration Template Import Project. -- API to manage operation create of the resource Configuration Template Import Template. + - Manage operations create, update and delete of the resource Configuration Template. + - API to create a template by project name and template name. + - API to update a template by template name and project name. + - API to delete a template by template name and project name. + - API to export the projects for given projectNames. + - API to export the templates for given templateIds. + - API to manage operation create of the resource Configuration Template Import Project. + - API to manage operation create of the resource Configuration Template Import Template. version_added: '6.6.0' extends_documentation_fragment: - cisco.dnac.workflow_manager_params @@ -38,11 +38,11 @@ state: description: The state of Cisco Catalyst Center after module completion. type: str - choices: [ merged, deleted ] + choices: [merged, deleted] default: merged config: description: - - List of details of templates being managed. + - List of details of templates being managed. type: list elements: dict required: true @@ -59,9 +59,9 @@ type: bool containing_templates: description: - - Refer to a set of templates within the main template to define more complex or modular configurations. - - This is particularly useful in systems that support hierarchical or nested templates. - - Here parent templates may contain child templates to form a complete configuration. + - Refer to a set of templates within the main template to define more complex or modular configurations. + - This is particularly useful in systems that support hierarchical or nested templates. + - Here parent templates may contain child templates to form a complete configuration. suboptions: composite: description: Specifies if the template is composite. @@ -252,8 +252,8 @@ type: str failure_policy: description: - - Define failure policy if template provisioning fails. - - failure_policy will be enabled only when the composite is set to True. + - Define failure policy if template provisioning fails. + - failure_policy will be enabled only when the composite is set to True. choices: - ABORT_TARGET_ON_ERROR type: str @@ -424,22 +424,22 @@ suboptions: do_version: description: - - Determines whether to create a new version of the project with the imported contents. - - If set to true and the project already exists, a new version will be created. - - If false, the operation will fail with a 'Project already exists' error if the project already exists. + - Determines whether to create a new version of the project with the imported contents. + - If set to true and the project already exists, a new version will be created. + - If false, the operation will fail with a 'Project already exists' error if the project already exists. type: bool project_file: description: - - Specifies the path to a JSON file that contains the import project configuration. - - If both 'project_file' and 'payload' are provided, the 'project_file' will be given priority. + - Specifies the path to a JSON file that contains the import project configuration. + - If both 'project_file' and 'payload' are provided, the 'project_file' will be given priority. type: str version_added: 6.17.0 payload: description: - - Directly imports configuration data into the system using the provided payload. - - Offers an alternative to 'project_file' for importing configurations without referencing an external file. - - Ignored if 'project_file' is also provided. - type: list + - Directly imports configuration data into the system using the provided payload. + - Offers an alternative to 'project_file' for importing configurations without referencing an external file. + - Ignored if 'project_file' is also provided. + type: list elements: dict suboptions: name: @@ -457,14 +457,14 @@ type: bool template_file: description: - - Specifies the path to a JSON file that contains an import template. - - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. + - Specifies the path to a JSON file that contains an import template. + - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. type: str payload: description: - - The payload parameter is used to directly import configuration data into the system. - - The payload provides an alternative way to import configurations without the need to reference an external file. - - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. + - The payload parameter is used to directly import configuration data into the system. + - The payload provides an alternative way to import configurations without the need to reference an external file. + - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. type: list elements: dict suboptions: @@ -476,9 +476,9 @@ type: bool containing_templates: description: - - Refer to a set of templates within the main template to define more complex or modular configurations. - - This is particularly useful in systems that support hierarchical or nested templates. - - Here parent templates may contain child templates to form a complete configuration. + - Refer to a set of templates within the main template to define more complex or modular configurations. + - This is particularly useful in systems that support hierarchical or nested templates. + - Here parent templates may contain child templates to form a complete configuration. suboptions: composite: description: Specifies if the template is composite. @@ -666,8 +666,8 @@ type: str failure_policy: description: - - Define failure policy if template provisioning fails. - - failure_policy will be enabled only when the composite is set to True. + - Define failure policy if template provisioning fails. + - failure_policy will be enabled only when the composite is set to True. choices: - ABORT_TARGET_ON_ERROR type: str @@ -885,8 +885,8 @@ requirements: -- dnacentersdk >= 2.7.2 -- python >= 3.9 + - dnacentersdk >= 2.7.2 + - python >= 3.9 notes: - SDK Method used are configuration_templates.ConfigurationTemplates.create_template, From a93967c97a2e5d29022243d5400e869cb9887e38 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 14:51:49 +0530 Subject: [PATCH 12/17] revert the space after - --- plugins/modules/template_workflow_manager.py | 70 ++++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index 32ab9c9ae..f21b38900 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -14,14 +14,14 @@ module: template_workflow_manager short_description: Resource module for Template functions description: - - Manage operations create, update and delete of the resource Configuration Template. - - API to create a template by project name and template name. - - API to update a template by template name and project name. - - API to delete a template by template name and project name. - - API to export the projects for given projectNames. - - API to export the templates for given templateIds. - - API to manage operation create of the resource Configuration Template Import Project. - - API to manage operation create of the resource Configuration Template Import Template. +- Manage operations create, update and delete of the resource Configuration Template. +- API to create a template by project name and template name. +- API to update a template by template name and project name. +- API to delete a template by template name and project name. +- API to export the projects for given projectNames. +- API to export the templates for given templateIds. +- API to manage operation create of the resource Configuration Template Import Project. +- API to manage operation create of the resource Configuration Template Import Template. version_added: '6.6.0' extends_documentation_fragment: - cisco.dnac.workflow_manager_params @@ -42,7 +42,7 @@ default: merged config: description: - - List of details of templates being managed. + - List of details of templates being managed. type: list elements: dict required: true @@ -59,9 +59,9 @@ type: bool containing_templates: description: - - Refer to a set of templates within the main template to define more complex or modular configurations. - - This is particularly useful in systems that support hierarchical or nested templates. - - Here parent templates may contain child templates to form a complete configuration. + - Refer to a set of templates within the main template to define more complex or modular configurations. + - This is particularly useful in systems that support hierarchical or nested templates. + - Here parent templates may contain child templates to form a complete configuration. suboptions: composite: description: Specifies if the template is composite. @@ -252,8 +252,8 @@ type: str failure_policy: description: - - Define failure policy if template provisioning fails. - - failure_policy will be enabled only when the composite is set to True. + - Define failure policy if template provisioning fails. + - failure_policy will be enabled only when the composite is set to True. choices: - ABORT_TARGET_ON_ERROR type: str @@ -424,22 +424,22 @@ suboptions: do_version: description: - - Determines whether to create a new version of the project with the imported contents. - - If set to true and the project already exists, a new version will be created. - - If false, the operation will fail with a 'Project already exists' error if the project already exists. + - Determines whether to create a new version of the project with the imported contents. + - If set to true and the project already exists, a new version will be created. + - If false, the operation will fail with a 'Project already exists' error if the project already exists. type: bool project_file: description: - - Specifies the path to a JSON file that contains the import project configuration. - - If both 'project_file' and 'payload' are provided, the 'project_file' will be given priority. + - Specifies the path to a JSON file that contains the import project configuration. + - If both 'project_file' and 'payload' are provided, the 'project_file' will be given priority. type: str version_added: 6.17.0 payload: description: - - Directly imports configuration data into the system using the provided payload. - - Offers an alternative to 'project_file' for importing configurations without referencing an external file. - - Ignored if 'project_file' is also provided. - type: list + - Directly imports configuration data into the system using the provided payload. + - Offers an alternative to 'project_file' for importing configurations without referencing an external file. + - Ignored if 'project_file' is also provided. + type: list elements: dict suboptions: name: @@ -457,14 +457,14 @@ type: bool template_file: description: - - Specifies the path to a JSON file that contains an import template. - - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. + - Specifies the path to a JSON file that contains an import template. + - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. type: str payload: description: - - The payload parameter is used to directly import configuration data into the system. - - The payload provides an alternative way to import configurations without the need to reference an external file. - - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. + - The payload parameter is used to directly import configuration data into the system. + - The payload provides an alternative way to import configurations without the need to reference an external file. + - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. type: list elements: dict suboptions: @@ -476,9 +476,9 @@ type: bool containing_templates: description: - - Refer to a set of templates within the main template to define more complex or modular configurations. - - This is particularly useful in systems that support hierarchical or nested templates. - - Here parent templates may contain child templates to form a complete configuration. + - Refer to a set of templates within the main template to define more complex or modular configurations. + - This is particularly useful in systems that support hierarchical or nested templates. + - Here parent templates may contain child templates to form a complete configuration. suboptions: composite: description: Specifies if the template is composite. @@ -666,8 +666,8 @@ type: str failure_policy: description: - - Define failure policy if template provisioning fails. - - failure_policy will be enabled only when the composite is set to True. + - Define failure policy if template provisioning fails. + - failure_policy will be enabled only when the composite is set to True. choices: - ABORT_TARGET_ON_ERROR type: str @@ -885,8 +885,8 @@ requirements: - - dnacentersdk >= 2.7.2 - - python >= 3.9 +- dnacentersdk >= 2.7.2 +- python >= 3.9 notes: - SDK Method used are configuration_templates.ConfigurationTemplates.create_template, From 933beff5646f577e38773b7c36950ab5b8b9189e Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 14:58:41 +0530 Subject: [PATCH 13/17] fix sanity errors --- plugins/modules/template_workflow_manager.py | 70 ++++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/plugins/modules/template_workflow_manager.py b/plugins/modules/template_workflow_manager.py index f21b38900..b5fc0b1ed 100644 --- a/plugins/modules/template_workflow_manager.py +++ b/plugins/modules/template_workflow_manager.py @@ -14,14 +14,14 @@ module: template_workflow_manager short_description: Resource module for Template functions description: -- Manage operations create, update and delete of the resource Configuration Template. -- API to create a template by project name and template name. -- API to update a template by template name and project name. -- API to delete a template by template name and project name. -- API to export the projects for given projectNames. -- API to export the templates for given templateIds. -- API to manage operation create of the resource Configuration Template Import Project. -- API to manage operation create of the resource Configuration Template Import Template. + - Manage operations create, update and delete of the resource Configuration Template. + - API to create a template by project name and template name. + - API to update a template by template name and project name. + - API to delete a template by template name and project name. + - API to export the projects for given projectNames. + - API to export the templates for given templateIds. + - API to manage operation create of the resource Configuration Template Import Project. + - API to manage operation create of the resource Configuration Template Import Template. version_added: '6.6.0' extends_documentation_fragment: - cisco.dnac.workflow_manager_params @@ -34,7 +34,7 @@ config_verify: description: Set to True to verify the Cisco Catalyst Center after applying the playbook config. type: bool - default: False + default: false state: description: The state of Cisco Catalyst Center after module completion. type: str @@ -42,7 +42,7 @@ default: merged config: description: - - List of details of templates being managed. + - List of details of templates being managed. type: list elements: dict required: true @@ -59,9 +59,9 @@ type: bool containing_templates: description: - - Refer to a set of templates within the main template to define more complex or modular configurations. - - This is particularly useful in systems that support hierarchical or nested templates. - - Here parent templates may contain child templates to form a complete configuration. + - Refer to a set of templates within the main template to define more complex or modular configurations. + - This is particularly useful in systems that support hierarchical or nested templates. + - Here parent templates may contain child templates to form a complete configuration. suboptions: composite: description: Specifies if the template is composite. @@ -252,8 +252,8 @@ type: str failure_policy: description: - - Define failure policy if template provisioning fails. - - failure_policy will be enabled only when the composite is set to True. + - Define failure policy if template provisioning fails. + - failure_policy will be enabled only when the composite is set to True. choices: - ABORT_TARGET_ON_ERROR type: str @@ -424,21 +424,21 @@ suboptions: do_version: description: - - Determines whether to create a new version of the project with the imported contents. - - If set to true and the project already exists, a new version will be created. - - If false, the operation will fail with a 'Project already exists' error if the project already exists. + - Determines whether to create a new version of the project with the imported contents. + - If set to true and the project already exists, a new version will be created. + - If false, the operation will fail with a 'Project already exists' error if the project already exists. type: bool project_file: description: - - Specifies the path to a JSON file that contains the import project configuration. - - If both 'project_file' and 'payload' are provided, the 'project_file' will be given priority. + - Specifies the path to a JSON file that contains the import project configuration. + - If both 'project_file' and 'payload' are provided, the 'project_file' will be given priority. type: str version_added: 6.17.0 payload: description: - - Directly imports configuration data into the system using the provided payload. - - Offers an alternative to 'project_file' for importing configurations without referencing an external file. - - Ignored if 'project_file' is also provided. + - Directly imports configuration data into the system using the provided payload. + - Offers an alternative to 'project_file' for importing configurations without referencing an external file. + - Ignored if 'project_file' is also provided. type: list elements: dict suboptions: @@ -457,14 +457,14 @@ type: bool template_file: description: - - Specifies the path to a JSON file that contains an import template. - - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. + - Specifies the path to a JSON file that contains an import template. + - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. type: str payload: description: - - The payload parameter is used to directly import configuration data into the system. - - The payload provides an alternative way to import configurations without the need to reference an external file. - - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. + - The payload parameter is used to directly import configuration data into the system. + - The payload provides an alternative way to import configurations without the need to reference an external file. + - If both 'template_file' and 'payload' are provided, the 'template_file' will be given priority. type: list elements: dict suboptions: @@ -476,9 +476,9 @@ type: bool containing_templates: description: - - Refer to a set of templates within the main template to define more complex or modular configurations. - - This is particularly useful in systems that support hierarchical or nested templates. - - Here parent templates may contain child templates to form a complete configuration. + - Refer to a set of templates within the main template to define more complex or modular configurations. + - This is particularly useful in systems that support hierarchical or nested templates. + - Here parent templates may contain child templates to form a complete configuration. suboptions: composite: description: Specifies if the template is composite. @@ -666,8 +666,8 @@ type: str failure_policy: description: - - Define failure policy if template provisioning fails. - - failure_policy will be enabled only when the composite is set to True. + - Define failure policy if template provisioning fails. + - failure_policy will be enabled only when the composite is set to True. choices: - ABORT_TARGET_ON_ERROR type: str @@ -885,8 +885,8 @@ requirements: -- dnacentersdk >= 2.7.2 -- python >= 3.9 + - dnacentersdk >= 2.7.2 + - python >= 3.9 notes: - SDK Method used are configuration_templates.ConfigurationTemplates.create_template, From c207857391fcdbf41c411984b8f764e633bc3fab Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 15:05:28 +0530 Subject: [PATCH 14/17] fix sanity for fabric site module --- .../sda_fabric_sites_zones_workflow_manager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py index bf7c9719f..54cecd21d 100644 --- a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py +++ b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py @@ -30,11 +30,11 @@ config_verify: description: Set to True to verify the Cisco Catalyst Center configuration after applying the playbook configuration. type: bool - default: False + default: false state: description: The desired state of Cisco Catalyst Center after the module execution. type: str - choices: [ merged, deleted ] + choices: [merged, deleted] default: merged config: description: A list containing detailed configurations for creating, updating, or deleting fabric sites or zones @@ -44,7 +44,7 @@ to authentication profiles. type: list elements: dict - required: True + required: true suboptions: fabric_sites: description: A dictionary containing detailed configurations for managing REST Endpoints that will receive Audit log @@ -57,13 +57,13 @@ sites or zones, as well as for updating the authentication profile template. This parameter is mandatory for any fabric site/zone management operation. type: str - required: True + required: true fabric_type: description: Specifies the type of site to be managed within the SDA environment. The acceptable values are 'fabric_site' and 'fabric_zone'. The default value is 'fabric_site', indicating the configuration of a broader network area, whereas 'fabric_zone' typically refers to a more specific segment within the site. type: str - required: True + required: true authentication_profile: description: The authentication profile applied to the specified fabric. This profile determines the security posture and controls for network access within the site. Possible values include 'Closed Authentication', 'Low Impact', @@ -107,8 +107,8 @@ requirements: -- dnacentersdk >= 2.9.2 -- python >= 3.9 + - dnacentersdk >= 2.9.2 + - python >= 3.9 notes: - To ensure the module operates correctly for scaled sets, which involve creating or updating fabric sites/zones and handling From ffa779984aabd5465bd1722fae015b3df675a7f7 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 15:10:56 +0530 Subject: [PATCH 15/17] fix sanity --- .../sda_fabric_sites_zones_workflow_manager.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py index 54cecd21d..7862cb481 100644 --- a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py +++ b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py @@ -14,13 +14,13 @@ module: sda_fabric_sites_zones_workflow_manager short_description: Manage fabric site(s)/zone(s) and update the authentication profile template in Cisco Catalyst Center. description: -- Creating fabric site(s) for the SDA operation in Cisco Catalyst Center. -- Updating fabric site(s) for the SDA operation in Cisco Catalyst Center. -- Creating fabric zone(s) for the SDA operation in Cisco Catalyst Center. -- Updating fabric zone(s) for the SDA operation in Cisco Catalyst Center. -- Deletes fabric site(s) from Cisco Catalyst Center. -- Deletes fabric zone(s) from Cisco Catalyst Center. -- Configure the authentication profile template for fabric site/zone in Cisco Catalyst Center. + - Creating fabric site(s) for the SDA operation in Cisco Catalyst Center. + - Updating fabric site(s) for the SDA operation in Cisco Catalyst Center. + - Creating fabric zone(s) for the SDA operation in Cisco Catalyst Center. + - Updating fabric zone(s) for the SDA operation in Cisco Catalyst Center. + - Deletes fabric site(s) from Cisco Catalyst Center. + - Deletes fabric zone(s) from Cisco Catalyst Center. + - Configure the authentication profile template for fabric site/zone in Cisco Catalyst Center. version_added: '6.17.0' extends_documentation_fragment: - cisco.dnac.workflow_manager_params From 885d7720cd1bd4669a7d6252ce55388b6521d5af Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 15:20:07 +0530 Subject: [PATCH 16/17] revert readme changes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b1c7a896..aafbc2f9a 100644 --- a/README.md +++ b/README.md @@ -210,4 +210,4 @@ Please read and familiarize yourself with this document. This collection follows [Semantic Versioning](https://semver.org/). More details on versioning can be found [in the Ansible docs](https://docs.ansible.com/ansible/latest/dev_guide/developing_collections.html#collection-versions). -New minor and major releases as well as deprecations will follow new releases and deprecations of the Cisco DNA Center product, its REST API and the corresponding Python SDK, which this project relies on. +New minor and major releases as well as deprecations will follow new releases and deprecations of the Cisco DNA Center product, its REST API and the corresponding Python SDK, which this project relies on. From af546a3992c08bedbd763b6a237ce097f6f317d7 Mon Sep 17 00:00:00 2001 From: Abhishek-121 Date: Thu, 28 Nov 2024 16:34:18 +0530 Subject: [PATCH 17/17] Update the log messages --- .../sda_fabric_sites_zones_workflow_manager.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py index 7862cb481..0d9630006 100644 --- a/plugins/modules/sda_fabric_sites_zones_workflow_manager.py +++ b/plugins/modules/sda_fabric_sites_zones_workflow_manager.py @@ -1340,14 +1340,17 @@ def get_diff_merged(self, config): # Create/Update Fabric sites/zones in Cisco Catalyst Center raw_fabric_sites = self.want.get('fabric_sites') # Preserve the order of input while deduplicating + self.log("Starting deduplication of raw_fabric_sites.", "DEBUG") unique_fabric_site_set = set() fabric_sites = [] for fabric_site_dict in raw_fabric_sites: # Convert dictionary to a frozenset - immutable set site_zone = frozenset(fabric_site_dict.items()) if site_zone not in unique_fabric_site_set: + self.log("New unique site found: '{0}'".format(site_zone), "DEBUG") unique_fabric_site_set.add(site_zone) fabric_sites.append(fabric_site_dict) + self.log("Deduplication complete. Total unique sites: {0}".format(len(fabric_sites)), "DEBUG") for site in fabric_sites: site_name = site.get("site_name_hierarchy") @@ -1502,7 +1505,20 @@ def get_diff_deleted(self, config): self.set_operation_result("failed", False, self.msg, "ERROR") return self - fabric_sites = self.want.get('fabric_sites') + raw_fabric_sites = self.want.get('fabric_sites') + # Preserve the order of input while deduplicating + self.log("Starting deduplication of raw_fabric_sites.", "DEBUG") + unique_fabric_site_set = set() + fabric_sites = [] + for fabric_site_dict in raw_fabric_sites: + # Convert dictionary to a frozenset - immutable set + site_zone = frozenset(fabric_site_dict.items()) + if site_zone not in unique_fabric_site_set: + self.log("New unique site found: '{0}'".format(site_zone), "DEBUG") + unique_fabric_site_set.add(site_zone) + fabric_sites.append(fabric_site_dict) + + self.log("Deduplication complete. Total unique sites: {0}".format(len(fabric_sites)), "DEBUG") fabric_site_dict = {} for site in fabric_sites: