2017-11-17 15:19:13 +00:00
|
|
|
# Test code for the ACI modules
|
2018-02-21 18:35:59 +00:00
|
|
|
# Copyright: (c) 2017, Jacob McGill (@jmcgill298)
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
- name: Test that we have an ACI APIC host, ACI username and ACI password
|
|
|
|
fail:
|
|
|
|
msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
|
|
|
|
when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
|
|
|
|
|
|
|
|
- name: ensure tenant exists for tests to kick off
|
|
|
|
aci_tenant: &aci_tenant_present
|
|
|
|
host: "{{ aci_hostname }}"
|
|
|
|
username: "{{ aci_username }}"
|
|
|
|
password: "{{ aci_password }}"
|
2018-01-20 23:38:20 +00:00
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-02-02 23:41:56 +00:00
|
|
|
output_level: debug
|
2017-11-17 15:19:13 +00:00
|
|
|
state: present
|
|
|
|
tenant: anstest
|
|
|
|
register: tenant_present
|
|
|
|
|
|
|
|
- name: ensure bd exists for tests to kick off
|
|
|
|
aci_bd: &aci_bd_present
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
bd: anstest
|
|
|
|
register: bd_present
|
|
|
|
|
|
|
|
- name: ensure ap exists for tests to kick off
|
|
|
|
aci_ap: &aci_ap_present
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
ap: anstest
|
|
|
|
register: ap_present
|
|
|
|
|
|
|
|
- name: create epg - check mode works
|
|
|
|
aci_epg: &aci_epg_present
|
|
|
|
<<: *aci_ap_present
|
|
|
|
epg: anstest
|
|
|
|
bd: anstest
|
|
|
|
description: Ansible Test
|
|
|
|
check_mode: yes
|
|
|
|
register: epg_present_check_mode
|
|
|
|
|
|
|
|
- name: create epg - creation works
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
register: epg_present
|
|
|
|
|
|
|
|
- name: create epg - idempotency works
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
register: epg_present_idempotent
|
|
|
|
|
|
|
|
- name: update epg - update works
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
description: Ansible Test Update
|
|
|
|
register: epg_present_update
|
|
|
|
|
|
|
|
- name: create epg - missing param
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
ap: "{{ fakevar | default(omit) }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
register: epg_present_missing_param
|
|
|
|
|
|
|
|
- name: create epg - used for query
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
epg: anstest2
|
|
|
|
|
|
|
|
- name: present assertions
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_present_check_mode is changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- epg_present_check_mode.previous == []
|
|
|
|
- epg_present_check_mode.sent.fvAEPg.attributes != {}
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_present_check_mode.sent.fvAEPg.children.0.fvRsBd.attributes.tnFvBDName == "anstest"
|
|
|
|
- epg_present is changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- epg_present.sent == epg_present_check_mode.sent
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_present_idempotent is not changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- epg_present_idempotent.sent == {}
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_present_update is changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- 'epg_present_update.sent == {"fvAEPg": {"attributes": {"descr": "Ansible Test Update"}}}'
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_present_missing_param is failed
|
2018-01-20 20:40:55 +00:00
|
|
|
- 'epg_present_missing_param.msg == "state is present but all of the following are missing: ap"'
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
- name: get specific epg
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
state: query
|
|
|
|
register: epg_query
|
|
|
|
|
|
|
|
- name: get all epgs
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
state: query
|
|
|
|
tenant: "{{ fakevar | default(omit) }}"
|
|
|
|
register: epg_query_all
|
|
|
|
|
|
|
|
- name: query assertions
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_query is not changed
|
2018-02-14 22:07:07 +00:00
|
|
|
- epg_query.current | length == 1
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_query.current.0.fvAEPg.attributes.name == "anstest"
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"tn-anstest/ap-anstest/epg-anstest.json" in epg_query.url'
|
2018-08-07 21:54:54 +00:00
|
|
|
- epg_query_all is not changed
|
2018-02-14 22:07:07 +00:00
|
|
|
- epg_query_all.current | length > 1
|
2017-11-17 15:19:13 +00:00
|
|
|
- '"rsp-subtree-class=fvRsBd" in epg_query_all.filter_string'
|
|
|
|
- '"class/fvAEPg.json" in epg_query_all.url'
|
|
|
|
|
|
|
|
- name: delete epg - check mode works
|
|
|
|
aci_epg: &aci_epg_absent
|
|
|
|
<<: *aci_epg_present
|
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: delete_epg_check_mode
|
|
|
|
|
|
|
|
- name: delete epg - delete works
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_absent
|
|
|
|
register: delete_epg
|
|
|
|
|
|
|
|
- name: delete epg - idempotency works
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_absent
|
|
|
|
register: delete_epg_idempotent
|
|
|
|
|
|
|
|
- name: delete epg - cleanup extra epg
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_absent
|
|
|
|
epg: anstest2
|
|
|
|
|
|
|
|
- name: delete epg - missing param fails
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_absent
|
|
|
|
tenant: "{{ fakevar | default(omit) }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
register: delete_epg_missing_param
|
|
|
|
|
|
|
|
- name: query assertions
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- delete_epg_check_mode is changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- delete_epg_check_mode.previous != []
|
2018-08-07 21:54:54 +00:00
|
|
|
- delete_epg is changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- delete_epg.previous == delete_epg_check_mode.previous
|
2018-08-07 21:54:54 +00:00
|
|
|
- delete_epg_idempotent is not changed
|
2018-02-02 23:41:56 +00:00
|
|
|
- delete_epg_idempotent.previous == []
|
2018-08-07 21:54:54 +00:00
|
|
|
- delete_epg_missing_param is failed
|
2018-01-20 20:40:55 +00:00
|
|
|
- 'delete_epg_missing_param.msg == "state is absent but all of the following are missing: tenant"'
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
- name: cleanup bd
|
|
|
|
aci_bd:
|
|
|
|
<<: *aci_bd_present
|
|
|
|
state: absent
|
2018-02-02 23:41:56 +00:00
|
|
|
when: bd_present.previous == []
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
- name: cleanup ap
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_present
|
|
|
|
state: absent
|
2018-02-02 23:41:56 +00:00
|
|
|
when: ap_present.previous == []
|
2017-11-17 15:19:13 +00:00
|
|
|
|
|
|
|
- name: cleanup tenant
|
|
|
|
aci_tenant:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
state: absent
|
2018-02-02 23:41:56 +00:00
|
|
|
when: tenant_present.previous == []
|