Skip to content

Commit

Permalink
[ignore] Added vlan pool_uuid and vlan pool name in the previous and …
Browse files Browse the repository at this point in the history
…current portion of the ndo_l3_domain module
  • Loading branch information
sajagana committed Dec 20, 2024
1 parent 39d30ea commit 2240b6b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
10 changes: 10 additions & 0 deletions plugins/modules/ndo_l3_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ def main():
match = get_l3_domain(mso_template, l3_domain_uuid, l3_domain)
if l3_domain_uuid or l3_domain:
if match:
if match.details.get("pool"):
match.details["pool_uuid"] = match.details.get("pool")
match.details["pool"] = mso_template.get_vlan_pool_name(match.details.get("pool"))
mso.existing = mso.previous = copy.deepcopy(match.details) # Query a specific object
elif match:
mso.existing = match # Query all objects
Expand Down Expand Up @@ -197,6 +200,10 @@ def main():

mso.sanitize(payload)

if module.check_mode:
mso.proposed["pool_uuid"] = payload["pool"]
mso.proposed["pool"] = pool

mso.existing = mso.proposed

elif state == "absent":
Expand All @@ -208,6 +215,9 @@ def main():
mso_template.template = mso.request(mso_template.template_path, method="PATCH", data=ops)
match = get_l3_domain(mso_template, l3_domain_uuid, l3_domain)
if match:
if match.details.get("pool"):
match.details["pool_uuid"] = match.details.get("pool")
match.details["pool"] = mso_template.get_vlan_pool_name(match.details.get("pool"))
mso.existing = match.details # When the state is present
else:
mso.existing = {} # When the state is absent
Expand Down
25 changes: 18 additions & 7 deletions tests/integration/targets/ndo_l3_domain/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,24 @@
- cm_create_new_l3_domain is changed
- cm_create_new_l3_domain.previous == {}
- cm_create_new_l3_domain.current.name == "ansible_test_l3_domain"
- cm_create_new_l3_domain.current.pool != ""
- cm_create_new_l3_domain.current.pool_uuid
- cm_create_new_l3_domain.current.pool == "ansible_test_vlan_pool_1"
- nm_create_new_l3_domain is changed
- nm_create_new_l3_domain.previous == {}
- nm_create_new_l3_domain.current.name == "ansible_test_l3_domain"
- nm_create_new_l3_domain.current.pool != ""
- nm_create_new_l3_domain.current.pool_uuid != ""
- nm_create_new_l3_domain.current.pool == "ansible_test_vlan_pool_1"
- nm_create_new_l3_domain_again is not changed
- nm_create_new_l3_domain_again.previous.name == "ansible_test_l3_domain"
- nm_create_new_l3_domain_again.previous.description == ""
- nm_create_new_l3_domain_again.previous.uuid is defined
- nm_create_new_l3_domain_again.previous.pool != ""
- nm_create_new_l3_domain_again.previous.pool_uuid != ""
- nm_create_new_l3_domain_again.previous.pool == "ansible_test_vlan_pool_1"
- nm_create_new_l3_domain_again.current.name == "ansible_test_l3_domain"
- nm_create_new_l3_domain_again.current.description == ""
- nm_create_new_l3_domain_again.current.uuid is defined
- nm_create_new_l3_domain_again.current.pool != ""
- nm_create_new_l3_domain_again.current.pool == "ansible_test_vlan_pool_1"
- nm_create_new_l3_domain_again.current.pool_uuid != ""

# UPDATE

Expand Down Expand Up @@ -147,6 +151,7 @@
cisco.mso.ndo_l3_domain:
<<: *update_l3_domain_name
pool: ""
output_level: debug
register: nm_update_l3_domain_pool_remove

- name: Assert l3 domain was updated
Expand All @@ -156,11 +161,15 @@
- nm_update_l3_domain_name.previous.name == "ansible_test_l3_domain"
- nm_update_l3_domain_name.current.name == "ansible_test_l3_domain_changed"
- nm_update_l3_domain_pool is changed
- nm_update_l3_domain_pool.previous.pool != ""
- nm_update_l3_domain_pool.current.pool != ""
- nm_update_l3_domain_pool.previous.pool_uuid != ""
- nm_update_l3_domain_pool.previous.pool == "ansible_test_vlan_pool_1"
- nm_update_l3_domain_pool.current.pool_uuid != ""
- nm_update_l3_domain_pool.current.pool == "ansible_test_vlan_pool_2"
- nm_update_l3_domain_pool_remove is changed
- nm_update_l3_domain_pool_remove.previous.pool != ""
- nm_update_l3_domain_pool_remove.previous.pool == "ansible_test_vlan_pool_2"
- nm_update_l3_domain_pool_remove.previous.pool_uuid != ""
- nm_update_l3_domain_pool_remove.current.pool is not defined
- nm_update_l3_domain_pool_remove.current.pool_uuid is not defined

# QUERY

Expand Down Expand Up @@ -217,10 +226,12 @@
- cm_delete_l3_domain is changed
- cm_delete_l3_domain.previous.name == 'ansible_test_l3_domain_changed'
- cm_delete_l3_domain.previous.pool is not defined
- cm_delete_l3_domain.previous.pool_uuid is not defined
- cm_delete_l3_domain.current == {}
- nm_delete_l3_domain is changed
- nm_delete_l3_domain.previous.name == 'ansible_test_l3_domain_changed'
- nm_delete_l3_domain.previous.pool is not defined
- nm_delete_l3_domain.previous.pool_uuid is not defined
- nm_delete_l3_domain.current == {}
- nm_delete_l3_domain_again is not changed
- nm_delete_l3_domain_again.previous == {}
Expand Down

0 comments on commit 2240b6b

Please sign in to comment.