Skip to content

Commit 2fdee82

Browse files
authored
[bugfix]: Add subclass to aci_domain_to_vlan_pool to fix deletion of binding (#695)
1 parent aa8b24c commit 2fdee82

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

plugins/modules/aci_domain_to_vlan_pool.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -330,21 +330,23 @@ def main():
330330
module_object=domain_mo,
331331
target_filter={"name": domain},
332332
),
333-
child_classes=["infraRsVlanNs"],
333+
subclass_1=dict(
334+
aci_class="infraRsVlanNs",
335+
aci_rn="rsvlanNs",
336+
module_object=aci_mo if pool_name else None,
337+
target_filter={"tDn": aci_mo} if pool_name else {},
338+
),
334339
)
335340

336341
aci.get_existing()
337342

338343
if state == "present":
339344
aci.payload(
340-
aci_class=domain_class,
341-
class_config=dict(name=domain),
342-
child_configs=[
343-
{"infraRsVlanNs": {"attributes": {"tDn": aci_mo}}},
344-
],
345+
aci_class="infraRsVlanNs",
346+
class_config=dict(tDn=aci_mo),
345347
)
346348

347-
aci.get_diff(aci_class=domain_class)
349+
aci.get_diff(aci_class="infraRsVlanNs")
348350

349351
aci.post_config()
350352

tests/integration/targets/aci_domain_to_vlan_pool/tasks/main.yml

+36-23
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@
6363
description: Test VLAN pool
6464
state: present
6565

66+
- name: Create domains
67+
cisco.aci.aci_domain:
68+
<<: *aci_info
69+
domain: "{{ item.domain }}"
70+
domain_type: "{{ item.domain_type }}"
71+
state: present
72+
loop:
73+
- {domain: phys_dom, domain_type: phys}
74+
- {domain: fc_dom, domain_type: fc}
75+
- {domain: l2dom_dom, domain_type: l2dom}
76+
- {domain: l3dom_dom, domain_type: l3dom}
77+
78+
- name: Add VMM domain
79+
cisco.aci.aci_domain:
80+
<<: *aci_info
81+
domain: anstest
82+
domain_type: vmm
83+
vm_provider: vmware
84+
state: present
6685

6786
# ADD BINDING
6887
- name: Add domain to VLAN pool binding (check_mode)
@@ -85,15 +104,11 @@
85104
that:
86105
- cm_add_binding is changed
87106
- nm_add_binding is changed
88-
- cm_add_binding.sent.physDomP.attributes.name == nm_add_binding.sent.physDomP.attributes.name == 'phys_dom'
89-
- cm_add_binding.sent.physDomP.children.0.infraRsVlanNs.attributes.tDn == nm_add_binding.sent.physDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
90-
- cm_add_binding.proposed.physDomP.attributes.name == nm_add_binding.proposed.physDomP.attributes.name == 'phys_dom'
91-
- cm_add_binding.proposed.physDomP.children.0.infraRsVlanNs.attributes.tDn == nm_add_binding.proposed.physDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
107+
- cm_add_binding.proposed.infraRsVlanNs.attributes.tDn == nm_add_binding.proposed.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
92108
- cm_add_binding.current == cm_add_binding.previous == nm_add_binding.previous == []
93-
- nm_add_binding.current.0.physDomP.attributes.annotation == 'orchestrator:ansible'
94-
- nm_add_binding.current.0.physDomP.attributes.name == 'phys_dom'
95-
- nm_add_binding.current.0.physDomP.attributes.dn == 'uni/phys-phys_dom'
96-
- nm_add_binding.current.0.physDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
109+
- nm_add_binding.current.0.infraRsVlanNs.attributes.annotation == 'orchestrator:ansible'
110+
- nm_add_binding.current.0.infraRsVlanNs.attributes.dn == 'uni/phys-phys_dom/rsvlanNs'
111+
- nm_add_binding.current.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
97112

