aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSeshu Kumar M <seshu.kumar.m@huawei.com>2017-09-22 09:17:57 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-22 09:17:57 +0000
commite07baf7bb429829483db01706c645adc3673ba92 (patch)
treec6427255a5f2def7bade5bba3cda9e9f71d16d49
parentb543c1cd7eb6f0e879ba15e73fbe6a2d6d45d052 (diff)
parentcae9c021f3b704d3601373d8a2bac70e0ce7b395 (diff)
Merge "Implement the tasks of the workflow"
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy81
1 files changed, 75 insertions, 6 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
index 43a2731eb6..ad0f6bc9b3 100644
--- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
+++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVFCNetworkServiceInstance.groovy
@@ -66,7 +66,12 @@ public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcesso
def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
String msg = ""
utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)
- try {
+ try {
+ //deal with nsName and Description
+ String nsServiceName = execution.getVariable("nsServiceName")
+ String nsServiceDescription = execution.getVariable("nsServiceDescription")
+ utils.log("DEBUG", "nsServiceName:" + nsServiceName + " nsServiceDescription:" + nsServiceDescription, isDebugEnabled)
+ //deal with operation key
String globalSubscriberId = execution.getVariable("globalSubscriberId")
utils.log("DEBUG", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
String serviceType = execution.getVariable("serviceType")
@@ -90,11 +95,12 @@ public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcesso
*/
String siRequest = execution.getVariable("segmentInformation")
utils.log("DEBUG", "Input Request:" + siRequest, isDebugEnabled)
- String nsOperationKey = "{\"globalSubscriberId\":" + globalSubscriberId + ",\"serviceType:\""
- + serviceType + ",\"serviceId\":" + serviceId + ",\"operationId\":" + operationId
- +",\"nodeTemplateUUID\":" + nodeTemplateUUID + "}";
+ String nsOperationKey = "{\"globalSubscriberId\":\"" + globalSubscriberId + "\",\"serviceType:\""
+ + serviceType + "\",\"serviceId\":\"" + serviceId + "\",\"operationId\":\"" + operationId
+ +"\",\"nodeTemplateUUID\":\"" + nodeTemplateUUID + "\"}";
execution.setVariable("nsOperationKey", nsOperationKey);
execution.setVariable("nsParameters", jsonUtil.getJsonValue(siRequest, "nsParameters"))
+
} catch (BpmnError e) {
throw e;
@@ -106,20 +112,82 @@ public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcesso
utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
}
+ /**
+ * create NS task
+ */
public void createNetworkService(Execution execution) {
-
+
+ String nsOperationKey = excution.getVariable("nsOperationKey");
+ String nsParameters = excution.getVariable("nsParameters");
+ String nsServiceName = execution.getVariable("nsServiceName")
+ String nsServiceDescription = execution.getVariable("nsServiceDescription")
+ String reqBody = "{\"nsServiceName\":\"" + nsServiceName + "\",\"nsServiceDescription\":\"" + nsServiceDescription
+ +"\",\"nsOperationKey\":" + nsOperationKey + ",\"nsParameters\":" + nsParameters
+ APIResponse createRsp = postRequest(createUrl, reqBody)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String nsInstanceId = "";
+ if(returnCode== "200"){
+ nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
+ }
+ execution.setVariable("nsInstanceId", nsInstanceId)
+
}
+ /**
+ * instantiate NS task
+ */
public void instantiateNetworkService(Execution execution) {
+ String nsOperationKey = excution.getVariable("nsOperationKey");
+ String nsParameters = excution.getVariable("nsParameters");
+ String nsServiceName = execution.getVariable("nsServiceName")
+ String nsServiceDescription = execution.getVariable("nsServiceDescription")
+ String reqBody = "{\"nsServiceName\":\"" + nsServiceName + "\",\"nsServiceDescription\":\"" + nsServiceDescription
+ +"\",\"nsOperationKey\":" + nsOperationKey + ",\"nsParameters\":" + nsParameters
+ String url = instantiateUrl.replaceAll("{nsInstanceId}", execution.getVariable("nsInstanceId"))
+ APIResponse createRsp = postRequest(url, reqBody)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String jobId = "";
+ if(returnCode== "200"){
+ jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
+ }
+ execution.setVariable("jobId", nsInstanceId)
}
+ /**
+ * query NS task
+ */
public void queryNSProgress(Execution execution) {
+ String jobId = execution.getVariable("jobId")
+ String nsOperationKey = excution.getVariable("nsOperationKey");
+ String url = queryJobUrl.replaceAll("{jobId}", execution.getVariable("jobId"))
+ APIResponse createRsp = postRequest(url, nsOperationKey)
+ String returnCode = apiResponse.getStatusCode()
+ String aaiResponseAsString = apiResponse.getResponseBodyAsString()
+ String operationStatus = "error"
+ if(returnCode== "200"){
+ operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
+ }
+ exection.setVariable("operationStatus", operationStatus)
}
+ /**
+ * delay 5 sec
+ */
public void timeDelay(Execution execution) {
+ try {
+ Thread.sleep(5000);
+ } catch(InterruptedException e) {
+ taskProcessor.utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
+ }
}
+ /**
+ * finish NS task
+ */
public void finishNSCreate(Execution execution) {
+ //no need to do anything util now
}
/**
@@ -136,11 +204,12 @@ public class CreateGenericE2EServiceInstance extends AbstractServiceTaskProcesso
RESTConfig config = new RESTConfig(url);
RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/json");
apiResponse = client.httpPost(requestBody)
+ taskProcessor.logDebug( "response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString(), isDebugEnabled)
taskProcessor.logDebug( "======== Completed Execute VF-C adapter Post Process ======== ", isDebugEnabled)
}catch(Exception e){
taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
throw new BpmnError("MSOWorkflowException")
- }
+ }
return apiResponse
}
}