From eb4051c7e1ae99cb0301ddafc1b6cf0fd78c98a6 Mon Sep 17 00:00:00 2001 From: subhash kumar singh Date: Mon, 6 Aug 2018 19:02:06 +0530 Subject: Implementation for DeactivateSDNCNetworkResource Implementation for DeactivateSDNCNetworkResource. Change-Id: If94af643665788ca110d91c1770839d18dcad3f7 Issue-ID: SO-689 Signed-off-by: subhash kumar singh --- .../scripts/ActivateSDNCNetworkResource.groovy | 1 + .../scripts/DeActivateSDNCNetworkResource.groovy | 169 +++++++++++++++++++++ 2 files changed, 170 insertions(+) (limited to 'bpmn/so-bpmn-infrastructure-flows/src/main/groovy/org') 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 = + """ + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(sdnc_svcAction)} + network-topology-operation + sdncCallback + generic-resource + + + + ${MsoUtils.xmlEscape(hdrRequestId)} + ${MsoUtils.xmlEscape(sdnc_requestAction)} + ${MsoUtils.xmlEscape(source)} + + + + + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(serviceType)} + + ${MsoUtils.xmlEscape(serviceModelInvariantUuid)} + ${MsoUtils.xmlEscape(serviceModelUuid)} + ${MsoUtils.xmlEscape(serviceModelVersion)} + ${MsoUtils.xmlEscape(serviceModelName)} + + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(globalCustomerId)} + + + + ${MsoUtils.xmlEscape(modelInvariantUuid)} + ${MsoUtils.xmlEscape(modelCustomizationUuid)} + ${MsoUtils.xmlEscape(modelUuid)} + ${MsoUtils.xmlEscape(modelVersion)} + ${MsoUtils.xmlEscape(modelName)} + + + + + + + """.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 = """ + + + + + ${MsoUtils.xmlEscape(operType)} + ${MsoUtils.xmlEscape(operationId)} + ${MsoUtils.xmlEscape(progress)} + ${MsoUtils.xmlEscape(resourceCustomizationUuid)} + ${MsoUtils.xmlEscape(serviceInstanceId)} + ${MsoUtils.xmlEscape(status)} + ${MsoUtils.xmlEscape(statusDescription)} + + + """; + + 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) { -- cgit 1.2.3-korg