Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…talyst-center-ansible-intg into pnp_workflow_bulk_issue_bug
  • Loading branch information
md-rafeek committed Dec 16, 2024
2 parents db2ca1c + e445cbe commit 72fabd8
Show file tree
Hide file tree
Showing 11 changed files with 478 additions and 6 deletions.
10 changes: 4 additions & 6 deletions plugins/modules/template_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,7 @@
device_details:
description: Details specific to devices where the template will be deployed, including lists of device IPs, hostnames,
serial numbers, or MAC addresses.
type: list
elements: dict
type: dict
suboptions:
device_ips:
description: A list of IP addresses of the devices where the template will be deployed.
Expand Down Expand Up @@ -1078,7 +1077,7 @@
- param_name: "vlan_name"
param_value: "testvlan31"
device_details:
- device_ips: ["10.1.2.1", "10.2.3.4"]
device_ips: ["10.1.2.1", "10.2.3.4"]
- name: Delete the given project or template from the Cisco Catalyst Center
cisco.dnac.template_workflow_manager:
Expand Down Expand Up @@ -1270,8 +1269,7 @@ def validate_input(self):
'param_value': {'type': 'str'},
},
'device_details': {
'type': 'list',
'elements': 'dict',
'type': 'dict',
'device_ips': {'type': 'list', 'elements': 'str'},
'device_hostnames': {'type': 'list', 'elements': 'str'},
'serial_numbers': {'type': 'list', 'elements': 'str'},
Expand Down Expand Up @@ -2420,7 +2418,7 @@ def get_export_template_values(self, export_values):

all_project_details = self.dnac._exec(
family="configuration_templates",
function='get_projects_details'
function='get_projects_details_v2'
)
all_project_details = all_project_details.get("response")
for values in export_values:
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/ccc_template_management/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
testcase: "*"
1 change: 1 addition & 0 deletions tests/integration/ccc_template_management/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dependencies: []
34 changes: 34 additions & 0 deletions tests/integration/ccc_template_management/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
- name: collect ccc test cases
find:
paths: "{{ role_path }}/tests"
patterns: "{{ testcase }}.yml"
connection: local
register: ccc_cases
tags: sanity

- debug:
msg: "CCC Cases: {{ ccc_cases }}"

- set_fact:
test_cases:
files: "{{ ccc_cases.files }}"
tags: sanity

- debug:
msg: "Test Cases: {{ test_cases }}"

- name: set test_items
set_fact:
test_items: "{{ test_cases.files | map(attribute='path') | list }}"
tags: sanity

- debug:
msg: "Test Items: {{ test_items }}"

- name: run test cases (connection=httpapi)
include_tasks: "{{ test_case_to_run }}"
loop: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run
tags: sanity
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"name": "test_template",
"tags": [],
"author": "admin",
"deviceTypes": [
{
"productFamily": "Switches and Hubs"
}
],
"softwareType": "IOS",
"softwareVariant": "XE",
"templateContent": "hostname cat9k-1\\n",
"templateParams": [],
"rollbackTemplateParams": [],
"composite": false,
"containingTemplates": [],
"language": "VELOCITY",
"promotedTemplateContent": "hostname cat9k-1\\n",
"promotedTemplateParams": [],
"customParamsOrder": false,
"createTime": 1719914895959,
"lastUpdateTime": 1719914895959,
"latestVersionTime": 1719914896486,
"validationErrors": {
"templateErrors": [],
"rollbackTemplateErrors": [],
"templateId": "10a9a332-44f8-419e-8274-45ad74a38e9b",
"templateVersion": null
},
"noOfConflicts": 0,
"projectAssociated": true,
"documentDatabase": false
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
- debug: msg="Starting export template and project test"
- debug: msg="Role Path {{ role_path }}"

- block:
- name: Load vars and declare dnac vars
include_vars:
file: "{{ role_path }}/vars/vars_export_template_and_project.yml"
name: vars_map
vars:
dnac_login: &dnac_login
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

# - debug:
# msg: "{{ vars_map.create_template_details }}"

# - debug:
# msg: "{{ vars_map.export_project_details }}"

# - debug:
# msg: "{{ vars_map.export_template_details }}"

#############################################
# Pre Tests Clean Up #
#############################################

- name: Create template before test
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: merged
config:
- "{{ item }}"
loop: "{{ vars_map.template_details }}"

#############################################
# EXPORT PROJECT #
#############################################

- name: Export project from export_project_details
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: merged
config:
- "{{ item }}"
register: result_export_project
loop: "{{ vars_map.export_project_details }}"
tags: merged

# - name: Debug item
# debug:
# var: item
# loop: "{{ result_export_project.results }}"
# when: result_export_project is defined

- name: Assert export of project
assert:
that:
- item.changed == true
loop: "{{ result_export_project.results }}"
when: result_export_project is defined

#############################################
# EXPORT TEMPLATE #
#############################################

- name: Export template from export_template_details
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: merged
config:
- "{{ item }}"
register: result_export_template
loop: "{{ vars_map.export_template_details }}"
tags: merged

# - name: Debug item
# debug:
# var: item
# loop: "{{ result_export_template.results }}"
# when: result_export_template is defined

- name: Assert export of template
assert:
that:
- item.changed == true
loop: "{{ result_export_template.results }}"
when: result_export_template is defined

#############################################
# POST TEST CLEAN UP #
#############################################

# - name: Pause for 10 seconds after each updation
# pause:
# seconds: 10

- name: Delete template after test
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: deleted
config:
- "{{ item }}"
loop: "{{ vars_map.template_details }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
- debug: msg="Starting import template and project test"
- debug: msg="Role Path {{ role_path }}"

- block:
- name: Load vars and declare dnac vars
include_vars:
file: "{{ role_path }}/vars/vars_import_template_and_project.yml"
name: vars_map
vars:
dnac_login: &dnac_login
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

# - debug:
# msg: "{{ vars_map.template_details }}"

# - debug:
# msg: "{{ vars_map.project_details }}"

# - debug:
# msg: "{{ vars_map.import_template_details }}"

# - debug:
# msg: "{{ vars_map.import_project_details }}"

#############################################
# Pre Tests Clean Up #
#############################################

- name: Clean up template before test
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: deleted
config:
- "{{ item }}"
loop: "{{ vars_map.template_details }}"

# - name: Clean up project before test
# cisco.dnac.template_workflow_manager:
# <<: *dnac_login
# state: deleted
# config:
# - "{{ item }}"
# loop: "{{ vars_map.project_details }}"

# #############################################
# # IMPORT PROJECT #
# #############################################

# - name: Import project from import_project_details
# cisco.dnac.template_workflow_manager:
# <<: *dnac_login
# state: merged
# config:
# - "{{ item }}"
# register: result_import_project
# loop: "{{ vars_map.import_project_details }}"
# tags: merged

# # - name: Debug item
# # debug:
# # var: item
# # loop: "{{ result_import_project.results }}"
# # when: result_import_project is defined

# - name: Assert import project
# assert:
# that:
# - item.changed == true
# - "'imported the project' in item.response[2].import.response.importProject"
# loop: "{{ result_import_project.results }}"
# when: result_import_project is defined

#############################################
# IMPORT TEMPLATE #
#############################################

- name: Import template from import_template_details
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: merged
config:
- "{{ item }}"
register: result_import_template
loop: "{{ vars_map.import_template_details }}"
tags: merged

# - name: Debug item
# debug:
# var: item
# loop: "{{ result_import_template.results }}"
# when: result_import_template is defined

- name: Assert import template
assert:
that:
- item.changed == true
- "'imported the templates' in item.response[2].import.response.importTemplate"
loop: "{{ result_import_template.results }}"
when: result_import_template is defined

#############################################
# Pre Tests Clean Up #
#############################################

- name: Clean up template before test
cisco.dnac.template_workflow_manager:
<<: *dnac_login
state: deleted
config:
- "{{ item }}"
loop: "{{ vars_map.template_details }}"

# - name: Clean up project before test
# cisco.dnac.template_workflow_manager:
# <<: *dnac_login
# state: deleted
# config:
# - "{{ item }}"
# loop: "{{ vars_map.project_details }}"
Loading

0 comments on commit 72fabd8

Please sign in to comment.