diff options
author | Aleem Raja <aleem.raja@t-systems.com> | 2022-08-10 21:20:12 +0530 |
---|---|---|
committer | Aleem Raja <aleem.raja@t-systems.com> | 2022-08-10 21:20:23 +0530 |
commit | ea65e0397e030bbd0a685f473b1c8416dd0a82f3 (patch) | |
tree | fc6acc9c4dbf23856ea3c21beb09478db5ebd5b6 /mso-api-handlers/mso-api-handler-infra/src/main/java | |
parent | b0f785e99096f230281d17e0fa89c21aca00fbac (diff) |
Multiple PNFs with same ModelInfo but different instance name not able to be instantiated
When instantiating a service with multiple PNFs, SO differentiates them using ModelCustomizationId. This causes issues when creating multiple instances of same model resource, and each lookup would return the same object.
With this patch, Instead of using ModelCustomizationId, we enable SO to use instanceName parameter to differentiate the PNFs.
Issue-ID: SO-3948
Signed-off-by: Aleem Raja <aleem.raja@t-systems.com>
Change-Id: I9dd039ac786a60f7cf4d4a9c456c7681f64d6786
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java')
-rw-r--r-- | mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java index 8646a74a2f..728d4df4ee 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/validation/UserParamsValidation.java @@ -34,6 +34,7 @@ import org.onap.so.apihandlerinfra.Actions; import org.onap.so.exceptions.ValidationException; import org.onap.so.serviceinstancebeans.ModelInfo; import org.onap.so.serviceinstancebeans.Networks; +import org.onap.so.serviceinstancebeans.Pnfs; import org.onap.so.serviceinstancebeans.Service; import org.onap.so.serviceinstancebeans.VfModules; import org.onap.so.serviceinstancebeans.Vnfs; @@ -116,6 +117,29 @@ public class UserParamsValidation implements ValidationRule { validateDuplicateInstanceNames(vnfCustomIdToInstanceNames, "vnf"); validateDuplicateInstanceNames(vfModuleCustomIdToInstanceNames, "vfModule"); + Map<String, Set<String>> pnfCustomIdToInstanceNames = new HashMap<>(); + + for (Pnfs pnf : validate.getResources().getPnfs()) { + if (pnf.getModelInfo() == null) { + throw new ValidationException("modelInfo in userParams pnf resources", true); + } else if (pnf.getModelInfo().getModelCustomizationId() == null) { + throw new ValidationException("modelCustomizationId in userParams pnf resources", true); + } else if (pnf.getModelInfo().getModelVersionId() == null) { + throw new ValidationException("modelVersionId in userParams pnf resources", true); + } + String pnfCustomizationId = pnf.getModelInfo().getModelCustomizationId(); + pnfCustomIdToInstanceNames.putIfAbsent(pnfCustomizationId, new HashSet<>()); + String pnfInstanceName = StringUtils.defaultString(pnf.getInstanceName()); + Set<String> pnfVisitedInstanceNames = pnfCustomIdToInstanceNames.get(pnfCustomizationId); + if (!pnfVisitedInstanceNames.add(pnfInstanceName)) { + throw new ValidationException( + "instanceName: same instanceName with same modelCustomizationId in userParams pnf resources", + true); + } + } + + validateDuplicateInstanceNames(pnfCustomIdToInstanceNames, "pnf"); + List<Networks> validateNetworks = new ArrayList<>(); validateNetworks = validate.getResources().getNetworks(); if (validateNetworks != null) { |