2017-11-17 16:19:13 +01:00
|
|
|
# Test code for the ACI modules
|
2018-02-21 19:35:59 +01:00
|
|
|
# Copyright: (c) 2017, Dag Wieers (@dagwieers) <dag@wieers.com>
|
2017-11-17 16:19:13 +01: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-21 00:38:20 +01:00
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-02-03 00:41:56 +01:00
|
|
|
output_level: debug
|
2017-11-17 16:19:13 +01:00
|
|
|
tenant: anstest
|
2018-08-06 22:42:10 +02:00
|
|
|
state: present
|
2017-11-17 16:19:13 +01:00
|
|
|
register: tenant_present
|
|
|
|
|
|
|
|
- name: ensure ap exists for tests to kick off
|
|
|
|
aci_ap: &aci_ap_present
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
ap: anstest
|
|
|
|
register: ap_present
|
|
|
|
|
|
|
|
- name: ensure epg exists for tests to kick off
|
|
|
|
aci_epg: &aci_epg_present
|
|
|
|
<<: *aci_ap_present
|
|
|
|
epg: anstest
|
|
|
|
register: epg_present
|
|
|
|
|
|
|
|
- name: ensure phys domain exists for tests to kick off
|
|
|
|
aci_rest: &aci_rest_phys_domain
|
2018-01-22 22:06:56 +01:00
|
|
|
host: "{{ aci_hostname }}"
|
2017-11-17 16:19:13 +01:00
|
|
|
username: "{{ aci_username }}"
|
|
|
|
password: "{{ aci_password }}"
|
2018-01-21 00:38:20 +01:00
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-08-06 22:42:10 +02:00
|
|
|
output_level: '{{ aci_output_level | default("info") }}'
|
2017-11-17 16:19:13 +01:00
|
|
|
method: post
|
|
|
|
path: api/mo/uni/phys-anstest.json
|
|
|
|
content: {"physDomP": {"attributes": {}}}
|
|
|
|
register: phys_domain_post
|
|
|
|
|
|
|
|
- name: ensure vmm domain exists for tests to kick off
|
|
|
|
aci_rest: &aci_rest_vmm_domain
|
|
|
|
<<: *aci_rest_phys_domain
|
|
|
|
path: api/mo/uni/vmmp-VMware/dom-anstest.json
|
|
|
|
content: {"vmmDomP": {"attributes": {}}}
|
|
|
|
register: vmm_domain_post
|
|
|
|
|
|
|
|
- name: bind phys domain to epg - check mode works
|
|
|
|
aci_epg_to_domain: &aci_epg_to_domain_present
|
|
|
|
<<: *aci_epg_present
|
|
|
|
domain: anstest
|
|
|
|
domain_type: phys
|
|
|
|
check_mode: yes
|
|
|
|
register: phys_check_mode_present
|
|
|
|
|
|
|
|
- name: bind phys domain to epg - creation works
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
register: phys_present
|
|
|
|
|
|
|
|
- name: bind phys domain to epg - idempotency works
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
register: phys_idempotent
|
|
|
|
|
|
|
|
- name: bind phys domain to epg - update works
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
deploy_immediacy: immediate
|
|
|
|
register: phys_update
|
|
|
|
|
|
|
|
- name: bind vmm domain to epg - creation works
|
|
|
|
aci_epg_to_domain: &aci_epg_to_domain_vmm_present
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
domain_type: vmm
|
|
|
|
vm_provider: vmware
|
|
|
|
resolution_immediacy: pre-provision
|
|
|
|
register: vmm_present
|
|
|
|
|
|
|
|
- name: bind vmm domain to epg - missing params
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_vmm_present
|
|
|
|
vm_provider: "{{ fake_var | default(omit) }}"
|
|
|
|
ignore_errors: yes
|
|
|
|
register: present_missing_params
|
|
|
|
|
|
|
|
- name: bind vmm domain to epg - invalid vlan
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
encap: 4097
|
|
|
|
ignore_errors: yes
|
|
|
|
register: invalid_vlan
|
|
|
|
|
|
|
|
- name: bind vmm domain to epg - incompatible params
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
vm_provider: vmware
|
|
|
|
ignore_errors: yes
|
|
|
|
register: incompatible_params
|
|
|
|
|
|
|
|
- name: present assertions
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 23:54:54 +02:00
|
|
|
- phys_check_mode_present is changed
|
|
|
|
- phys_present is changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- phys_present.previous == []
|
|
|
|
- 'phys_present.sent == {"fvRsDomAtt": {"attributes": {}}}'
|
2017-11-17 16:19:13 +01:00
|
|
|
- '"[uni/phys-anstest].json" in phys_present.url'
|
2018-08-07 23:54:54 +02:00
|
|
|
- phys_idempotent is not changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- phys_idempotent.sent == {}
|
2018-08-07 23:54:54 +02:00
|
|
|
- phys_update is changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- 'phys_update.sent == {"fvRsDomAtt": {"attributes": {"instrImedcy": "immediate"}}}'
|
2018-08-07 23:54:54 +02:00
|
|
|
- vmm_present is changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- 'vmm_present.sent == {"fvRsDomAtt": {"attributes": {"resImedcy": "pre-provision"}}}'
|
2017-11-17 16:19:13 +01:00
|
|
|
- '"[uni/vmmp-VMware/dom-anstest].json" in vmm_present.url'
|
2018-08-07 23:54:54 +02:00
|
|
|
- present_missing_params is failed
|
2018-01-20 21:40:55 +01:00
|
|
|
- 'present_missing_params.msg == "domain_type is vmm but all of the following are missing: vm_provider"'
|
2018-08-07 23:54:54 +02:00
|
|
|
- invalid_vlan is failed
|
|
|
|
- invalid_vlan.msg == "Valid VLAN assigments are from 1 to 4096"
|
|
|
|
- incompatible_params is failed
|
2017-11-17 16:19:13 +01:00
|
|
|
- incompatible_params.msg == "Domain type 'phys' cannot have a 'vm_provider'"
|
|
|
|
|
|
|
|
- name: get domain epg binding
|
|
|
|
aci_epg_to_domain: &aci_epg_domain_query
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
state: query
|
|
|
|
tenant: "{{ fake_var | default(omit) }}"
|
|
|
|
register: binding_query
|
|
|
|
|
|
|
|
- name: query assertions
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 23:54:54 +02:00
|
|
|
- binding_query is not changed
|
2018-02-14 23:07:07 +01:00
|
|
|
- binding_query.current | length > 1
|
2017-11-17 16:19:13 +01:00
|
|
|
- '"class/fvRsDomAtt.json" in binding_query.url'
|
|
|
|
|
|
|
|
- name: delete domain epg binding - check mode
|
|
|
|
aci_epg_to_domain: &aci_epg_to_domain_absent
|
|
|
|
<<: *aci_epg_to_domain_present
|
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: epg_domain_check_mode_absent
|
|
|
|
|
|
|
|
- name: delete phys domain epg binding - delete works
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_absent
|
|
|
|
register: epg_domain_absent
|
|
|
|
|
|
|
|
- name: delete vmm domain epg binding - delete works
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_vmm_present
|
|
|
|
state: absent
|
|
|
|
register: epg_vmm_domain_absent
|
|
|
|
|
|
|
|
- name: delete domain epg binding - idempotency works
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_epg_to_domain_absent
|
|
|
|
register: idempotency_absent
|
|
|
|
|
|
|
|
- name: delete domain epg binding - missing param
|
|
|
|
aci_epg_to_domain:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
state: absent
|
|
|
|
ignore_errors: true
|
|
|
|
register: absent_missing_param
|
|
|
|
|
|
|
|
- name: absent assertions
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 23:54:54 +02:00
|
|
|
- epg_domain_check_mode_absent is changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- epg_domain_check_mode_absent.previous != []
|
2018-08-07 23:54:54 +02:00
|
|
|
- epg_domain_absent is changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- epg_domain_absent.previous == epg_domain_check_mode_absent.previous
|
2018-08-07 23:54:54 +02:00
|
|
|
- epg_vmm_domain_absent is changed
|
|
|
|
- idempotency_absent is not changed
|
2018-02-03 00:41:56 +01:00
|
|
|
- idempotency_absent.previous == []
|
2018-08-07 23:54:54 +02:00
|
|
|
- absent_missing_param is failed
|
2018-01-20 21:40:55 +01:00
|
|
|
- 'absent_missing_param.msg == "state is absent but all of the following are missing: ap, domain, domain_type, epg"'
|
2017-11-17 16:19:13 +01:00
|
|
|
|
|
|
|
- name: remove vmm domain - cleanup
|
|
|
|
aci_rest:
|
|
|
|
<<: *aci_rest_vmm_domain
|
|
|
|
method: delete
|
2018-08-07 23:54:54 +02:00
|
|
|
when: vmm_domain_post is changed
|
2017-11-17 16:19:13 +01:00
|
|
|
|
|
|
|
- name: remove phys domain - cleanup
|
|
|
|
aci_rest:
|
|
|
|
<<: *aci_rest_phys_domain
|
|
|
|
method: delete
|
2018-08-07 23:54:54 +02:00
|
|
|
when: phys_domain_post is changed
|
2017-11-17 16:19:13 +01:00
|
|
|
|
|
|
|
- name: remove epg - cleanup
|
|
|
|
aci_epg:
|
|
|
|
<<: *aci_epg_present
|
|
|
|
state: absent
|
2018-08-07 23:54:54 +02:00
|
|
|
when: epg_present is changed
|
2017-11-17 16:19:13 +01:00
|
|
|
|
|
|
|
- name: remove ap - cleanup
|
|
|
|
aci_ap:
|
|
|
|
<<: *aci_ap_present
|
|
|
|
state: absent
|
2018-08-07 23:54:54 +02:00
|
|
|
when: ap_present is changed
|
2017-11-17 16:19:13 +01:00
|
|
|
|
|
|
|
- name: remove tenant - cleanup
|
|
|
|
aci_tenant:
|
|
|
|
<<: *aci_tenant_present
|
|
|
|
state: absent
|
2018-08-07 23:54:54 +02:00
|
|
|
when: tenant_present is changed
|