Skip to content

add Nutanix support to aci_epg_to_domain (DCNE-446) #770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions plugins/module_utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@
openstack="OpenStack",
redhat="Redhat",
vmware="VMware",
nutanix="Nutanix",
)

VM_SCOPE_MAPPING = dict(
cloudfoundry="cloudfoundry",
kubernetes="kubernetes",
microsoft="MicrosoftSCVMM",
openshift="openshift",
openstack="openstack",
redhat="rhev",
vmware="vm",
nutanix="nutanix",
)

MATCH_TYPE_GROUP_MAPPING = {"all": "ALL", "all_in_pod": "ALL_IN_POD", "range": "range"}
Expand Down Expand Up @@ -451,3 +463,5 @@
L4L7_FUNC_TYPES_MAPPING = {"go_to": "GoTo", "go_through": "GoThrough", "l1": "L1", "l2": "L2"}

L4L7_HASH_ALGORITHMS_MAPPING = {"source_ip": "sip", "destination_ip": "dip", "ip_and_protocol": "sip-dip-prototype"}

COS_MAPPING = {"cos_0": "Cos0", "cos_1": "Cos1", "cos_2": "Cos2", "cos_3": "Cos3", "cos_4": "Cos4", "cos_5": "Cos5", "cos_6": "Cos6", "cos_7": "Cos7"}
4 changes: 2 additions & 2 deletions plugins/modules/aci_aep_to_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix ]
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -227,7 +227,7 @@ def main():
domain=dict(type="str", aliases=["domain_name", "domain_profile"]), # Not required for querying all objects
domain_type=dict(type="str", choices=["fc", "l2dom", "l3dom", "phys", "vmm"], aliases=["type"]), # Not required for querying all objects
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING.keys())),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
)

module = AnsibleModule(
Expand Down
15 changes: 3 additions & 12 deletions plugins/modules/aci_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix ]
vswitch:
description:
- The virtual switch to use for vmm domains.
Expand Down Expand Up @@ -279,16 +279,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_owner_spec

VM_PROVIDER_MAPPING = dict(
cloudfoundry="CloudFoundry",
kubernetes="Kubernetes",
microsoft="Microsoft",
openshift="OpenShift",
openstack="OpenStack",
redhat="Redhat",
vmware="VMware",
)
from ansible_collections.cisco.aci.plugins.module_utils.constants import VM_PROVIDER_MAPPING

VSWITCH_MAPPING = dict(
avs="n1kv",
Expand Down Expand Up @@ -341,7 +332,7 @@ def main():
tag_collection=dict(type="bool"),
multicast_address=dict(type="str"),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
vm_provider=dict(type="str", choices=["cloudfoundry", "kubernetes", "microsoft", "openshift", "openstack", "redhat", "vmware"]),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
vswitch=dict(type="str", choices=["avs", "default", "dvs", "unknown"]),
name_alias=dict(type="str"),
access_mode=dict(type="str", choices=["read-write", "read-only"]),
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/aci_domain_to_encap_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix ]
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -266,7 +266,7 @@ def main():
pool=dict(type="str", aliases=["pool_name"]), # Not required for querying all objects
pool_allocation_mode=dict(type="str", aliases=["allocation_mode", "mode"], choices=["dynamic", "static"]),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING.keys())),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
)

module = AnsibleModule(
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/aci_domain_to_vlan_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix]
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -265,7 +265,7 @@ def main():
pool=dict(type="str", aliases=["pool_name", "vlan_pool"]), # Not required for querying all objects
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"]),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING.keys())),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
)

