vfModule instanceName is not unique in macro service instantiation template
Our team was trying to instantiate multiple service instances from the same SDC model with macro instantiation.
Now it is not possible, because in macro service instantiation template vfModule instanceName is not unique.
vfModule instanceName is retrieved from SDC model and is common for all service instances.
"vfModules": [
{% for vf_module in vnf.vf_modules %}
{
"modelInfo": {
"modelName": "{{ vf_module.metadata["vfModuleModelName"] }}",
"modelVersionId": "{{ vf_module.metadata["vfModuleModelUUID"] }}",
"modelInvariantUuid": "{{ vf_module.metadata["vfModuleModelInvariantUUID"] }}",
"modelVersion": "{{ vf_module.metadata["vfModuleModelVersion"] }}",
"modelCustomizationId": "{{ vf_module.metadata["vfModuleModelCustomizationUUID"] }}"
},
"instanceName": "{{ vf_module.name }}",
"instanceParams": [
{
{% for vnf_parameter in vnf_parameters %}
{% if vnf_parameter.name == vnf.metadata["name"] %}
{% set mylist = vf_module.name.split('..') %}
{% set item = mylist|length-2 %}
{% for vf_module_parameter in vnf_parameter.vfmodule_parameters %}
{% if vf_module_parameter.name == mylist[item] %}
{% for parameter in vf_module_parameter.vfmodule_parameters %}
"{{ parameter.name }}": "{{ parameter.value }}"{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
}
]
}{% if not loop.last %},{% endif %}
{% endfor %}
]
Issue does not occur for a-la-carte instantiation. vfModule instanceName is defined by user, or if not unique value is generated.
if vf_module_instance_name is None:
vf_module_instance_name = \
f"Python_ONAP_SDK_vf_module_instance_{str(uuid4())}"
I propose two possible solutions:
- Modify only template for macro instantiation and assign to vfModule instanceName value composed of service_instance_name (always unique) and vfmodule name: "instanceName": "{{ service_instance_name }}_{{ vf_module.name }}"}}
- Modify template and add to instanceName suffix, that could be random value generated with uuid4() and passed to template from the instantiation request.
I think the first option is much more smart. What is your opinion?