Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[minor_changes] Adding new module for physical interface (DCNE-50) #560

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions plugins/module_utils/mso.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,19 @@ def write_file(module, url, dest, content, resp, tmpsrc=None):
os.remove(tmpsrc)


def format_interface_descriptions(interface_descriptions, node=None):
formated_interface_descriptions = [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
formated_interface_descriptions = [
formatted_interface_descriptions = [

{
"nodeID": node if node is not None else interface_description.get("node"),
"interfaceID": interface_description.get("interface_id", interface_description.get("interfaceID")),
"description": interface_description.get("description"),
}
for interface_description in interface_descriptions
]

return formated_interface_descriptions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return formated_interface_descriptions
return formatted_interface_descriptions



class MSOModule(object):
def __init__(self, module):
self.module = module
Expand Down
13 changes: 13 additions & 0 deletions plugins/module_utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def get_object_by_key_value_pairs(self, object_description, search_list, kv_list
:param fail_module: When match is not found fail the ansible module. -> Bool
:return: The object. -> Dict | None
"""
if search_list is None or kv_list is None:
return None
match, existing = self.get_object_from_list(search_list, kv_list)
if not match and fail_module:
msg = "Provided {0} with '{1}' not matching existing object(s): {2}".format(object_description, kv_list, ", ".join(existing))
Expand Down Expand Up @@ -207,3 +209,14 @@ def get_l3out_node_routing_policy_object(self, uuid=None, name=None, fail_module
"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

def get_interface_policy_group_uuid(self, interface_policy_group):
"""
Get the UUID of an Interface Policy Group by name.
:param interface_policy_group: Name of the Interface Policy Group to search for -> Str
:return: UUID of the Interface Policy Group. -> Str
"""
existing_policy_groups = self.template.get("fabricPolicyTemplate", {}).get("template", {}).get("interfacePolicyGroups", [])
kv_list = [KVPair("name", interface_policy_group)]
match = self.get_object_by_key_value_pairs("Interface Policy Groups", existing_policy_groups, kv_list, fail_module=True)
return match.details.get("uuid")
Loading
Loading