module = AnsibleModule(
Expand Down
120 changes: 96 additions & 24 deletions plugins/modules/aci_epg_to_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix ]
custom_epg_name:
description:
- The custom epg name in VMM domain association.
Expand Down Expand Up @@ -169,6 +169,62 @@
type: str
choices: [ accept, reject ]
default: reject
epg_cos:
description:
- The class of service (CoS).
- The APIC defaults to C(cos_0) when unset during creation.
type: str
choices: [ cos_0, cos_1, cos_2, cos_3, cos_4, cos_5, cos_6, cos_7 ]
epg_cos_preference:
description:
- The class of service (CoS) preference.
- The APIC defaults to C(disabled) when unset during creation.
type: str
choices: [ enabled, disabled ]
ipam_dhcp_override:
description:
- The IP Address Management (IPAM) Dynamic Host Configuration Protocol (DHCP) override.
- Only applicable for Nutanix domains.
type: str
ipam_enabled:
description:
- The IP Address Management (IPAM) enabled state.
- Only applicable for Nutanix domains.
- The APIC defaults to C(false) when unset during creation.
type: bool
ipam_gateway:
description:
- The IP Address Management (IPAM) gateway.
- Only applicable for Nutanix domains.
type: str
lag_policy_name:
description:
- The link aggregation group (LAG) policy name.
type: str
netflow_direction:
description:
- The NetFlow monitoring direction.
- The APIC defaults to C(both) when unset during creation.
type: str
choices: [ both, ingress, egress ]
primary_encap_inner:
description:
- The primary inner encapsulation.
- This is used for the portgroup at the VMWare Distributed Virtual Switch (DVS).
- This VLAN is internal to the DVS and is used for communication between the other VMs and the AVE VM at a host.
- Traffic is not forwarded to the fabric over the VLAN.
- Only applicable for Cisco ACI Virtual Edge (AVE) domains.
- Accepted values range between C(1) and C(4096).
type: int
secondary_encap_inner:
description:
- The secondary inner encapsulation.
- This is used for the portgroup at the VMWare Distributed Virtual Switch (DVS).
- This VLAN is internal to the DVS and is used for communication between the other VMs and the AVE VM at a host.
- Traffic is not forwarded to the fabric over the VLAN.
- Only applicable for Cisco ACI Virtual Edge (AVE) domains.
- Accepted values range between C(1) and C(4096).
type: int
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -349,16 +405,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec

VM_PROVIDER_MAPPING = dict(
cloudfoundry="CloudFoundry",
kubernetes="Kubernetes",
microsoft="Microsoft",
openshift="OpenShift",
openstack="OpenStack",
redhat="Redhat",
vmware="VMware",
)
from ansible_collections.cisco.aci.plugins.module_utils.constants import COS_MAPPING, VM_PROVIDER_MAPPING


def main():
Expand All @@ -382,7 +429,7 @@ def main():
resolution_immediacy=dict(type="str", choices=["immediate", "lazy", "pre-provision"]),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
tenant=dict(type="str", aliases=["tenant_name"]), # Not required for querying all objects
vm_provider=dict(type="str", choices=["cloudfoundry", "kubernetes", "microsoft", "openshift", "openstack", "redhat", "vmware"]),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
promiscuous=dict(type="str", default="reject", choices=["accept", "reject"]),
custom_epg_name=dict(type="str"),
delimiter=dict(type="str", choices=["|", "~", "!", "@", "^", "+", "=", "_"]),
Expand All @@ -392,6 +439,15 @@ def main():
number_of_ports=dict(type="int"),
forged_transmits=dict(type="str", default="reject", choices=["accept", "reject"]),
mac_changes=dict(type="str", default="reject", choices=["accept", "reject"]),
epg_cos=dict(type="str", choices=list(COS_MAPPING)),
epg_cos_preference=dict(type="str", choices=["enabled", "disabled"]),
ipam_dhcp_override=dict(type="str"),
ipam_enabled=dict(type="bool"),
ipam_gateway=dict(type="str"),
lag_policy_name=dict(type="str"),
netflow_direction=dict(type="str", choices=["both", "ingress", "egress"]),
primary_encap_inner=dict(type="int"),
secondary_encap_inner=dict(type="int"),
)

