Skip to content

Commit

Permalink
[ignore] Addition of 'aci_l3out_floating_svi_path_attributes' module …
Browse files Browse the repository at this point in the history
…to add secondary ips
  • Loading branch information
shrsr committed Sep 27, 2023
1 parent 4598bf8 commit 183a864
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 79 deletions.
56 changes: 26 additions & 30 deletions plugins/modules/aci_l3out_floating_svi_path_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ def main():
forged_transmit=dict(type="str", choices=["enabled", "disabled"]),
mac_change=dict(type="str", choices=["enabled", "disabled"]),
promiscuous_mode=dict(type="str", choices=["enabled", "disabled"]),
domain_type=dict(type="str", choices=["physical", "virtual"], required=True),
domain_type=dict(type="str", choices=["physical", "vmware"], required=True),
domain=dict(type="str", required=True),
enhanced_lag_policy=dict(type="str"),
)
Expand All @@ -331,14 +331,14 @@ def main():
domain_type = module.params.get("domain_type")
domain = module.params.get("domain")
enhanced_lag_policy = module.params.get("enhanced_lag_policy")

aci = ACIModule(module)

node_dn = "topology/pod-{0}/node-{1}".format(pod_id, node_id)

if domain_type == "physical":
tDn = "uni/phys-{0}".format(domain)
else:
tDn = "uni/phys-{0}".format(domain)
elif domain_type == "vmware":
tDn = "uni/vmmp-VMware/dom-{0}".format(domain)

aci.construct_url(
Expand Down Expand Up @@ -375,7 +375,7 @@ def main():
module_object=tDn,
target_filter={"tDn": tDn},
),
child_classes=["l3extVirtualLIfPLagPolAtt"]
child_classes=["l3extVirtualLIfPLagPolAtt"],
)

aci.get_existing()
Expand All @@ -388,7 +388,12 @@ def main():
for child in aci.existing[0].get("l3extRsDynPathAtt", {}).get("children", {}):
if child.get("l3extVirtualLIfPLagPolAtt"):
existing_enhanced_lag_policy = (
child.get("l3extVirtualLIfPLagPolAtt").get("children")[0].get("l3extRsVSwitchEnhancedLagPol").get("attributes").get("tDn").split("enlacplagp-")[1]
child.get("l3extVirtualLIfPLagPolAtt")
.get("children")[0]
.get("l3extRsVSwitchEnhancedLagPol")
.get("attributes")
.get("tDn")
.split("enlacplagp-")[1]
)
if enhanced_lag_policy == "":
child_configs.append(
Expand All @@ -400,39 +405,30 @@ def main():
)

