ACI: Fixes to domain parameters dependencies (#36158)

We identified an incompleteness to parameter dependencies that affects
querying all domain-related objects.

This PR also includes:
- Improvements to integration tests
- Add missing vm_provider types
- Fix examples

This relates to #36131
This commit is contained in:
Dag Wieers 2018-02-14 13:51:38 +01:00 committed by GitHub
commit da5cf72236
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 213 additions and 110 deletions

View file

@ -194,7 +194,7 @@ def main():
['state', 'present', ['aep', 'domain', 'domain_type']],
],
required_together=[
['domain', 'domain_type']
['domain', 'domain_type'],
],
)

View file

@ -260,7 +260,7 @@ def main():
'CS0', 'CS1', 'CS2', 'CS3', 'CS4', 'CS5', 'CS6', 'CS7', 'EF', 'VA', 'unspecified'],
aliases=['target']),
domain=dict(type='str', aliases=['domain_name', 'domain_profile', 'name']),
domain_type=dict(type='str', choices=['fc', 'l2dom', 'l3dom', 'phys', 'vmm'], aliases=['type']),
domain_type=dict(type='str', required=True, choices=['fc', 'l2dom', 'l3dom', 'phys', 'vmm'], aliases=['type']),
encap_mode=dict(type='str', choices=['unknown', 'vlan', 'vxlan']),
multicast_address=dict(type='str'),
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
@ -291,13 +291,13 @@ def main():
if domain_type != 'vmm':
if vm_provider is not None:
module.fail_json(msg="Domain type '{0}' cannot have a 'vm_provider'".format(domain_type))
module.fail_json(msg="Domain type '{0}' cannot have parameter 'vm_provider'".format(domain_type))
if encap_mode is not None:
module.fail_json(msg="Domain type '{0}' cannot have an 'encap_mode'".format(domain_type))
module.fail_json(msg="Domain type '{0}' cannot have parameter 'encap_mode'".format(domain_type))
if multicast_address is not None:
module.fail_json(msg="Domain type '{0}' cannot have a 'multicast_address'".format(domain_type))
module.fail_json(msg="Domain type '{0}' cannot have parameter 'multicast_address'".format(domain_type))
if vswitch is not None:
module.fail_json(msg="Domain type '{0}' cannot have a 'vswitch'".format(domain_type))
module.fail_json(msg="Domain type '{0}' cannot have parameter 'vswitch'".format(domain_type))
if dscp is not None and domain_type not in ['l2dom', 'l3dom']:
module.fail_json(msg="DSCP values can only be assigned to 'l2ext and 'l3ext' domains")
@ -324,6 +324,10 @@ def main():
domain_mo = 'uni/vmmp-{0}/dom-{1}'.format(VM_PROVIDER_MAPPING[vm_provider], domain)
domain_rn = 'vmmp-{0}/dom-{1}'.format(VM_PROVIDER_MAPPING[vm_provider], domain)
# Ensure that querying all objects works when only domain_type is provided
if domain is None:
domain_mo = None
aci = ACIModule(module)
aci.construct_url(
root_class=dict(

View file

@ -186,13 +186,13 @@ VM_PROVIDER_MAPPING = dict(
POOL_MAPPING = dict(
vlan=dict(
aci_mo='uni/infra/vlanns-',
aci_mo='uni/infra/vlanns-{0}',
),
vxlan=dict(
aci_mo='uni/infra/vxlanns-',
aci_mo='uni/infra/vxlanns-{0}',
),
vsan=dict(
aci_mo='uni/infra/vsanns-',
aci_mo='uni/infra/vsanns-{0}',
),
)
@ -265,7 +265,11 @@ def main():
domain_mo = 'uni/vmmp-{0}/dom-{1}'.format(VM_PROVIDER_MAPPING[vm_provider], domain)
domain_rn = 'vmmp-{0}/dom-{1}'.format(VM_PROVIDER_MAPPING[vm_provider], domain)
pool_mo = POOL_MAPPING[pool_type]["aci_mo"] + pool_name
# Ensure that querying all objects works when only domain_type is provided
if domain is None:
domain_mo = None
pool_mo = POOL_MAPPING[pool_type]["aci_mo"].format(pool_name)
aci = ACIModule(module)
aci.construct_url(

View file

@ -122,6 +122,7 @@ EXAMPLES = r'''
host: apic
username: admin
password: SomeSecretPassword
domain_type: phys
state: query
'''
@ -234,7 +235,10 @@ from ansible.module_utils.network.aci.aci import ACIModule, aci_argument_spec
from ansible.module_utils.basic import AnsibleModule
VM_PROVIDER_MAPPING = dict(
cloudfoundry='CloudFoundry',
kubernetes='Kubernetes',
microsoft='Microsoft',
openshift='OpenShift',
openstack='OpenStack',
redhat='Redhat',
vmware='VMware',
@ -245,7 +249,7 @@ def main():
argument_spec = aci_argument_spec()
argument_spec.update(
domain=dict(type='str', aliases=['domain_name', 'domain_profile']),
domain_type=dict(type='str', choices=['fc', 'l2dom', 'l3dom', 'phys', 'vmm']),
domain_type=dict(type='str', required=True, choices=['fc', 'l2dom', 'l3dom', 'phys', 'vmm']),
pool=dict(type='str', aliases=['pool_name', 'vlan_pool']),
pool_allocation_mode=dict(type='str', required=True, aliases=['allocation_mode', 'mode'], choices=['dynamic', 'static']),
state=dict(type='str', default='present', choices=['absent', 'present', 'query']),
@ -300,7 +304,11 @@ def main():
domain_mo = 'uni/vmmp-{0}/dom-{1}'.format(VM_PROVIDER_MAPPING[vm_provider], domain)
domain_rn = 'dom-{0}'.format(domain)
aci_mo = 'uni/infra/vlanns-' + pool_name
# Ensure that querying all objects works when only domain_type is provided
if domain is None:
domain_mo = None
aci_mo = 'uni/infra/vlanns-{0}'.format(pool_name)
aci = ACIModule(module)
aci.construct_url(