aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org
diff options
context:
space:
mode:
authorsubhash kumar singh <subhash.kumar.singh@huawei.com>2018-08-06 19:02:06 +0530
committersubhash kumar singh <subhash.kumar.singh@huawei.com>2018-08-06 19:15:41 +0530
commiteb4051c7e1ae99cb0301ddafc1b6cf0fd78c98a6 (patch)
treef0675e87395718d9d093071a1bf7fd3a6d983dd1 /bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org
parent32e6529145ef77a8189b3a5316f5de509bbe7ac7 (diff)
Implementation for DeactivateSDNCNetworkResource
Implementation for DeactivateSDNCNetworkResource. Change-Id: If94af643665788ca110d91c1770839d18dcad3f7 Issue-ID: SO-689 Signed-off-by: subhash kumar singh <subhash.kumar.singh@huawei.com>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org')
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy1
-rw-r--r--bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy169
2 files changed, 170 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
index e034393151..69e973d7c3 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy
@@ -78,6 +78,7 @@ public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor {
operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType")
}
+ // TODO: based on the resource type decide action and operation type
String sdnc_svcAction = "activate"
operationType = "SOTNConnectivity"
diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
index 913c82fc58..31bda63a49 100644
--- a/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
+++ b/bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeActivateSDNCNetworkResource.groovy
@@ -50,18 +50,187 @@ public class DeActivateSDNCNetworkResource extends AbstractServiceTaskProcessor
public void preProcessRequest(DelegateExecution execution) {
msoLogger.info(" ***** started preProcessRequest*****")
+
+ try {
+
+ //get bpmn inputs from resource request.
+ String requestId = execution.getVariable("mso-request-id")
+ String requestAction = execution.getVariable("requestAction")
+ msoLogger.info("The requestAction is: " + requestAction)
+ String recipeParamsFromRequest = execution.getVariable("recipeParams")
+ msoLogger.info("The recipeParams is: " + recipeParamsFromRequest)
+ String resourceInput = execution.getVariable("resourceInput")
+ msoLogger.info("The resourceInput is: " + resourceInput)
+ //Get ResourceInput Object
+ org.onap.so.bpmn.common.recipe.ResourceInput resourceInputObj = org.onap.so.bpmn.common.resource.ResourceRequestBuilder.getJsonObject(resourceInput, org.onap.so.bpmn.common.recipe.ResourceInput.class)
+ execution.setVariable(Prefix + "resourceInput", resourceInputObj)
+
+ //Deal with recipeParams
+ String recipeParamsFromWf = execution.getVariable("recipeParamXsd")
+ String resourceModelName = resourceInputObj.getResourceModelInfo().getModelName()
+ //For sdnc requestAction default is "NetworkInstance"
+ String operationType = "Network"
+ if(!StringUtils.isBlank(recipeParamsFromRequest) && "null" != 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")
+ }
+
+
+ // TODO: based on the resource type decide action and operation type
+ String sdnc_svcAction = "deactivate"
+ operationType = "SOTNConnectivity"
+
+ 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()
+ msoLogger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
}
public void prepareSDNCRequest(DelegateExecution execution) {
msoLogger.info(" ***** started prepareSDNCRequest *****")
+
+ 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 deleteNetworkInput = execution.getVariable(Prefix + "networkRequest")
+
+ String hdrRequestId = execution.getVariable("mso-request-id")
+ String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
+ String source = execution.getVariable("source")
+ String sdnc_service_id = execution.getVariable(Prefix + "sdncServiceId")
+ org.onap.so.bpmn.common.recipe.ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String serviceType = resourceInputObj.getServiceType()
+ String serviceModelInvariantUuid = resourceInputObj.getServiceModelInfo().getModelInvariantUuid()
+ String serviceModelUuid = resourceInputObj.getServiceModelInfo().getModelUuid()
+ String serviceModelVersion = resourceInputObj.getServiceModelInfo().getModelVersion()
+ String serviceModelName = resourceInputObj.getServiceModelInfo().getModelName()
+ String globalCustomerId = resourceInputObj.getGlobalSubscriberId()
+ String modelInvariantUuid = resourceInputObj.getResourceModelInfo().getModelInvariantUuid();
+ String modelCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String modelUuid = resourceInputObj.getResourceModelInfo().getModelUuid()
+ String modelName = resourceInputObj.getResourceModelInfo().getModelName()
+ String modelVersion = resourceInputObj.getResourceModelInfo().getModelVersion()
+ // 1. prepare assign topology via SDNC Adapter SUBFLOW call
+ String sndcTopologyDeleteRequest =
+ """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.onap.so/workflow/sdnc/adapter/schema/v1"
+ xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${MsoUtils.xmlEscape(hdrRequestId)}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${MsoUtils.xmlEscape(sdnc_svcAction)}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>network-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${MsoUtils.xmlEscape(hdrRequestId)}</request-id>
+ <request-action>${MsoUtils.xmlEscape(sdnc_requestAction)}</request-action>
+ <source>${MsoUtils.xmlEscape(source)}</source>
+ <notification-url></notification-url>
+ <order-number></order-number>
+ <order-version></order-version>
+ </request-information>
+ <service-information>
+ <service-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-id>
+ <subscription-service-type>${MsoUtils.xmlEscape(serviceType)}</subscription-service-type>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(serviceModelInvariantUuid)}</model-invariant-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(serviceModelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(serviceModelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(serviceModelName)}</model-name>
+ </onap-model-information>
+ <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
+ <global-customer-id>${MsoUtils.xmlEscape(globalCustomerId)}</global-customer-id>
+ </service-information>
+ <network-information>
+ <onap-model-information>
+ <model-invariant-uuid>${MsoUtils.xmlEscape(modelInvariantUuid)}</model-invariant-uuid>
+ <model-customization-uuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</model-customization-uuid>
+ <model-uuid>${MsoUtils.xmlEscape(modelUuid)}</model-uuid>
+ <model-version>${MsoUtils.xmlEscape(modelVersion)}</model-version>
+ <model-name>${MsoUtils.xmlEscape(modelName)}</model-name>
+ </onap-model-information>
+ </network-information>
+ <network-request-input>
+ <network-input-parameters></network-input-parameters>
+ </network-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </aetgt:SDNCAdapterWorkflowRequest>""".trim()
+
+ String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest)
+ utils.logAudit(sndcTopologyDeleteRequesAsString)
+ execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyDeleteRequesAsString)
+ msoLogger.info("sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString)
+
+ } catch (Exception ex) {
+ String exceptionMessage = " Bpmn error encountered in DeleteSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage()
+ msoLogger.debug(exceptionMessage)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+ msoLogger.info(" ***** Exit prepareSDNCRequest *****")
}
public void prepareUpdateAfterDeActivateSDNCResource(DelegateExecution execution) {
msoLogger.info("***** started prepareUpdateAfterDeActivateSDNCResource *****")
+
+ ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput")
+ String operType = resourceInputObj.getOperationType()
+ String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid()
+ String serviceInstanceId = resourceInputObj.getServiceInstanceId()
+ String operationId = resourceInputObj.getOperationId()
+ String progress = "100"
+ String status = "finished"
+ String statusDescription = "SDCN resource delete completed"
+
+ //String operationId = execution.getVariable("operationId")
+
+ String body = """
+ <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
+ xmlns:ns="http://org.onap.so/requestsdb">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateResourceOperationStatus>
+ <operType>${MsoUtils.xmlEscape(operType)}</operType>
+ <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
+ <progress>${MsoUtils.xmlEscape(progress)}</progress>
+ <resourceTemplateUUID>${MsoUtils.xmlEscape(resourceCustomizationUuid)}</resourceTemplateUUID>
+ <serviceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceId>
+ <status>${MsoUtils.xmlEscape(status)}</status>
+ <statusDescription>${MsoUtils.xmlEscape(statusDescription)}</statusDescription>
+ </ns:updateResourceOperationStatus>
+ </soapenv:Body>
+ </soapenv:Envelope>""";
+
+ setProgressUpdateVariables(execution, body)
}
public void postDeactivateSDNCCall(DelegateExecution execution) {
msoLogger.info(" ***** started postDeactivateSDNCCall *****")
+ String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode")
+ String responseObj = execution.getVariable(Prefix + "SuccessIndicator")
+
+ msoLogger.info("response from sdnc, response code :" + responseCode + " response object :" + responseObj)
+ msoLogger.info(" ***** Exit prepareSDNCRequest *****")
}
public void sendSyncResponse(DelegateExecution execution) {