Skip to content

Commit 18b3a08

Browse files
committed
[ignore] change logic for aci_vmm_vswitch_policy to leverage the VM_PROVIDER constant
1 parent 8b0c31c commit 18b3a08

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

plugins/modules/aci_vmm_vswitch_policy.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,20 +300,20 @@
300300
"""
301301

302302
from ansible.module_utils.basic import AnsibleModule
303-
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, enhanced_lag_spec, netflow_spec
304-
from ansible_collections.cisco.aci.plugins.module_utils.aci import aci_annotation_spec, aci_owner_spec
303+
from ansible_collections.cisco.aci.plugins.module_utils.aci import (
304+
ACIModule,
305+
aci_argument_spec,
306+
enhanced_lag_spec,
307+
netflow_spec,
308+
aci_annotation_spec,
309+
aci_owner_spec,
310+
)
311+
from ansible_collections.cisco.aci.plugins.module_utils.constants import (
312+
VM_PROVIDER_MAPPING,
313+
)
305314

306315
# via UI vSwitch Policy can only be added for VMware and Microsoft vmm domains
307316
# behavior for other domains is currently untested.
308-
VM_PROVIDER_MAPPING = dict(
309-
cloudfoundry="CloudFoundry",
310-
kubernetes="Kubernetes",
311-
microsoft="Microsoft",
312-
openshift="OpenShift",
313-
openstack="OpenStack",
314-
redhat="Redhat",
315-
vmware="VMware",
316-
)
317317

318318
# enhanced_lag_spec = dict(
319319
# name=dict(type='str', required=True),
@@ -326,7 +326,6 @@
326326
# 'src-dst-l4port', 'src-port-id', 'vlan']),
327327
# number_uplinks=dict(type='int'),
328328
# )
329-
330329
# netflow_spec = dict(
331330
# name=dict(type='str', required=True),
332331
# active_flow_timeout=dict(type='int'),
@@ -336,6 +335,11 @@
336335

337336

338337
def main():
338+
339+
# Remove nutanix from VM_PROVIDER_MAPPING as it is not supported
340+
CLEAN_VM_PROVIDER_MAPPING = VM_PROVIDER_MAPPING.copy()
341+
CLEAN_VM_PROVIDER_MAPPING.pop("nutanix")
342+
339343
argument_spec = aci_argument_spec()
340344
argument_spec.update(aci_annotation_spec())
341345
argument_spec.update(aci_owner_spec())
@@ -349,7 +353,7 @@ def main():
349353
netflow_exporter=dict(type="dict", options=netflow_spec()),
350354
domain=dict(type="str", aliases=["domain_name", "domain_profile"]),
351355
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
352-
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING.keys())),
356+
vm_provider=dict(type="str", choices=list(CLEAN_VM_PROVIDER_MAPPING),
353357
)
354358

355359
module = AnsibleModule(
@@ -388,7 +392,7 @@ def main():
388392
aci.construct_url(
389393
root_class=dict(
390394
aci_class="vmmProvP",
391-
aci_rn="vmmp-{0}".format(VM_PROVIDER_MAPPING.get(vm_provider)),
395+
aci_rn="vmmp-{0}".format(CLEAN_VM_PROVIDER_MAPPING.get(vm_provider)),
392396
module_object=vm_provider,
393397
target_filter={"name": vm_provider},
394398
),

0 commit comments

Comments
 (0)