module = AnsibleModule(
Expand All @@ -414,25 +470,15 @@ def main():
vm_provider = module.params.get("vm_provider")
promiscuous = module.params.get("promiscuous")
custom_epg_name = module.params.get("custom_epg_name")
encap = module.params.get("encap")
if encap is not None:
if encap in range(1, 4097):
encap = "vlan-{0}".format(encap)
else:
module.fail_json(msg="Valid VLAN assignments are from 1 to 4096")
encap = format_vlan(aci, module.params.get("encap"))
encap_mode = module.params.get("encap_mode")
switching_mode = module.params.get("switching_mode")
epg = module.params.get("epg")
enhanced_lag_policy = module.params.get("enhanced_lag_policy")
vmm_uplink_active = module.params.get("vmm_uplink_active")
vmm_uplink_standby = module.params.get("vmm_uplink_standby")
netflow = aci.boolean(module.params.get("netflow"), "enabled", "disabled")
primary_encap = module.params.get("primary_encap")
if primary_encap is not None:
if primary_encap in range(1, 4097):
primary_encap = "vlan-{0}".format(primary_encap)
else:
module.fail_json(msg="Valid VLAN assignments are from 1 to 4096")
primary_encap = format_vlan(aci, module.params.get("primary_encap"))
resolution_immediacy = module.params.get("resolution_immediacy")
state = module.params.get("state")
tenant = module.params.get("tenant")
Expand All @@ -449,6 +495,15 @@ def main():
number_of_ports = module.params.get("number_of_ports")
forged_transmits = module.params.get("forged_transmits")
mac_changes = module.params.get("mac_changes")
epg_cos = COS_MAPPING.get(module.params.get("epg_cos"))
epg_cos_pref = module.params.get("epg_cos_preference")
ipam_dhcp_override = module.params.get("ipam_dhcp_override")
ipam_enabled = aci.boolean(module.params.get("ipam_enabled"))
ipam_gateway = module.params.get("ipam_gateway")
lag_policy_name = module.params.get("lag_policy_name")
netflow_direction = module.params.get("netflow_direction")
primary_encap_inner = format_vlan(aci, module.params.get("primary_encap_inner"))
secondary_encap_inner = format_vlan(aci, module.params.get("secondary_encap_inner"))

child_classes = None
child_configs = None
Expand Down Expand Up @@ -535,6 +590,15 @@ def main():
bindingType=port_binding,
portAllocation=port_allocation,
numPorts=number_of_ports,
epgCos=epg_cos,
epgCosPref=epg_cos_pref,
ipamDhcpOverride=ipam_dhcp_override,
ipamEnabled=ipam_enabled,
ipamGateway=ipam_gateway,
lagPolicyName=lag_policy_name,
netflowDir=netflow_direction,
primaryEncapInner=primary_encap_inner,
secondaryEncapInner=secondary_encap_inner,
),
child_configs=child_configs,
)
Expand All @@ -549,5 +613,13 @@ def main():
aci.exit_json()


def format_vlan(aci, vlan):
if vlan in range(1, 4097):
return "vlan-{0}".format(vlan)
if vlan is not None:
aci.fail_json(msg="Valid VLAN assignments are from 1 to 4096")
return vlan


if __name__ == "__main__":
main()
25 changes: 3 additions & 22 deletions plugins/modules/aci_vmm_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix ]
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -248,26 +248,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec

VM_PROVIDER_MAPPING = dict(
cloudfoundry="CloudFoundry",
kubernetes="Kubernetes",
microsoft="Microsoft",
openshift="OpenShift",
openstack="OpenStack",
redhat="Redhat",
vmware="VMware",
)

VM_SCOPE_MAPPING = dict(
cloudfoundry="cloudfoundry",
kubernetes="kubernetes",
microsoft="MicrosoftSCVMM",
openshift="openshift",
openstack="openstack",
redhat="rhev",
vmware="vm",
)
from ansible_collections.cisco.aci.plugins.module_utils.constants import VM_PROVIDER_MAPPING, VM_SCOPE_MAPPING


def main():
Expand All @@ -284,7 +265,7 @@ def main():
inband_management_epg=dict(type="str"),
name_alias=dict(type="str"),
datacenter=dict(type="str"),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING.keys())),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
)

module = AnsibleModule(
Expand Down
15 changes: 3 additions & 12 deletions plugins/modules/aci_vmm_credential.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
- Support for Kubernetes was added in ACI v3.0.
- Support for CloudFoundry, OpenShift and Red Hat was added in ACI v3.1.
type: str
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware ]
choices: [ cloudfoundry, kubernetes, microsoft, openshift, openstack, redhat, vmware, nutanix ]
extends_documentation_fragment:
- cisco.aci.aci
- cisco.aci.annotation
Expand Down Expand Up @@ -229,16 +229,7 @@

from ansible.module_utils.basic import AnsibleModule
from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec, aci_annotation_spec, aci_owner_spec

VM_PROVIDER_MAPPING = dict(
cloudfoundry="CloudFoundry",
kubernetes="Kubernetes",
microsoft="Microsoft",
openshift="OpenShift",
openstack="OpenStack",
redhat="Redhat",
vmware="VMware",
)
from ansible_collections.cisco.aci.plugins.module_utils.constants import VM_PROVIDER_MAPPING


def main():
Expand All @@ -252,7 +243,7 @@ def main():
description=dict(type="str", aliases=["descr"]),
domain=dict(type="str", aliases=["domain_name", "domain_profile"]),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING.keys())),
vm_provider=dict(type="str", choices=list(VM_PROVIDER_MAPPING)),
name_alias=dict(type="str"),
)

Expand Down
Loading