-
Notifications
You must be signed in to change notification settings - Fork 33
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
2c1cdce
to
02aa230
Compare
…ed shared ipsla monitoring policy function.
2639627
to
8f03fc8
Compare
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 ] |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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). |
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"), | ||
], |
There was a problem hiding this comment.
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?
Fixes #460