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_change] Added new module for IPSLA Track Lists (DCNE-134) #600

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

samiib
Copy link
Collaborator

@samiib samiib commented Jan 22, 2025

Fixes #460

@samiib samiib self-assigned this Jan 22, 2025
@samiib samiib changed the title [minor_change] Added new module for IPSLA Track List. [minor_change] Added new module for IPSLA Track Lists Jan 22, 2025
@github-actions github-actions bot changed the title [minor_change] Added new module for IPSLA Track Lists [minor_change] Added new module for IPSLA Track Lists (DCNE-134) Jan 22, 2025
@samiib samiib added the jira-sync Sync this issue to Jira label Jan 22, 2025
plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
anvitha-jain
anvitha-jain previously approved these changes Jan 22, 2025
Copy link
Collaborator

@anvitha-jain anvitha-jain left a comment

Choose a reason for hiding this comment

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

LGTM

plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
Comment on lines 423 to 471
def get_bd_uuid(mso, schema_obj, template, bd):
# Get template
templates = [t.get("name") for t in schema_obj.get("templates")]
if template not in templates:
mso.fail_json(msg="Provided template '{0}' does not exist. Existing templates: {1}".format(template, ", ".join(templates)))
template_idx = templates.index(template)
# Get BD
bds = [b.get("name") for b in schema_obj.get("templates")[template_idx]["bds"]]
if bd not in bds:
mso.fail_json(msg="Provided BD '{0}' does not exist. Existing BDs: {1}".format(bd, ", ".join(bds)))
return schema_obj.get("templates")[template_idx]["bds"][bds.index(bd)].get("uuid")


def get_l3out_uuid(l3out_template_object, name):
l3outs = l3out_template_object.template.get("l3outTemplate", {}).get("l3outs", [])
match = l3out_template_object.get_object_by_key_value_pairs(
"L3Out",
l3outs,
[KVPair("name", name)],
fail_module=True,
)
if match:
return match.details.get("uuid")


def get_ipsla_monitoring_policy_uuid(tenant_template_obj, uuid, name):
existing_ipsla_policies = tenant_template_obj.template.get("tenantPolicyTemplate", {}).get("template", {}).get("ipslaMonitoringPolicies", [])
match = tenant_template_obj.get_object_by_key_value_pairs(
"IPSLA Monitoring Policy",
existing_ipsla_policies,
[(KVPair("uuid", uuid) if uuid else KVPair("name", name))],
fail_module=True,
)
if match:
return match.details.get("uuid")
Copy link
Collaborator

@akinross akinross Jan 23, 2025

Choose a reason for hiding this comment

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

should we make these functions available in schema.py or template.py or utils.py so we can re-use when needed in other modules?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have updated it to use existing functions for BD and L3Out objects. I added a new function for IPSLA Monitoring policies.

plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
plugins/modules/ndo_ipsla_track_list.py Outdated Show resolved Hide resolved
@samiib samiib requested a review from akinross January 26, 2025 10:44
Comment on lines +93 to +103
ipsla_monitoring_policy_uuid:
description:
- The UUID of the IPSLA Monitoring Policy to use for the member.
- This parameter can be used instead of O(members.ipsla_monitoring_policy).
type: str
ipsla_monitoring_policy:
description:
- The name IPSLA Monitoring Policy to use for the member.
- This parameter can be used instead of O(members.ipsla_monitoring_policy_uuid).
type: str
aliases: [ ipsla_monitoring_policy_name ]
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we decide to input uuid for these nested inputs, should we then do it for all objects that have an uuid? think template in that case also has an uuid.

schema:
description:
- The name of the Schema associated with the BD scope.
- This parameter is only required when the O(members.scope_type) is V(bd).
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
- This parameter is only required when the O(members.scope_type) is V(bd).
- This parameter is only required when the O(members.scope_type=bd).

Comment on lines +312 to +319
mutually_exclusive=[
("ipsla_monitoring_policy_uuid", "ipsla_monitoring_policy"),
("scope_uuid", "scope"),
],
required_one_of=[
("ipsla_monitoring_policy_uuid", "ipsla_monitoring_policy"),
("scope_uuid", "scope"),
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why do we do this here and not for ipsla_track_list_uuid, should we just keep the same precedence order as we do for the other ipsla_track_list_uuid/name. Or should we enforce only 1 is provided?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira-sync Sync this issue to Jira
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhancement: New module for IPSLA Track List Policy in Tenant Tenant Policies Template (DCNE-134)
4 participants