98113
- name: Add domain to VLAN pool binding again (check_mode)
99114
cisco.aci.aci_domain_to_vlan_pool: *binding_present
@@ -155,17 +170,17 @@
155170
- err_not_vmm_with_vm_provider is not changed
156171
- err_not_vmm_with_vm_provider.msg == "Domain type 'phys' cannot have a 'vm_provider'"
157172
- nm_fc_type is changed
158-
- nm_fc_type.current.0.fcDomP.attributes.dn == "uni/fc-fc_dom"
159-
- nm_fc_type.current.0.fcDomP.children.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-static"
173+
- nm_fc_type.current.0.infraRsVlanNs.attributes.dn == "uni/fc-fc_dom/rsvlanNs"
174+
- nm_fc_type.current.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-static"
160175
- nm_l2dom_type is changed
161-
- nm_l2dom_type.current.0.l2extDomP.attributes.dn == "uni/l2dom-l2dom_dom"
162-
- nm_l2dom_type.current.0.l2extDomP.children.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-dynamic"
176+
- nm_l2dom_type.current.0.infraRsVlanNs.attributes.dn == "uni/l2dom-l2dom_dom/rsvlanNs"
177+
- nm_l2dom_type.current.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-dynamic"
163178
- nm_l3dom_type is changed
164-
- nm_l3dom_type.current.0.l3extDomP.attributes.dn == "uni/l3dom-l3dom_dom"
165-
- nm_l3dom_type.current.0.l3extDomP.children.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-dynamic"
179+
- nm_l3dom_type.current.0.infraRsVlanNs.attributes.dn == "uni/l3dom-l3dom_dom/rsvlanNs"
180+
- nm_l3dom_type.current.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-dynamic"
166181
- nm_vmm_type is changed
167-
- nm_vmm_type.current.0.vmmDomP.attributes.dn == "uni/vmmp-VMware/dom-anstest"
168-
- nm_vmm_type.current.0.vmmDomP.children.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-dynamic"
182+
- nm_vmm_type.current.0.infraRsVlanNs.attributes.dn == "uni/vmmp-VMware/dom-anstest/rsvlanNs"
183+
- nm_vmm_type.current.0.infraRsVlanNs.attributes.tDn == "uni/infra/vlanns-[test_pool]-dynamic"
169184

170185
# QUERY ALL BINDINGS
171186
- name: Query all domain to VLAN pool bindings (check_mode)
@@ -214,10 +229,9 @@
214229
- cm_query_binding is not changed
215230
- nm_query_binding is not changed
216231
- cm_query_binding == nm_query_binding
217-
- nm_query_binding.current.0.physDomP.attributes.dn == 'uni/phys-phys_dom'
218-
- nm_query_binding.current.0.physDomP.attributes.name == 'phys_dom'
219-
- nm_query_binding.current.0.physDomP.children.0.infraRsVlanNs.attributes.tCl == 'fvnsVlanInstP'
220-
- nm_query_binding.current.0.physDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
232+
- nm_query_binding.current.0.infraRsVlanNs.attributes.dn == 'uni/phys-phys_dom/rsvlanNs'
233+
- nm_query_binding.current.0.infraRsVlanNs.attributes.tCl == 'fvnsVlanInstP'
234+
- nm_query_binding.current.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
221235

222236

223237
# REMOVE BINDING
@@ -235,9 +249,8 @@
235249
that:
236250
- cm_remove_binding is changed
237251
- nm_remove_binding is changed
238-
- cm_remove_binding.current.0.physDomP.attributes.dn == cm_remove_binding.previous.0.physDomP.attributes.dn == nm_remove_binding.previous.0.physDomP.attributes.dn == 'uni/phys-phys_dom'
239-
- cm_remove_binding.current.0.physDomP.attributes.name == cm_remove_binding.previous.0.physDomP.attributes.name == nm_remove_binding.previous.0.physDomP.attributes.name == 'phys_dom'
240-
- cm_remove_binding.current.0.physDomP.children.0.infraRsVlanNs.attributes.tDn == cm_remove_binding.previous.0.physDomP.children.0.infraRsVlanNs.attributes.tDn == nm_remove_binding.previous.0.physDomP.children.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
252+
- cm_remove_binding.current.0.infraRsVlanNs.attributes.dn == cm_remove_binding.previous.0.infraRsVlanNs.attributes.dn == nm_remove_binding.previous.0.infraRsVlanNs.attributes.dn == 'uni/phys-phys_dom/rsvlanNs'
253+
- cm_remove_binding.current.0.infraRsVlanNs.attributes.tDn == cm_remove_binding.previous.0.infraRsVlanNs.attributes.tDn == nm_remove_binding.previous.0.infraRsVlanNs.attributes.tDn == 'uni/infra/vlanns-[test_pool]-dynamic'
241254
- nm_remove_binding.current == []
242255

243256
- name: Remove domain to VLAN pool binding again (check_mode)

0 commit comments

Comments
 (0)