Skip to content

Commit

Permalink
Merge pull request #41 from rukapse/main
Browse files Browse the repository at this point in the history
latest changes 04/01/2024
  • Loading branch information
rukapse authored Apr 1, 2024
2 parents 94a705e + d76952f commit c9cf3e2
Show file tree
Hide file tree
Showing 5 changed files with 320 additions and 8 deletions.
30 changes: 30 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ parameters:
run-swim:
type: boolean
default: false
run-pnp:
type: boolean
default: false

jobs:

Expand Down Expand Up @@ -194,6 +197,16 @@ jobs:
command: |
echo " - ccc_swim_management" >> ccc_roles.yml
- when:
condition:
or: [ << pipeline.parameters.run-pnp >>, << pipeline.parameters.run-all >> ]
steps:
- run:
command: |
echo " - ccc_pnp_management" >> ccc_roles.yml
- run:
command: cat ccc_roles.yml

Expand Down Expand Up @@ -280,6 +293,18 @@ jobs:
set -x
rm -rf ${HOME}/repo/$CIRCLE_PROJECT_REPONAME
post_pnp_testing:
machine: true
resource_class: rukapse/dnacenter-ansible
working_directory: ~/repo

steps:
- when:
condition: << pipeline.parameters.run-pnp >>
steps:
- run:
command: |
python ${HOME}/static/pnp_script.py
workflows:

Expand Down Expand Up @@ -314,12 +339,14 @@ workflows:
plugins/modules/discovery_workflow_manager.py run-discovery true
plugins/modules/inventory_workflow_manager.py run-inventory true
plugins/modules/swim_workflow_manager.py run-swim true
plugins/modules/pnp_workflow_manager.py run-pnp true
tests/integration/ccc_site_management/.* run-site true
tests/integration/ccc_device_credential_management/.* run-devicecredential true
tests/integration/ccc_discovery_management/.* run-discovery true
tests/integration/ccc_inventory_management/.* run-inventory true
tests/integration/ccc_swim_management/.* run-swim true
tests/integration/ccc_pnp_management/.* run-pnp true
integration-testing:
when: << pipeline.parameters.run-any >>
Expand All @@ -333,3 +360,6 @@ workflows:
parameters:
ansible_cisco_dnac_version:
- "6.9.0"
# - post_pnp_testing:
# requires:
# - sanity-tests
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ delete_discoveries:
- discovery_name: Multi Range Discovery - preferred_mgmt
- discovery_name: CDP Discovery - preferred_mgmt
- discovery_name: LLDP Discovery - preferred_mgmt
- discovery_name: CIDR Discovery - preferred_mgmt
- discovery_name: CIDR Discovery - preferred_mgmt
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@
# loop: "{{ result_update_device_role.results }}"
# when: result_update_device_role is defined

- name: Assert device role update
assert:
that:
- item.changed == true
- "'role updated successfully' in item.response"
loop: "{{ result_update_device_role.results }}"
when: result_update_device_role is defined
# - name: Assert device role update
# assert:
# that:
# - item.changed == true
# - "'role updated successfully' in item.response"
# loop: "{{ result_update_device_role.results }}"
# when: result_update_device_role is defined

#############################################
# Update Device Interface Description #
Expand Down
226 changes: 226 additions & 0 deletions tests/integration/ccc_pnp_management/tests/test_pnp_management.yml
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 tests/integration/ccc_pnp_management/vars/vars_pnp_management.yml
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

0 comments on commit c9cf3e2

Please sign in to comment.