2018-02-12 22:16:35 +00:00
|
|
|
# Test code for the ACI modules
|
2018-02-21 18:35:59 +00:00
|
|
|
# Copyright: (c) 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
2018-02-12 22:16:35 +00:00
|
|
|
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
|
|
|
|
# CLEAN ENVIRONMENT
|
|
|
|
- name: Remove AEP to domain binding
|
|
|
|
aci_aep_to_domain: &binding_absent
|
|
|
|
host: '{{ aci_hostname }}'
|
|
|
|
username: '{{ aci_username }}'
|
|
|
|
password: '{{ aci_password }}'
|
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-08-06 20:42:10 +00:00
|
|
|
output_level: '{{ aci_output_level | default("info") }}'
|
2018-02-12 22:16:35 +00:00
|
|
|
aep: test_aep
|
|
|
|
domain: phys_dom
|
|
|
|
domain_type: phys
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Create AEP
|
|
|
|
aci_aep:
|
|
|
|
host: "{{ aci_hostname }}"
|
|
|
|
username: "{{ aci_username }}"
|
|
|
|
password: "{{ aci_password }}"
|
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-08-06 20:42:10 +00:00
|
|
|
output_level: '{{ aci_output_level | default("info") }}'
|
2018-02-12 22:16:35 +00:00
|
|
|
aep: test_aep
|
|
|
|
description: Test AEP
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create physical domain
|
|
|
|
aci_domain:
|
|
|
|
host: "{{ aci_hostname }}"
|
|
|
|
username: "{{ aci_username }}"
|
|
|
|
password: "{{ aci_password }}"
|
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-08-06 20:42:10 +00:00
|
|
|
output_level: '{{ aci_output_level | default("info") }}'
|
2018-02-12 22:16:35 +00:00
|
|
|
domain: phys_dom
|
|
|
|
domain_type: phys
|
|
|
|
state: present
|
|
|
|
|
|
|
|
|
|
|
|
# ADD BINDING
|
|
|
|
- name: Add AEP to domain binding (check_mode)
|
|
|
|
aci_aep_to_domain: &binding_present
|
|
|
|
host: '{{ aci_hostname }}'
|
|
|
|
username: '{{ aci_username }}'
|
|
|
|
password: '{{ aci_password }}'
|
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-08-06 20:42:10 +00:00
|
|
|
output_level: '{{ aci_output_level | default("info") }}'
|
2018-02-12 22:16:35 +00:00
|
|
|
aep: test_aep
|
|
|
|
domain: phys_dom
|
|
|
|
domain_type: phys
|
|
|
|
state: present
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_add_binding
|
|
|
|
|
|
|
|
- name: Add AEP to domain binding (normal mode)
|
|
|
|
aci_aep_to_domain: *binding_present
|
|
|
|
register: nm_add_binding
|
|
|
|
|
2018-02-14 12:51:38 +00:00
|
|
|
- name: Verify add_binding
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_add_binding is changed
|
|
|
|
- nm_add_binding is changed
|
2018-02-14 12:51:38 +00:00
|
|
|
- 'cm_add_binding.sent == nm_add_binding.sent == {"infraRsDomP": {"attributes": {"tDn": "uni/phys-phys_dom"}}}'
|
|
|
|
- 'cm_add_binding.proposed == nm_add_binding.proposed == {"infraRsDomP": {"attributes": {"tDn": "uni/phys-phys_dom"}}}'
|
|
|
|
- cm_add_binding.current == cm_add_binding.previous == nm_add_binding.previous == []
|
|
|
|
- 'nm_add_binding.current == [{"infraRsDomP": {"attributes": {"dn": "uni/infra/attentp-test_aep/rsdomP-[uni/phys-phys_dom]", "tDn": "uni/phys-phys_dom"}}}]'
|
|
|
|
|
2018-02-12 22:16:35 +00:00
|
|
|
- name: Add AEP to domain binding again (check_mode)
|
|
|
|
aci_aep_to_domain: *binding_present
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_add_binding_again
|
|
|
|
|
|
|
|
- name: Add AEP to domain binding again (normal mode)
|
|
|
|
aci_aep_to_domain: *binding_present
|
|
|
|
register: nm_add_binding_again
|
|
|
|
|
2018-02-14 12:51:38 +00:00
|
|
|
- name: Verify add_binding_again
|
2018-02-12 22:16:35 +00:00
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_add_binding_again is not changed
|
|
|
|
- nm_add_binding_again is not changed
|
2018-02-12 22:16:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# QUERY ALL BINDINGS
|
|
|
|
- name: Query all AEP to domain bindings (check_mode)
|
|
|
|
aci_aep_to_domain: &binding_query
|
|
|
|
host: '{{ aci_hostname }}'
|
|
|
|
username: '{{ aci_username }}'
|
|
|
|
password: '{{ aci_password }}'
|
|
|
|
validate_certs: '{{ aci_validate_certs | default(false) }}'
|
|
|
|
use_ssl: '{{ aci_use_ssl | default(true) }}'
|
|
|
|
use_proxy: '{{ aci_use_proxy | default(true) }}'
|
2018-08-06 20:42:10 +00:00
|
|
|
output_level: '{{ aci_output_level | default("info") }}'
|
2018-02-12 22:16:35 +00:00
|
|
|
state: query
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_query_all_bindings
|
|
|
|
|
|
|
|
- name: Query all AEP to domain bindings (normal mode)
|
|
|
|
aci_aep_to_domain: *binding_query
|
|
|
|
register: nm_query_all_bindings
|
|
|
|
|
|
|
|
- name: Verify query_all_bindings
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_query_all_bindings is not changed
|
|
|
|
- nm_query_all_bindings is not changed
|
2018-02-13 18:07:23 +00:00
|
|
|
- cm_query_all_bindings == nm_query_all_bindings
|
|
|
|
- nm_query_all_bindings.current|length >= 1
|
2018-02-12 22:16:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# QUERY A BINDING
|
|
|
|
- name: Query our AEP to domain binding (check_mode)
|
|
|
|
aci_aep_to_domain:
|
|
|
|
<<: *binding_query
|
|
|
|
aep: test_aep
|
|
|
|
domain: phys_dom
|
2018-02-13 18:07:23 +00:00
|
|
|
domain_type: phys
|
2018-02-12 22:16:35 +00:00
|
|
|
check_mode: yes
|
|
|
|
register: cm_query_binding
|
|
|
|
|
|
|
|
- name: Query our AEP to domain binding (normal mode)
|
|
|
|
aci_aep_to_domain:
|
|
|
|
<<: *binding_query
|
2018-02-13 18:07:23 +00:00
|
|
|
aep: test_aep
|
2018-02-12 22:16:35 +00:00
|
|
|
domain: phys_dom
|
2018-02-13 18:07:23 +00:00
|
|
|
domain_type: phys
|
2018-02-12 22:16:35 +00:00
|
|
|
register: nm_query_binding
|
|
|
|
|
|
|
|
- name: Verify query_binding
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_query_binding is not changed
|
|
|
|
- nm_query_binding is not changed
|
2018-02-12 22:16:35 +00:00
|
|
|
- cm_query_binding == nm_query_binding
|
|
|
|
- nm_query_binding.current.0.infraRsDomP.attributes.dn == 'uni/infra/attentp-test_aep/rsdomP-[uni/phys-phys_dom]'
|
2018-02-13 18:07:23 +00:00
|
|
|
- nm_query_binding.current.0.infraRsDomP.attributes.tCl == 'physDomP'
|
2018-02-12 22:16:35 +00:00
|
|
|
- nm_query_binding.current.0.infraRsDomP.attributes.tDn == 'uni/phys-phys_dom'
|
|
|
|
|
|
|
|
|
|
|
|
# REMOVE BINDING
|
|
|
|
- name: Remove AEP to domain binding (check_mode)
|
|
|
|
aci_aep_to_domain: *binding_absent
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_remove_binding
|
|
|
|
|
|
|
|
- name: Remove AEP to domain binding (normal mode)
|
|
|
|
aci_aep_to_domain: *binding_absent
|
|
|
|
register: nm_remove_binding
|
|
|
|
|
2018-02-14 12:51:38 +00:00
|
|
|
- name: Verify remove_binding
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_remove_binding is changed
|
|
|
|
- nm_remove_binding is changed
|
2018-02-14 12:51:38 +00:00
|
|
|
- 'cm_remove_binding.current == cm_remove_binding.previous == nm_remove_binding.previous == [{"infraRsDomP": {"attributes": {"dn": "uni/infra/attentp-test_aep/rsdomP-[uni/phys-phys_dom]", "tDn": "uni/phys-phys_dom"}}}]'
|
|
|
|
- nm_remove_binding.current == []
|
|
|
|
|
2018-02-12 22:16:35 +00:00
|
|
|
- name: Remove AEP to domain binding again (check_mode)
|
|
|
|
aci_aep_to_domain: *binding_absent
|
|
|
|
check_mode: yes
|
|
|
|
register: cm_remove_binding_again
|
|
|
|
|
|
|
|
- name: Remove AEP to domain binding again (normal mode)
|
|
|
|
aci_aep_to_domain: *binding_absent
|
|
|
|
register: nm_remove_binding_again
|
|
|
|
|
2018-02-14 12:51:38 +00:00
|
|
|
- name: Verify remove_binding_again
|
2018-02-12 22:16:35 +00:00
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_remove_binding_again is not changed
|
|
|
|
- nm_remove_binding_again is not changed
|
2018-02-12 22:16:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
# QUERY NON-EXISTING BINDING
|
|
|
|
- name: Query non-existing AEP to domain binding (check_mode)
|
2018-02-13 18:07:23 +00:00
|
|
|
aci_aep_to_domain:
|
|
|
|
<<: *binding_query
|
|
|
|
aep: test_aep
|
|
|
|
domain: phys_dom
|
|
|
|
domain_type: phys
|
2018-02-12 22:16:35 +00:00
|
|
|
check_mode: yes
|
|
|
|
register: cm_query_non_binding
|
|
|
|
|
|
|
|
- name: Query non-existing AEP to domain binding (normal mode)
|
2018-02-13 18:07:23 +00:00
|
|
|
aci_aep_to_domain:
|
|
|
|
<<: *binding_query
|
|
|
|
aep: test_aep
|
|
|
|
domain: phys_dom
|
|
|
|
domain_type: phys
|
2018-02-12 22:16:35 +00:00
|
|
|
register: nm_query_non_binding
|
|
|
|
|
|
|
|
- name: Verify query_non_binding
|
|
|
|
assert:
|
|
|
|
that:
|
2018-08-07 21:54:54 +00:00
|
|
|
- cm_query_non_binding is not changed
|
|
|
|
- nm_query_non_binding is not changed
|
2018-02-12 22:16:35 +00:00
|
|
|
- cm_query_non_binding == nm_query_non_binding
|
|
|
|
- nm_query_non_binding.current == []
|