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

Add a new module to manage Port Channel Interfaces in Fabric Resource Policies Template. (DCNE-52) #539

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
15 changes: 15 additions & 0 deletions plugins/module_utils/mso.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,21 @@ def write_file(module, url, dest, content, resp, tmpsrc=None):
os.remove(tmpsrc)


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

Choose a reason for hiding this comment

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

Do we use this function in mso.py? If not, move it to the module.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we will be using it in three different modules, Physical, Port Channel and VPC interfaces. that's why it's currently in mso.py as the default script to place our generic functions.

if interface_descriptions:
formated_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
]
else:
formated_interface_descriptions = []
return formated_interface_descriptions


class MSOModule(object):
def __init__(self, module):
self.module = module
Expand Down
11 changes: 11 additions & 0 deletions plugins/module_utils/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,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