diff --git a/plugins/module_utils/template.py b/plugins/module_utils/template.py index 8e39002f..55d235b4 100644 --- a/plugins/module_utils/template.py +++ b/plugins/module_utils/template.py @@ -189,16 +189,21 @@ def get_vrf_object(self, vrf_dict, tenant_id, templates_objects_path): else: self.mso.fail_json(msg="Provided VRF {0} not found.".format(vrf_dict.get("name"))) - def get_l3out_node_routing_policy_object(self, uuid, name): + def get_l3out_node_routing_policy_object(self, uuid=None, name=None, fail_module=False): """ - Get the L3Out Node Routing Policy by uuid or name. + Get the L3Out Node Routing Policy by UUID or Name. :param uuid: UUID of the L3Out Node Routing Policy to search for -> Str :param name: Name of the L3Out Node Routing Policy to search for -> Str - :return: The L3Out Node Routing Policy object. -> Str + :param fail_module: When match is not found fail the ansible module -> Bool + :return: Dict | None | List[Dict] | List[]: The processed result which could be: + When the UUID | Name is existing in the search list -> Dict + When the UUID | Name is not existing in the search list -> None + When both UUID and Name are None, and the search list is not empty -> List[Dict] + When both UUID and Name are None, and the search list is empty -> List[] """ existing_l3out_node_routing_policy = self.template.get("tenantPolicyTemplate", {}).get("template", {}).get("l3OutNodePolGroups", []) if uuid or name: # Query a specific object return self.get_object_by_key_value_pairs( - "L3Out Node Routing Policy", existing_l3out_node_routing_policy, [KVPair("uuid", uuid) if uuid else KVPair("name", name)] + "L3Out Node Routing Policy", existing_l3out_node_routing_policy, [KVPair("uuid", uuid) if uuid else KVPair("name", name)], fail_module ) return existing_l3out_node_routing_policy # Query all objects diff --git a/plugins/modules/ndo_l3out_node_routing_policy.py b/plugins/modules/ndo_l3out_node_routing_policy.py index c882cbf6..5cfb4c19 100644 --- a/plugins/modules/ndo_l3out_node_routing_policy.py +++ b/plugins/modules/ndo_l3out_node_routing_policy.py @@ -177,7 +177,7 @@ username: admin password: SomeSecretPassword template: ansible_tenant_template - uuid: "{{ nrp_2.current.uuid }} + uuid: "{{ nrp_2.current.uuid }}" name: nrp_2_updated bgp_node_settings: graceful_restart_helper: disabled