Skip to content

Commit 0406c59

Browse files
shrsrlhercot
authored andcommitted
[ignore] Changes to update_config_with_template_and_references() in template.py with appropriate argument name
1 parent 4e17b98 commit 0406c59

File tree

1 file changed

+37
-44
lines changed

1 file changed

+37
-44
lines changed

plugins/module_utils/template.py

Lines changed: 37 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -335,16 +335,14 @@ def get_template_object_by_uuid(self, object_type, uuid, fail_module=True):
335335
self.mso.fail_json(msg=msg)
336336
return response_object
337337

338-
def update_config_with_template_and_references(self, config_data, reference_dict=None):
338+
def update_config_with_template_and_references(self, config_data, reference_collections=None):
339339
"""
340-
Return the updated config_data with the template values and reference_dict if provided
341-
340+
Return the updated config_data with the template values and reference_collections if provided
342341
:param config_data: The original config_data that requires to be updated -> Dict
343-
:param reference_dict: A dict containing the object type, references and the corresponding names -> Dict
342+
:param reference_collections: A dict containing the object type, references and the corresponding names -> Dict
344343
:return: Updated config_data with names for references -> Dict
345-
346344
Example 1:
347-
reference_dict = {
345+
reference_collections = {
348346
"qos": {
349347
"name": "qosName",
350348
"reference": "qosRef",
@@ -360,28 +358,25 @@ def update_config_with_template_and_references(self, config_data, reference_dict
360358
"templateId": "interfaceRoutingPolicyTemplateId",
361359
},
362360
}
363-
364361
config_data = {
365362
"qosRef": "unique-qos-id",
366363
"interfaceRoutingPolicyRef": "unique-interface-id"
367364
}
368-
369-
updated_config_data = MSOHandler.set_names_for_references(mso_instance, config_data, reference_dict)
370-
# Expected Output:
371-
# { "templateName": "template_name",
372-
# "templateId": "unique-template-id",
373-
# "qosRef": "unique-qos-id",
374-
# "interfaceRoutingPolicyRef": "unique-interface-id",
375-
# "qosName": "Resolved QoS Name",
376-
# "qosTemplateName": "Resolved QoS Template Name",
377-
# "qosTemplateId": "Resolved QoS Template ID",
378-
# "interfaceRoutingPolicyName": "Resolved Interface Routing Policy Name",
379-
# "interfaceRoutingPolicyTemplateName": "Resolved Interface Routing Policy Template Name",
380-
# "interfaceRoutingPolicyTemplateId": "Resolved Interface Routing Policy Template ID"
381-
# }
382-
365+
updated_config_data = mso_template_object.set_names_for_references(mso_instance, config_data, reference_collections)
366+
Expected Output:
367+
{ "templateName": "template_name",
368+
"templateId": "unique-template-id",
369+
"qosRef": "unique-qos-id",
370+
"interfaceRoutingPolicyRef": "unique-interface-id",
371+
"qosName": "Resolved QoS Name",
372+
"qosTemplateName": "Resolved QoS Template Name",
373+
"qosTemplateId": "Resolved QoS Template ID",
374+
"interfaceRoutingPolicyName": "Resolved Interface Routing Policy Name",
375+
"interfaceRoutingPolicyTemplateName": "Resolved Interface Routing Policy Template Name",
376+
"interfaceRoutingPolicyTemplateId": "Resolved Interface Routing Policy Template ID"
377+
}
383378
Example 2:
384-
reference_dict = {
379+
reference_collections = {
385380
"stateLimitRouteMap": {
386381
"name": "stateLimitRouteMapName",
387382
"reference": "stateLimitRouteMapRef",
@@ -398,21 +393,19 @@ def update_config_with_template_and_references(self, config_data, reference_dict
398393
"type": "mcastRouteMap"
399394
},
400395
}
401-
402396
config_data = {
403397
"stateLimitRouteMapRef": "unique-state-limit-id",
404398
"reportPolicyRouteMapRef": "unique-report-policy-id"
405399
}
406-
407-
updated_config_data = MSOHandler.set_names_for_references(mso_instance, config_data, reference_dict)
408-
# Expected Output:
409-
# { "templateName": "template_name",
410-
# "templateId": "unique-template-id",
411-
# "stateLimitRouteMapRef": "unique-state-limit-id",
412-
# "reportPolicyRouteMapRef": "unique-report-policy-id",
413-
# "stateLimitRouteMapName": "Resolved State Limit Route Map Name",
414-
# "reportPolicyRouteMapName": "Resolved Report Policy Route Map Name"
415-
# }
400+
updated_config_data = mso_template_object.set_names_for_references(mso_instance, config_data, reference_collections)
401+
Expected Output:
402+
{ "templateName": "template_name",
403+
"templateId": "unique-template-id",
404+
"stateLimitRouteMapRef": "unique-state-limit-id",
405+
"reportPolicyRouteMapRef": "unique-report-policy-id",
406+
"stateLimitRouteMapName": "Resolved State Limit Route Map Name",
407+
"reportPolicyRouteMapName": "Resolved Report Policy Route Map Name"
408+
}
416409
"""
417410

418411
# Set template ID and template name if available
@@ -421,16 +414,16 @@ def update_config_with_template_and_references(self, config_data, reference_dict
421414
if self.template_name:
422415
config_data["templateName"] = self.template_name
423416

424-
# Update config data with reference names if reference_dict is provided
425-
if reference_dict:
426-
for object_values in reference_dict.values():
427-
if config_data.get(object_values.get("reference")):
428-
template_object = self.get_template_object_by_uuid(object_values.get("type"), config_data.get(object_values.get("reference")))
429-
config_data[object_values.get("name")] = template_object.get("name")
430-
if object_values.get("template"):
431-
config_data[object_values.get("template")] = template_object.get("templateName")
432-
if object_values.get("templateId"):
433-
config_data[object_values.get("templateId")] = template_object.get("templateId")
417+
# Update config data with reference names if reference_collections is provided
418+
if reference_collections:
419+
for reference_details in reference_collections.values():
420+
if config_data.get(reference_details.get("reference")):
421+
template_object = self.get_template_object_by_uuid(reference_details.get("type"), config_data.get(reference_details.get("reference")))
422+
config_data[reference_details.get("name")] = template_object.get("name")
423+
if reference_details.get("template"):
424+
config_data[reference_details.get("template")] = template_object.get("templateName")
425+
if reference_details.get("templateId"):
426+
config_data[reference_details.get("templateId")] = template_object.get("templateId")
434427
return config_data
435428

436429
def check_template_when_name_is_provided(self, parameter):

0 commit comments

Comments
 (0)