Skip to content

Commit

Permalink
[ignore] Modify conditions to delete loopback_address for aci_l3out_l…
Browse files Browse the repository at this point in the history
…ogical_node.
  • Loading branch information
gmicol committed Sep 14, 2023
1 parent 704ab60 commit 416e3e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
25 changes: 10 additions & 15 deletions plugins/modules/aci_l3out_logical_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,8 @@
loopback_address:
description:
- Loopback IP.
- to delete an existing loopback address, pass an empty string.
type: str
delete_loopback_address:
description:
- Option to delete the current loopback interface profile.
- the current loopback address needs to be provided in order to be deleted.
type: str
choices: [ 'yes', 'no' ]
default: 'no'
state:
description:
- Use C(present) or C(absent) for adding or removing.
Expand Down Expand Up @@ -255,7 +249,6 @@ def main():
router_id=dict(type="str"),
router_id_as_loopback=dict(type="str", default="yes", choices=["yes", "no"]),
loopback_address=dict(type="str"),
delete_loopback_address=dict(type="str", default="no", choices=["yes", "no"]),
state=dict(type="str", default="present", choices=["absent", "present", "query"]),
)

Expand All @@ -276,7 +269,6 @@ def main():
router_id = module.params.get("router_id")
router_id_as_loopback = module.params.get("router_id_as_loopback")
loopback_address = module.params.get("loopback_address")
delete_loopback_address = module.params.get("delete_loopback_address")
state = module.params.get("state")

tdn = None
Expand All @@ -289,12 +281,6 @@ def main():

child_configs = []

if loopback_address is not None:
if delete_loopback_address == "yes":
child_configs.extend([dict(l3extLoopBackIfP=dict(attributes=dict(addr=loopback_address, status="deleted")))])
else:
child_configs.extend([dict(l3extLoopBackIfP=dict(attributes=dict(addr=loopback_address)))])

aci.construct_url(
root_class=dict(
aci_class="fvTenant",
Expand Down Expand Up @@ -325,6 +311,15 @@ def main():

aci.get_existing()

if loopback_address is not None:
if loopback_address == "" and isinstance(aci.existing, list) and len(aci.existing) > 0:
for child in aci.existing[0].get("l3extRsNodeL3OutAtt", {}).get("children", {}):
if child.get("l3extLoopBackIfP"):
previous_loopback_address = child.get("l3extLoopBackIfP").get("attributes").get("addr")
child_configs.extend([dict(l3extLoopBackIfP=dict(attributes=dict(addr=previous_loopback_address,status="deleted")))])
elif loopback_address:
child_configs.extend([dict(l3extLoopBackIfP=dict(attributes=dict(addr=loopback_address)))])

if state == "present":
aci.payload(
aci_class="l3extRsNodeL3OutAtt",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@
- name: Remove loopback address
aci_l3out_logical_node: &node_remove_loopback
<<: *node_add_loopback
loopback_address: 11.11.11.12
delete_loopback_address: "yes"
loopback_address: ""
register: remove_loopback_ip

- name: Verify update_node
Expand Down

0 comments on commit 416e3e2

Please sign in to comment.