Skip to content

Commit

Permalink
[ignore_changes] Made route map policy name and uuid mutually exclusi…
Browse files Browse the repository at this point in the history
…ve and changed update task to support the changes.
  • Loading branch information
anvitha-jain committed Jan 22, 2025
1 parent 89f07d6 commit a038ff4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 29 deletions.
40 changes: 17 additions & 23 deletions plugins/modules/ndo_tenant_igmp_interface_policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
type: int
state_limit_route_map_uuid:
description:
- The state limit route map name.
- The UUID of the state limit route map.
type: str
aliases: [ state_limit_route_map_for_multicast ]
state_limit_route_map:
Expand All @@ -146,7 +146,7 @@
aliases: [ state_limit_route_map_policy, state_limit_route_map_policy_multicast ]
report_policy_route_map_uuid:
description:
- The report policy route map name.
- The UUID of the report policy route map.
type: str
aliases: [ report_policy_route_map_for_multicast ]
report_policy_route_map:
Expand All @@ -169,7 +169,7 @@
aliases: [ report_policy_route_map_policy, report_policy_route_map_policy_multicast ]
static_report_route_map_uuid:
description:
- The static report route map name.
- The UUID of the static report route map.
type: str
aliases: [ static_report_route_map_for_multicast ]
static_report_route_map:
Expand Down Expand Up @@ -218,6 +218,7 @@
Use M(cisco.mso.ndo_tenant_route_map_policy_for_multicast) to create the Route Map Policy for Multicast.
seealso:
- module: cisco.mso.ndo_template
- module: cisco.mso.ndo_tenant_route_map_policy_for_multicast
extends_documentation_fragment: cisco.mso.modules
"""

Expand All @@ -240,8 +241,8 @@
startup_query_interval: 31
querier_timeout: 255
robustness_variable: 2
state_limit_route_map_uuid: TestStateLimitRouteMap
report_policy_route_map_uuid: TestReportPolicyRouteMap
state_limit_route_map_uuid: route_map_policy_for_multicast_uuid
report_policy_route_map_uuid: route_map_policy_for_multicast_uuid
static_report_route_map:
name: TestStaticReportRouteMap
template: TestTenantTemplate
Expand All @@ -257,7 +258,7 @@
password: SomeSecretPassword
template: tenant_template
name: test_igmp_interface_policy_updated
uuid: "{{ igmp_interface_policy_1.current.uuid }}"
uuid: "{{ igmp_interface_policy.current.uuid }}"
state: present
register: igmp_interface_policy_update
Expand All @@ -277,7 +278,7 @@
username: admin
password: SomeSecretPassword
template: TestTenantTemplate
uuid: "{{ igmp_snooping_policy_1.current.uuid }}"
uuid: "{{ igmp_interface_policy.current.uuid }}"
state: query
register: query_uuid
Expand Down Expand Up @@ -305,7 +306,7 @@
username: admin
password: SomeSecretPassword
template: TestTenantTemplate
uuid: "{{ igmp_interface_policy_1.current.uuid }}"
uuid: "{{ igmp_interface_policy.current.uuid }}"
state: absent
"""

Expand Down Expand Up @@ -379,6 +380,11 @@ def main():
["state", "absent", ["name", "uuid"], True],
["state", "present", ["name", "uuid"], True],
],
mutually_exclusive=[
["state_limit_route_map_uuid", "state_limit_route_map"],
["report_policy_route_map_uuid", "report_policy_route_map"],
["static_report_route_map_uuid", "static_report_route_map"],
],
)

mso = MSOModule(module)
Expand Down Expand Up @@ -434,19 +440,13 @@ def main():
mso.fail_json(msg="{0} with the UUID: '{1}' not found".format(object_description, uuid))

if state_limit_route_map and not state_limit_route_map_uuid:
state_limit_route_map_uuid = get_route_map_policy_uuid_from_name(
mso_template, mso, state_limit_route_map.get("template"), state_limit_route_map.get("name")
)
state_limit_route_map_uuid = mso_template.get_route_map_policy_for_multicast_uuid(state_limit_route_map.get("name"))

if report_policy_route_map and not report_policy_route_map_uuid:
report_policy_route_map_uuid = get_route_map_policy_uuid_from_name(
mso_template, mso, report_policy_route_map.get("template"), report_policy_route_map.get("name")
)
report_policy_route_map_uuid = mso_template.get_route_map_policy_for_multicast_uuid(report_policy_route_map.get("name"))

if static_report_route_map and not static_report_route_map_uuid:
static_report_route_map_uuid = get_route_map_policy_uuid_from_name(
mso_template, mso, static_report_route_map.get("template"), static_report_route_map.get("name")
)
static_report_route_map_uuid = mso_template.get_route_map_policy_for_multicast_uuid(static_report_route_map.get("name"))

