Fix serviceInstanceName in Homing 87/48987/1
authorMarcus G K Williams <marcus.williams@intel.com>
Thu, 24 May 2018 16:20:56 +0000 (09:20 -0700)
committerMarcus G K Williams <marcus.williams@intel.com>
Thu, 24 May 2018 16:21:40 +0000 (09:21 -0700)
serviceInstanceName was not set
in CreateVcpeResCustService and not
made available in Homing Flow.

Issue-ID: SO-573
Change-Id: I9d3098aa252ceba139c75a24c71950bab70b14b6
Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/OofUtils.groovy
bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/bpmn/common/OofHomingTest.java
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy
bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVcpeResCustService.bpmn

index 79134fe..f07a477 100644 (file)
@@ -60,13 +60,19 @@ class OofUtils {
         ServiceInstance serviceInstance = decomposition.getServiceInstance()
         def serviceInstanceId = ""
         def serviceInstanceName = ""
-        if (serviceInstance == null) {
-            utils.log("DEBUG", "Unable to obtain Service Instance Id, ServiceInstance Object is null", isDebugEnabled)
+
+        serviceInstanceId = execution.getVariable("serviceInstanceId")
+        serviceInstanceName = execution.getVariable("serviceInstanceName")
+
+        if (serviceInstanceId == null || serviceInstanceId == "null") {
+            utils.log("DEBUG", "Unable to obtain Service Instance Id", isDebugEnabled)
             exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
-                    "obtain Service Instance Id, ServiceInstance Object is null")
-        } else {
-            serviceInstanceId = serviceInstance.getInstanceId()
-            serviceInstanceName = serviceInstance.getInstanceName()
+                    "obtain Service Instance Id, execution.getVariable(\"serviceInstanceName\") is null")
+        }
+        if (serviceInstanceName == null || serviceInstanceName == "null") {
+            utils.log("DEBUG", "Unable to obtain Service Instance Name", isDebugEnabled)
+            exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - Unable to " +
+                    "obtain Service Instance Name, execution.getVariable(\"serviceInstanceName\") is null")
         }
         //Model Info
         ModelInfo model = decomposition.getModelInfo()
