-
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
Replaced the ndo modules current value with actual API response value (DCNE-185) #589
base: master
Are you sure you want to change the base?
Replaced the ndo modules current value with actual API response value (DCNE-185) #589
Conversation
8c27fc9
to
39d30ea
Compare
2240b6b
to
5943cf6
Compare
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
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
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
076d777
… response value and fixed the output value of the ndo_route_map_policy_multicast and ndo_vlan_pool modules
…current portion of the ndo_l3_domain module
076d777
to
1590fde
Compare
1590fde
to
284f9f2
Compare
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.
Sanity's failing on compiling for Python 2.7
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_dhcp_option_policy(mso_template, uuid=None, name=None, fail_module=False): | ||
""" | ||
Get the DHCP Option Policy by UUID or Name. | ||
:param uuid: UUID of the DHCP Option Policy to search for -> Str | ||
:param name: Name of the DHCP Option Policy to search for -> 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[] | ||
""" |
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.
just a quick question about consistency: this get_object
function has a description in this module but the other get_object
functions doesn't have any description in the following modules. I think they should all have a description or none but up to you to decide
l3outs = mso_template.template.get("l3outTemplate", {}).get("l3outs", []) | ||
object_description = "L3Out" | ||
|
||
if state in ["query", "absent"] and l3outs == []: | ||
mso.exit_json() | ||
elif state == "query" and not (name or uuid): | ||
mso.existing = l3outs | ||
if l3outs: | ||
mso.existing = [insert_l3out_relation_name(l3out, mso_template) for l3out in l3outs] | ||
elif l3outs and (name or uuid): | ||
match = l3out_template_object.get_object_by_key_value_pairs(object_description, l3outs, [KVPair("uuid", uuid) if uuid else KVPair("name", name)]) | ||
match = mso_template.get_object_by_key_value_pairs(object_description, l3outs, [KVPair("uuid", uuid) if uuid else KVPair("name", name)]) | ||
if match: | ||
mso.existing = mso.previous = copy.deepcopy(match.details) | ||
mso.existing = mso.previous = copy.deepcopy(insert_l3out_relation_name(match.details, mso_template)) |
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.
Again a quick question about consistency here: you did not create a get_object
function because of the extra conditional statement:
if state in ["query", "absent"] and l3outs == []:
mso.exit_json()
elif state == "query" and not (name or uuid):
the issue is we should be as consistent as possible across all similar modules. So should we remove these extra conditional statements (they have a slight advantage but nothing that impactful) and add these get_object
you were adding to older modules, or should we keep it that way but that means applying the same thing to other modules? I don't know which one is best but I would really appreciate having a discussion on the logic we want to have
) | ||
|
||
if "importRouteMapRef" in l3out_object: | ||
if check_mode: | ||
l3out_object["importRouteMapName"] = get_template_object_name_by_uuid(mso_template.mso, "routeMap", l3out_object["importRouteMapRef"]) | ||
else: | ||
l3out_object["importRouteMapName"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
l3out_object["importRouteMapRef"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
|
||
advanced_route_maps = l3out_object.get("advancedRouteMapRefs") | ||
if advanced_route_maps is not None: | ||
if "attachedHostRouteRedistRef" in advanced_route_maps: | ||
if check_mode: | ||
l3out_object["advancedRouteMapRefs"]["attachedHostRouteRedistName"] = get_template_object_name_by_uuid( | ||
mso_template.mso, "routeMap", advanced_route_maps["attachedHostRouteRedistRef"] | ||
) | ||
else: | ||
l3out_object["advancedRouteMapRefs"]["attachedHostRouteRedistName"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
advanced_route_maps["attachedHostRouteRedistRef"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
|
||
if "connectedRouteRedistRef" in advanced_route_maps: | ||
if check_mode: | ||
l3out_object["advancedRouteMapRefs"]["connectedRouteRedistName"] = get_template_object_name_by_uuid( | ||
mso_template.mso, "routeMap", advanced_route_maps["connectedRouteRedistRef"] | ||
) | ||
else: | ||
l3out_object["advancedRouteMapRefs"]["connectedRouteRedistName"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
advanced_route_maps["connectedRouteRedistRef"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
|
||
if "interleakRef" in advanced_route_maps: | ||
if check_mode: | ||
l3out_object["advancedRouteMapRefs"]["interleakName"] = get_template_object_name_by_uuid( | ||
mso_template.mso, "routeMap", advanced_route_maps["interleakRef"] | ||
) | ||
else: | ||
l3out_object["advancedRouteMapRefs"]["interleakName"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
advanced_route_maps["interleakRef"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
|
||
if "routeDampeningV4Ref" in advanced_route_maps: | ||
if check_mode: | ||
l3out_object["advancedRouteMapRefs"]["routeDampeningV4Name"] = get_template_object_name_by_uuid( | ||
mso_template.mso, "routeMap", advanced_route_maps["routeDampeningV4Ref"] | ||
) | ||
else: | ||
l3out_object["advancedRouteMapRefs"]["routeDampeningV4Name"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
advanced_route_maps["routeDampeningV4Ref"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
|
||
if "routeDampeningV6Ref" in advanced_route_maps: | ||
if check_mode: | ||
l3out_object["advancedRouteMapRefs"]["routeDampeningV6Name"] = get_template_object_name_by_uuid( | ||
mso_template.mso, "routeMap", advanced_route_maps["routeDampeningV6Ref"] | ||
) | ||
else: | ||
l3out_object["advancedRouteMapRefs"]["routeDampeningV6Name"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
advanced_route_maps["routeDampeningV6Ref"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
|
||
if "staticRouteRedistRef" in advanced_route_maps: | ||
if check_mode: | ||
l3out_object["advancedRouteMapRefs"]["staticRouteRedistName"] = get_template_object_name_by_uuid( | ||
mso_template.mso, "routeMap", advanced_route_maps["staticRouteRedistRef"] | ||
) | ||
else: | ||
l3out_object["advancedRouteMapRefs"]["staticRouteRedistName"] = get_name_by_key_value( | ||
mso_template, | ||
"Route Map", | ||
advanced_route_maps["staticRouteRedistRef"], | ||
"ref", | ||
l3out_relations.get("relations", {}).get("identities", {}).get("routeMapPolicies", []), | ||
) | ||
return l3out_object |
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 like the idea of inserting name for referenced objects but that's huge amount of API calls in one module, how impactful is it on runtime when you tested?
Note:
Fixed the below NDO modules: