Update create flow for E2E service 81/43881/2
authorc00149107 <chenchuanyu@huawei.com>
Fri, 20 Apr 2018 09:02:24 +0000 (17:02 +0800)
committerc00149107 <chenchuanyu@huawei.com>
Fri, 20 Apr 2018 11:30:26 +0000 (19:30 +0800)
Update create generic flow for E2E service

Change-Id: I7f5c912348ce0d0ee9035aa3a5e34979ee14b247
Issue-ID: SO-583
Signed-off-by: c00149107 <chenchuanyu@huawei.com>
adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/VfcManager.java
adapters/mso-vfc-adapter/src/main/java/org/openecomp/mso/adapters/vfc/model/NSResourceInputParameter.java
bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnIntegerParam.java [new file with mode: 0644]
bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnRestClient.java
bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/ResourceRecipeRequest.java
bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/resource/ResourceRequestBuilder.java
bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy
bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVFCNSResource.bpmn

index 8e16d1c..0673af2 100644 (file)
@@ -88,7 +88,7 @@ public class VfcManager {
   public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException {
 
     // Step1: get service template by node type
-    String csarId = segInput.getNsOperationKey().getNodeTemplateUUID();
+    String csarId = segInput.getNsServiceModelUUID();
     // nsdId for NFVO is "id" in the response, while for SDNO is "servcice template id"
     LOGGER.info("serviceTemplateId is {}, id is {}", csarId);
 
index 765ee52..d468443 100644 (file)
@@ -45,6 +45,8 @@ public class NSResourceInputParameter {
     private String nsServiceName;
 
     private String nsServiceDescription;
+    
+    private String nsServiceModelUUID;
 
     private NsParameters nsParameters;
 
@@ -136,4 +138,15 @@ public class NSResourceInputParameter {
     public void setNsScaleParameters(NsScaleParameters nsScaleParameters) {
         this.nsScaleParameters = nsScaleParameters;
     }
+
+
+       public String getNsServiceModelUUID() {
+               return nsServiceModelUUID;
+       }
+
+
+       public void setNsServiceModelUUID(String nsServiceModelUUID) {
+               this.nsServiceModelUUID = nsServiceModelUUID;
+       }
+    
 }
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnIntegerParam.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/bpmn/common/recipe/BpmnIntegerParam.java
new file mode 100644 (file)
index 0000000..033c687
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018 Huawei Technologies Co., Ltd. All rights reserved.
+ * ================================================================================
+ * 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
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.mso.bpmn.common.recipe;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+public class BpmnIntegerParam {
+
+       @JsonProperty("value")
+       private int value;
+       @JsonProperty("type")
+       private final String type = "Integer";
+
+       public BpmnIntegerParam() {
+       }
+
+       @JsonProperty("value")
+       public int getValue() {
+               return value;
+       }
+
+       @JsonProperty("type")
+       public void setValue(int value) {
+               this.value = value;
+       }
+
+       @Override
+       public String toString() {
+               return "CamundaInput [value=" + Integer.toString(value) + ", type=" + type + "]";
+       }
+}
index 016afa8..1dc0451 100644 (file)
@@ -115,9 +115,6 @@ public class BpmnRestClient {
 \r
         HttpPost post = new HttpPost(recipeUri);\r
         MsoJavaProperties props = loadMsoProperties();\r
-        RequestConfig requestConfig =\r
-                RequestConfig.custom().setSocketTimeout(recipeTimeout).setConnectTimeout(recipeTimeout).setConnectionRequestTimeout(recipeTimeout).build();\r
-        post.setConfig(requestConfig);\r
         msoLogger.debug("call the bpmn,  url:" + recipeUri);\r
         String jsonReq = wrapResourceRequest(requestId, recipeTimeout, requestAction, serviceInstanceId, serviceType, requestDetails, recipeParamXsd);\r
 \r
@@ -177,6 +174,8 @@ public class BpmnRestClient {
             BpmnParam serviceInstanceIdInput = new BpmnParam();\r
             BpmnParam serviceTypeInput = new BpmnParam();\r
             BpmnParam recipeParamsInput = new BpmnParam();\r
+            BpmnIntegerParam recipeTimeoutInput = new BpmnIntegerParam();\r
+            recipeTimeoutInput.setValue(recipeTimeout);\r
             // host.setValue(parseURL());\r
             requestIdInput.setValue(requestId);\r
             requestActionInput.setValue(requestAction);\r
@@ -191,6 +190,7 @@ public class BpmnRestClient {
             recipeRequest.setServiceType(serviceTypeInput);\r
             recipeRequest.setRecipeParams(recipeParamsInput);\r
             recipeRequest.setResourceInput(resourceInput);\r
+            recipeRequest.setRecipeTimeout(recipeTimeoutInput);\r
             jsonReq = recipeRequest.toString();\r
             msoLogger.debug("request body is " + jsonReq);\r
         } catch(Exception e) {\r
index 5bf5a02..194f7c4 100644 (file)
@@ -56,6 +56,9 @@ public class ResourceRecipeRequest {
     @JsonProperty("recipeParams")
     private BpmnParam recipeParams;
 
+    @JsonProperty("recipeTimeout")
+    private BpmnIntegerParam recipeTimeout;
+    
     @JsonProperty("resourceInput")
     public BpmnParam getResourceInput() {
         return resourceInput;
@@ -126,7 +129,17 @@ public class ResourceRecipeRequest {
         this.recipeParams = recipeParams;
     }
 
-    @Override
+    @JsonProperty("recipeTimeout")
+    public BpmnIntegerParam getRecipeTimeout() {
+               return recipeTimeout;
+       }
+    
+    @JsonProperty("recipeTimeout")
+       public void setRecipeTimeout(BpmnIntegerParam recipeTimeout) {
+               this.recipeTimeout = recipeTimeout;
+       }
+
+       @Override
     public String toString() {
         ObjectMapper mapper = new ObjectMapper();
         mapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
index 9aa1793..636b8b5 100644 (file)
@@ -34,9 +34,6 @@ import org.camunda.bpm.engine.runtime.Execution;
 import org.jboss.resteasy.client.jaxrs.ResteasyClient;
 import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder;
 import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget;
-import org.openecomp.mso.bpmn.core.json.JsonUtils;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
 import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
 import org.onap.sdc.tosca.parser.exceptions.SdcToscaParserException;
 import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
@@ -44,6 +41,10 @@ import org.onap.sdc.toscaparser.api.NodeTemplate;
 import org.onap.sdc.toscaparser.api.Property;
 import org.onap.sdc.toscaparser.api.functions.GetInput;
 import org.onap.sdc.toscaparser.api.parameters.Input;
+import org.openecomp.mso.bpmn.core.PropertyConfiguration;
+import org.openecomp.mso.bpmn.core.json.JsonUtils;
+import org.openecomp.mso.logger.MessageEnum;
+import org.openecomp.mso.logger.MsoLogger;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -55,10 +56,11 @@ public class ResourceRequestBuilder {
 
     public static String CUSTOMIZATION_UUID = "customizationUUID";
 
-    public static String SERVICE_URL_TOSCA_CSAR = "http://mso:8080/ecomp/mso/catalog/v3/serviceToscaCsar?serviceModelUuid=";
+    public static String SERVICE_URL_TOSCA_CSAR = "/v3/serviceToscaCsar?serviceModelUuid=";
 
     private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
 
+   
     static JsonUtils jsonUtil = new JsonUtils();
 
         /**
@@ -179,7 +181,9 @@ public class ResourceRequestBuilder {
     private static String getCsarFromUuid(String uuid) throws Exception {
 
         ResteasyClient client = new ResteasyClientBuilder().build();
-        ResteasyWebTarget target = client.target(SERVICE_URL_TOSCA_CSAR + uuid);
+               Map<String, String> properties = PropertyConfiguration.getInstance().getProperties("mso.bpmn.urn.properties");
+               String catalogEndPoint = properties.get("mso.catalog.db.endpoint");
+               ResteasyWebTarget target = client.target(catalogEndPoint + SERVICE_URL_TOSCA_CSAR + uuid);
         Response response = target.request().get();
         String value = response.readEntity(String.class);
 
index 9456007..ca32420 100644 (file)
@@ -87,10 +87,11 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
            String serviceId = execution.getVariable("serviceInstanceId")\r
            utils.log("INFO", "serviceId:" + serviceId, isDebugEnabled)\r
 \r
-           String operationId = execution.getVariable("requestId")\r
+           String operationId = jsonUtil.getJsonValue(resourceInput, "operationId")\r
            utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)\r
 \r
-           String nodeTemplateUUID = jsonUtil.getJsonValue(resourceParameters, "requestInputs.nsd0_providing_service_uuid")\r
+           String nodeTemplateUUID = jsonUtil.getJsonValue(resourceInput, "resourceModelInfo.modelCustomizationUuid")\r
+           String nsServiceModelUUID = jsonUtil.getJsonValue(resourceParameters, "requestInputs.nsd0_providing_service_uuid")\r
            utils.log("INFO", "nodeTemplateUUID:" + nodeTemplateUUID, isDebugEnabled)\r
            /*\r
             * segmentInformation needed as a object of segment\r
@@ -114,6 +115,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
                     }"""\r
            execution.setVariable("nsOperationKey", nsOperationKey);\r
            execution.setVariable("nsParameters", nsParameters)\r
+           execution.setVariable("nsServiceModelUUID", nsServiceModelUUID);\r
            \r
 \r
        } catch (BpmnError e) {\r
@@ -133,6 +135,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
         def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
         utils.log("INFO"," *****  createNetworkService *****",  isDebugEnabled)\r
         String nsOperationKey = execution.getVariable("nsOperationKey");\r
+        String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID");\r
         String nsParameters = execution.getVariable("nsParameters");\r
         String nsServiceName = execution.getVariable("nsServiceName")\r
         String nsServiceDescription = execution.getVariable("nsServiceDescription")\r
@@ -141,6 +144,7 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
         String reqBody ="""{\r
                 "nsServiceName":"${nsServiceName}",\r
                 "nsServiceDescription":"${nsServiceDescription}",\r
+                "nsServiceModelUUID":"${nsServiceModelUUID}",\r
                 "nsOperationKey":${nsOperationKey},\r
                 "nsParameters":{\r
                      "locationConstraints":${locationConstraints},\r
@@ -305,4 +309,26 @@ public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
         }        \r
         return apiResponse\r
     }\r
+    \r
+       public void sendSyncResponse (DelegateExecution execution) {\r
+               def isDebugEnabled=execution.getVariable("isDebugLogEnabled")\r
+               utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)\r
+\r
+               try {\r
+                       String nsInstanceId = execution.getVariable("nsInstanceId")\r
+                       String operationStatus = execution.getVariable("operationStatus")\r
+                       // RESTResponse for main flow\r
+                       String createVFCResourceRestRsp = """{"nsInstanceId":"${nsInstanceId}","operationStatus":"${operationStatus}"}""".trim()\r
+                       utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createVFCResourceRestRsp, isDebugEnabled)\r
+                       sendWorkflowResponse(execution, 202, createVFCResourceRestRsp)\r
+                       execution.setVariable("sentSyncResponse", true)\r
+\r
+               } catch (Exception ex) {\r
+                       String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()\r
+                       utils.log("DEBUG", msg, isDebugEnabled)\r
+                       exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)\r
+               }\r
+               utils.log("DEBUG"," ***** Exit sendSyncResopnse *****",  isDebugEnabled)\r
+       }\r
+\r
 }\r
index e4254f2..2370165 100644 (file)
@@ -34,10 +34,10 @@ dcsi.instantiateNetworkService(execution)]]></bpmn:script>
       <bpmn:outgoing>createNSFailed_SequenceFlow</bpmn:outgoing>
     </bpmn:exclusiveGateway>
     <bpmn:sequenceFlow id="createNSSuccess_SequenceFlow" name="yes" sourceRef="ExclusiveGateway_0zfksms" targetRef="instantiate_NSTask">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("nsInstanceName" )  != null && execution.getVariable("nsInstanceName" )  != "" )}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("nsInstanceId" )  != null && execution.getVariable("nsInstanceId" )  != "" )}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:sequenceFlow id="createNSFailed_SequenceFlow" name="no" sourceRef="ExclusiveGateway_0zfksms" targetRef="createNSFailed_EndEvent">
-      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("nsInstanceName" )  == null || execution.getVariable("nsInstanceName" )  == "" )}]]></bpmn:conditionExpression>
+      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("nsInstanceId" )  == null || execution.getVariable("nsInstanceId" )  == "" )}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
     <bpmn:exclusiveGateway id="ExclusiveGateway_1is7zys" name="Instantiate NS Success?">
       <bpmn:incoming>SequenceFlow_1ywe21t</bpmn:incoming>
@@ -62,7 +62,7 @@ dcsi.instantiateNetworkService(execution)]]></bpmn:script>
     <bpmn:sequenceFlow id="operationProcessing_SequenceFlow" name="no" sourceRef="ExclusiveGateway_15492gl" targetRef="timeDelay_Task">
       <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression"><![CDATA[#{(execution.getVariable("operationStatus" )  == "processing" )}]]></bpmn:conditionExpression>
     </bpmn:sequenceFlow>
-    <bpmn:sequenceFlow id="SequenceFlow_0cq2q6g" sourceRef="finishNSCreate_Task" targetRef="EndEvent_1x6k78c" />
+    <bpmn:sequenceFlow id="SequenceFlow_0cq2q6g" sourceRef="finishNSCreate_Task" targetRef="ScriptTask_1890l78" />
     <bpmn:endEvent id="createNSFailed_EndEvent" name="createNSFailed">
       <bpmn:incoming>createNSFailed_SequenceFlow</bpmn:incoming>
     </bpmn:endEvent>
@@ -70,7 +70,7 @@ dcsi.instantiateNetworkService(execution)]]></bpmn:script>
       <bpmn:incoming>instantiateFailed_SequenceFlow</bpmn:incoming>
     </bpmn:endEvent>
     <bpmn:endEvent id="EndEvent_1x6k78c">
-      <bpmn:incoming>SequenceFlow_0cq2q6g</bpmn:incoming>
+      <bpmn:incoming>SequenceFlow_1lwqmo9</bpmn:incoming>
     </bpmn:endEvent>
     <bpmn:scriptTask id="queryJob_Task" name="Query NS Progress" scriptFormat="groovy">
       <bpmn:incoming>instantiateSuccess_SequenceFlow</bpmn:incoming>
@@ -80,7 +80,7 @@ dcsi.instantiateNetworkService(execution)]]></bpmn:script>
 def dcsi = new CreateVFCNSResource()
 dcsi.queryNSProgress(execution)]]></bpmn:script>
     </bpmn:scriptTask>
-    <bpmn:scriptTask id="finishNSCreate_Task" name="Finish NS Create">
+    <bpmn:scriptTask id="finishNSCreate_Task" name="Add NS Relationship" scriptFormat="groovy">
       <bpmn:incoming>operationFinished_SequenceFlow</bpmn:incoming>
       <bpmn:outgoing>SequenceFlow_0cq2q6g</bpmn:outgoing>
       <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
@@ -96,6 +96,14 @@ def dcsi = new CreateVFCNSResource()
 dcsi.timeDelay(execution)]]></bpmn:script>
     </bpmn:scriptTask>
     <bpmn:sequenceFlow id="SequenceFlow_1gsbpxj" sourceRef="timeDelay_Task" targetRef="queryJob_Task" />
+    <bpmn:scriptTask id="ScriptTask_1890l78" name="Send Sync Ack Response" scriptFormat="groovy">
+      <bpmn:incoming>SequenceFlow_0cq2q6g</bpmn:incoming>
+      <bpmn:outgoing>SequenceFlow_1lwqmo9</bpmn:outgoing>
+      <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def csi = new  CreateVFCNSResource()
+csi.sendSyncResponse(execution)]]></bpmn:script>
+    </bpmn:scriptTask>
+    <bpmn:sequenceFlow id="SequenceFlow_1lwqmo9" sourceRef="ScriptTask_1890l78" targetRef="EndEvent_1x6k78c" />
   </bpmn:process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_1">
     <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateVFCNSResource">
@@ -192,11 +200,9 @@ dcsi.timeDelay(execution)]]></bpmn:script>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0hftgi6_di" bpmnElement="operationFinished_SequenceFlow">
         <di:waypoint xsi:type="dc:Point" x="1034" y="595" />
-        <di:waypoint xsi:type="dc:Point" x="909" y="595" />
-        <di:waypoint xsi:type="dc:Point" x="909" y="595" />
-        <di:waypoint xsi:type="dc:Point" x="783" y="595" />
+        <di:waypoint xsi:type="dc:Point" x="902" y="595" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="963" y="574" width="19" height="12" />
+          <dc:Bounds x="929.1428571428571" y="574" width="18" height="14" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0omec46_di" bpmnElement="operationProcessing_SequenceFlow">
@@ -208,10 +214,10 @@ dcsi.timeDelay(execution)]]></bpmn:script>
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge id="SequenceFlow_0cq2q6g_di" bpmnElement="SequenceFlow_0cq2q6g">
-        <di:waypoint xsi:type="dc:Point" x="683" y="595" />
-        <di:waypoint xsi:type="dc:Point" x="520" y="595" />
+        <di:waypoint xsi:type="dc:Point" x="802" y="595" />
+        <di:waypoint xsi:type="dc:Point" x="690" y="595" />
         <bpmndi:BPMNLabel>
-          <dc:Bounds x="556.5" y="574" width="90" height="12" />
+          <dc:Bounds x="701" y="574" width="90" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNShape id="EndEvent_1ido9wi_di" bpmnElement="createNSFailed_EndEvent">
@@ -236,7 +242,7 @@ dcsi.timeDelay(execution)]]></bpmn:script>
         <dc:Bounds x="1009" y="271" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape id="ScriptTask_0xxyfku_di" bpmnElement="finishNSCreate_Task">
-        <dc:Bounds x="683" y="555" width="100" height="80" />
+        <dc:Bounds x="802" y="555" width="100" height="80" />
       </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge id="SequenceFlow_0xqo13p_di" bpmnElement="SequenceFlow_0xqo13p">
         <di:waypoint xsi:type="dc:Point" x="1059" y="351" />
@@ -256,6 +262,16 @@ dcsi.timeDelay(execution)]]></bpmn:script>
           <dc:Bounds x="1227" y="352.5" width="0" height="12" />
         </bpmndi:BPMNLabel>
       </bpmndi:BPMNEdge>
+      <bpmndi:BPMNShape id="ScriptTask_1890l78_di" bpmnElement="ScriptTask_1890l78">
+        <dc:Bounds x="590" y="555" width="100" height="80" />
+      </bpmndi:BPMNShape>
+      <bpmndi:BPMNEdge id="SequenceFlow_1lwqmo9_di" bpmnElement="SequenceFlow_1lwqmo9">
+        <di:waypoint xsi:type="dc:Point" x="590" y="595" />
+        <di:waypoint xsi:type="dc:Point" x="520" y="595" />
+        <bpmndi:BPMNLabel>
+          <dc:Bounds x="555" y="573" width="0" height="14" />
+        </bpmndi:BPMNLabel>
+      </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>
 </bpmn:definitions>