aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy182
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateSDNCNetworkResource.bpmn90
2 files changed, 163 insertions, 109 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
index d2d93d5568..072c3810c2 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy
@@ -24,9 +24,12 @@ import static org.apache.commons.lang3.StringUtils.*;
import groovy.xml.XmlUtil
import groovy.json.*
import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
+import org.openecomp.mso.bpmn.common.recipe.ResourceInput;
+import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder
import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.core.json.JsonUtils
+import org.openecomp.mso.bpmn.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
import org.openecomp.mso.rest.APIResponse
import java.util.UUID;
@@ -46,99 +49,116 @@ import org.openecomp.mso.rest.APIResponse;
*/
public class CreateSDNCCNetworkResource extends AbstractServiceTaskProcessor {
- String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
- String host = "http://mso.mso.testlab.openecomp.org:8080"
-
+ String Prefix="CRESDNCRES_"
+
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
+ public void preProcessRequest(DelegateExecution execution){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled)
+ try {
+
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("requestId")
+ String requestAction = execution.getVariable("requestAction")
+ utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ utils.log("INFO","The recipeParams is: " + recipeParams, isDebugEnabled)
+ String resourceInput = execution.getVariable("requestInput")
+ utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled)
+ //Get ResourceInput Object
+ ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, resourceInputObj)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+
+ //Deal with recipeParams
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+ String resourceName = resourceInputObj.getResourceInstanceName()
+ //For sdnc requestAction default is "createNetworkInstance"
+ String operationType = "Network"
+ if(!StringUtils.isBlank(recipeParamsFromRequest)){
+ //the operationType from worflow(first node) is second priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType")
+ }
+ if(!StringUtils.isBlank(recipeParamsFromWf)){
+ //the operationType from worflow(first node) is highest priority.
+ operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
+ }
+
+
+ //For sdnc, generate svc_action and request_action
+ String sdnc_svcAction = "create"
+ if(StringUtils.containsIgnoreCase(resourceInputObj.getResourceInstanceName(), "overlay")){
+ //This will be resolved in R3.
+ sdnc_svcAction ="activate"
+ operationType = "NCINetwork"
+ }
+ if(StringUtils.containsIgnoreCase(resourceInputObj.getResourceInstanceName(), "underlay")){
+ //This will be resolved in R3.
+ operationType ="Network"
+ }
+ String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance"
+ execution.setVariable(Prefix + "svcAction", sdnc_svcAction)
+ execution.setVariable(Prefix + "requestAction", sdnc_requestAction)
+ execution.setVariable(Prefix + "serviceInstanceId", resourceInputObj.getServiceInstanceId())
+ execution.setVariable("mso-request-id", requestId)
+ execution.setVariable("mso-service-instance-id", resourceInputObj.getServiceInstanceId())
+ //TODO Here build networkrequest
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception ex){
+ msg = "Exception in preProcessRequest " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
+
/**
* Pre Process the BPMN Flow Request
* Inclouds:
* generate the nsOperationKey
* generate the nsParameters
*/
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String msg = ""
- utils.log("INFO", " *** preProcessRequest() *** ", isDebugEnabled)
- try {
- //deal with nsName and Description
- String nsServiceName = execution.getVariable("nsServiceName")
- String nsServiceDescription = execution.getVariable("nsServiceDescription")
- utils.log("INFO", "nsServiceName:" + nsServiceName + " nsServiceDescription:" + nsServiceDescription, isDebugEnabled)
- //deal with operation key
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
- String serviceType = execution.getVariable("serviceType")
- utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
- String serviceId = execution.getVariable("serviceId")
- utils.log("INFO", "serviceId:" + serviceId, isDebugEnabled)
- String operationId = execution.getVariable("operationId")
- utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
- String nodeTemplateUUID = execution.getVariable("resourceUUID")
- utils.log("INFO", "nodeTemplateUUID:" + nodeTemplateUUID, isDebugEnabled)
- /*
- * segmentInformation needed as a object of segment
- * {
- * "domain":"",
- * "nodeTemplateName":"",
- * "nodeType":"",
- * "nsParameters":{
- * //this is the nsParameters sent to VF-C
- * }
- * }
- */
- String nsParameters = execution.getVariable("resourceParameters")
- utils.log("INFO", "nsParameters:" + nsParameters, isDebugEnabled)
- String nsOperationKey = """{
- "globalSubscriberId":"${globalSubscriberId}",
- "serviceType":"${serviceType}",
- "serviceId":"${serviceId}",
- "operationId":"${operationId}",
- "nodeTemplateUUID":"${nodeTemplateUUID}"
- }"""
- execution.setVariable("nsOperationKey", nsOperationKey);
- execution.setVariable("nsParameters", nsParameters)
-
+ public void prepareSDNCRequest (DelegateExecution execution) {
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled)
+
+ try {
+ // get variables
+ String sdnc_svcAction = execution.getVariable(Prefix + "svcAction")
+ String sdnc_requestAction = execution.getVariable(Prefix + "requestAction")
+ String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback")
+ String createNetworkInput = execution.getVariable(Prefix + "networkRequest")
+
+ String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
+
+ // 1. prepare assign topology via SDNC Adapter SUBFLOW call
+ String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, sdnc_svcAction, sdnc_requestAction, null, null, null)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- msg = "Exception in preProcessRequest " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled)
+ String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
+ utils.logAudit(sndcTopologyCreateRequesAsString)
+ execution.setVariable(Prefix + "createSDNCRequest", sndcTopologyCreateRequesAsString)
+ utils.log("DEBUG", Prefix + "createSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString, isDebugEnabled)
+
+ } catch (Exception ex) {
+ String exceptionMessage = " Bpmn error encountered in CreateSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
+ utils.log("DEBUG", exceptionMessage, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+ utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled)
}
-
- /**
- * post request
- * url: the url of the request
- * requestBody: the body of the request
- */
- private APIResponse postRequest(DelegateExecution execution, String url, String requestBody){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Started Execute VFC adapter Post Process *****", isDebugEnabled)
- utils.log("INFO","url:"+url +"\nrequestBody:"+ requestBody, isDebugEnabled)
- APIResponse apiResponse = null
- try{
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("Content-Type", "application/json").addHeader("Accept","application/json").addHeader("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk");
- apiResponse = client.httpPost(requestBody)
- utils.log("INFO","response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString(), isDebugEnabled)
- utils.log("INFO","======== Completed Execute VF-C adapter Post Process ======== ", isDebugEnabled)
- }catch(Exception e){
- utils.log("ERROR","Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- return apiResponse
- }
-
public void postCreateSDNCCall(DelegateExecution execution){
+ def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
+ utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled)
+ String responseCode = execution.getVariable(Prefix + "sdncCreateReturnCode")
+ String responseObj = execution.getVariable(Prefix + "SuccessIndicator")
+ utils.log("INFO","response from sdnc, response code :" + responseCode + " response object :" + responseObj, isDebugEnabled)
+ utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled)
}
}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateSDNCNetworkResource.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateSDNCNetworkResource.bpmn
index c88f78763b..34ab27c6c7 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateSDNCNetworkResource.bpmn
+++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateSDNCNetworkResource.bpmn
@@ -4,26 +4,26 @@
<bpmn:startEvent id="createNS_StartEvent" name="createNS_StartEvent">
<bpmn:outgoing>SequenceFlow_1qo2pln</bpmn:outgoing>
</bpmn:startEvent>
- <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="PreprocessIncomingRequest_task" />
+ <bpmn:sequenceFlow id="SequenceFlow_1qo2pln" sourceRef="createNS_StartEvent" targetRef="Task_1dlrfiw" />
<bpmn:sequenceFlow id="SequenceFlow_0khtova" sourceRef="PreprocessIncomingRequest_task" targetRef="CallActivity_1600xlj" />
- <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="Preprocess Incoming Request" scriptFormat="groovy">
- <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming>
+ <bpmn:scriptTask id="PreprocessIncomingRequest_task" name="prepare SDNC Request" scriptFormat="groovy">
+ <bpmn:incoming>SequenceFlow_18l3crb</bpmn:incoming>
<bpmn:outgoing>SequenceFlow_0khtova</bpmn:outgoing>
<bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
def dcsi = new CreateSDNCNetworkResource()
-dcsi.preProcessRequest(execution)]]></bpmn:script>
+dcsi.prepareSDNCRequest(execution)]]></bpmn:script>
</bpmn:scriptTask>
<bpmn:endEvent id="EndEvent_1x6k78c" name="create SDNC call end">
<bpmn:incoming>SequenceFlow_0ow44q0</bpmn:incoming>
</bpmn:endEvent>
<bpmn:callActivity id="CallActivity_1600xlj" name="Call SDNC RSRC Create&#10; Adapter V1&#10;" calledElement="sdncAdapter">
<bpmn:extensionElements>
- <camunda:in source="CRENWKI_activateSDNCRequest" target="sdncAdapterWorkflowRequest" />
+ <camunda:in source="CRESDNCRES_activateSDNCRequest" target="sdncAdapterWorkflowRequest" />
<camunda:in source="mso-request-id" target="mso-request-id" />
<camunda:in source="mso-service-instance-id" target="mso-service-instance-id" />
<camunda:out source="sdncAdapterResponse" target="CRENWKI_activateSDNCResponse" />
- <camunda:out source="SDNCA_ResponseCode" target="CRENWKI_sdncActivateReturnCode" />
- <camunda:out source="SDNCA_SuccessIndicator" target="SDNCA_SuccessIndicator" />
+ <camunda:out source="SDNCA_ResponseCode" target="CRESDNCRES_sdncCreateReturnCode" />
+ <camunda:out source="SDNCA_SuccessIndicator" target="CRESDNCRES_SuccessIndicator" />
<camunda:out source="WorkflowException" target="WorkflowException" />
</bpmn:extensionElements>
<bpmn:incoming>SequenceFlow_0khtova</bpmn:incoming>
@@ -38,59 +38,93 @@ dcsi.preProcessRequest(execution)]]></bpmn:script>
def dcsi = new CreateSDNCNetworkResource()
dcsi.postCreateSDNCCall(execution)]]></bpmn:script>
</bpmn:scriptTask>
+ <bpmn:sequenceFlow id="SequenceFlow_0w2es8j" sourceRef="Task_1dlrfiw" targetRef="Task_13sx2bp" />
+ <bpmn:sequenceFlow id="SequenceFlow_18l3crb" sourceRef="Task_13sx2bp" targetRef="PreprocessIncomingRequest_task" />
+ <bpmn:scriptTask id="Task_1dlrfiw" name="Set the Recipe DesignTimeParam" scriptFormat="groovy">
+ <bpmn:incoming>SequenceFlow_1qo2pln</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_0w2es8j</bpmn:outgoing>
+ <bpmn:script><![CDATA[String recipeParamXsdDemo="""{"operationType":"GRE"}"""
+String recipeParamXsd=""
+execution.setVariable("recipeParamXsd", recipeParamXsd)]]></bpmn:script>
+ </bpmn:scriptTask>
+ <bpmn:scriptTask id="Task_13sx2bp" name="Pre Process Request" scriptFormat="groovy">
+ <bpmn:incoming>SequenceFlow_0w2es8j</bpmn:incoming>
+ <bpmn:outgoing>SequenceFlow_18l3crb</bpmn:outgoing>
+ <bpmn:script><![CDATA[import org.openecomp.mso.bpmn.infrastructure.scripts.*
+def dcsi = new CreateSDNCNetworkResource()
+dcsi.preProcessRequest(execution)]]></bpmn:script>
+ </bpmn:scriptTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="CreateSDNCNetworkResource">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="createNS_StartEvent">
- <dc:Bounds x="175" y="111" width="36" height="36" />
+ <dc:Bounds x="80" y="111" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="152" y="147" width="83" height="24" />
+ <dc:Bounds x="57" y="147" width="83" height="24" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1qo2pln_di" bpmnElement="SequenceFlow_1qo2pln">
- <di:waypoint xsi:type="dc:Point" x="211" y="129" />
- <di:waypoint xsi:type="dc:Point" x="251" y="129" />
- <di:waypoint xsi:type="dc:Point" x="251" y="129" />
- <di:waypoint xsi:type="dc:Point" x="293" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="116" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="185" y="129" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="266" y="123" width="0" height="12" />
+ <dc:Bounds x="105.5" y="108" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0khtova_di" bpmnElement="SequenceFlow_0khtova">
- <di:waypoint xsi:type="dc:Point" x="393" y="129" />
- <di:waypoint xsi:type="dc:Point" x="544" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="677" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="739" y="129" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="423.5" y="108" width="90" height="12" />
+ <dc:Bounds x="663" y="108" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_03j6ogo_di" bpmnElement="PreprocessIncomingRequest_task">
- <dc:Bounds x="293" y="89" width="100" height="80" />
+ <dc:Bounds x="577" y="89" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="EndEvent_15pcuuc_di" bpmnElement="EndEvent_1x6k78c">
- <dc:Bounds x="951" y="111" width="36" height="36" />
+ <dc:Bounds x="1079" y="111" width="36" height="36" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="912" y="153" width="85" height="24" />
+ <dc:Bounds x="1040" y="153" width="85" height="24" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="CallActivity_1600xlj_di" bpmnElement="CallActivity_1600xlj">
- <dc:Bounds x="544" y="89" width="100" height="80" />
+ <dc:Bounds x="739" y="89" width="100" height="80" />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="SequenceFlow_1xk5xed_di" bpmnElement="SequenceFlow_1xk5xed">
- <di:waypoint xsi:type="dc:Point" x="644" y="129" />
- <di:waypoint xsi:type="dc:Point" x="800" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="839" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="902" y="129" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="677" y="108" width="90" height="12" />
+ <dc:Bounds x="825.5" y="108" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="SequenceFlow_0ow44q0_di" bpmnElement="SequenceFlow_0ow44q0">
- <di:waypoint xsi:type="dc:Point" x="900" y="129" />
- <di:waypoint xsi:type="dc:Point" x="951" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="1002" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="1079" y="129" />
<bpmndi:BPMNLabel>
- <dc:Bounds x="880.5" y="108" width="90" height="12" />
+ <dc:Bounds x="995.5" y="108" width="90" height="12" />
</bpmndi:BPMNLabel>
</bpmndi:BPMNEdge>
<bpmndi:BPMNShape id="ScriptTask_0gyej62_di" bpmnElement="Task_023hred">
- <dc:Bounds x="800" y="89" width="100" height="80" />
+ <dc:Bounds x="902" y="89" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNEdge id="SequenceFlow_0w2es8j_di" bpmnElement="SequenceFlow_0w2es8j">
+ <di:waypoint xsi:type="dc:Point" x="285" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="385" y="129" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="335" y="108" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNEdge id="SequenceFlow_18l3crb_di" bpmnElement="SequenceFlow_18l3crb">
+ <di:waypoint xsi:type="dc:Point" x="485" y="129" />
+ <di:waypoint xsi:type="dc:Point" x="577" y="129" />
+ <bpmndi:BPMNLabel>
+ <dc:Bounds x="531" y="108" width="0" height="12" />
+ </bpmndi:BPMNLabel>
+ </bpmndi:BPMNEdge>
+ <bpmndi:BPMNShape id="ScriptTask_0lc6l7a_di" bpmnElement="Task_1dlrfiw">
+ <dc:Bounds x="185" y="89" width="100" height="80" />
+ </bpmndi:BPMNShape>
+ <bpmndi:BPMNShape id="ScriptTask_14l9mlv_di" bpmnElement="Task_13sx2bp">
+ <dc:Bounds x="385" y="89" width="100" height="80" />
</bpmndi:BPMNShape>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>