Support instantiation of same model vnfs/vf-modules
[so.git] / bpmn / MSOCommonBPMN / src / main / java / org / onap / so / client / cds / VnfCDSRequestProvider.java
index d33976d..5f63732 100644 (file)
@@ -4,6 +4,8 @@
  * ================================================================================
  * Copyright (C) 2019 Bell Canada
  * ================================================================================
+ * Modifications Copyright (c) 2020 Tech Mahindra
+ * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -21,6 +23,7 @@
 package org.onap.so.client.cds;
 
 import com.google.gson.JsonObject;
+import org.apache.commons.lang3.StringUtils;
 import org.onap.so.bpmn.common.BuildingBlockExecution;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
@@ -79,8 +82,8 @@ public class VnfCDSRequestProvider implements CDSRequestProvider {
             final String modelCustomizationUuid = genericVnf.getModelInfoGenericVnf().getModelCustomizationUuid();
 
             resolutionKey = genericVnf.getVnfName();
-            blueprintName = genericVnf.getBlueprintName();
-            blueprintVersion = genericVnf.getBlueprintVersion();
+            blueprintName = genericVnf.getModelInfoGenericVnf().getBlueprintName();
+            blueprintVersion = genericVnf.getModelInfoGenericVnf().getBlueprintVersion();
 
             vnfObject.addProperty("service-instance-id", serviceInstance.getServiceInstanceId());
             vnfObject.addProperty("service-model-uuid", serviceInstance.getModelInfoServiceInstance().getModelUuid());
@@ -91,9 +94,11 @@ public class VnfCDSRequestProvider implements CDSRequestProvider {
             final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock();
             List<Map<String, Object>> userParamsFromRequest =
                     buildingBlock.getRequestContext().getRequestParameters().getUserParams();
-
-            configureInstanceParamsForVnf.populateInstanceParams(vnfObject, userParamsFromRequest,
-                    modelCustomizationUuid);
+            String vnfInstanceName = execution.getLookupMap().getOrDefault(ResourceKey.VNF_INSTANCE_NAME, "");
+            if (userParamsFromRequest != null && userParamsFromRequest.size() != 0) {
+                configureInstanceParamsForVnf.populateInstanceParams(vnfObject, userParamsFromRequest,
+                        modelCustomizationUuid, vnfInstanceName);
+            }
         } catch (Exception e) {
             throw new PayloadGenerationException("Failed to buildPropertyObjectForVnf", e);
         }