forked from cisco-en-programmability/dnacenter-ansible
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from rukapse/main
latest changes 04/01/2024
- Loading branch information
Showing
5 changed files
with
320 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
226 changes: 226 additions & 0 deletions
226
tests/integration/ccc_pnp_management/tests/test_pnp_management.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
--- | ||
- debug: msg="Starting pnp management test" | ||
- debug: msg="Role Path {{ role_path }}" | ||
|
||
- block: | ||
- name: Load vars and declare dnac vars | ||
include_vars: | ||
file: "{{ role_path }}/vars/vars_pnp_management.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.pnp_delete }}" | ||
# - debug: | ||
# msg: "{{ vars_map.pnp_claim }}" | ||
# - debug: | ||
# msg: "{{ vars_map.bulk }}" | ||
# - debug: | ||
# msg: "{{ vars_map.delete_devices }}" | ||
|
||
############################################# | ||
# Clean Up # | ||
############################################# | ||
|
||
- name: Delete PnP devices | ||
cisco.dnac.pnp_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.pnp_delete.delete }}" | ||
|
||
- name: Delete PnP devices | ||
cisco.dnac.pnp_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.bulk.add }}" | ||
|
||
# - name: Delete device from Inventory | ||
# cisco.dnac.inventory_workflow_manager: | ||
# <<: *dnac_login | ||
# state: deleted | ||
# config: | ||
# - "{{ item }}" | ||
# loop: "{{ vars_map.delete_devices }}" | ||
|
||
############################################# | ||
# Add device but not Claim PNP Device # | ||
############################################# | ||
|
||
- name: Adding devices but not claiming | ||
cisco.dnac.pnp_workflow_manager: | ||
<<: *dnac_login | ||
state: merged | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.pnp_delete.add }}" | ||
register: result_add_device | ||
|
||
# - name: Debug Adding devices but not claiming | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_add_device.results }}" | ||
# when: result_add_device is defined | ||
|
||
- name: Assert adding devices but not claiming | ||
assert: | ||
that: | ||
- item.changed == true | ||
- "'Only Device Added Successfully' in item.msg" | ||
loop: "{{ result_add_device.results }}" | ||
when: result_add_device is defined | ||
|
||
############################################# | ||
# Delete Unclaimed Devices # | ||
############################################# | ||
|
||
- name: Delete PnP devices | ||
cisco.dnac.pnp_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.pnp_delete.delete }}" | ||
register: result_delete_device | ||
|
||
# - name: Debug delete unclaimed devices | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_delete_device.results }}" | ||
# when: result_delete_device is defined | ||
|
||
- name: Assert deletion of unclaimed PnP devices | ||
assert: | ||
that: | ||
- item.changed == true | ||
- "'Deleted Successfully' in item.msg" | ||
loop: "{{ result_delete_device.results }}" | ||
when: result_delete_device is defined | ||
|
||
############################################# | ||
# Bulk Add device but not Claim PNP Device # | ||
############################################# | ||
|
||
- name: Bulk Adding devices but not claiming | ||
cisco.dnac.pnp_workflow_manager: | ||
<<: *dnac_login | ||
state: merged | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.bulk.add }}" | ||
register: result_add_device | ||
|
||
# - name: Debug Bulk Adding devices but not claiming | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_add_device.results }}" | ||
# when: result_add_device is defined | ||
|
||
- name: Assert bulk adding devices but not claiming | ||
assert: | ||
that: | ||
- item.changed == true | ||
- "'imported successfully' in item.msg" | ||
loop: "{{ result_add_device.results }}" | ||
when: result_add_device is defined | ||
|
||
############################################# | ||
# Bulk Delete Unclaimed Devices # | ||
############################################# | ||
|
||
- name: Delete Bulk Unclaimed PnP devices | ||
cisco.dnac.pnp_workflow_manager: | ||
<<: *dnac_login | ||
state: deleted | ||
config: | ||
- "{{ item }}" | ||
loop: "{{ vars_map.bulk.add }}" | ||
register: result_delete_device | ||
|
||
# - name: Debug Bulk delete unclaimed devices | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_delete_device.results }}" | ||
# when: result_delete_device is defined | ||
|
||
- name: Assert Bulk deletion of unclaimed PnP devices | ||
assert: | ||
that: | ||
- item.changed == true | ||
- "'Deleted Successfully' in item.msg" | ||
loop: "{{ result_delete_device.results }}" | ||
when: result_delete_device is defined | ||
|
||
############################################# | ||
# Add and Claim PNP Device # | ||
############################################# | ||
|
||
# - name: Add and Claim PnP devices | ||
# cisco.dnac.pnp_workflow_manager: | ||
# <<: *dnac_login | ||
# state: merged | ||
# config: | ||
# - "{{ item }}" | ||
# loop: "{{ vars_map.pnp_claim.cat9k }}" | ||
# register: result_claim_device | ||
|
||
# - name: Debug Add and Claim device | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_claim_device.results }}" | ||
# when: result_claim_device is defined | ||
|
||
# - name: Assert Add and Claim device | ||
# assert: | ||
# that: | ||
# - item.changed == true | ||
# - "'Claimed Successfully' in item.msg" | ||
# loop: "{{ result_claim_device.results }}" | ||
# when: result_claim_device is defined | ||
|
||
############################################# | ||
# Pause to Complete Provisioning # | ||
############################################# | ||
|
||
# - name: Pause for 10 minutes | ||
# pause: | ||
# seconds: 600 | ||
|
||
############################################# | ||
# Delete Devices # | ||
############################################# | ||
|
||
# - name: Delete device | ||
# cisco.dnac.inventory_workflow_manager: | ||
# <<: *dnac_login | ||
# state: deleted | ||
# config: | ||
# - "{{ item }}" | ||
# loop: "{{ vars_map.delete_devices }}" | ||
# register: result_device_deleted | ||
|
||
# - name: Debug item | ||
# debug: | ||
# var: item | ||
# loop: "{{ result_device_deleted.results }}" | ||
# when: result_device_deleted is defined | ||
|
||
# - name: Assert device deletion success | ||
# assert: | ||
# that: | ||
# - result_device_deleted.changed == true | ||
# when: result_device_deleted is defined |
56 changes: 56 additions & 0 deletions
56
tests/integration/ccc_pnp_management/vars/vars_pnp_management.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
pnp_delete: | ||
add: | ||
- device_info: | ||
- serial_number: FJC2721271T | ||
hostname: SJ-EN-9300 | ||
state: Unclaimed | ||
pid: C9300-48T | ||
|
||
delete: | ||
- device_info: | ||
- serial_number: FJC2721271T | ||
hostname: SJ-EN-9300 | ||
state: Unclaimed | ||
pid: C9300-48T | ||
|
||
|
||
pnp_claim: | ||
cat9k: | ||
- device_info: | ||
- serial_number: FJC2721271T | ||
hostname: Switch | ||
state: Unclaimed | ||
pid: C9300-48T | ||
site_name: Global/ITest_PnP_Area/ITest_PnP_Building | ||
template_name: "Ansible_PNP_Switch" | ||
project_name: Onboarding Configuration | ||
template_params: | ||
hostname: SJ-EN-9300 | ||
interface: GigabitEthernet1/1/4 | ||
|
||
|
||
bulk: | ||
add: | ||
- device_info: | ||
- serial_number: FOX2639PAYD | ||
hostname: SJ-EWLC-1 | ||
state: Unclaimed | ||
pid: C9800-40-K9 | ||
- serial_number: FJC271924D9 | ||
hostname: SJ-EN-9300 | ||
state: Unclaimed | ||
pid: C9300-48UXM | ||
- serial_number: FJC271925Q1 | ||
hostname: NY-EN-9300 | ||
state: Unclaimed | ||
pid: C9300-48UXM | ||
- serial_number: FJC2402A0TX | ||
hostname: SF-BN-ISR | ||
state: Unclaimed | ||
pid: ISR4451-X/K9 | ||
|
||
|
||
delete_devices: | ||
- ip_address_list: ["204.1.2.1"] | ||
clean_config: False |