@@ -115,7 +121,7 @@ class OofUtils {
                 def resouceModelVersion = resourceModelInfo.getModelVersion()
                 def resouceModelVersionId = resourceModelInfo.getModelUuid()
                 def resouceModelType = resourceModelInfo.getModelType()
-                def tenantId = execution.getTenantId()
+                def tenantId = "" //Optional
                 def requiredCandidatesJson = ""
 
                 requiredCandidatesJson = createCandidateJson(
index 9020701..283f3c6 100644 (file)
@@ -549,7 +549,8 @@ public class OofHomingTest extends WorkflowTest {
         variables.put("isDebugLogEnabled", "true");
         //     variables.put("mso-request-id", "testRequestId");
         variables.put("msoRequestId", "testRequestId");
-        variables.put("serviceInstanceId", "testServiceInstanceId");
+        variables.put("serviceInstanceId", "testServiceInstanceId123");
+        variables.put("serviceInstanceName", "testServiceName");
         variables.put("serviceDecomposition", serviceDecomposition);
         variables.put("subscriberInfo", subscriber2);
     }
@@ -590,7 +591,8 @@ public class OofHomingTest extends WorkflowTest {
         variables.put("cloudRegionId", "TNZED");
         variables.put("isDebugLogEnabled", "true");
         variables.put("msoRequestId", "testRequestId");
-        variables.put("serviceInstanceId", "testServiceInstanceId");
+        variables.put("serviceInstanceId", "testServiceInstanceId123");
+        variables.put("serviceInstanceName", "testServiceName");
         variables.put("serviceDecomposition", serviceDecomposition);
         variables.put("subscriberInfo", subscriber2);
     }
@@ -610,7 +612,8 @@ public class OofHomingTest extends WorkflowTest {
         variables.put("isDebugLogEnabled", "true");
         //     variables.put("mso-request-id", "testRequestId");
         variables.put("msoRequestId", "testRequestId");
-        variables.put("serviceInstanceId", "testServiceInstanceId");
+        variables.put("serviceInstanceId", "testServiceInstanceId123");
+        variables.put("serviceInstanceName", "testServiceName");
         variables.put("serviceDecomposition", null);
         variables.put("subscriberInfo", subscriber2);
     }
@@ -719,16 +722,16 @@ public class OofHomingTest extends WorkflowTest {
                 "{\"globalSubscriberId\":\"SUB12_0322_DS_1201\",\"subscriberName\":\"SUB_12_0322_DS_1201\"," +
                 "\"subscriberCommonSiteId\":\"\"},\"placementDemands\":[{\"resourceModuleName\":\"ALLOTTED_RESOURCE\"" +
                 ",\"serviceResourceId\":\"testResourceIdAR\",\"tenantId\":" +
-                "\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," +
+                "\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR\"," +
                 "\"modelVersionId\":\"testARModelUuid\",\"modelName\":\"testModelNameAR\",\"modelType\":" +
                 "\"testModelTypeAR\",\"modelVersion\":\"testModelVersionAR\",\"modelCustomizationName\":\"\"}}," +
                 "{\"resourceModuleName\":\"ALLOTTED_RESOURCE\",\"serviceResourceId\":\"testResourceIdAR2\"," +
-                "\"tenantId\":\"null\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," +
+                "\"tenantId\":\"\",\"resourceModelInfo\":{\"modelInvariantId\":\"testModelInvariantIdAR2\"," +
                 "\"modelVersionId\":\"testAr2ModelUuid\",\"modelName\":\"testModelNameAR2\"," +
                 "\"modelType\":\"testModelTypeAR2\",\"modelVersion\":\"testModelVersionAR2\"," +
                 "\"modelCustomizationName\":\"\"}}]},\"serviceInfo\":" +
                 "{\"serviceInstanceId\":\"testServiceInstanceId123\"," +
-                "\"serviceName\":\"null\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
+                "\"serviceName\":\"testServiceName\",\"modelInfo\":{\"modelType\":\"\",\"modelInvariantId\":" +
                 "\"testModelInvariantId\",\"modelVersionId\":\"testModelUuid\",\"modelName\":\"testModelName\"," +
                 "\"modelVersion\":\"testModelVersion\",\"modelCustomizationName\":\"" +
                 "\"}}}";
index 694aafc..ce117d3 100644 (file)
@@ -129,6 +129,11 @@ public class CreateVcpeResCustService extends AbstractServiceTaskProcessor {
 
             serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8")
             execution.setVariable("serviceInstanceId", serviceInstanceId)
+            utils.log("DEBUG", "Incoming serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
+
+            String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName")
+            execution.setVariable("serviceInstanceName", serviceInstanceName)
+            utils.log("DEBUG", "Incoming serviceInstanceName is: " + serviceInstanceName, isDebugEnabled)
 
             String requestAction = execution.getVariable("requestAction")
             execution.setVariable("requestAction", requestAction)
index ea48104..9342e34 100644 (file)
@@ -451,6 +451,7 @@ CreateVcpeResCustService.prepareCreateAllottedResourceTXC(execution)]]></bpmn2:s
         <camunda:in source="customerLocation" target="customerLocation" />
         <camunda:in source="cloudOwner" target="cloudOwner" />
         <camunda:in source="cloudRegionId" target="cloudRegionId" />
+        <camunda:in source="serviceInstanceName" target="serviceInstanceName" />
       </bpmn2:extensionElements>
       <bpmn2:incoming>SequenceFlow_11efpvh</bpmn2:incoming>
       <bpmn2:outgoing>SequenceFlow_1jbuf1t</bpmn2:outgoing>