aci_domain_to_vlan_pool: Add missing integration tests (#36079)
This commit is contained in:
parent
98a3059f7b
commit
9f028e9dea
3 changed files with 201 additions and 8 deletions
|
@ -25,10 +25,10 @@ author:
|
|||
- Dag Wieers (@dagwieers)
|
||||
version_added: '2.5'
|
||||
options:
|
||||
allocation_mode:
|
||||
pool_allocation_mode:
|
||||
description:
|
||||
- The method used for allocating VLANs to resources.
|
||||
aliases: [ mode ]
|
||||
aliases: [ allocation_mode, mode ]
|
||||
choices: [ dynamic, static]
|
||||
description:
|
||||
description:
|
||||
|
@ -54,6 +54,7 @@ EXAMPLES = r'''
|
|||
username: admin
|
||||
password: SomeSecretPassword
|
||||
pool: production
|
||||
pool_allocation_mode: dynamic
|
||||
description: Production VLANs
|
||||
state: present
|
||||
|
||||
|
@ -63,6 +64,7 @@ EXAMPLES = r'''
|
|||
username: admin
|
||||
password: SomeSecretPassword
|
||||
pool: production
|
||||
pool_allocation_mode: dynamic
|
||||
state: absent
|
||||
|
||||
- name: Query a VLAN pool
|
||||
|
@ -71,6 +73,7 @@ EXAMPLES = r'''
|
|||
username: admin
|
||||
password: SomeSecretPassword
|
||||
pool: production
|
||||
pool_allocation_mode: dynamic
|
||||
state: query
|
||||
|
||||
- name: Query all VLAN pools
|
||||
|
@ -193,9 +196,9 @@ from ansible.module_utils.basic import AnsibleModule
|
|||
def main():
|
||||
argument_spec = aci_argument_spec()
|
||||
argument_spec.update(
|
||||
allocation_mode=dict(type='str', aliases=['mode'], choices=['dynamic', 'static']),
|
||||
description=dict(type='str', aliases=['descr']),
|
||||
pool=dict(type='str', aliases=['name', 'pool_name']),
|
||||
pool_allocation_mode=dict(type='str', aliases=['allocation_mode', 'mode'], choices=['dynamic', 'static']),
|
||||
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
|
||||
)
|
||||
|
||||
|
@ -208,19 +211,19 @@ def main():
|
|||
],
|
||||
)
|
||||
|
||||
allocation_mode = module.params['allocation_mode']
|
||||
description = module.params['description']
|
||||
pool = module.params['pool']
|
||||
pool_allocation_mode = module.params['pool_allocation_mode']
|
||||
state = module.params['state']
|
||||
|
||||
pool_name = pool
|
||||
|
||||
# ACI Pool URL requires the allocation mode for vlan and vsan pools (ex: uni/infra/vlanns-[poolname]-static)
|
||||
if pool is not None:
|
||||
if allocation_mode is not None:
|
||||
pool_name = '[{0}]-{1}'.format(pool, allocation_mode)
|
||||
if pool_allocation_mode is not None:
|
||||
pool_name = '[{0}]-{1}'.format(pool, pool_allocation_mode)
|
||||
else:
|
||||
module.fail_json(msg="ACI requires the 'allocation_mode' when 'pool' is provided")
|
||||
module.fail_json(msg="ACI requires the 'pool_allocation_mode' when 'pool' is provided")
|
||||
|
||||
aci = ACIModule(module)
|
||||
aci.construct_url(
|
||||
|
@ -239,7 +242,7 @@ def main():
|
|||
aci.payload(
|
||||
aci_class='fvnsVlanInstP',
|
||||
class_config=dict(
|
||||
allocMode=allocation_mode,
|
||||
allocMode=pool_allocation_mode,
|
||||
descr=description,
|
||||
name=pool,
|
||||
)
|
||||
|
|
0
test/integration/targets/aci_domain_to_vlan_pool/aliases
Normal file
0
test/integration/targets/aci_domain_to_vlan_pool/aliases
Normal file
190
test/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml
Normal file
190
test/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml
Normal file
|
@ -0,0 +1,190 @@
|
|||
# Test code for the ACI modules
|
||||
# Copyright 2018, Dag Wieers (@dagwieers) <dag@wieers.com>
|
||||
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
||||
# CLEAN ENVIRONMENT
|
||||
- name: Remove domain to VLAN pool binding
|
||||
aci_domain_to_vlan_pool: &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) }}'
|
||||
output_level: info
|
||||
domain: phys_dom
|
||||
domain_type: phys
|
||||
pool: test_pool
|
||||
pool_allocation_mode: dynamic
|
||||
state: absent
|
||||
|
||||
- name: Remove 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) }}'
|
||||
domain: phys_dom
|
||||
domain_type: phys
|
||||
state: absent
|
||||
|
||||
- name: Create VLAN pool
|
||||
aci_vlan_pool:
|
||||
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) }}'
|
||||
pool: test_pool
|
||||
pool_allocation_mode: dynamic
|
||||
description: Test VLAN pool
|
||||
state: present
|
||||
|
||||
|
||||
# ADD BINDING
|
||||
- name: Add domain to VLAN pool binding (check_mode)
|
||||
aci_domain_to_vlan_pool: &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) }}'
|
||||
output_level: info
|
||||
domain: phys_dom
|
||||
domain_type: phys
|
||||
pool: test_pool
|
||||
pool_allocation_mode: dynamic
|
||||
state: present
|
||||
check_mode: yes
|
||||
register: cm_add_binding
|
||||
|
||||
- name: Add domain to VLAN pool binding (normal mode)
|
||||
aci_domain_to_vlan_pool: *binding_present
|
||||
register: nm_add_binding
|
||||
|
||||
- name: Add domain to VLAN pool binding again (check_mode)
|
||||
aci_domain_to_vlan_pool: *binding_present
|
||||
check_mode: yes
|
||||
register: cm_add_binding_again
|
||||
|
||||
- name: Add domain to VLAN pool binding again (normal mode)
|
||||
aci_domain_to_vlan_pool: *binding_present
|
||||
register: nm_add_binding_again
|
||||
|
||||
- name: Verify add_binding
|
||||
assert:
|
||||
that:
|
||||
- cm_add_binding.changed == nm_add_binding.changed == true
|
||||
- cm_add_binding_again.changed == nm_add_binding_again.changed == false
|
||||
- 'cm_add_binding.sent == nm_add_binding.sent == {"physDomP": {"attributes": {"name": "phys_dom"}, "children": [{"infraRsVlanNs": {"attributes": {"tDn": "uni/infra/vlanns-[test_pool]-dynamic"}}}]}}'
|
||||
- 'cm_add_binding.proposed == nm_add_binding.proposed == {"physDomP": {"attributes": {"name": "phys_dom"}, "children": [{"infraRsVlanNs": {"attributes": {"tDn": "uni/infra/vlanns-[test_pool]-dynamic"}}}]}}'
|
||||
- cm_add_binding.current == cm_add_binding.previous == nm_add_binding.previous == []
|
||||
- 'nm_add_binding.current == [{"physDomP": {"attributes": {"dn": "uni/phys-phys_dom", "name": "phys_dom", "nameAlias": "", "ownerKey": "", "ownerTag": ""}, "children": [{"infraRsVlanNs": {"attributes": {"tDn": "uni/infra/vlanns-[test_pool]-dynamic"}}}]}}]'
|
||||
|
||||
|
||||
# QUERY ALL BINDINGS
|
||||
- name: Query all domain to VLAN pool bindings (check_mode)
|
||||
aci_domain_to_vlan_pool: &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) }}'
|
||||
output_level: info
|
||||
domain_type: phys
|
||||
pool: test_pool
|
||||
pool_allocation_mode: dynamic
|
||||
state: query
|
||||
check_mode: yes
|
||||
register: cm_query_all_bindings
|
||||
|
||||
- name: Query all domain to VLAN pool bindings (normal mode)
|
||||
aci_domain_to_vlan_pool: *binding_query
|
||||
register: nm_query_all_bindings
|
||||
|
||||
- name: Verify query_all_bindings
|
||||
assert:
|
||||
that:
|
||||
- cm_query_all_bindings.changed == nm_query_all_bindings.changed == false
|
||||
# NOTE: Order of bindings is not stable between calls
|
||||
#- cm_query_all_bindings == nm_query_all_bindings
|
||||
|
||||
|
||||
# QUERY A BINDING
|
||||
- name: Query our domain to VLAN pool binding (check_mode)
|
||||
aci_domain_to_vlan_pool:
|
||||
<<: *binding_query
|
||||
domain: phys_dom
|
||||
pool: test_pool
|
||||
pool_allocation_mode: dynamic
|
||||
check_mode: yes
|
||||
register: cm_query_binding
|
||||
|
||||
- name: Query our domain to VLAN pool binding (normal mode)
|
||||
aci_domain_to_vlan_pool:
|
||||
<<: *binding_query
|
||||
domain: phys_dom
|
||||
register: nm_query_binding
|
||||
|
||||
- name: Verify query_binding
|
||||
assert:
|
||||
that:
|
||||
- cm_query_binding.changed == nm_query_binding.changed == false
|
||||
- cm_query_binding == nm_query_binding
|
||||
- nm_query_binding.current.0.physDomP.attributes.dn == 'uni/phys-phys_dom'
|
||||
- nm_query_binding.current.0.physDomP.attributes.name == 'phys_dom'
|
||||
- nm_query_binding.current.0.physDomP.children.0.infraRsVlanNs.attributes.tCl == 'fvnsVlanInstP'
|
||||
- nm_query_binding.current.0.physDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
|
||||
|
||||
|
||||
# REMOVE BINDING
|
||||
- name: Remove domain to VLAN pool binding (check_mode)
|
||||
aci_domain_to_vlan_pool: *binding_absent
|
||||
check_mode: yes
|
||||
register: cm_remove_binding
|
||||
|
||||
- name: Remove domain to VLAN pool binding (normal mode)
|
||||
aci_domain_to_vlan_pool: *binding_absent
|
||||
register: nm_remove_binding
|
||||
|
||||
- name: Remove domain to VLAN pool binding again (check_mode)
|
||||
aci_domain_to_vlan_pool: *binding_absent
|
||||
check_mode: yes
|
||||
register: cm_remove_binding_again
|
||||
|
||||
- name: Remove domain to VLAN pool binding again (normal mode)
|
||||
aci_domain_to_vlan_pool: *binding_absent
|
||||
register: nm_remove_binding_again
|
||||
|
||||
- name: Verify remove_binding
|
||||
assert:
|
||||
that:
|
||||
- cm_remove_binding.changed == nm_remove_binding.changed == true
|
||||
- cm_remove_binding_again.changed == nm_remove_binding_again.changed == false
|
||||
- 'cm_remove_binding.current == cm_remove_binding.previous == nm_remove_binding.previous == [{"physDomP": {"attributes": {"dn": "uni/phys-phys_dom", "name": "phys_dom", "nameAlias": "", "ownerKey": "", "ownerTag": ""}, "children": [{"infraRsVlanNs": {"attributes": {"tDn": "uni/infra/vlanns-[test_pool]-dynamic"}}}]}}]'
|
||||
- nm_remove_binding.current == []
|
||||
|
||||
|
||||
# QUERY NON-EXISTING BINDING
|
||||
- name: Query non-existing domain to VLAN pool binding (check_mode)
|
||||
aci_domain_to_vlan_pool: *binding_query
|
||||
check_mode: yes
|
||||
register: cm_query_non_binding
|
||||
|
||||
- name: Query non-existing domain to VLAN pool binding (normal mode)
|
||||
aci_domain_to_vlan_pool: *binding_query
|
||||
register: nm_query_non_binding
|
||||
|
||||
- name: Verify query_non_binding
|
||||
assert:
|
||||
that:
|
||||
- cm_query_non_binding.changed == nm_query_non_binding.changed == false
|
||||
- cm_query_non_binding == nm_query_non_binding
|
||||
- nm_query_non_binding.current == []
|
Loading…
Reference in a new issue