mso_values = dict(
name=name,
Expand Down Expand Up @@ -498,11 +498,5 @@ def main():
mso.exit_json()


def get_route_map_policy_uuid_from_name(mso_template, mso, template, name):
route_map_policy_for_multicast = MSOTemplate(mso, "tenant", template)
mso_template.validate_template("tenantPolicy")
return route_map_policy_for_multicast.get_route_map_policy_for_multicast_uuid(name)


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,10 @@
# UPDATE
- name: Update an IGMP interface policy (check mode)
cisco.mso.ndo_tenant_igmp_interface_policy: &igmp_interface_policy_update
<<: *igmp_interface_policy_2
description: 'IGMP Interface Policy description updated'
<<: *mso_info
template: ansible_tenant_template
name: ansible_igmp_interface_policy_2
description: 'IGMP Interface Policy 2 description updated'
version3_asm: 'disabled'
fast_leave: 'disabled'
report_link_local_groups: 'disabled'
Expand All @@ -258,7 +260,7 @@
querier_timeout: 701
robustness_variable: 7
state_limit_route_map_uuid: "{{ create_route_map_policy_multicast_2.current.uuid }}"
static_report_route_map_uuid: "{{ create_route_map_policy_multicast_3.current.uuid }}"
report_policy_route_map_uuid: "{{ create_route_map_policy_multicast_3.current.uuid }}"
static_report_route_map:
name: ansible_test_route_map_policy_1
template: ansible_tenant_template
Expand Down Expand Up @@ -286,7 +288,7 @@
- cm_update_igmp_interface_policy.previous.name == nm_update_igmp_interface_policy.previous.name == 'ansible_igmp_interface_policy_2'
- cm_update_igmp_interface_policy.current.name == nm_update_igmp_interface_policy.current.name == 'ansible_igmp_interface_policy_2'
- cm_update_igmp_interface_policy.previous.description == nm_update_igmp_interface_policy.previous.description == 'IGMP Interface Policy 2 description'
- cm_update_igmp_interface_policy.current.description == nm_update_igmp_interface_policy.current.description == 'IGMP Interface Policy description updated'
- cm_update_igmp_interface_policy.current.description == nm_update_igmp_interface_policy.current.description == 'IGMP Interface Policy 2 description updated'
- cm_update_igmp_interface_policy.previous.enableFastLeaveControl == nm_update_igmp_interface_policy.previous.enableFastLeaveControl == true
- cm_update_igmp_interface_policy.current.enableFastLeaveControl == nm_update_igmp_interface_policy.current.enableFastLeaveControl == false
- cm_update_igmp_interface_policy.previous.enableReportLinkLocalGroups == nm_update_igmp_interface_policy.previous.enableReportLinkLocalGroups == true
Expand Down Expand Up @@ -325,7 +327,7 @@
- cm_update_igmp_interface_policy.current.staticReportRouteMapRef == nm_update_igmp_interface_policy.current.staticReportRouteMapRef
- nm_update_igmp_interface_policy_again is not changed
- nm_update_igmp_interface_policy_again.previous.name == nm_update_igmp_interface_policy_again.current.name == 'ansible_igmp_interface_policy_2'
- nm_update_igmp_interface_policy_again.previous.description == nm_update_igmp_interface_policy_again.current.description == 'IGMP Interface Policy description updated'
- nm_update_igmp_interface_policy_again.previous.description == nm_update_igmp_interface_policy_again.current.description == 'IGMP Interface Policy 2 description updated'
- nm_update_igmp_interface_policy_again.previous.enableFastLeaveControl == nm_update_igmp_interface_policy_again.current.enableFastLeaveControl == false
- nm_update_igmp_interface_policy_again.previous.enableReportLinkLocalGroups == nm_update_igmp_interface_policy_again.current.enableReportLinkLocalGroups == false
- nm_update_igmp_interface_policy_again.previous.enableV3Asm == nm_update_igmp_interface_policy_again.current.enableV3Asm == false
Expand Down Expand Up @@ -425,7 +427,7 @@
- cm_delete_igmp_interface_policy.current == nm_delete_igmp_interface_policy.current == {}
- cm_delete_igmp_interface_policy.previous.name == nm_delete_igmp_interface_policy.previous.name == 'ansible_igmp_interface_policy_2_updated'
- cm_delete_igmp_interface_policy.previous.uuid == nm_delete_igmp_interface_policy.previous.uuid
- cm_delete_igmp_interface_policy.previous.description == nm_delete_igmp_interface_policy.previous.description == 'IGMP Interface Policy description updated'
- cm_delete_igmp_interface_policy.previous.description == nm_delete_igmp_interface_policy.previous.description == 'IGMP Interface Policy 2 description updated'
- cm_delete_igmp_interface_policy.previous.enableFastLeaveControl == nm_delete_igmp_interface_policy.previous.enableFastLeaveControl == false
- cm_delete_igmp_interface_policy.previous.enableReportLinkLocalGroups == nm_delete_igmp_interface_policy.previous.enableReportLinkLocalGroups == false
- cm_delete_igmp_interface_policy.previous.enableV3Asm == nm_delete_igmp_interface_policy.previous.enableV3Asm == false
Expand Down

0 comments on commit a038ff4

Please sign in to comment.