if enhanced_lag_policy != "":
child=[
dict(
l3extRsVSwitchEnhancedLagPol=dict(
attributes=dict(
tDn="{0}/vswitchpolcont/enlacplagp-{1}".format(tDn, enhanced_lag_policy)
),
)
),
]
child = [
dict(
l3extRsVSwitchEnhancedLagPol=dict(
attributes=dict(tDn="{0}/vswitchpolcont/enlacplagp-{1}".format(tDn, enhanced_lag_policy)),
)
),
]
if enhanced_lag_policy != existing_enhanced_lag_policy and existing_enhanced_lag_policy != "":
child.append(
dict(
l3extRsVSwitchEnhancedLagPol=dict(
attributes=dict(
status="deleted",
tDn="{0}/vswitchpolcont/enlacplagp-{1}".format(tDn, existing_enhanced_lag_policy)
),
)
dict(
l3extRsVSwitchEnhancedLagPol=dict(
attributes=dict(status="deleted", tDn="{0}/vswitchpolcont/enlacplagp-{1}".format(tDn, existing_enhanced_lag_policy)),
)
)
child_configs.append(
dict(
l3extVirtualLIfPLagPolAtt=dict(
attributes=dict(),
children=child
)
)
)
child_configs.append(dict(l3extVirtualLIfPLagPolAtt=dict(attributes=dict(), children=child)))

aci.payload(
aci_class="l3extRsDynPathAtt",
class_config=dict(
floatingAddr=floating_ip, forgedTransmit=forged_transmit, macChange=mac_change, promMode=promiscuous_mode,
floatingAddr=floating_ip,
forgedTransmit=forged_transmit,
macChange=mac_change,
promMode=promiscuous_mode,
),
child_configs=child_configs,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

DOCUMENTATION = r"""
---
module: aci_l3out_interface_floating_svi
module: aci_l3out_floating_svi
short_description: Manage Layer 3 Outside (L3Out) interfaces (l3ext:RsPathL3OutAtt)
description:
- Manage L3Out interfaces on Cisco ACI fabrics.
Expand Down Expand Up @@ -298,16 +298,19 @@ def main():
node_profile=dict(type="str", aliases=["node_profile_name", "logical_node"], required=True),
interface_profile=dict(type="str", aliases=["interface_profile_name", "logical_interface"], required=True),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
pod_id=dict(type="str"),
node_id=dict(type="str"),
encap=dict(type="str"),
external_bridge_group_profile=dict(type="str"),
pod_id=dict(type="str", required=True),
node_id=dict(type="str", required=True),
encap=dict(type="str", required=True),
floating_ip=dict(type="str", aliases=["floating_address"], required=True),
domain_type=dict(type="str", choices=["physical", "vmware"], required=True),
domain=dict(type="str", required=True),
address=dict(type="str", aliases=["addr", "ip_address"]),
)

module = AnsibleModule(
argument_spec=argument_spec,
supports_check_mode=True,
required_if=[["state", "present", ["pod_id", "node_id", "encap", "external_bridge_group_profile"]], ["state", "absent", ["pod_id", "node_id"]]],
required_if=[["state", "present", ["address"]], ["state", "absent", ["address"]]],
)

tenant = module.params.get("tenant")
Expand All @@ -318,12 +321,19 @@ def main():
pod_id = module.params.get("pod_id")
node_id = module.params.get("node_id")
encap = module.params.get("encap")
external_bridge_group_profile = module.params.get("external_bridge_group_profile")
domain_type = module.params.get("domain_type")
domain = module.params.get("domain")
address = module.params.get("address")

aci = ACIModule(module)

node_dn = "topology/pod-{0}/node-{1}".format(pod_id, node_id)

if domain_type == "physical":
tDn = "uni/phys-{0}".format(domain)
elif domain_type == "vmware":
tDn = "uni/vmmp-VMware/dom-{0}".format(domain)

aci.construct_url(
root_class=dict(
aci_class="fvTenant",
Expand All @@ -349,34 +359,29 @@ def main():
module_object=interface_profile,
target_filter={"name": interface_profile},
),
subclass_4=dict(aci_class="l3extVirtualLIfP", aci_rn="vlifp-[{0}]-[vlan-{1}]".format(node_dn, encap), module_object=node_dn, target_filter={"nodeDn": node_dn}),
subclass_4=dict(
aci_class="l3extVirtualLIfP", aci_rn="vlifp-[{0}]-[{1}]".format(node_dn, encap), module_object=node_dn, target_filter={"nodeDn": node_dn}
),
subclass_5=dict(
aci_class="l3extBdProfileCont",
aci_rn="bdprofilecont",
#module_object=True,
aci_class="l3extRsDynPathAtt",
aci_rn="rsdynPathAtt-[{0}]".format(tDn),
module_object=tDn,
target_filter={"tDn": tDn},
),
subclass_6=dict(
aci_class="l3extIp",
aci_rn="addr-[{0}]".format(address),
module_object=address,
target_filter={"addr": address},
),
child_classes=["l3extRsBdProfile"],
)

aci.get_existing()

if state == "present":
child_configs = []
child_configs.append(
dict(
l3extRsBdProfile=dict(
attributes=dict(
tDn="uni/tn-{0}/bdprofile-{1}".format(tenant, external_bridge_group_profile),
),
),
)
)
aci.payload(
aci_class="l3extBdProfileCont",
child_configs=child_configs,
)
aci.payload(aci_class="l3extIp", class_config=dict(addr=address, ipv6Dad="disabled"))

aci.get_diff(aci_class="l3extBdProfileCont")
aci.get_diff(aci_class="l3extIp")

aci.post_config()

Expand Down
36 changes: 15 additions & 21 deletions plugins/modules/aci_l3out_floating_svi_secondary_ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,14 +276,14 @@ def main():
argument_spec = aci_argument_spec()
argument_spec.update(aci_annotation_spec())
argument_spec.update(
tenant=dict(type="str", aliases=["tenant_name"]),
l3out=dict(type="str", aliases=["l3out_name"]),
node_profile=dict(type="str", aliases=["node_profile_name", "logical_node"]),
interface_profile=dict(type="str", aliases=["interface_profile_name", "logical_interface"]),
tenant=dict(type="str", aliases=["tenant_name"], required=True),
l3out=dict(type="str", aliases=["l3out_name"], required=True),
node_profile=dict(type="str", aliases=["node_profile_name", "logical_node"], required=True),
interface_profile=dict(type="str", aliases=["interface_profile_name", "logical_interface"], required=True),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
pod_id=dict(type="str"),
node_id=dict(type="str"),
encap=dict(type="str"),
pod_id=dict(type="str", required=True),
node_id=dict(type="str", required=True),
encap=dict(type="str", required=True),
address=dict(type="str", aliases=["addr", "ip_address"]),
)

Expand All @@ -295,24 +295,14 @@ def main():
"state",
"absent",
[
"tenant",
"l3out",
"node_profile",
"interface_profile",
"pod_id",
"node_id",
"address",
],
],
[
"state",
"present",
[
"tenant",
"l3out",
"node_profile",
"interface_profile",
"pod_id",
"node_id",
"address",
],
],
],
Expand All @@ -324,7 +314,7 @@ def main():
interface_profile = module.params.get("interface_profile")
pod_id = module.params.get("pod_id")
node_id = module.params.get("node_id")
encap = module.params.get("encap"),
encap = (module.params.get("encap"),)
address = module.params.get("address")
state = module.params.get("state")

Expand Down Expand Up @@ -357,7 +347,9 @@ def main():
module_object=interface_profile,
target_filter={"name": interface_profile},
),
subclass_4=dict(aci_class="l3extVirtualLIfP", aci_rn="vlifp-[{0}]-[vlan-{1}]".format(node_dn, encap), module_object=node_dn, target_filter={"nodeDn": node_dn}),
subclass_4=dict(
aci_class="l3extVirtualLIfP", aci_rn="vlifp-[{0}]-[{1}]".format(node_dn, encap), module_object=node_dn, target_filter={"nodeDn": node_dn}
),
subclass_5=dict(
aci_class="l3extIp",
aci_rn="addr-[{0}]".format(address),
Expand All @@ -370,7 +362,9 @@ def main():

if state == "present":
aci.payload(aci_class="l3extIp", class_config=dict(addr=address, ipv6Dad="enabled"))

aci.get_diff(aci_class="l3extIp")

aci.post_config()

elif state == "absent":
Expand Down

0 comments on commit 183a864

Please sign in to comment.