diff options
author | 2018-07-30 15:56:09 -0400 | |
---|---|---|
committer | 2018-07-31 11:09:25 -0400 | |
commit | 5a6a6de6f1a26a1897e4917a0df613e25a24eb70 (patch) | |
tree | 59a968f27b4b603aacc9d5e7b51fb598aeec5321 /bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso | |
parent | b6dc38501f3b746426b42d9de4cc883d894149e8 (diff) |
Containerization feature of SO
Change-Id: I95381232eeefcd247a66a5cec370a8ce1c288e18
Issue-ID: SO-670
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso')
82 files changed, 0 insertions, 39626 deletions
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy deleted file mode 100644 index e2a2de66d0..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ActivateSDNCNetworkResource.groovy +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - 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.infrastructure.scripts - -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils - -/** - * This groovy class supports the <class>ActivateSDNCCNetworkResource.bpmn</class> process. - * flow for SDNC Network Resource Activate - */ -public class ActivateSDNCNetworkResource extends AbstractServiceTaskProcessor { - - String Prefix = "ACTSDNCRES_" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - JsonUtils jsonUtil = new JsonUtils() - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started preProcessRequest *****", isDebugEnabled) - } - - public void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** started prepareUpdateAfterActivateSDNCResource *****", isDebugEnabled) - } - - public void postCreateSDNCCall(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** started postCreateSDNCCall *****", isDebugEnabled) - } - - public void sendSyncResponse(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** started sendSyncResponse *****", isDebugEnabled) - } -}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy deleted file mode 100644 index 3652d56303..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CompareModelofE2EServiceInstance.groovy +++ /dev/null @@ -1,278 +0,0 @@ -/*- - * ============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.infrastructure.scripts; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.domain.CompareModelsResult -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource -/** - * This groovy class supports the <class>CompareModelofE2EServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - * @param - subscriptionServiceType - * @param - serviceInstanceId - * @param - modelInvariantIdTarget - * @param - modelVersionIdTarget - - * - * Outputs: - * @param - WorkflowException - */ -public class CompareModelofE2EServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="CMPMDSI_" - private static final String DebugFlag = "isDebugEnabled" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - - utils.log("INFO", " *** preProcessRequest Request *** ", isDebugEnabled) - - try { - // check for incoming json message/input - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("INFO", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)) { - msg = "Input serviceInstanceId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - utils.log("INFO", msg, isDebugEnabled) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //subscriptionServiceType - String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("serviceType", subscriptionServiceType) - } - - //modelInvariantIdTarget - String modelInvariantIdTarget = jsonUtil.getJsonValue(siRequest, "modelInvariantIdTarget") - if (isBlank(modelInvariantIdTarget)) { - msg = "Input modelInvariantIdTarget' is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("modelInvariantIdTarget", modelInvariantIdTarget) - } - - //modelVersionIdTarget - String modelVersionIdTarget = jsonUtil.getJsonValue(siRequest, "modelVersionIdTarget") - if (isBlank(modelVersionIdTarget)) { - msg = "Input modelVersionIdTarget is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("modelVersionIdTarget", modelVersionIdTarget) - } - - execution.setVariable("operationType", "CompareModel") - - } 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) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - CompareModelsResult compareModelsResult = execution.getVariable("compareModelsResult") - - // RESTResponse (for API Handler(APIH) Reply Task) - String syncResponse = compareModelsResult.toJsonStringNoRootName() - utils.log("INFO", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse: " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("INFO", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareCompletionRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>COMPAREMODEL</action> - <source>${source}</source> - </request-info> - <aetgt:status-message>E2E Service Instance Compare model successfully.</aetgt:status-message> - <aetgt:mso-bpel-name>CompareModelofE2EServiceInstance</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("completionRequest", xmlMsoCompletionRequest) - utils.log("INFO", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("INFO", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>COMPAREMODEL</action> - <source>${source}</source> - </request-info>""" - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("INFO", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in CompareModelofE2EServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>COMPAREMODEL</action> - <source>UUI</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("INFO", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } - -} - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateActivateSDNCResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateActivateSDNCResource.groovy deleted file mode 100644 index e5f52a7406..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateActivateSDNCResource.groovy +++ /dev/null @@ -1,425 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - 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.infrastructure.scripts - -import org.json.JSONObject -import org.json.XML; - -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.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.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.infrastructure.workflow.service.ServicePluginFactory -import java.util.UUID; - -import org.camunda.bpm.engine.runtime.Execution -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -/** - * This groovy class supports the <class>CreateActivateSDNCResource.bpmn</class> process. - * flow for SDNC Network Resource Create - */ -public class CreateActivateSDNCResource extends AbstractServiceTaskProcessor { - - String Prefix="CRESDNCRES_" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - JsonUtils jsonUtil = new JsonUtils() - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - 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("mso-request-id") - String requestAction = execution.getVariable("requestAction") - utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled) - String recipeParamsFromRequest = execution.getVariable("recipeParams") - utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled) - String resourceInput = execution.getVariable("resourceInput") - utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled) - //Get ResourceInput Object - ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class) - 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" - String apiType = "network" - if(!StringUtils.isBlank(recipeParamsFromRequest)){ - //the operationType from worflow(first node) is second priority. - operationType = jsonUtil.getJsonValue(recipeParamsFromRequest, "operationType") - apiType = jsonUtil.getJsonValue(recipeParamsFromRequest, "apiType") - } - if(!StringUtils.isBlank(recipeParamsFromWf)){ - //the operationType from worflow(first node) is highest priority. - operationType = jsonUtil.getJsonValue(recipeParamsFromWf, "operationType") - apiType = jsonUtil.getJsonValue(recipeParamsFromRequest, "apiType") - } - - execution.setVariable(Prefix + "operationType", operationType) - execution.setVariable(Prefix + "apiType", apiType) - 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){ - String msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - - String customizeResourceParam(String netowrkInputParametersJson) { - List<Map<String, Object>> paramList = new ArrayList(); - JSONObject jsonObject = new JSONObject(netowrkInputParametersJson); - Iterator iterator = jsonObject.keys(); - while (iterator.hasNext()) { - String key = iterator.next(); - HashMap<String, String> hashMap = new HashMap(); - hashMap.put("name", key); - hashMap.put("value", jsonObject.get(key)) - paramList.add(hashMap) - } - Map<String, List<Map<String, Object>>> paramMap = new HashMap(); - paramMap.put("param", paramList); - - return new JSONObject(paramMap).toString(); - } - - public void prepareSDNCRequest (DelegateExecution execution) { - String svcAction = "create" - prepareSDNCRequestReq(execution, svcAction, "") - } - - - public void prepareSDNCActivateRequest (DelegateExecution execution) { - String svcAction = "activate" - String sndcResourceId = execution.getVariable(Prefix + "sdncResourceId") - prepareSDNCRequestReq(execution, svcAction, sndcResourceId) - } - /** - * Pre Process the BPMN Flow Request - * Inclouds: - * generate the nsOperationKey - * generate the nsParameters - */ - public void prepareSDNCRequestReq (DelegateExecution execution, String svcAction, String sdncResourceId) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled) - - try { - // get variables - String operationType = execution.getVariable(Prefix + "operationType") - String sdnc_apiType = execution.getVariable(Prefix + "apiType") - String sdnc_svcAction = svcAction - String sdnc_requestAction = StringUtils.capitalize(sdnc_svcAction) + operationType +"Instance" - - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = 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") - 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() - String resourceInputPrameters = resourceInputObj.getResourceParameters() - String netowrkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs") - //here convert json string to xml string - String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(netowrkInputParametersJson))) - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${sdnc_svcAction}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${sdnc_apiType}-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${hdrRequestId}</request-id> - <request-action>${sdnc_requestAction}</request-action> - <source>${source}</source> - <notification-url></notification-url> - <order-number></order-number> - <order-version></order-version> - </request-information> - <service-information> - <service-id>${serviceInstanceId}</service-id> - <subscription-service-type>${serviceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid> - <model-uuid>${serviceModelUuid}</model-uuid> - <model-version>${serviceModelVersion}</model-version> - <model-name>${serviceModelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <${sdnc_apiType}-information> - <${sdnc_apiType}-id>${sdncResourceId}</${sdnc_apiType}-id> - <onap-model-information> - <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> - <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid> - <model-uuid>${modelUuid}</model-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - </${sdnc_apiType}-information> - <${sdnc_apiType}-request-input> - <${sdnc_apiType}-input-parameters>${netowrkInputParameters}</${sdnc_apiType}-input-parameters> - </${sdnc_apiType}-request-input> - </sdncadapterworkflow:SDNCRequestData> - </aetgt:SDNCAdapterWorkflowRequest>""".trim() - - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyCreateRequesAsString) - execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString) - utils.log("INFO","sdncAdapterWorkflowRequest :" + sndcTopologyCreateRequesAsString, isDebugEnabled) - utils.log("DEBUG","sdncAdapterWorkflowRequest - " + "\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) - } - - private void setProgressUpdateVariables(DelegateExecution execution, String body) { - def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - execution.setVariable("CVFMI_updateResOperStatusRequest", body) - } - - public void prepareUpdateBeforeCreateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareUpdateBeforeCreateSDNCResource *****", isDebugEnabled) - - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String operType = resourceInputObj.getOperationType() - String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String ServiceInstanceId = resourceInputObj.getServiceInstanceId() - String operationId = resourceInputObj.getOperationId() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String progress = "20" - String status = "processing" - String statusDescription = "Create " + modelName - - execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${ServiceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - utils.log("INFO"," ***** End prepareUpdateBeforeCreateSDNCResource *****", isDebugEnabled) - } - - public void postCreateSDNC(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - ServicePluginFactory.getInstance().test() - utils.log("INFO"," ***** Started postCreateSDNC *****", isDebugEnabled) - String sdnc_apiType = execution.getVariable(Prefix + "apiType") - String sdncAdapterResponse = execution.getVariable("sdncAdapterResponse") - utils.log("INFO","sdncAdapterResponse for create:" + sdncAdapterResponse , isDebugEnabled) - sdncAdapterResponse = sdncAdapterResponse.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "") - sdncAdapterResponse = sdncAdapterResponse.replaceAll('tag0:', '').replaceAll(':tag0', '') - utils.log("INFO","sdncAdapterResponse for create after replace:" + sdncAdapterResponse , isDebugEnabled) - //if it is vnf we need to query the vnf-id,if it is network , we need to query the network-id - String sdncRespData = utils.getNodeText1(sdncAdapterResponse, "RequestData") - utils.log("INFO","sdncRespData:" + sdncRespData , isDebugEnabled) - String objectKey = "/" + sdnc_apiType + "/" - String objectDataKey = "/" + sdnc_apiType + "-data/" - String objectPath = utils.getNodeText1(sdncRespData, "object-path") - - String resourceObjId = objectPath.substring(objectPath.indexOf(objectKey) + objectKey.length(), objectPath.indexOf(objectDataKey)) - utils.log("INFO", "resourceObjId:" + resourceObjId, isDebugEnabled) - execution.setVariable(Prefix + "sdncResourceId", resourceObjId) - - utils.log("INFO"," ***** End postCreateSDNC *****", isDebugEnabled) - - } - - public void postActivateSDNC(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started postActivateSDNC *****", isDebugEnabled) - String sdncAdapterResponse = execution.getVariable("sdncAdapterResponse") - utils.log("INFO","sdncAdapterResponse for activate:" + sdncAdapterResponse , isDebugEnabled) - utils.log("INFO"," ***** End postActivateSDNC *****", isDebugEnabled) - } - - public void prepareUpdateAfterCreateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareUpdateAfterCreateSDNCResource *****", isDebugEnabled) - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String operType = resourceInputObj.getOperationType() - String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String ServiceInstanceId = resourceInputObj.getServiceInstanceId() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String operationId = resourceInputObj.getOperationId() - String progress = "50" - String status = "processing" - String statusDescription = "Instantiate " + modelName - - execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${ServiceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - utils.log("INFO"," ***** End prepareUpdateAfterCreateSDNCResource *****", isDebugEnabled) - } - - public void prepareUpdateAfterActivateSDNCResource(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareUpdateAfterActivateSDNCResource *****", isDebugEnabled) - ResourceInput resourceInputObj = execution.getVariable(Prefix + "resourceInput") - String operType = resourceInputObj.getOperationType() - String resourceCustomizationUuid = resourceInputObj.getResourceModelInfo().getModelCustomizationUuid() - String ServiceInstanceId = resourceInputObj.getServiceInstanceId() - String modelName = resourceInputObj.getResourceModelInfo().getModelName() - String operationId = resourceInputObj.getOperationId() - String progress = "100" - String status = "finished" - String statusDescription = "Instantiate " + modelName + " finished" - - execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${ServiceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - utils.log("INFO"," ***** End prepareUpdateAfterActivateSDNCResource *****", isDebugEnabled) - } - - 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) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String operationStatus = "finished" - // RESTResponse for main flow - String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled) - sendWorkflowResponse(execution, 202, resourceOperationResp) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy deleted file mode 100644 index 3903e12ba2..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateCustomE2EServiceInstance.groovy +++ /dev/null @@ -1,344 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 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.infrastructure.scripts;
-
-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.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-
-/**
- * This groovy class supports the <class>CreateServiceInstance.bpmn</class> process.
- * AlaCarte flow for 1702 ServiceInstance Create
- *
- */
-public class CreateCustomE2EServiceInstance extends AbstractServiceTaskProcessor {
- String Prefix="CRESI_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
-
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- String msg = ""
- utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled)
-
- try {
-
- String siRequest = execution.getVariable("bpmnRequest")
- utils.logAudit(siRequest)
-
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
- utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled)
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- if (isBlank(serviceInstanceId)) {
- serviceInstanceId = UUID.randomUUID().toString()
- }
- utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled)
- serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceInstanceId)
-
- //subscriberInfo
- String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId")
- if (isBlank(globalSubscriberId)) {
- msg = "Input globalSubscriberId' is null"
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- }
-
- //requestInfo
- execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source"))
- execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName"))
- execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback"))
- String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId")
- if (isBlank(productFamilyId))
- {
- msg = "Input productFamilyId is null"
- utils.log("DEBUG", msg, isDebugEnabled)
- //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("productFamilyId", productFamilyId)
- }
-
- //modelInfo
- String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo")
- if (isBlank(serviceModelInfo)) {
- msg = "Input serviceModelInfo is null"
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else
- {
- execution.setVariable("serviceModelInfo", serviceModelInfo)
- }
-
- utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled)
-
- //requestParameters
- String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType")
- if (isBlank(subscriptionServiceType)) {
- msg = "Input subscriptionServiceType is null"
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- }
-
-
- /*
- * Extracting User Parameters from incoming Request and converting into a Map
- */
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
-
- Map reqMap = jsonSlurper.parseText(siRequest)
-
- //InputParams
- def userParamsList = reqMap.requestDetails?.requestParameters?.userParams
-
- Map<String, String> inputMap = [:]
- if (userParamsList) {
- for (def i=0; i<userParamsList.size(); i++) {
- def userParams1 = userParamsList.get(i)
- userParams1.each { param -> inputMap.put(param.key, param.value)}
- }
- }
-
-
- utils.log("DEBUG", "User Input Parameters map: " + inputMap.toString(), isDebugEnabled)
- execution.setVariable("serviceInputParams", inputMap)
- execution.setVariable("uuiRequest", inputMap.get("UUIRequest"))
- execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
- //TODO
- //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams"))
- //execution.setVariable("failExists", true)
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- msg = "Exception in preProcessRequest " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
- }
-
- public void sendSyncResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
-
- try {
- String operationId = execution.getVariable("operationId")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- // RESTResponse for API Handler (APIH) Reply Task
- String createServiceRestRequest = """{"service":{"serviceId":"${serviceInstanceId}","operationId":"${operationId}"}}""".trim()
- utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestRequest, isDebugEnabled)
- sendWorkflowResponse(execution, 202, createServiceRestRequest)
- execution.setVariable("sentSyncResponse", true)
-
- } catch (Exception ex) {
- String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
- }
-
-
- public void sendSyncError (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled)
-
- try {
- String errorMessage = ""
- if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
- WorkflowException wfe = execution.getVariable("WorkflowException")
- errorMessage = wfe.getErrorMessage()
- } else {
- errorMessage = "Sending Sync Error."
- }
-
- String buildworkflowException =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
-
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
-
- }
-
- public void prepareCompletionRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled)
-
- try {
- String requestId = execution.getVariable("msoRequestId")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- String source = execution.getVariable("source")
-
- String msoCompletionRequest =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>
- <status-message>Service Instance was created successfully.</status-message>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- <mso-bpel-name>CreateGenericALaCarteServiceInstance</mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- execution.setVariable("completionRequest", xmlMsoCompletionRequest)
- utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- String msg = " Exception in prepareCompletion:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled)
- }
-
- public void prepareFalloutRequest(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled)
-
- try {
- WorkflowException wfex = execution.getVariable("WorkflowException")
- utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled)
- String requestId = execution.getVariable("msoRequestId")
- String source = execution.getVariable("source")
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>"""
-
- String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
- execution.setVariable("falloutRequest", falloutRequest)
- } catch (Exception ex) {
- utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled)
- String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage()
- String requestId = execution.getVariable("msoRequestId")
- String falloutRequest =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>UUI</source>
- </request-info>
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- execution.setVariable("falloutRequest", falloutRequest)
- }
- utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
- }
-
- /**
- * Init the service Operation Status
- */
- public void prepareInitServiceOperationStatus(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = UUID.randomUUID().toString()
- String operationType = "CREATE"
- String userId = ""
- String result = "processing"
- String progress = "0"
- String reason = ""
- String operationContent = "Prepare service creation"
- utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceId)
- execution.setVariable("operationId", operationId)
- execution.setVariable("operationType", operationType)
-
- def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
- <serviceId>${serviceId}</serviceId>
- <operationId>${operationId}</operationId>
- <operationType>${operationType}</operationType>
- <userId>${userId}</userId>
- <result>${result}</result>
- <operationContent>${operationContent}</operationContent>
- <progress>${progress}</progress>
- <reason>${reason}</reason>
- </ns:updateServiceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
- utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled)
- utils.logAudit("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage())
- }
- utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy deleted file mode 100644 index 0de28f77ce..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy +++ /dev/null @@ -1,359 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -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.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils -import org.json.JSONException; - -/** - * This groovy class supports the <class>CreateGenericALaCarteServiceInstance.bpmn</class> process. - * AlaCarte flow for 1702 ServiceInstance Create - * - */ -public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { - String Prefix="CRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - utils.log("DEBUG", " *** preProcessRequest() of CreateGenericALaCarteServiceInstance *** ", isDebugEnabled) - - try { - - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)) { - serviceInstanceId = UUID.randomUUID().toString() - utils.log("DEBUG", "Generated new Service Instance ID:" + serviceInstanceId, isDebugEnabled) - } else { - utils.log("DEBUG", "Using provided Service Instance ID:" + serviceInstanceId, isDebugEnabled) - } - - serviceInstanceId = UriUtils.encode(serviceInstanceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceInstanceId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //requestInfo - execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source")) - execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName")) - execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback")) - String productFamilyId = null; - try { - productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") - } catch (JSONException e) { - productFamilyId = null; - } - if (isBlank(productFamilyId)) - { - msg = "Input productFamilyId is null" - utils.log("DEBUG", msg, isDebugEnabled) - //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("productFamilyId", productFamilyId) - } - - //modelInfo - String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") - if (isBlank(serviceModelInfo)) { - msg = "Input serviceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceModelInfo", serviceModelInfo) - } - - utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled) - - //requestParameters - String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - - /* - * Extracting User Parameters from incoming Request and converting into a Map - */ - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - - Map reqMap = jsonSlurper.parseText(siRequest) - - //InputParams - def userParams = reqMap.requestDetails?.requestParameters?.userParams - - Map<String, String> inputMap = [:] - if (userParams) { - userParams.each { - userParam -> inputMap.put(userParam.name, userParam.value.toString()) - } - } - - utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) - execution.setVariable("serviceInputParams", inputMap) - - //TODO - //execution.setVariable("failExists", true) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest of CreateGenericALaCarteServiceInstance *****", isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - // RESTResponse for API Handler (APIH) Reply Task - String createServiceRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createServiceRestRequest, isDebugEnabled) - sendWorkflowResponse(execution, 202, createServiceRestRequest) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - // ******************************* - // - // ******************************* - public void prepareDecomposeService(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateGenericALaCarteServiceInstance ***** ", isDebugEnabled) - try { - String siRequest = execution.getVariable("bpmnRequest") - String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") - execution.setVariable("serviceModelInfo", serviceModelInfo) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateGenericALaCarteServiceInstance ***** ", isDebugEnabled) - } - - - // ******************************* - // - // ******************************* - public void prepareCreateServiceInstance(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateGenericALaCarteServiceInstance ***** ", isDebugEnabled) - - /* - * Extracting User Parameters from incoming Request and converting into a Map - */ - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - def siRequest = execution.getVariable("bpmnRequest") - Map reqMap = jsonSlurper.parseText(siRequest) - //InputParams - def userParams = reqMap.requestDetails?.requestParameters?.userParams - Map<String, String> inputMap = [:] - if (userParams != null) { - userParams.each { - userParam -> inputMap.put(userParam.name, userParam.value) - } - } - - utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) - execution.setVariable("serviceInputParams", inputMap) - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - serviceDecomposition.getServiceInstance().setInstanceId(serviceInstanceId) - - String serviceInstanceName = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName") - serviceDecomposition.getServiceInstance().setInstanceName(serviceInstanceName) - execution.setVariable("serviceInstanceName", serviceInstanceName) - execution.setVariable("serviceDecomposition", serviceDecomposition) - execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString()) - utils.log("DEBUG", "serviceDecomposition.serviceInstanceName: " + serviceDecomposition.getServiceInstance().getInstanceName(), isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateGenericALaCarteServiceInstance ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - public void prepareCompletionRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String source = execution.getVariable("source") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info> - <status-message>Service Instance was created successfully.</status-message> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - <mso-bpel-name>CreateGenericALaCarteServiceInstance</mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("completionRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info>""" - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>VID</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } -}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy deleted file mode 100644 index 5f7d1e3452..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateNetworkInstance.groovy +++ /dev/null @@ -1,457 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -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.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the <class>CreateNetworkInstance.bpmn</class> process. - * - */ -public class CreateNetworkInstance extends AbstractServiceTaskProcessor { - String Prefix="CRENI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public InitializeProcessVariables(DelegateExecution execution){ - - execution.setVariable(Prefix + "source", "") - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "CompleteMsoProcessRequest", "") - execution.setVariable(Prefix + "FalloutHandlerRequest", "") - execution.setVariable(Prefix + "isSilentSuccess", false) - - } - - - /** - * This method is executed during the preProcessRequest task of the <class>CreateNetworkInstance.bpmn</class> process. - * @param execution - */ - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>CreateNetworkInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of CreateNetworkInstance Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null || sdncVersion == '1610') { - // 'a-la-cart' default, sdncVersion = '1610' - execution.setVariable("sdncVersion", "1610") - String bpmnRequest = execution.getVariable("bpmnRequest") - // set 'disableRollback' - if (bpmnRequest != null) { - String disableRollback = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.requestInfo.suppressRollback") - if (disableRollback != null) { - execution.setVariable("disableRollback", disableRollback) - utils.log("DEBUG", "Received 'suppressRollback': " + disableRollback , isDebugEnabled) - } else { - execution.setVariable("disableRollback", false) - } - utils.log("DEBUG", " Set 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } else { - String dataErrorMessage = " Invalid 'bpmnRequest' request." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } else { - // 'macro' TEST ONLY, sdncVersion = '1702' - utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - - // get/set 'requestId' - if (execution.getVariable("requestId") == null) { - execution.setVariable("requestId", requestId) - } - - //Place holder for additional code. - - // TODO ??? - // userParams??? 1) pre-loads indicator, 2) 'auto-activation' - // Tag/Value parameters - // - // Map: 'networkInputParams': 'auto-activation'' - // Sample format? - // "requestParameters": { - // "userParams": [ - // { - // "name": "someUserParam1", - // "value": "someValue1" - // } - // ] - // } - // - // String userParams = //use json util to extract "userParams"// - // execution.setVariable("networkInputParams", userParams) - // else: execution.setVariable("networkInputParams", null) - // - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in CreateNetworkInstance, PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncResponse() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String createNetworkRestRequest = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + createNetworkRestRequest, isDebugEnabled) - sendWorkflowResponse(execution, 202, createNetworkRestRequest) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in CreateNetworkInstance flow. sendSyncResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - public void getNetworkModelInfo (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - - // For Ala-Carte (sdnc = 1610): - // 1. the Network ModelInfo is expected to be sent - // via requestDetails.modelInfo (modelType = network). - // 2. the Service ModelInfo is expected to be sent but will be IGNORE - // via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service) - - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in CreateNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncError() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - - String requestId = execution.getVariable("mso-request-id") - - // REST Error (for API Handler (APIH) Reply Task) - String syncError = """{"requestReferences":{"instanceId":"","requestId":"${requestId}"}}""".trim() - - sendWorkflowResponse(execution, 500, syncError) - - } catch (Exception ex) { - utils.log("DEBUG", " Bpmn error encountered in CreateNetworkInstance flow. sendSyncError() - " + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareDBRequestError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError() of CreateNetworkInstance ***** ", isDebugEnabled) - - // set DB Header Authorization - setBasicDBAuthHeader(execution, isDebugEnabled) - - String statusMessage = "" - WorkflowException wfe = null - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - wfe = execution.getVariable("WorkflowException") - statusMessage = wfe.getErrorMessage() - } - - String requestId = execution.getVariable(Prefix + "requestId") - String networkName = execution.getVariable("networkName") !=null ? execution.getVariable("networkName") : "" - String networkId = execution.getVariable("networkId") !=null ? execution.getVariable("networkId") : "" - String dbRequest = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb"> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <statusMessage>${statusMessage}</statusMessage> - <responseBody></responseBody> - <requestStatus>FAILED</requestStatus> - <vnfOutputs><network-id>${networkId}</network-id><network-name>${networkName}</network-names></vnfOutputs> - </ns:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope>""" - - execution.setVariable(Prefix + "createDBRequest", dbRequest) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - utils.logAudit(dbRequest) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareDBRequestError() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareCompletion (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareCompletion() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - - String requestId = execution.getVariable("mso-request-id") - String source = execution.getVariable(Prefix + "source") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>VID</source> - </request-info> - <aetgt:status-message>Network has been created successfully.</aetgt:status-message> - <aetgt:mso-bpel-name>BPMN Network action: CREATE</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - // normal path - execution.setVariable(Prefix + "Success", true) - execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - - - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void postProcessResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - - if (execution.getVariable("CMSO_ResponseCode") == "200") { - execution.setVariable(Prefix + "Success", true) - utils.log("DEBUG", " ***** CreateNetworkInstance Success ***** ", isDebugEnabled) - // Place holder for additional code. - - } else { - execution.setVariable(Prefix + "Success", false) - utils.log("DEBUG", " ***** CreateNetworkInstance Failed in CompletionMsoProces flow!. ***** ", isDebugEnabled) - - } - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - public void processRollbackData (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside processRollbackData() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - //execution.getVariable("orchestrationStatus") - //execution.getVariable("networkId") - //execution.getVariable("networkName") - //networkOutputParams - //rollbackData - //rolledBack - - } catch (Exception ex) { - utils.log("DEBUG", " Bpmn error encountered in CreateNetworkInstance flow. callDBCatalog() - " + ex.getMessage(), isDebugEnabled) - } - - } - - // Prepare for FalloutHandler - public void buildErrorResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", "DB updateInfraRequest ResponseCode: " + execution.getVariable(Prefix + "dbReturnCode"), isDebugEnabled) - utils.log("DEBUG", "DB updateInfraRequest Response: " + execution.getVariable(Prefix + "createDBResponse"), isDebugEnabled) - - utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) - - String falloutHandlerRequest = "" - String requestId = execution.getVariable("mso-request-id") - - try { - - WorkflowException wfe = execution.getVariable("WorkflowException") - String errorCode = String.valueOf(wfe.getErrorCode()) - String errorMessage = wfe.getErrorMessage() - falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>VID</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - utils.logAudit(falloutHandlerRequest) - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } catch (Exception ex) { - String errorException = " Bpmn error encountered in CreateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse()" - utils.log("DEBUG", "Exception error in CreateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage(), isDebugEnabled) - falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>VID</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } - - } - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled) - } - -} 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 deleted file mode 100644 index 43b32a4d85..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateSDNCNetworkResource.groovy +++ /dev/null @@ -1,341 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - 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.infrastructure.scripts
-
-import org.json.JSONObject
-import org.json.XML;
-
-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.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.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.rest.APIResponse;
-
-/**
- * This groovy class supports the <class>CreateSDNCCNetworkResource.bpmn</class> process.
- * flow for SDNC Network Resource Create
- */
-public class CreateSDNCNetworkResource extends AbstractServiceTaskProcessor {
-
- String Prefix="CRESDNCRES_"
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
-
- 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("mso-request-id")
- String requestAction = execution.getVariable("requestAction")
- utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled)
- String recipeParamsFromRequest = execution.getVariable("recipeParams")
- utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled)
- String resourceInput = execution.getVariable("resourceInput")
- utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled)
- //Get ResourceInput Object
- ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, ResourceInput.class)
- 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)
- }
- }
-
- String customizeResourceParam(String netowrkInputParametersJson) {
- List<Map<String, Object>> paramList = new ArrayList();
- JSONObject jsonObject = new JSONObject(netowrkInputParametersJson);
- Iterator iterator = jsonObject.keys();
- while (iterator.hasNext()) {
- String key = iterator.next();
- HashMap<String, String> hashMap = new HashMap();
- hashMap.put("name", key);
- hashMap.put("value", jsonObject.get(key))
- paramList.add(hashMap)
- }
- Map<String, List<Map<String, Object>>> paramMap = new HashMap();
- paramMap.put("param", paramList);
-
- return new JSONObject(paramMap).toString();
- }
-
- /**
- * Pre Process the BPMN Flow Request
- * Inclouds:
- * generate the nsOperationKey
- * generate the 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 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")
- 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()
- String resourceInputPrameters = resourceInputObj.getResourceParameters()
- String netowrkInputParametersJson = jsonUtil.getJsonValue(resourceInputPrameters, "requestInputs")
- //here convert json string to xml string
- String netowrkInputParameters = XML.toString(new JSONObject(customizeResourceParam(netowrkInputParametersJson)))
- // 1. prepare assign topology via SDNC Adapter SUBFLOW call
- String sndcTopologyCreateRequest =
- """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>${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>${hdrRequestId}</request-id>
- <request-action>${sdnc_requestAction}</request-action>
- <source>${source}</source>
- <notification-url></notification-url>
- <order-number></order-number>
- <order-version></order-version>
- </request-information>
- <service-information>
- <service-id>${serviceInstanceId}</service-id>
- <subscription-service-type>${serviceType}</subscription-service-type>
- <onap-model-information>
- <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid>
- <model-uuid>${serviceModelUuid}</model-uuid>
- <model-version>${serviceModelVersion}</model-version>
- <model-name>${serviceModelName}</model-name>
- </onap-model-information>
- <service-instance-id>${serviceInstanceId}</service-instance-id>
- <global-customer-id>${globalCustomerId}</global-customer-id>
- </service-information>
- <network-information>
- <onap-model-information>
- <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
- <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid>
- <model-uuid>${modelUuid}</model-uuid>
- <model-version>${modelVersion}</model-version>
- <model-name>${modelName}</model-name>
- </onap-model-information>
- </network-information>
- <network-request-input>
- <network-input-parameters>${netowrkInputParameters}</network-input-parameters>
- </network-request-input>
- </sdncadapterworkflow:SDNCRequestData>
- </aetgt:SDNCAdapterWorkflowRequest>""".trim()
-
- String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest)
- utils.logAudit(sndcTopologyCreateRequesAsString)
- execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyCreateRequesAsString)
- utils.log("DEBUG","sdncAdapterWorkflowRequest - " + "\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)
- }
-
- private void setProgressUpdateVariables(DelegateExecution execution, String body) {
- def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- execution.setVariable("CVFMI_updateResOperStatusRequest", body)
- }
-
- public void prepareUpdateBeforeCreateSDNCResource(DelegateExecution execution) {
- 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 = "20"
- String status = "processing"
- String statusDescription = "SDCN resource creation invoked"
-
- execution.getVariable("operationId")
-
- String body = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateResourceOperationStatus>
- <operType>${operType}</operType>
- <operationId>${operationId}</operationId>
- <progress>${progress}</progress>
- <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
- <serviceId>${ServiceInstanceId}</serviceId>
- <status>${status}</status>
- <statusDescription>${statusDescription}</statusDescription>
- </ns:updateResourceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>""";
-
- setProgressUpdateVariables(execution, body)
-
- }
-
- public void prepareUpdateAfterCreateSDNCResource(execution) {
- 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 creation completed"
-
- execution.getVariable("operationId")
-
- String body = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateResourceOperationStatus>
- <operType>${operType}</operType>
- <operationId>${operationId}</operationId>
- <progress>${progress}</progress>
- <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID>
- <serviceId>${ServiceInstanceId}</serviceId>
- <status>${status}</status>
- <statusDescription>${statusDescription}</statusDescription>
- </ns:updateResourceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>""";
-
- setProgressUpdateVariables(execution, body)
- }
-
- 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)
- }
-
- public void sendSyncResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
-
- try {
- String operationStatus = "finished"
- // RESTResponse for main flow
- String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
- utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
- sendWorkflowResponse(execution, 202, resourceOperationResp)
- execution.setVariable("sentSyncResponse", true)
-
- } catch (Exception ex) {
- String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy deleted file mode 100644 index fd819fd3d5..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVFCNSResource.groovy +++ /dev/null @@ -1,335 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - SO
- * ================================================================================
- * Copyright (C) 2017 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.infrastructure.scripts;
-
-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.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.rest.APIResponse;
-
-/**
- * This groovy class supports the <class>DoCreateVFCNetworkServiceInstance.bpmn</class> process.
- * flow for VFC Network Service Create
- */
-public class CreateVFCNSResource extends AbstractServiceTaskProcessor {
-
- String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
- String host = "http://mso.mso.testlab.openecomp.org:8080"
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- /**
- * CreateVFCNSResource
- * Pre Process the BPMN Flow Request
- * Inclouds:
- * generate the nsOperationKey
- * generate the nsParameters
- */
- public void preProcessRequest (DelegateExecution execution) {
- JsonUtils jsonUtil = new JsonUtils()
-
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String msg = ""
- utils.log("INFO", " *** preProcessRequest() *** ", isDebugEnabled)
- try {
- //deal with nsName and Description
- String resourceInput = execution.getVariable("resourceInput")
-
- String resourceParameters = jsonUtil.getJsonValue(resourceInput, "resourceParameters")
- // get service name
- String resourceName = jsonUtil.getJsonValue(resourceInput, "resourceInstanceName")
- execution.setVariable("nsServiceName", resourceName)
-
- String nsServiceDescription = execution.getVariable("nsServiceDescription")
- utils.log("INFO", "nsServiceName:" + resourceName + " nsServiceDescription:" + nsServiceDescription, isDebugEnabled)
- //deal with operation key
- String globalSubscriberId = jsonUtil.getJsonValue(resourceInput, "globalSubscriberId")
- utils.log("INFO", "globalSubscriberId:" + globalSubscriberId, isDebugEnabled)
- //set local globalSubscriberId variable
- execution.setVariable("globalSubscriberId", globalSubscriberId);
-
- String serviceType = execution.getVariable("serviceType")
- utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
-
- String serviceId = execution.getVariable("serviceInstanceId")
- utils.log("INFO", "serviceId:" + serviceId, isDebugEnabled)
-
- String operationId = jsonUtil.getJsonValue(resourceInput, "operationId")
- utils.log("INFO", "serviceType:" + serviceType, isDebugEnabled)
-
- String nodeTemplateUUID = jsonUtil.getJsonValue(resourceInput, "resourceModelInfo.modelCustomizationUuid")
- String nsServiceModelUUID = jsonUtil.getJsonValue(resourceParameters, "requestInputs.nsd0_providing_service_uuid")
- 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 = jsonUtil.getJsonValue(resourceInput, "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)
- execution.setVariable("nsServiceModelUUID", nsServiceModelUUID);
-
-
- } 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)
- }
-
- /**
- * create NS task
- */
- public void createNetworkService(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** createNetworkService *****", isDebugEnabled)
- String nsOperationKey = execution.getVariable("nsOperationKey");
- String nsServiceModelUUID = execution.getVariable("nsServiceModelUUID");
- String nsParameters = execution.getVariable("nsParameters");
- String nsServiceName = execution.getVariable("nsServiceName")
- String nsServiceDescription = execution.getVariable("nsServiceDescription")
- String locationConstraints = jsonUtil.getJsonValue(nsParameters, "locationConstraints")
- String requestInputs = jsonUtil.getJsonValue(nsParameters, "requestInputs")
- String reqBody ="""{
- "nsServiceName":"${nsServiceName}",
- "nsServiceDescription":"${nsServiceDescription}",
- "nsServiceModelUUID":"${nsServiceModelUUID}",
- "nsOperationKey":${nsOperationKey},
- "nsParameters":{
- "locationConstraints":${locationConstraints},
- "additionalParamForNs":${requestInputs}
- }
- }"""
- APIResponse apiResponse = postRequest(execution, host + vfcUrl + "/ns", reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
- String nsInstanceId = "";
- if(returnCode== "200" || returnCode == "201"){
- nsInstanceId = jsonUtil.getJsonValue(aaiResponseAsString, "nsInstanceId")
- }
- execution.setVariable("nsInstanceId", nsInstanceId)
- utils.log("INFO"," *****Exit createNetworkService *****", isDebugEnabled)
- }
-
- /**
- * instantiate NS task
- */
- public void instantiateNetworkService(DelegateExecution execution) {
- def isDebugEnabled= execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** instantiateNetworkService *****", isDebugEnabled)
- String nsOperationKey = execution.getVariable("nsOperationKey");
- String nsParameters = execution.getVariable("nsParameters");
- String nsServiceName = execution.getVariable("nsServiceName")
- String nsServiceDescription = execution.getVariable("nsServiceDescription")
- String reqBody ="""{
- "nsServiceName":"${nsServiceName}",
- "nsServiceDescription":"${nsServiceDescription}",
- "nsOperationKey":${nsOperationKey},
- "nsParameters":${nsParameters}
- }"""
- String nsInstanceId = execution.getVariable("nsInstanceId")
- String url = host + vfcUrl + "/ns/" +nsInstanceId + "/instantiate"
- APIResponse apiResponse = postRequest(execution, url, reqBody)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
- String jobId = "";
- if(returnCode== "200"|| returnCode == "201"){
- jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
- }
- execution.setVariable("jobId", jobId)
- utils.log("INFO"," *****Exit instantiateNetworkService *****", isDebugEnabled)
- }
-
- /**
- * query NS task
- */
- public void queryNSProgress(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** queryNSProgress *****", isDebugEnabled)
- String jobId = execution.getVariable("jobId")
- String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/jobs/" + jobId
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
- String operationStatus = "error"
- if(returnCode== "200"|| returnCode == "201"){
- operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status")
- }
- execution.setVariable("operationStatus", operationStatus)
- utils.log("INFO"," *****Exit queryNSProgress *****", isDebugEnabled)
- }
-
- /**
- * delay 5 sec
- */
- public void timeDelay(DelegateExecution execution) {
- def isDebugEnabled= execution.getVariable("isDebugLogEnabled")
- try {
- Thread.sleep(5000);
- } catch(InterruptedException e) {
- utils.log("ERROR", "Time Delay exception" + e , isDebugEnabled)
- }
- }
-
- /**
- * finish NS task
- */
- public void addNSRelationship(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** addNSRelationship *****", isDebugEnabled)
- String nsInstanceId = execution.getVariable("nsInstanceId")
- if(nsInstanceId == null || nsInstanceId == ""){
- utils.log("INFO"," create NS failed, so do not need to add relationship", isDebugEnabled)
- return
- }
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String serviceType = execution.getVariable("serviceType")
- String serviceId = execution.getVariable("serviceInstanceId")
- String addRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">
- <related-to>service-instance</related-to>
- <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${serviceId}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${globalSubscriberId}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${serviceType}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${serviceId}</relationship-value>
- </relationship-data>
- </relationship>"""
- String endpoint = execution.getVariable("URN_aai_endpoint")
- utils.log("INFO","Add Relationship req:\n" + addRelationPayload, isDebugEnabled)
- String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + nsInstanceId + "/relationship-list/relationship"
- APIResponse aaiRsp = executeAAIPutCall(execution, url, addRelationPayload)
- utils.log("INFO","aai response status code:" + aaiRsp.getStatusCode(), isDebugEnabled)
- utils.log("INFO","aai response content:" + aaiRsp.getResponseBodyAsString(), isDebugEnabled)
- utils.log("INFO"," *****Exit addNSRelationship *****", isDebugEnabled)
- }
-
- public APIResponse executeAAIPutCall(DelegateExecution execution, String url, String payload){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " ======== Started Execute AAI Put Process ======== ", isDebugEnabled)
- APIResponse apiResponse = null
- try{
- String uuid = execution.getVariable("mso-request-id");
- utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled)
- utils.log("INFO","URL to be used is: " + url, isDebugEnabled)
- String userName = execution.getVariable("URN_aai_auth")
- String password = execution.getVariable("URN_mso_msoKey")
- String basicAuthCred = utils.getBasicAuth(userName,password)
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpPut(payload)
- utils.log("INFO","======== Completed Execute AAI Put Process ======== ", isDebugEnabled)
- }catch(Exception e){
- utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- return apiResponse
- }
-
- /**
- * 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 sendSyncResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled)
-
- try {
- String operationStatus = execution.getVariable("operationStatus")
- // RESTResponse for main flow
- String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim()
- utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled)
- sendWorkflowResponse(execution, 202, resourceOperationResp)
- execution.setVariable("sentSyncResponse", true)
-
- } catch (Exception ex) {
- String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy deleted file mode 100644 index 0a53526263..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy +++ /dev/null @@ -1,639 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import groovy.json.JsonSlurper
-import groovy.json.JsonOutput
-
-import javax.xml.parsers.DocumentBuilder
-import javax.xml.parsers.DocumentBuilderFactory
-
-import org.w3c.dom.Document
-import org.w3c.dom.Element
-import org.w3c.dom.Node
-import org.w3c.dom.NodeList
-import org.xml.sax.InputSource
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.onap.appc.client.lcm.model.Action
-import org.apache.commons.lang3.*
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
-import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils;
-import org.openecomp.mso.bpmn.common.scripts.VidUtils;
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.infrastructure.aai.AAICreateResources;
-import org.onap.aai.domain.yang.v12.GenericVnf;
-
-public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
- private AbstractServiceTaskProcessor taskProcessor
-
- public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
- this.taskProcessor = taskProcessor
- }
-
- /**
- * Validates the request message and sets up the workflow.
- * @param execution the execution
- */
- public void preProcessRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessRequest(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- execution.setVariable("CVFMI_sentSyncResponse", false)
-
- def prefix = 'CVFMI_'
- logDebug('Entered 1' + method, isDebugLogEnabled)
- execution.setVariable('prefix', prefix)
- logDebug('Entered 2' + method, isDebugLogEnabled)
- execution.setVariable("isVidRequest", "false")
-
- logDebug("Set variables", isDebugLogEnabled)
-
- def rollbackData = execution.getVariable("RollbackData")
- if (rollbackData == null) {
- rollbackData = new RollbackData()
- }
- execution.setVariable("RollbackData", rollbackData)
-
- logDebug("Set rollback data", isDebugLogEnabled)
- def incomingRequest = execution.getVariable('bpmnRequest')
-
- utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
- utils.logAudit("CreateVfModule Infra incoming Request: " + incomingRequest)
-
- setBasicDBAuthHeader(execution, isDebugLogEnabled)
-
- // check if request is xml or json
- try {
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
- Map reqMap = jsonSlurper.parseText(incomingRequest)
- utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
-
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def vnfId = execution.getVariable('vnfId')
-
- execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId)
- execution.setVariable(prefix+'vnfId', vnfId)
- execution.setVariable("isVidRequest", "true")
-
- def vnfName = ''
- def asdcServiceModelVersion = ''
- def serviceModelInfo = null
- def vnfModelInfo = null
-
- def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
-
- if (relatedInstanceList != null) {
- relatedInstanceList.each {
- if (it.relatedInstance.modelInfo?.modelType == 'service') {
- asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
- serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
-
- }
- if (it.relatedInstance.modelInfo.modelType == 'vnf') {
- vnfName = it.relatedInstance.instanceName ?: ''
- vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
- }
- }
- }
-
- execution.setVariable(prefix + 'vnfName', vnfName)
- execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion)
- execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo)
- execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo)
-
-
- def vnfType = execution.getVariable('vnfType')
- execution.setVariable(prefix + 'vnfType', vnfType)
- def vfModuleId = execution.getVariable('vfModuleId')
- execution.setVariable(prefix + 'vfModuleId', vfModuleId)
- def volumeGroupId = execution.getVariable('volumeGroupId')
- execution.setVariable(prefix + 'volumeGroupId', volumeGroupId)
- def userParams = reqMap.requestDetails?.requestParameters?.userParams
-
- Map<String, String> userParamsMap = [:]
- if (userParams != null) {
- userParams.each { userParam ->
- userParamsMap.put(userParam.name, jsonOutput.toJson(userParam.value).toString())
- }
- }
-
- utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
-
- execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap)
-
- def isBaseVfModule = "false"
- if (execution.getVariable('isBaseVfModule') == true) {
- isBaseVfModule = "true"
- }
-
- execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule)
-
- def requestId = execution.getVariable("mso-request-id")
- execution.setVariable(prefix + 'requestId', requestId)
-
- def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
- execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo)
-
- def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback
-
-
- def backoutOnFailure = ""
- if(suppressRollback != null){
- if ( suppressRollback == true) {
- backoutOnFailure = "false"
- } else if ( suppressRollback == false) {
- backoutOnFailure = "true"
- }
- }
-
- execution.setVariable('disableRollback', suppressRollback)
-
- def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
- execution.setVariable(prefix + 'vfModuleName', vfModuleName)
-
- def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: ''
- execution.setVariable(prefix + 'serviceId', serviceId)
-
- def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
- execution.setVariable(prefix + 'usePreload', usePreload)
-
- // This is aLaCarte flow, so aLaCarte flag is always on
- execution.setVariable(prefix + 'aLaCarte', true)
-
- def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
- def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId
- execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId)
- def tenantId = cloudConfiguration.tenantId
- execution.setVariable(prefix + 'tenantId', tenantId)
-
- def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
- execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId)
-
- execution.setVariable(prefix + 'sdncVersion', '1702')
-
- execution.setVariable("CreateVfModuleInfraSuccessIndicator", false)
- execution.setVariable("RollbackCompleted", false)
-
- execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
-
-
- def source = reqMap.requestDetails?.requestInfo?.source
- execution.setVariable("CVFMI_source", source)
-
- //For Completion Handler & Fallout Handler
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable("CVFMI_requestInfo", requestInfo)
-
- //backoutOnFailure
-
- execution.setVariable("CVFMI_originalWorkflowException", null)
-
-
- def newVfModuleId = UUID.randomUUID().toString()
- execution.setVariable("newVfModuleId", newVfModuleId)
- execution.setVariable(prefix + 'vfModuleId', newVfModuleId)
- execution.setVariable('actionHealthCheck', Action.HealthCheck)
- execution.setVariable('actionConfigScaleOut', Action.ConfigScaleOut)
- execution.setVariable('controllerType', "APPC")
- def controllerType = execution.getVariable('controllerType')
- execution.setVariable(prefix + 'controllerType', controllerType)
- execution.setVariable('healthCheckIndex0', 0)
-
- logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled)
-
- logDebug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled"), isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError bpmnError) {
- throw bpmnError
- }
- catch(groovy.json.JsonException je) {
- utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
- }
- catch(Exception e) {
- String restFaultMessage = e.getMessage()
- //execution.setVariable("CVFMODVOL2_RESTFault", restFaultMessage)
- //execution.setVariable("CVFMODVOL2_isDataOk", false)
- utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
- }
-
- }
-
- /**
- * Validates a workflow response.
- * @param execution the execution
- * @param responseVar the execution variable in which the response is stored
- * @param responseCodeVar the execution variable in which the response code is stored
- * @param errorResponseVar the execution variable in which the error response is stored
- */
- public void validateWorkflowResponse(DelegateExecution execution, String responseVar,
- String responseCodeVar, String errorResponseVar) {
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
- }
-
-
- /**
- * Sends the empty, synchronous response back to the API Handler.
- * @param execution the execution
- */
- public void sendResponse(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.sendResponse(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def requestInfo = execution.getVariable('CVFMI_requestInfo')
- def requestId = execution.getVariable('CVFMI_requestId')
- def source = execution.getVariable('CVFMI_source')
-
- // RESTResponse (for API Handler (APIH) Reply Task)
- def newVfModuleId = execution.getVariable("newVfModuleId")
- String synchResponse = """{"requestReferences":{"instanceId":"${newVfModuleId}","requestId":"${requestId}"}}""".trim()
-
- sendWorkflowResponse(execution, 200, synchResponse)
-
- execution.setVariable("CVFMI_sentSyncResponse", true)
- utils.logAudit("CreateVfModule Infra Response: " + synchResponse)
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
- }
- }
-
- /**
- * Query AAI for vnf orchestration status to determine if health check and config scaling should be run
- */
- public void queryAAIForVnfOrchestrationStatus(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- def vnfId = execution.getVariable("CVFMI_vnfId")
- execution.setVariable("runHealthCheck", false);
- execution.setVariable("runConfigScaleOut", false);
- AAICreateResources aaiCreateResources = new AAICreateResources();
- Optional<GenericVnf> vnf = aaiCreateResources.getVnfInstance(vnfId);
- if(vnf.isPresent()){
- def vnfOrchestrationStatus = vnf.get().getOrchestrationStatus();
- if("active".equalsIgnoreCase(vnfOrchestrationStatus)){
- execution.setVariable("runHealthCheck", false);
- execution.setVariable("runConfigScaleOut", true);
- }
- }
- }
-
- /**
- * Retrieve data for ConfigScaleOut from SDNC topology
- */
-
- public void retreiveConfigScaleOutData(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
- String ipAddress = "";
- String oamIpAddress = "";
- String vnfHostIpAddress = "";
-
- String vnfGetSDNC = execution.getVariable("DCVFM_getSDNCAdapterResponse");
-
- String data = utils.getNodeXml(vnfGetSDNC, "response-data")
- data = data.replaceAll("<", "<")
- data = data.replaceAll(">", ">")
-
- InputSource source = new InputSource(new StringReader(data));
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- docFactory.setNamespaceAware(true)
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
- Document responseXml = docBuilder.parse(source)
-
- NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters")
- for (int z = 0; z < paramsList.getLength(); z++) {
- Node node = paramsList.item(z)
- Element eElement = (Element) node
- String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name")
- String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value")
- if (vnfParameterName.equals("vlb_private_ip_1")) {
- vnfHostIpAddress = vnfParameterValue
- }
- else if (vnfParameterName.equals("vdns_private_ip_0")) {
- ipAddress = vnfParameterValue
- }
- else if (vnfParameterName.equals("vdns_private_ip_1")) {
- oamIpAddress = vnfParameterValue
- }
- }
-
- String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"" + vnfHostIpAddress + "\",\"vf-module-id\":\"" + vfModuleId + "\"},\"configuration-parameters\":{\"ip-addr\":\"" + ipAddress +"\", \"oam-ip-addr\":\""+ oamIpAddress +"\",\"enabled\":\"true\"}}"
- execution.setVariable("payload", payload);
- }
-
- /**
- *
- * @param execution the execution
- */
- public void postProcessResponse(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ======== STARTED PostProcessResponse Process ======== ", isDebugEnabled)
- try{
- def requestInfo = execution.getVariable("CVFMI_requestInfo")
- def action = utils.getNodeText1(requestInfo, "action")
-
- utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled)
- utils.log("DEBUG", "action is: " + action, isDebugEnabled)
-
- String payload =
- """ <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- ${requestInfo}
- </request-info>
- <ns8:status-message>Vf Module has been created successfully.</ns8:status-message>
- <ns8:mso-bpel-name>BPMN</ns8:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_SuccessFlag", true)
- execution.setVariable("CVFMI_msoCompletionRequest", payload)
- utils.logAudit("CreateVfModuleInfra completion request: " + payload)
- utils.log("DEBUG", "Outgoing MsoCompletionRequest: \n" + payload, isDebugEnabled)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing PostProcessResponse. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occured during PostProcessResponse Method:\n" + e.getMessage())
- }
- utils.log("DEBUG", "======== COMPLETED PostProcessResponse Process ======== ", isDebugEnabled)
- }
-
-
-
-
-
- /**
- * Validates the request, request id and service instance id. If a problem is found,
- * a WorkflowException is generated and an MSOWorkflowException event is thrown. This
- * method also sets up the log context for the workflow.
- * @param execution the execution
- * @return the validated request
- */
- public String validateInfraRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.validateInfraRequest(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- String processKey = getProcessKey(execution);
- def prefix = execution.getVariable("prefix")
-
- if (prefix == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null")
- }
-
- try {
- def request = execution.getVariable(prefix + 'Request')
-
- if (request == null) {
- request = execution.getVariable(processKey + 'Request')
-
- if (request == null) {
- request = execution.getVariable('bpmnRequest')
- }
-
- setVariable(execution, processKey + 'Request', null);
- setVariable(execution, 'bpmnRequest', null);
- setVariable(execution, prefix + 'Request', request);
- }
-
- if (request == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null")
- }
-
- /*
-
- def requestId = execution.getVariable("mso-request-id")
-
- if (requestId == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id")
- }
-
- setVariable(execution, prefix + 'requestId', requestId)
-
- def serviceInstanceId = execution.getVariable("mso-service-instance-id")
-
- if (serviceInstanceId == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id")
- }
-
- utils.logContext(requestId, serviceInstanceId)
- */
- utils.logAudit("CreateVfModule incoming request: " + request)
- logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled)
- logDebug('Exited ' + method, isDebugLogEnabled)
- return request
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
- }
- }
-
- public void prepareUpdateInfraRequest(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ======== STARTED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
- try{
-
-
- String requestInfo = execution.getVariable("CVFMI_requestInfo")
- def aicCloudRegion = execution.getVariable("CVFMI_lcpCloudRegionId")
- def tenantId = execution.getVariable("CVFMI_tenantId")
- def requestId = utils.getNodeText1(requestInfo, "request-id")
- def vnfId = execution.getVariable("CVFMI_vnfId")
- def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
- // vfModuleName may be generated by DoCreateVfModule subprocess if it is not specified on the input
- def vfModuleName = execution.getVariable("CVFMI_vfModuleName")
-
- def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>VF Module successfully created</statusMessage>
- <responseBody></responseBody>
- <requestStatus>COMPLETE</requestStatus>
- <progress>100</progress>
- <vnfOutputs><vnf-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"><vnf-id>${vnfId}</vnf-id><vf-module-id>${vfModuleId}</vf-module-id></vnf-outputs></vnfOutputs>
- <vfModuleId>${vfModuleId}</vfModuleId>
- <vfModuleName>${vfModuleName}</vfModuleName>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_updateInfraRequest", payload)
- utils.log("DEBUG", "Outgoing UpdateInfraRequest: \n" + payload, isDebugEnabled)
- utils.logAudit("CreateVfModuleInfra Outgoing UpdateInfra Request: " + payload)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing prepareUpdateInfraRequest. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateInfraRequest Method:\n" + e.getMessage())
- }
- utils.log("DEBUG", "======== COMPLETED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
- }
-
- /**
- * Builds a "FalloutHandler" request and stores it in the specified execution variable.
- *
- * @param execution the execution
- * @param resultVar the execution variable in which the result will be stored
- */
- public void falloutHandlerPrep(DelegateExecution execution, String resultVar) {
- def method = getClass().getSimpleName() + '.falloutHandlerPrep(' +
- 'execution=' + execution.getId() +
- ', resultVar=' + resultVar +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
-
- try {
- def WorkflowException workflowException = execution.getVariable("WorkflowException")
- def requestInformation = execution.getVariable("CVFMI_requestInfo")
- def errorResponseCode = workflowException.getErrorCode()
- def errorResponseMsg = workflowException.getErrorMessage()
- def encErrorResponseMsg = ""
- if (errorResponseMsg != null) {
- encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">")
- }
-
- String content = """
- <aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
- xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
- xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
- ${requestInformation}
- <aetgt:WorkflowException>
- <aetgt:ErrorMessage>${encErrorResponseMsg}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${errorResponseCode}</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>
- """
-
- logDebug("CONTENT before translation: " + content, isDebugLogEnabled)
- content = utils.formatXml(content)
- logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
- utils.logAudit("CreateVfModuleInfra FallOutHander Request: " + content)
- execution.setVariable(resultVar, content)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error')
- }
- }
-
- public void logAndSaveOriginalException(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- logWorkflowException(execution, 'CreateVfModuleInfra caught an event')
- saveWorkflowException(execution, 'CVFMI_originalWorkflowException')
- }
-
- public void validateRollbackResponse(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- def originalException = execution.getVariable("CVFMI_originalWorkflowException")
- execution.setVariable("WorkflowException", originalException)
-
- execution.setVariable("RollbackCompleted", true)
-
- }
-
- public void sendErrorResponse(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " *** STARTED CreateVfModulenfra sendErrorResponse Process *** ", isDebugEnabled)
- try {
- def sentSyncResponse = execution.getVariable("CVFMI_sentSyncResponse")
- if(sentSyncResponse == false){
- WorkflowException wfex = execution.getVariable("WorkflowException")
- String response = exceptionUtil.buildErrorResponseXml(wfex)
-
- utils.logAudit(response)
- sendWorkflowResponse(execution, 500, response)
- }else{
- utils.log("DEBUG", "Not Sending Error Response. Sync Response Already Sent", isDebugEnabled)
- }
-
- } catch (Exception ex) {
- utils.log("DEBUG", "Error Occured in CreateVfModuleInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVfModuleInfra sendErrorResponse Process")
-
- }
- utils.log("DEBUG", "*** COMPLETED CreateVfModuleInfra sendErrorResponse Process ***", isDebugEnabled)
- }
-
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy deleted file mode 100644 index 49d67cb097..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy +++ /dev/null @@ -1,363 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import org.openecomp.mso.bpmn.common.scripts.AaiUtil; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse -import java.util.Map; - -import groovy.json.JsonOutput -import groovy.json.JsonSlurper - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.apache.commons.lang3.* - -class CreateVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor { - - public static final String prefix='CVMVINFRAV1_' - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - setBasicDBAuthHeader(execution, isDebugEnabled) - preProcessRequest(execution, isDebugEnabled) - } - - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * @param execution - * @param isDebugEnabled - */ - public void preProcessRequest (DelegateExecution execution, isDebugEnabled) { - - execution.setVariable("prefix",prefix) - setSuccessIndicator(execution, false) - execution.setVariable(prefix+'syncResponseSent', false) - - String createVolumeIncoming = validateRequest(execution, 'vnfId') - utils.logAudit(createVolumeIncoming) - - try { - def jsonSlurper = new JsonSlurper() - Map reqMap = jsonSlurper.parseText(createVolumeIncoming) - setupVariables(execution, reqMap, isDebugEnabled) - utils.log("DEBUG", "XML request:\n" + createVolumeIncoming, isDebugEnabled) - } - catch(groovy.json.JsonException je) { - (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'Request is not a valid JSON document') - } - - // For rollback in this flow - setBasicDBAuthHeader(execution, isDebugEnabled) - setRollbackEnabled(execution, isDebugEnabled) - } - - - /** - * Set up variables that will be passed to the BB DoCreatevfModuleVolume flow - * @param execution - * @param requestMap - * @param serviceInstanceId - * @param isDebugLogEnabled - */ - public void setupVariables(DelegateExecution execution, Map requestMap, isDebugLogEnabled) { - - def jsonOutput = new JsonOutput() - - // volumeGroupId - is generated - String volumeGroupId = UUID.randomUUID() - execution.setVariable('volumeGroupId', volumeGroupId) - utils.log("DEBUG", "Generated volumeGroupId: " + volumeGroupId, isDebugLogEnabled) - - // volumeGroupName - def volGrpName = requestMap.requestDetails.requestInfo?.instanceName ?: '' - execution.setVariable('volumeGroupName', volGrpName) - - // vfModuleModelInfo - def vfModuleModelInfo = jsonOutput.toJson(requestMap.requestDetails?.modelInfo) - execution.setVariable('vfModuleModelInfo', vfModuleModelInfo) - - // lcpCloudRegonId - def lcpCloudRegionId = requestMap.requestDetails.cloudConfiguration.lcpCloudRegionId - execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) - - // tenant - def tenantId = requestMap.requestDetails.cloudConfiguration.tenantId - execution.setVariable('tenantId', tenantId) - - // source - def source = requestMap.requestDetails.requestInfo.source - execution.setVariable(prefix+'source', source) - - // vnfType and asdcServiceModelVersion - - def serviceName = '' - def asdcServiceModelVersion = '' - def modelCustomizationName = '' - - def relatedInstanceList = requestMap.requestDetails.relatedInstanceList - relatedInstanceList.each { - if (it.relatedInstance.modelInfo?.modelType == 'service') { - serviceName = it.relatedInstance.modelInfo?.modelName - asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion - } - if (it.relatedInstance.modelInfo?.modelType == 'vnf') { - modelCustomizationName = it.relatedInstance.modelInfo?.modelCustomizationName - } - } - - def vnfType = serviceName + '/' + modelCustomizationName - execution.setVariable('vnfType', vnfType) - execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion) - - // vfModuleInputParams - def userParams = requestMap.requestDetails?.requestParameters?.userParams - Map<String, String> vfModuleInputMap = [:] - - userParams.each { userParam -> - vfModuleInputMap.put(userParam.name, userParam.value.toString()) - } - execution.setVariable('vfModuleInputParams', vfModuleInputMap) - - // disableRollback (true or false) - def disableRollback = requestMap.requestDetails.requestInfo.suppressRollback - execution.setVariable('disableRollback', disableRollback) - utils.log("DEBUG", 'disableRollback (suppressRollback) from request: ' + disableRollback, isDebugLogEnabled) - - } - - - - public void sendSyncResponse (DelegateExecution execution, isDebugEnabled) { - def volumeGroupId = execution.getVariable('volumeGroupId') - def requestId = execution.getVariable("mso-request-id") - def serviceInstanceId = execution.getVariable("serviceInstanceId") - - String syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", "Sync Response: " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 200, syncResponse) - - execution.setVariable(prefix+'syncResponseSent', true) - } - - - public void sendSyncError (DelegateExecution execution, isDebugEnabled) { - WorkflowException we = execution.getVariable('WorkflowException') - def errorCode = we?.getErrorCode() - def errorMessage = we?.getErrorMessage() - //default to 400 since only invalid request will trigger this method - sendWorkflowResponse(execution, 400, errorMessage) - } - - - /** - * Create a WorkflowException - * @param execution - * @param isDebugEnabled - */ - public void buildWorkflowException(DelegateExecution execution, int errorCode, errorMessage, isDebugEnabled) { - utils.log("DEBUG", errorMessage, isDebugEnabled) - (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) - } - - - /** - * Build Infra DB Request - * @param execution - * @param isDebugEnabled - */ - public void prepareDbInfraSuccessRequest(DelegateExecution execution, isDebugEnabled) { - def dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') - def requestId = execution.getVariable('mso-request-id') - def statusMessage = "VolumeGroup successfully created." - def requestStatus = "COMPLETED" - def progress = "100" - - /* - from: $gVolumeGroup/aai:volume-group-id/text() - to: vnfreq:volume-outputs/vnfreq:volume-group-id - */ - // for now assume, generated volumeGroupId is accepted - def volumeGroupId = execution.getVariable(prefix+'volumeGroupId') - - String dbRequest = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb"> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <statusMessage>${statusMessage}</statusMessage> - <responseBody></responseBody> - <requestStatus>${requestStatus}</requestStatus> - <progress>${progress}</progress> - <vnfOutputs>${dbVnfOutputs}</vnfOutputs> - <volumeGroupId>${volumeGroupId}</volumeGroupId> - </ns:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope>""" - - String buildDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable(prefix+"createDBRequest", buildDBRequestAsString) - utils.log("DEBUG", "DB Infra Request: " + buildDBRequestAsString, isDebugEnabled) - utils.logAudit(buildDBRequestAsString) - } - - - /** - * Build CommpleteMsoProcess request - * @param execution - * @param isDebugEnabled - */ - public void postProcessResponse (DelegateExecution execution, isDebugEnabled) { - - def dbReturnCode = execution.getVariable(prefix+'dbReturnCode') - def createDBResponse = execution.getVariable(prefix+'createDBResponse') - - utils.logAudit('DB return code: ' + dbReturnCode) - utils.logAudit('DB response: ' + createDBResponse) - - def requestId = execution.getVariable("mso-request-id") - def source = execution.getVariable(prefix+'source') - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info> - <aetgt:status-message>Volume Group has been created successfully.</aetgt:status-message> - <aetgt:mso-bpel-name>BPMN VF Module Volume action: CREATE</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(createDBResponse) - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable(prefix+'Success', true) - execution.setVariable(prefix+'CompleteMsoProcessRequest', xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } - - public void prepareFalloutHandlerRequest(DelegateExecution execution, isDebugEnabled) { - - WorkflowException we = execution.getVariable('WorkflowException') - def errorCode = we?.getErrorCode() - def errorMessage = we?.getErrorMessage() - - def requestId = execution.getVariable("mso-request-id") - def source = execution.getVariable(prefix+'source') - - String falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info> - <aetgt:WorkflowException> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> - </aetgt:WorkflowException> - - </aetgt:FalloutHandlerRequest>""" - - // Format Response - String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest) - utils.logAudit(xmlHandlerRequest) - - execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest) - utils.log("ERROR", "Overall Error Response going to FalloutHandler: " + "\n" + xmlHandlerRequest, isDebugEnabled) - } - - - /** - * Query AAI service instance - * @param execution - * @param isDebugEnabled - */ - public void callRESTQueryAAIServiceInstance(DelegateExecution execution, isDebugEnabled) { - - def request = execution.getVariable(prefix+"Request") - def serviceInstanceId = utils.getNodeText1(request, "service-instance-id") - - AaiUtil aaiUtil = new AaiUtil(this) - String aaiEndpoint = aaiUtil.getSearchNodesQueryEndpoint(execution) - - def String queryAAIRequest = aaiEndpoint + "?search-node-type=service-instance&filter=service-instance-id:EQUALS:" + serviceInstanceId - utils.logAudit("AAI query service instance request: " + queryAAIRequest) - - APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest) - - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - - utils.logAudit("AAI query service instance return code: " + returnCode) - utils.logAudit("AAI query service instance response: " + aaiResponseAsString) - - utils.log("DEBUG", "AAI query service instance return code: " + returnCode, isDebugEnabled) - utils.log("DEBUG", "AAI query service instance response: " + aaiResponseAsString, isDebugEnabled) - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - if (returnCode=='200') { - utils.log("DEBUG", 'Service instance ' + serviceInstanceId + ' found in AAI.', isDebugEnabled) - } else { - if (returnCode=='404') { - def message = 'Service instance ' + serviceInstanceId + ' was not found in AAI. Return code: 404.' - utils.log("DEBUG", message, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message) - } else { - WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - throw new BpmnError("MSOWorkflowException") - } - } - } - - public void logAndSaveOriginalException(DelegateExecution execution, isDebugLogEnabled) { - logWorkflowException(execution, 'CreateVfModuleVolumeInfraV1 caught an event') - saveWorkflowException(execution, 'CVMVINFRAV1_originalWorkflowException') - } - - public void validateRollbackResponse(DelegateExecution execution, isDebugLogEnabled) { - - def originalException = execution.getVariable("CVMVINFRAV1_originalWorkflowException") - execution.setVariable("WorkflowException", originalException) - execution.setVariable("RollbackCompleted", true) - - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy deleted file mode 100644 index 24487d5013..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy +++ /dev/null @@ -1,551 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; - -import static org.apache.commons.lang3.StringUtils.*; -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils; -import org.json.JSONObject; -import org.json.JSONArray; - -import org.openecomp.mso.bpmn.common.scripts.AaiUtil; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.bpmn.infrastructure.aai.AAICreateResources; - - -/** - * This class supports the CreateVnfInfra Flow - * with the creation of a generic vnf for - * infrastructure. - */ -class CreateVnfInfra extends AbstractServiceTaskProcessor { - - String Prefix="CREVI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - CatalogDbUtils cutils = new CatalogDbUtils() - AAICreateResources aaiCR = new AAICreateResources() - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - * - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED CreateVnfInfra PreProcessRequest Process*** ", isDebugEnabled) - - setBasicDBAuthHeader(execution, isDebugEnabled) - execution.setVariable("CREVI_sentSyncResponse", false) - - try{ - // Get Variables - String createVnfRequest = execution.getVariable("bpmnRequest") - execution.setVariable("CREVI_createVnfRequest", createVnfRequest) - utils.logAudit("Incoming CreateVnfInfra Request is: \n" + createVnfRequest) - - if(createVnfRequest != null){ - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("CREVI_requestId", requestId) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("CREVI_serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfType = execution.getVariable("vnfType") - execution.setVariable("CREVI_vnfType", vnfType) - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) - - String vnfName = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.instanceName") - execution.setVariable("CREVI_vnfName", vnfName) - utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) - - String serviceId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("CREVI_serviceId", serviceId) - utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) - - String source = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.source") - execution.setVariable("CREVI_source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - String suppressRollback = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("CREVI_suppressRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled) - - def vnfModelInfo = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo") - execution.setVariable("CREVI_vnfModelInfo", vnfModelInfo) - - String modelInvariantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelInvariantUuid") - execution.setVariable("CREVI_modelInvariantId", modelInvariantId) - utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) - - String modelVersion = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.modelInfo.modelVersion") - execution.setVariable("CREVI_modelVersion", modelVersion) - utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled) - - def cloudConfiguration = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration") - execution.setVariable("CREVI_cloudConfiguration", cloudConfiguration) - - String cloudSiteId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("CREVI_cloudSiteId", cloudSiteId) - utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) - - String tenantId = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("CREVI_tenantId", tenantId) - utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable("CREVI_requestInfo", requestInfo) - - //TODO: Orch Status - TBD, will come from SDN-C Response in 1702 - String orchStatus = "Created" - execution.setVariable("CREVI_orchStatus", orchStatus) - - //TODO: Equipment Role - Should come from SDN-C Response in 1702 - String equipmentRole = " " - execution.setVariable("CREVI_equipmentRole", equipmentRole) - - String vnfId = execution.getVariable("testVnfId") // for junits - if(isBlank(vnfId)){ - vnfId = UUID.randomUUID().toString() - utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) - } - execution.setVariable("CREVI_vnfId", vnfId) - - // Setting for Sub Flow Calls - execution.setVariable("CREVI_type", "generic-vnf") - execution.setVariable("GENGS_type", "service-instance") - - String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - execution.setVariable("CREVI_sdncCallbackUrl", sdncCallbackUrl) - - def vnfInputParameters = null - try { - vnfInputParameters = jsonUtil.getJsonValue(createVnfRequest, "requestDetails.requestParameters.userParams") - } - catch (Exception e) { - utils.log("DEBUG", "userParams are not present in the request", isDebugEnabled) - } - execution.setVariable("CREVI_vnfInputParameters", vnfInputParameters) - - - utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) - logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) - - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Bpmn Request is Null.") - } - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in CreateVnfInfra PreProcessRequest method!" + e.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PreProcessRequest Process ***", isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra SendSyncResponse Process *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("CREVI_requestId") - String vnfId = execution.getVariable("CREVI_vnfId") - - String createVnfResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " CreateVnfInfra Sync Response is: \n" + createVnfResponse, isDebugEnabled) - - sendWorkflowResponse(execution, 202, createVnfResponse) - - execution.setVariable("CREVI_sentSyncResponse", true) - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVnfInfra SendSyncResponse Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra SendSyncResponse Process") - - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra SendSyncResponse Process ***", isDebugEnabled) - } - - - public void preProcessSDNCAssignRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - def vnfId = execution.getVariable("CREVI_vnfId") - def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId") - logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled) - utils.logAudit("NEW VNF ID: " + vnfId) - - try{ - //Build SDNC Request - - String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign") - - assignSDNCRequest = utils.formatXml(assignSDNCRequest) - execution.setVariable("CREVI_assignSDNCRequest", assignSDNCRequest) - logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCActivateRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - try{ - String vnfId = execution.getVariable("CREVI_vnfId") - String serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId") - - String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate") - - execution.setVariable("CREVI_activateSDNCRequest", activateSDNCRequest) - logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) - - }catch(Exception e){ - log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("CREVI_sdncCallbackUrl") - def requestId = execution.getVariable("CREVI_requestId") - def serviceId = execution.getVariable("CREVI_serviceId") - def vnfType = execution.getVariable("CREVI_vnfType") - def vnfName = execution.getVariable("CREVI_vnfName") - def tenantId = execution.getVariable("CREVI_tenantId") - def source = execution.getVariable("CREVI_source") - def vnfId = execution.getVariable("CREVI_vnfId") - def cloudSiteId = execution.getVariable("CREVI_cloudSiteId") - - String sdncVNFParamsXml = "" - - if(execution.getVariable("CREVI_vnfParamsExistFlag") == true){ - sdncVNFParamsXml = buildSDNCParamsXml(execution) - }else{ - sdncVNFParamsXml = "" - } - - String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>VNFActivateRequest</request-action> - <source>${source}</source> - <notification-url/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <service-type>${serviceId}</service-type> - <service-instance-id>${svcInstId}</service-instance-id> - <subscriber-name>notsurewecare</subscriber-name> - </service-information> - <vnf-request-information> - <vnf-id>${vnfId}</vnf-id> - <vnf-name>${vnfName}</vnf-name> - <vnf-type>${vnfType}</vnf-type> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - <tenant>${tenantId}</tenant> - ${sdncVNFParamsXml} - </vnf-request-information> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - } - - public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - public void prepareCompletionHandlerRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra PrepareCompletionHandlerRequest Process *** ", isDebugEnabled) - - try { - String requestInfo = execution.getVariable("CREVI_requestInfo") - String vnfId = execution.getVariable("CREVI_vnfId") - requestInfo = utils.removeXmlPreamble(requestInfo) - - String request = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - ${requestInfo} - <status-message>Vnf has been created successfully.</status-message> - <vnfId>${vnfId}</vnfId> - <mso-bpel-name>CreateVnfInfra</mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - execution.setVariable("CREVI_completionHandlerRequest", request) - utils.log("DEBUG", "Completion Handler Request is: " + request, isDebugEnabled) - - execution.setVariable("WorkflowResponse", "Success") // for junits - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCompletionHandlerRequest Process") - - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCompletionHandlerRequest Process ***", isDebugEnabled) - } - - public void sendErrorResponse(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra sendErrorResponse Process *** ", isDebugEnabled) - try { - def sentSyncResponse = execution.getVariable("CREVI_sentSyncResponse") - if(sentSyncResponse == false){ - WorkflowException wfex = execution.getVariable("WorkflowException") - String response = exceptionUtil.buildErrorResponseXml(wfex) - - utils.logAudit(response) - sendWorkflowResponse(execution, 500, response) - }else{ - utils.log("DEBUG", "Not Sending Error Response. Sync Response Already Sent", isDebugEnabled) - } - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVnfInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra sendErrorResponse Process") - - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra sendErrorResponse Process ***", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("CREVI_requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("CREVI_falloutRequest", falloutRequest) - - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVnfInfra prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra prepareFalloutRequest Process") - - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void queryCatalogDB (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra QueryCatalogDB Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfModelInfo = execution.getVariable("CREVI_vnfModelInfo") - String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") - utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugEnabled) - - JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(execution, - vnfModelCustomizationUuid, "v2") - utils.log("DEBUG", "obtained VNF list: " + vnfs, isDebugEnabled) - - if (vnfs == null) { - utils.log("ERROR", "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNFs in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid) - } - - // Only one match here - JSONObject vnf = vnfs.get(0) - - if (vnf == null) { - utils.log("ERROR", "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "No matching VNF in Catalog DB for vnfModelCustomizationUuid=" + vnfModelCustomizationUuid) - } - - VnfResource vnfResource = new VnfResource() - String nfType = jsonUtil.getJsonValueForKey(vnf, "nfType") - vnfResource.setNfType(nfType) - String nfRole = jsonUtil.getJsonValueForKey(vnf, "nfRole") - vnfResource.setNfRole(nfRole) - String nfFunction = jsonUtil.getJsonValueForKey(vnf, "nfFunction") - vnfResource.setNfFunction(nfFunction) - String nfNamingCode = jsonUtil.getJsonValueForKey(vnf, "nfNamingCode") - vnfResource.setNfNamingCode(nfNamingCode) - - execution.setVariable("CREVI_vnfResourceDecomposition", vnfResource) - - }catch(BpmnError e) { - throw e; - }catch(Exception ex) { - utils.log("DEBUG", "Error Occurred in CreateVnfInfra QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occurred in CreateVnfInfra QueryCatalogDB Process") - } - - - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra QueryCatalogDb Process ***", isDebugEnabled) - } - public void createPlatform (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** START createPlatform *****", isDebugEnabled) - - String request = execution.getVariable("bpmnRequest") - String platformName = jsonUtil.getJsonValue(request, "requestDetails.platform.platformName") - String vnfId = execution.getVariable("CREVI_vnfId") - - utils.log("DEBUG","Platform NAME: " + platformName, isDebugEnabled) - utils.log("DEBUG","VnfID: " + vnfId, isDebugEnabled) - - if(platformName == null||platformName.equals("")){ - String msg = "Exception in createPlatform. platformName was not found in the request."; - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - }else{ - utils.log("DEBUG", "platformName was found.", isDebugEnabled) - try{ - AAICreateResources aaiCR = new AAICreateResources() - aaiCR.createAAIPlatform(platformName, vnfId) - }catch(Exception ex){ - String msg = "Exception in createPlatform. " + ex.getMessage(); - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - utils.log("DEBUG"," *** Exit createPlatform *** ", isDebugEnabled) - } - public void createLineOfBusiness (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** START createLineOfBusiness *****", isDebugEnabled) - - String request = execution.getVariable("bpmnRequest") - String lineOfBusiness = jsonUtil.getJsonValue(request, "requestDetails.lineOfBusiness.lineOfBusinessName") - String vnfId = execution.getVariable("CREVI_vnfId") - - utils.log("DEBUG","LineOfBusiness NAME: " + lineOfBusiness, isDebugEnabled) - utils.log("DEBUG","VnfID: " + vnfId, isDebugEnabled) - - if(lineOfBusiness == null || lineOfBusiness.equals("")){ - utils.log("DEBUG", "LineOfBusiness was not found. Continuing on with flow...", isDebugEnabled) - }else{ - utils.log("DEBUG", "LineOfBusiness was found.", isDebugEnabled) - try{ - AAICreateResources aaiCR = new AAICreateResources() - aaiCR.createAAILineOfBusiness(lineOfBusiness, vnfId) - }catch(Exception ex){ - String msg = "Exception in LineOfBusiness. " + ex.getMessage(); - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - utils.log("DEBUG"," *** Exit createLineOfBusiness *** ", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy deleted file mode 100644 index 8c8543345f..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteCustomE2EServiceInstance.groovy +++ /dev/null @@ -1,394 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 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.infrastructure.scripts;
-
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-
-import java.util.UUID;
-import javax.xml.parsers.DocumentBuilder
-import javax.xml.parsers.DocumentBuilderFactory
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONObject;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.w3c.dom.Document
-import org.w3c.dom.Element
-import org.w3c.dom.Node
-import org.w3c.dom.NodeList
-import org.xml.sax.InputSource
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.springframework.web.util.UriUtils;
-
-/**
- * This groovy class supports the <class>DelE2EServiceInstance.bpmn</class> process.
- *
- */
-public class DeleteCustomE2EServiceInstance extends AbstractServiceTaskProcessor {
-
- String Prefix="DELSI_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils()
-
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- String msg = ""
-
- utils.log("INFO", " *** preProcessRequest Request *** ", isDebugEnabled)
-
- try {
- // check for incoming json message/input
- String siRequest = execution.getVariable("bpmnRequest")
- utils.logAudit(siRequest)
-
-
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
- utils.log("INFO", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled)
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- if (isBlank(serviceInstanceId)) {
- msg = "Input serviceInstanceId' is null"
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
-
- //requestInfo
-// String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId")
-// if (isBlank(productFamilyId))
-// {
-// msg = "Input productFamilyId is null"
-// utils.log("INFO", msg, isDebugEnabled)
-// //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
-// } else {
-// execution.setVariable("productFamilyId", productFamilyId)
-// }
- String source = jsonUtil.getJsonValue(siRequest, "source")
- execution.setVariable("source", source)
-
- //subscriberInfo
- String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "globalSubscriberId")
- if (isBlank(globalSubscriberId)) {
- msg = "Input globalSubscriberId' is null"
- utils.log("INFO", msg, isDebugEnabled)
- } else {
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- }
-
- //requestParameters
- String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "serviceType")
- if (isBlank(subscriptionServiceType)) {
- msg = "Input subscriptionServiceType is null"
- utils.log("DEBUG", msg, isDebugEnabled)
- //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- } else {
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- }
- String operationId = jsonUtil.getJsonValue(siRequest, "operationId")
- execution.setVariable("operationId", operationId)
-
- execution.setVariable("operationType", "DELETE")
- } 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)
- }
-
- public void sendSyncResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** sendSyncResponse *** ", isDebugEnabled)
- try {
- String operationId = execution.getVariable("operationId")
- String syncResponse = """{"operationId":"${operationId}"}""".trim()
- utils.log("INFO", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
- sendWorkflowResponse(execution, 202, syncResponse)
-
- } catch (Exception ex) {
- String msg = "Exception in sendSyncResponse: " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO"," ***** Exit sendSyncResopnse *****", isDebugEnabled)
- }
-
- public void sendSyncError (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** sendSyncError *** ", isDebugEnabled)
-
- try {
- String errorMessage = ""
- if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
- WorkflowException wfe = execution.getVariable("WorkflowException")
- errorMessage = wfe.getErrorMessage()
- } else {
- errorMessage = "Sending Sync Error."
- }
-
- String buildworkflowException =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
-
- } catch (Exception ex) {
- utils.log("INFO", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
-
- }
-
- public void prepareCompletionRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** prepareCompletion *** ", isDebugEnabled)
-
- try {
- String requestId = execution.getVariable("msoRequestId")
- String source = execution.getVariable("source")
- String msoCompletionRequest =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:status-message>E2E Service Instance was deleted successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>DeleteCustomE2EServiceInstance</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- execution.setVariable("completionRequest", xmlMsoCompletionRequest)
- utils.log("INFO", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- String msg = " Exception in prepareCompletion:" + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO", "*** Exit prepareCompletionRequest ***", isDebugEnabled)
- }
-
- public void prepareFalloutRequest(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** prepareFalloutRequest *** ", isDebugEnabled)
-
- try {
- WorkflowException wfex = execution.getVariable("WorkflowException")
- utils.log("INFO", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled)
- String requestId = execution.getVariable("msoRequestId")
- String source = execution.getVariable("source")
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>"""
-
- String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
- execution.setVariable("falloutRequest", falloutRequest)
- } catch (Exception ex) {
- utils.log("INFO", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled)
- String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage()
- String requestId = execution.getVariable("msoRequestId")
- String falloutRequest =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>VID</source>
- </request-info>
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- execution.setVariable("falloutRequest", falloutRequest)
- }
- utils.log("INFO", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
- }
-
-
- // *******************************
- // Build DB request Section
- // *******************************
- public void prepareDBRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
-
- try {
- utils.log("INFO", " ***** Inside prepareDBRequest of DeleteCustomE2EServiceInstance ***** ", isDebugEnabled)
-
- String requestId = execution.getVariable("DELSI_requestId")
- String statusMessage = "E2E Service Instance successfully deleted."
-
- //TODO - verify the format for Service Instance Delete,
- String dbRequest =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>COMPLETED</requestStatus>
- <progress>100</progress>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- String buildDeleteDBRequestAsString = utils.formatXml(dbRequest)
- execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString)
- utils.logAudit(buildDeleteDBRequestAsString)
-
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DeleteCustomE2EServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- // *******************************
- // Build Error Section
- // *******************************
- public void prepareDBRequestError (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
-
- utils.log("INFO", " ***** Inside prepareDBRequestError of DeleteCustomE2EServiceInstance ***** ", isDebugEnabled)
-
- try {
- String requestId = execution.getVariable("DELSI_requestId")
- String statusMessage = ""
- if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
- WorkflowException wfe = execution.getVariable("WorkflowException")
- statusMessage = wfe.getErrorMessage()
-
- } else {
- statusMessage = "Encountered Error during DeleteCustomE2EServiceInstance proccessing. "
- }
-
- //TODO - verify the format for Service Instance Create,
- String dbRequest =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>FAILED</requestStatus>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- String buildDBRequestAsString = utils.formatXml(dbRequest)
- execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString)
- utils.logAudit(buildDBRequestAsString)
-
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DeleteCustomE2EServiceInstance flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage()
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- public void processJavaException(DelegateExecution execution) {
- //TODO:
- }
-
- /**
- * Init the service Operation Status
- */
- public void prepareInitServiceOperationStatus(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = execution.getVariable("operationId")
- String userId = ""
- String result = "processing"
- String progress = "0"
- String reason = ""
- String operationContent = "Prepare service creation"
- utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
-
- def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
- <serviceId>${serviceId}</serviceId>
- <operationId>${operationId}</operationId>
- <operationType>DELETE</operationType>
- <userId>${userId}</userId>
- <result>${result}</result>
- <operationContent>${operationContent}</operationContent>
- <progress>${progress}</progress>
- <reason>${reason}</reason>
- </ns:updateServiceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
- utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage())
- }
- utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled)
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy deleted file mode 100644 index c731a613cc..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy +++ /dev/null @@ -1,374 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; - -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource -import static org.apache.commons.lang3.StringUtils.*; - -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the <class>DelServiceInstance.bpmn</class> process. - * - */ -public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DELSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - - utils.log("DEBUG", " *** preProcessRequest Request *** ", isDebugEnabled) - - try { - // check for incoming json message/input - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)) { - msg = "Input serviceInstanceId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - //String xmlRequestDetails = vidUtils.getJsonRequestDetailstoXml(siRequest) - //execution.setVariable("requestDetails", xmlRequestDetails) - - //modelInfo - String serviceModelInfo = jsonUtil.getJsonValue(siRequest, "requestDetails.modelInfo") - if (isBlank(serviceModelInfo)) { - msg = "Input serviceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - } else - { - execution.setVariable("serviceModelInfo", serviceModelInfo) - //utils.log("DEBUG", "modelInfo" + serviceModelInfo, isDebugEnabled) - } - - //requestInfo - String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") - if (isBlank(productFamilyId)) - { - msg = "Input productFamilyId is null" - utils.log("DEBUG", msg, isDebugEnabled) - //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("productFamilyId", productFamilyId) - } - String source = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source") - execution.setVariable("source", source) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - utils.log("DEBUG", msg, isDebugEnabled) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //requestParameters - String subscriptionServiceType = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - /* - * Extracting User Parameters from incoming Request and converting into a Map - */ - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - - Map reqMap = jsonSlurper.parseText(siRequest) - - //InputParams - def userParams = reqMap.requestDetails?.requestParameters?.userParams - - Map<String, String> inputMap = [:] - if (userParams) { - userParams.each { - userParam -> inputMap.put(userParam.name, userParam.value.toString()) - } - } - - utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) - execution.setVariable("serviceInputParams", inputMap) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // RESTResponse (for API Handler (APIH) Reply Task) - String syncResponse = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse: " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareCompletionRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELETE</action> - <source>${source}</source> - </request-info> - <aetgt:status-message>Service Instance was deleted successfully.</aetgt:status-message> - <aetgt:mso-bpel-name>DeleteGenericALaCarteServiceInstance</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("completionRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELETE</action> - <source>${source}</source> - </request-info>""" - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELETE</action> - <source>VID</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } - - - // ******************************* - // Build DB request Section - // ******************************* - public void prepareDBRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequest of DeleteGenericALaCarteServiceInstance ***** ", isDebugEnabled) - - String requestId = execution.getVariable("DELSI_requestId") - String statusMessage = "Service Instance successfully deleted." - - //TODO - verify the format for Service Instance Delete, - String dbRequest = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb"> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <statusMessage>${statusMessage}</statusMessage> - <responseBody></responseBody> - <requestStatus>COMPLETED</requestStatus> - <progress>100</progress> - </ns:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope>""" - - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString) - utils.logAudit(buildDeleteDBRequestAsString) - - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ******************************* - // Build Error Section - // ******************************* - public void prepareDBRequestError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteGenericALaCarteServiceInstance ***** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("DELSI_requestId") - String statusMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - statusMessage = wfe.getErrorMessage() - - } else { - statusMessage = "Encountered Error during DeleteGenericALaCarteServiceInstance proccessing. " - } - - //TODO - verify the format for Service Instance Create, - String dbRequest = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb"> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <statusMessage>${statusMessage}</statusMessage> - <responseBody></responseBody> - <requestStatus>FAILED</requestStatus> - </ns:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope>""" - - String buildDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString) - utils.logAudit(buildDBRequestAsString) - - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage() - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy deleted file mode 100644 index a9aef7f3ee..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy +++ /dev/null @@ -1,421 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils -import groovy.xml.XmlUtil -import groovy.json.* - -public class DeleteNetworkInstance extends AbstractServiceTaskProcessor { - String Prefix="DELNI_" - String groovyClassName = "DeleteNetworkInstance" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - - - public InitializeProcessVariables(DelegateExecution execution){ - - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "CompleteMsoProcessRequest", "") - execution.setVariable(Prefix + "FalloutHandlerRequest", "") - execution.setVariable(Prefix + "isSilentSuccess", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of " + groovyClassName + " ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null || sdncVersion == '1610') { - // 'a-la-cart' default, sdncVersion = '1610' - execution.setVariable("sdncVersion", "1610") - String bpmnRequest = execution.getVariable("bpmnRequest") - // set 'disableRollback' - if (bpmnRequest != null) { - String disableRollback = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.requestInfo.suppressRollback") - if (disableRollback != null) { - execution.setVariable("disableRollback", disableRollback) - utils.log("DEBUG", "Received 'suppressRollback': " + disableRollback , isDebugEnabled) - } else { - execution.setVariable("disableRollback", false) - } - utils.log("DEBUG", " Set 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } else { - String dataErrorMessage = " Invalid 'bpmnRequest' request." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } else { - // 'macro' test ONLY, sdncVersion = '1702' - utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - - // get/set 'requestId' - if (execution.getVariable("requestId") == null) { - execution.setVariable("requestId", requestId) - } - - // set action to "DELETE" - execution.setVariable("action", "DELETE") - - //Place holder for additional code. - - // TODO ??? - // userParams??? 1) pre-loads indicator, 2) 'auto-activation' - // Tag/Value parameters - // - // Map: 'networkInputParams': 'auto-activation'' - // Sample format? - // "requestParameters": { - // "userParams": [ - // { - // "name": "someUserParam1", - // "value": "someValue1" - // } - // ] - // } - // - // String userParams = //use json util to extract "userParams"// - // execution.setVariable("networkInputParams", userParams) - // else: execution.setVariable("networkInputParams", null) - // - - - } catch (Exception ex){ - sendSyncError(execution) - String exceptionMessage = "Exception Encountered in " + groovyClassName + ", PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void getNetworkModelInfo (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of DeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // For Ala-Carte (sdnc = 1610): - // 1. the Network ModelInfo is expected to be sent - // via requestDetails.modelInfo (modelType = network), ex: modelCustomizationId. - // 2. the Service ModelInfo is expected to be sent but will be IGNORE - // via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service) - - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncResponse() of DeleteNetworkInstance ***** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // RESTResponse (for API Handler (APIH) Reply Task) - String deleteNetworkRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + deleteNetworkRestRequest, isDebugEnabled) - - sendWorkflowResponse(execution, 202, deleteNetworkRestRequest) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Exception Encountered in DeleteNetworkInstance, sendSyncResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareCompletion (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareCompletion() of CreateNetworkInstance ***** ", isDebugEnabled) - - try { - - String requestId = execution.getVariable("mso-request-id") - String source = execution.getVariable(Prefix + "source") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELETE</action> - <source>VID</source> - </request-info> - <aetgt:status-message>Network has been deleted successfully.</aetgt:status-message> - <aetgt:mso-bpel-name>BPMN Network action: DELETE</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - // normal path - execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void prepareDBRequestError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteNetworkInstance ***** ", isDebugEnabled) - - // set DB Header Authorization - setBasicDBAuthHeader(execution, isDebugEnabled) - - WorkflowException wfe = execution.getVariable("WorkflowException") - String statusMessage = wfe.getErrorMessage() - String requestId = execution.getVariable(Prefix +"requestId") - - String dbRequest = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb"> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <statusMessage>${statusMessage}</statusMessage> - <responseBody></responseBody> - <requestStatus>FAILED</requestStatus> - <progress></progress> - <vnfOutputs><network-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"/></vnfOutputs> - </ns:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope>""" - - execution.setVariable(Prefix + "deleteDBRequest", dbRequest) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, prepareDBRequestError() - " + ex.getMessage() - logError(exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void postProcessResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse() of DeleteNetworkInstance ***** ", isDebugEnabled) - - try { - if (execution.getVariable("CMSO_ResponseCode") == "200") { - execution.setVariable(Prefix + "Success", true) - utils.log("DEBUG", " ***** DeleteNetworkInstance Success ***** ", isDebugEnabled) - // Place holder for additional code. - - } else { - execution.setVariable(Prefix + "Success", false) - utils.log("DEBUG", " ***** DeleteNetworkInstance Failed in CompletionMsoProces flow!. ***** ", isDebugEnabled) - - } - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DeleteNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - // Prepare for FalloutHandler - public void buildErrorResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) - - String dbReturnCode = execution.getVariable(Prefix + "dbReturnCode") - utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) - utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + execution.getVariable(Prefix + "deleteDBResponse"), isDebugEnabled) - - String falloutHandlerRequest = "" - String requestId = execution.getVariable("mso-request-id") - String source = execution.getVariable(Prefix + "source") - execution.setVariable(Prefix + "Success", false) - try { - WorkflowException wfe = execution.getVariable("WorkflowException") - String errorCode = String.valueOf(wfe.getErrorCode()) - String errorMessage = wfe.getErrorMessage() - - falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELETE</action> - <source>${source}</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - utils.logAudit(falloutHandlerRequest) - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("ERROR", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, buildErrorResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELEtE</action> - <source>${source}</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${exceptionMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>9999</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - } - } - - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // RESTResponse (for API Handler (APIH) Reply Task) - String deleteNetworkRestError = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + deleteNetworkRestError, isDebugEnabled) - - sendWorkflowResponse(execution, 500, deleteNetworkRestError) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed - DeleteNetworkInstance, sendSyncError(): " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy deleted file mode 100644 index 9a12a699f9..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteSDNCNetworkResource.groovy +++ /dev/null @@ -1,320 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - 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.infrastructure.scripts - -import org.json.JSONObject -import org.json.XML; - -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.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.infrastructure.workflow.serviceTask.client.builder.AbstractBuilder -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.rest.APIResponse; - -/** - * This groovy class supports the <class>DeleteSDNCCNetworkResource.bpmn</class> process. - * flow for SDNC Network Resource - */ -public class DeleteSDNCNetworkResource extends AbstractServiceTaskProcessor { - - String Prefix="DELSDNCRES_" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - JsonUtils jsonUtil = new JsonUtils() - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - 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("mso-request-id") - String requestAction = execution.getVariable("requestAction") - utils.log("INFO","The requestAction is: " + requestAction, isDebugEnabled) - String recipeParamsFromRequest = execution.getVariable("recipeParams") - utils.log("INFO","The recipeParams is: " + recipeParamsFromRequest, isDebugEnabled) - String resourceInput = execution.getVariable("resourceInput") - utils.log("INFO","The resourceInput is: " + resourceInput, isDebugEnabled) - //Get ResourceInput Object - ResourceInput resourceInputObj = ResourceRequestBuilder.getJsonObject(resourceInput, 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") - } - - - //For sdnc, generate svc_action and request_action - String sdnc_svcAction = "delete" - if(StringUtils.containsIgnoreCase(resourceModelName, "overlay")){ - //This will be resolved in R3. - sdnc_svcAction ="deactivate" - operationType = "NCINetwork" - } - if(StringUtils.containsIgnoreCase(resourceModelName, "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 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 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") - 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.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${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>${hdrRequestId}</request-id> - <request-action>${sdnc_requestAction}</request-action> - <source>${source}</source> - <notification-url></notification-url> - <order-number></order-number> - <order-version></order-version> - </request-information> - <service-information> - <service-id>${serviceInstanceId}</service-id> - <subscription-service-type>${serviceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid> - <model-uuid>${serviceModelUuid}</model-uuid> - <model-version>${serviceModelVersion}</model-version> - <model-name>${serviceModelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <network-information> - <onap-model-information> - <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> - <model-customization-uuid>${modelCustomizationUuid}</model-customization-uuid> - <model-uuid>${modelUuid}</model-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${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) - utils.log("INFO","sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DeleteSDNCCNetworkResource flow. prepareSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - utils.log("INFO"," ***** Exit prepareSDNCRequest *****", isDebugEnabled) - } - - private void setProgressUpdateVariables(DelegateExecution execution, String body) { - def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - execution.setVariable("CVFMI_updateResOperStatusRequest", body) - } - - public void prepareUpdateBeforeDeleteSDNCResource(DelegateExecution execution) { - 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 = "20" - String status = "processing" - String statusDescription = "SDCN resource delete invoked" - - //String operationId = execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${serviceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - - } - - public void prepareUpdateAfterDeleteSDNCResource(DelegateExecution execution) { - 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.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${serviceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - setProgressUpdateVariables(execution, body) - } - - public void postDeleteSDNCCall(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareSDNCRequest *****", isDebugEnabled) - String responseCode = execution.getVariable(Prefix + "sdncDeleteReturnCode") - 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) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String operationStatus = "finished" - // RESTResponse for main flow - String resourceOperationResp = """{"operationStatus":"${operationStatus}"}""".trim() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + resourceOperationResp, isDebugEnabled) - sendWorkflowResponse(execution, 202, resourceOperationResp) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy deleted file mode 100644 index 72b88cb13d..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVFCNSResource.groovy +++ /dev/null @@ -1,87 +0,0 @@ - -/*- - * ============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.infrastructure.scripts - -import com.fasterxml.jackson.databind.ObjectMapper -import org.openecomp.mso.bpmn.common.recipe.ResourceInput -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil - - -public class DeleteVFCNSResource extends AbstractServiceTaskProcessor { - - String Prefix = "DCUSE_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** start preProcessRequest *****", isDebugEnabled) - - String resourceInputStr = execution.getVariable("resourceInput") - ResourceInput resourceInput = new ObjectMapper().readValue(resourceInputStr, ResourceInput.class) - - String globalSubscriberId = resourceInput.getGlobalSubscriberId() - String serviceType = execution.getVariable("serviceType") - String operationId = resourceInput.getOperationId() - String resourceModeluuid = resourceInput.getResourceModelInfo().getModelCustomizationUuid() - String resourceInstanceId = resourceInput.getResourceInstancenUuid() - - - execution.setVariable("globalSubscriberId",globalSubscriberId) - execution.setVariable("serviceType", serviceType) - execution.setVariable("operationId", operationId) - execution.setVariable("resourceTemplateId", resourceModeluuid) - execution.setVariable("resourceInstanceId", resourceInstanceId) - - utils.log("INFO"," ***** end preProcessRequest *****", isDebugEnabled) - } - - public void postProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** start postProcessRequest *****", isDebugEnabled) - - utils.log("INFO"," ***** end postProcessRequest *****", isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String nsInstanceId = execution.getVariable("nsInstanceId") - String operationStatus = execution.getVariable("operationStatus") - // RESTResponse for main flow - String createVFCResourceRestRsp = """{"nsInstanceId":"${nsInstanceId}","operationStatus":"${operationStatus}"}""".trim() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + createVFCResourceRestRsp, isDebugEnabled) - sendWorkflowResponse(execution, 202, createVFCResourceRestRsp) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } -}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy deleted file mode 100644 index 0aef81770f..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleInfra.groovy +++ /dev/null @@ -1,375 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import java.io.Serializable; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution - -import groovy.json.JsonSlurper - -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; - - -public class DeleteVfModuleInfra extends AbstractServiceTaskProcessor { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'DELVfModI_') - execution.setVariable('DELVfModI_requestInfo', null) - execution.setVariable('DELVfModI_requestId', null) - execution.setVariable('DELVfModI_source', null) - execution.setVariable('DELVfModI_vnfInputs', null) - execution.setVariable('DELVfModI_vnfId', null) - execution.setVariable('DELVfModI_vfModuleId', null) - execution.setVariable('DELVfModI_tenantId', null) - execution.setVariable('DELVfModI_volumeGroupId', null) - execution.setVariable('DELVfModI_vnfParams', null) - execution.setVariable('DELVfModI_updateInfraRequest', null) - execution.setVariable('DeleteVfModuleRequest', null) - execution.setVariable('DeleteVfModuleSuccessIndicator', false) - } - - /** - * Process the incoming DELETE_VF_MODULE vnf-request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("isVidRequest", "false") - initProcessVariables(execution) - - def prefix = execution.getVariable('prefix') - - def incomingRequest = execution.getVariable('bpmnRequest') - - utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) - utils.logAudit("DeleteVfModule Infra incoming Request: " + incomingRequest) - - // check if request is xml or json - try { - def jsonSlurper = new JsonSlurper() - Map reqMap = jsonSlurper.parseText(incomingRequest) - utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - utils.log("DEBUG", "serviceInstanceId is: " + serviceInstanceId, isDebugLogEnabled) - def vnfId = execution.getVariable('vnfId') - utils.log("DEBUG", "vnfId is: " + vnfId, isDebugLogEnabled) - def cloudConfiguration = jsonUtil.getJsonValue(incomingRequest, "requestDetails.cloudConfiguration") - execution.setVariable("cloudConfiguration", cloudConfiguration) - utils.log("DEBUG", "CloudConfiguration is: " + cloudConfiguration, isDebugLogEnabled) - def vfModuleModelInfo = jsonUtil.getJsonValue(incomingRequest, "requestDetails.modelInfo") - - execution.setVariable("vfModuleModelInfo", vfModuleModelInfo) - utils.log("DEBUG", "VfModuleModelInfo is: " + vfModuleModelInfo, isDebugLogEnabled) - - // This is aLaCarte flow, so aLaCarte flag is always on - execution.setVariable('aLaCarte', true) - - def vidUtils = new VidUtils(this) - - String requestInXmlFormat = vidUtils.createXmlVfModuleRequest(execution, reqMap, 'DELETE_VF_MODULE', serviceInstanceId) - - utils.log("DEBUG", " Request in XML format: " + requestInXmlFormat, isDebugLogEnabled) - - setBasicDBAuthHeader(execution, isDebugLogEnabled) - - execution.setVariable(prefix + 'Request', requestInXmlFormat) - execution.setVariable(prefix+'vnfId', vnfId) - execution.setVariable("isVidRequest", "true") - - } - catch(groovy.json.JsonException je) { - utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") - - } - catch(Exception e) { - String restFaultMessage = e.getMessage() - utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Internal Error - During PreProcess Request") - } - - - try { - - String request = validateRequest(execution) - execution.setVariable('DeleteVfModuleRequest', request) - utils.logAudit("DeleteVfModuleInfra Request: " + request) - - def requestInfo = getRequiredNodeXml(execution, request, 'request-info') - execution.setVariable('DELVfModI_requestInfo', requestInfo) - execution.setVariable('DELVfModI_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) - execution.setVariable('DELVfModI_source', getNodeTextForce(requestInfo, 'source')) - - def vnfInputs = getRequiredNodeXml(execution, request, 'vnf-inputs') - execution.setVariable('DELVfModI_vnfInputs', vnfInputs) - execution.setVariable('DELVfModI_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) - execution.setVariable('DELVfModI_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) - execution.setVariable('DELVfModI_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name')) - execution.setVariable('DELVfModI_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) - execution.setVariable('DELVfModI_volumeGroupId', getNodeTextForce(vnfInputs, 'volume-group-id')) - - def vnfParams = utils.getNodeXml(request, 'vnf-params') - execution.setVariable('DELVfModI_vnfParams', vnfParams) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) - } - } - - /** - * Sends the 'IN_PROGRESS' synchronous response. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = execution.getVariable('DELVfModI_requestInfo') - def requestId = execution.getVariable('DELVfModI_requestId') - def source = execution.getVariable('DELVfModI_source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - - // RESTResponse (for API Handler (APIH) Reply Task) - def vfModuleId = execution.getVariable('DELVfModI_vfModuleId') - String synchResponse = """{"requestReferences":{"instanceId":"${vfModuleId}","requestId":"${requestId}"}}""".trim() - - utils.logAudit("DeleteVfModuleInfra Synch Response: " + synchResponse) - sendWorkflowResponse(execution, 200, synchResponse) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) - } - } - - /** - * Currently passing the entire DELETE_VF_MODULE vnf-request to DoDeleteVfModule. - * 'DeleteVfModuleRequest' is now being set in preProcessRequest(). - * TBD: may want to eventually create a specific request that only contains the needed fields. - * - * @param execution The flow's execution instance. - */ - public void prepDoDeleteVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepDoDeleteVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoDeleteVfModule(): ' + e.getMessage()) - } - } - - /** - * Prepare the DB update to add an entry for the Vf Module request. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateInfraRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateInfraRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('DELVfModI_requestId') - def vnfId = execution.getVariable('DELVfModI_vnfId') - def vfModuleId = execution.getVariable('DELVfModI_vfModuleId') - def tenantId = execution.getVariable('DELVfModI_tenantId') - def volumeGroupId = execution.getVariable('DELVfModI_volumeGroupId') - - String updateInfraRequest = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:req="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <req:updateInfraRequest> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <requestStatus>COMPLETED</requestStatus> - <progress>100</progress> - </req:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope> - """ - - updateInfraRequest = utils.formatXml(updateInfraRequest) - execution.setVariable('DELVfModI_updateInfraRequest', updateInfraRequest) - utils.logAudit("DeleteAAIVfModuleInfra Update Request: " + updateInfraRequest) - logDebug('Request for Update Infra Request:\n' + updateInfraRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepInfraRequest(): ' + e.getMessage()) - } - } - - /** - * Builds a "CompletionHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void completionHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.completionHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def request = execution.getVariable("DeleteVfModuleRequest") - def requestInfo = utils.getNodeXml(request, 'request-info', false) - def action = utils.getNodeText1(requestInfo, "action") - - String content = - """ <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - ${requestInfo} - </request-info> - <ns8:status-message>Vf Module has been deleted successfully.</ns8:status-message> - <ns8:mso-bpel-name>BPMN</ns8:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - utils.logAudit("DeleteVfModule Infra Completion Handler Request: " + content) - execution.setVariable(resultVar, content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') - } - } - - /** - * Builds a "FalloutHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void falloutHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def prefix = execution.getVariable('prefix') - def request = execution.getVariable("DeleteVfModuleRequest") - def requestInfo = utils.getNodeXml(request, 'request-info', false) - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def errorResponseCode = workflowException.getErrorCode() - def errorResponseMsg = workflowException.getErrorMessage() - def encErrorResponseMsg = "" - if (errorResponseMsg != null) { - encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") - } - - String content = """ - <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1" - xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1" - xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1"> - ${requestInfo} - <sdncadapterworkflow:WorkflowException> - <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage> - <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode> - </sdncadapterworkflow:WorkflowException> - </sdncadapterworkflow:FalloutHandlerRequest> - """ - content = utils.formatXml(content) - utils.logAudit("DeleteVfModuleInfra Fallout Handler Request: " + content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') - } - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy deleted file mode 100644 index 5a38d9f011..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVfModuleVolumeInfraV1.groovy +++ /dev/null @@ -1,549 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import groovy.json.JsonSlurper
-
-import java.util.concurrent.ExecutionException;
-
-import org.springframework.web.util.UriUtils
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil;
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
-import org.openecomp.mso.bpmn.common.scripts.VidUtils;
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse
-
-/**
- * This groovy class supports the <class>DeleteVfModuleVolume.bpmn</class> process.
- */
-public class DeleteVfModuleVolumeInfraV1 extends AbstractServiceTaskProcessor {
-
- private XmlParser xmlParser = new XmlParser()
- /**
- * This method is executed during the preProcessRequest task of the <class>DeleteVfModuleVolume.bpmn</class> process.
- * @param execution
- */
- public InitializeProcessVariables(DelegateExecution execution){
- execution.setVariable('prefix', 'DELVfModVol_')
- execution.setVariable("DELVfModVol_volumeRequest", null)
- execution.setVariable('DELVfModVol_requestInfo', null)
- execution.setVariable('DELVfModVol_requestId', null)
- execution.setVariable('DELVfModVol_source', null)
- execution.setVariable('DELVfModVol_volumeInputs', null)
- execution.setVariable('DELVfModVol_volumeOutputs', null)
- execution.setVariable('DELVfModVol_volumeGroupId', null)
- execution.setVariable('DELVfModVol_vnfType', null)
- execution.setVariable('DELVfModVol_serviceId', null)
- execution.setVariable('DELVfModVol_cloudRegion', null)
- execution.setVariable('DELVfModVol_tenantId', null)
- execution.setVariable('DELVfModVol_volumeParams', null)
- execution.setVariable('DELVfModVol_volumeGroupHeatStackId', null)
- execution.setVariable('DELVfModVol_volumeGroupTenantId', null)
- execution.setVariable("DELVfModVol_queryAAIVolGrpResponse", null)
- execution.setVariable('DELVfModVol_messageId', null)
- execution.setVariable('DELVfModVol_deleteVnfARequest', null)
- execution.setVariable('DELVfModVol_updateInfraRequest', null)
- execution.setVariable('DELVfModVol_CompleteMsoProcessRequest', null)
- execution.setVariable('DELVfModVol_WorkflowException', null)
- execution.setVariable('DELVfModVol_TransactionSuccessIndicator', false)
- execution.setVariable("DELVfModVol_isErrorMessageException", false)
- execution.setVariable('DELVfModVol_syncResponseSent', false)
- }
-
- /**
- * Perform initial processing, such as request validation, initialization of variables, etc.
- * * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- preProcessRequest(execution, isDebugEnabled)
- }
-
- /**
- * This method is executed during the preProcessRequest task of the <class>DeleteVfModuleVolume.bpmn</class> process.
- * @param execution
- */
- public void preProcessRequest (DelegateExecution execution, isDebugLogEnabled) {
-
- InitializeProcessVariables(execution)
-
- String createVolumeIncoming = validateRequest(execution)
- utils.logAudit(createVolumeIncoming)
-
- // check if request is xml or json
- try {
- def jsonSlurper = new JsonSlurper()
- Map reqMap = jsonSlurper.parseText(createVolumeIncoming)
- utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
-
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- def vidUtils = new VidUtils(this)
- createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'DELETE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId)
- execution.setVariable("DELVfModVol_isVidRequest", true)
- }
- catch(groovy.json.JsonException je) {
- utils.log("DEBUG", " Request is in XML format.", isDebugLogEnabled)
- // assume request is in XML format - proceed as usual to process XML request
- }
-
- String request = utils.getNodeXml(createVolumeIncoming, "volume-request").drop(38).trim().replace("tag0:","").replace(":tag0","")
- execution.setVariable("DELVfModVol_volumeRequest", request)
-
- def requestInfo = getRequiredNodeXml(execution, request, 'request-info')
- execution.setVariable('DELVfModVol_requestInfo', requestInfo)
- String requestId = execution.getVariable("mso-request-id")
- if (requestId == null || requestId == "") {
- requestId = getRequiredNodeText(execution, requestInfo, 'request-id')
- }
- execution.setVariable('DELVfModVol_requestId', requestId)
- execution.setVariable('DELVfModVol_source', getNodeTextForce(requestInfo, 'source'))
-
- def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs')
- execution.setVariable('DELVfModVol_volumeInputs', volumeInputs)
- execution.setVariable('DELVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id'))
- execution.setVariable('DELVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type'))
- execution.setVariable('DELVfModVol_serviceId', utils.getNodeText1(volumeInputs, 'service-id'))
- execution.setVariable('DELVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id'))
- execution.setVariable('DELVfModVol_messageId', UUID.randomUUID().toString())
- execution.setVariable('DELVfModVol_volumeOutputs', utils.getNodeXml(request, 'volume-outputs', false))
- execution.setVariable('DELVfModVol_volumeParams', utils.getNodeXml(request, 'volume-params'))
- execution.setVariable('DELVfModVol_cloudRegion', utils.getNodeText1(request, 'aic-cloud-region'))
-
- setBasicDBAuthHeader(execution, isDebugLogEnabled)
-
- logDebug('Request: ' + createVolumeIncoming, isDebugLogEnabled)
- }
-
- public void sendSyncResponse (DelegateExecution execution, isDebugEnabled) {
-
- String volumeRequest = execution.getVariable("DELVfModVol_volumeRequest")
- utils.log("DEBUG", " DELVfModVol_volumeRequest - " + "\n" + volumeRequest, isDebugEnabled)
- // RESTResponse (for API Handler (APIH) Reply Task)
- String deleteVolumeRequest =
- """<rest:RESTResponse xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd" statusCode="200">
- <rest:payload xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"
- contentType="text/xml">
- ${volumeRequest}
- </rest:payload>
- </rest:RESTResponse>""".trim()
-
- def isVidRequest = execution.getVariable('DELVfModVol_isVidRequest')
- def syncResponse = ''
-
- if(isVidRequest) {
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- def requestId = execution.getVariable('DELVfModVol_requestId')
- syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim()
- }
- else {
- syncResponse = utils.formatXml(deleteVolumeRequest)
- }
-
- execution.setVariable('DELVfModVol_syncResponseSent', true)
-
- sendWorkflowResponse(execution, 200, syncResponse)
- }
-
-
- public void sendSyncError (DelegateExecution execution, isDebugEnabled) {
- WorkflowException we = execution.getVariable('WorkflowException')
- def errorCode = we?.getErrorCode()
- def errorMessage = we?.getErrorMessage()
- //default to 400 since only invalid request will trigger this method
- sendWorkflowResponse(execution, 400, errorMessage)
- }
-
-
- public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) {
-
- String cloudRegion = execution.getVariable('DELVfModVol_cloudRegion')
-
- String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- AaiUtil aaiUtil = new AaiUtil(this)
- String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
- String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
- utils.logAudit(queryCloudRegionRequest)
- execution.setVariable("DELVfModVol_queryCloudRegionRequest", queryCloudRegionRequest)
- utils.log("DEBUG", " DELVfModVol_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled)
-
- cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if ((cloudRegion != "ERROR")) {
- if(execution.getVariable("DELVfModVol_queryCloudRegionReturnCode") == "404"){
- execution.setVariable("DELVfModVol_aicCloudRegion", "AAIAIC25")
- }else{
- execution.setVariable("DELVfModVol_aicCloudRegion", cloudRegion)
- }
- execution.setVariable("DELVfModVol_cloudRegion", cloudRegion)
- execution.setVariable("DELVfModVol_isCloudRegionGood", true)
-
- } else {
- utils.log("DEBUG", "AAI Query Cloud Region Unsuccessful.", isDebugEnabled)
- execution.setVariable("DELVfModVol_isCloudRegionGood", false)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable("DELVfModVol_queryCloudRegionReturnCode"))
- }
-
- utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable("DELVfModVol_isCloudRegionGood"), isDebugEnabled)
- }
-
- /**
- * Query volume group by id
- * @param execution
- */
- public void queryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) {
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId')
- if(volumeGroupId == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'volume-group-id is not provided in the request')
- throw new Exception('volume-group-id is not provided in the request')
- }
- String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8")
-
- utils.logAudit('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
- logDebug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest, isDebugLogEnabled)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query volume group by id return code: " + returnCode)
- utils.logAudit("AAI query volume group by id response: " + aaiResponseAsString)
-
- execution.setVariable("DELVfModVol_queryAAIVolGrpResponse", aaiResponseAsString)
-
- if (returnCode=='200' || returnCode == '204') {
-
- def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
- execution.setVariable('DELVfModVol_volumeGroupHeatStackId', heatStackId)
-
- if(hasVfModuleRelationship(aaiResponseAsString)){
- utils.log("DEBUG", 'Volume Group ' + volumeGroupId + ' currently in use', isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.")
- }
-
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
- if (volumeGroupTenantId == null) {
- utils.log("DEBUG", "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
- }
-
- execution.setVariable('DELVfModVol_volumeGroupTenantId', volumeGroupTenantId)
- logDebug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId , isDebugLogEnabled)
- }
- else {
- if (returnCode=='404') {
- utils.log("DEBUG", "Volume Group ${volumeGroupId} not found in AAI", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
- /**
- * Extract the Tenant Id from the Volume Group information returned by AAI.
- *
- * @param volumeGroupXml Volume Group XML returned by AAI.
- * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if
- * the Tenant Id is missing or could not otherwise be extracted.
- */
- private String getTenantIdFromVolumeGroup(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) {
- def NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data')
- for (Node relationshipData in relationshipDataList) {
- def Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key')
- if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) {
- def Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value')
- if (relationshipValue != null) {
- return relationshipValue.text()
- }
- }
- }
- }
- }
- }
- return null
- }
-
- private boolean hasVnfRelationship(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('generic-vnf'))) {
- def Node relatedLink = utils.getChildNode(relationship, 'related-link')
- if (relatedLink !=null && relatedLink.text() != null){
- return true
- }
- }
- }
- }
- return false
- }
-
- private boolean hasVfModuleRelationship(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('vf-module'))) {
- def Node relatedLink = utils.getChildNode(relationship, 'related-link')
- if (relatedLink !=null && relatedLink.text() != null){
- return true
- }
- }
- }
- }
- return false
- }
-
- public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) {
- def cloudRegion = execution.getVariable('DELVfModVol_cloudRegion')
- def tenantId = execution.getVariable('DELVfModVol_tenantId')
- def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId')
- def volumeGroupHeatStackId = execution.getVariable('DELVfModVol_volumeGroupHeatStackId')
- def requestId = execution.getVariable('DELVfModVol_requestId')
- def serviceId = execution.getVariable('DELVfModVol_serviceId')
-
- def messageId = execution.getVariable('DELVfModVol_messageId')
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
-
- String vnfAdapterRestRequest = """
- <deleteVolumeGroupRequest>
- <cloudSiteId>${cloudRegion}</cloudSiteId>
- <tenantId>${tenantId}</tenantId>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- <volumeGroupStackId>${volumeGroupHeatStackId}</volumeGroupStackId>
- <skipAAI>true</skipAAI>
- <msoRequest>
- <requestId>${requestId}</requestId>
- <serviceInstanceId>${serviceId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </deleteVolumeGroupRequest>
- """
- vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
- execution.setVariable('DELVfModVol_deleteVnfARequest', vnfAdapterRestRequest)
- logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
- }
-
-
- public void deleteVolGrpId(DelegateExecution execution, isDebugEnabled) {
-
- // get variables
- String queryAAIVolGrpIdResponse = execution.getVariable("DELVfModVol_queryAAIVolGrpResponse")
- String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id")
- String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version")
- String messageId = execution.getVariable('DELVfModVol_messageId')
- String cloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8")
-
- if(resourceVersion !=null){
- deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8')
- }
-
- utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest)
- utils.log("DEBUG", "Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest, isDebugEnabled)
-
- APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI delete volume group return code: " + returnCode)
- utils.logAudit("AAI delete volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- if (returnCode=='200' || (returnCode == '204')) {
- utils.log("DEBUG", "Volume group $groupId deleted.", isDebugEnabled)
- } else {
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $groupId not found for delete in AAI Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
- public void prepareDBRequest (DelegateExecution execution, isDebugLogEnabled) {
-
- WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException")
- ExceptionUtil exceptionUtil = new ExceptionUtil();
- def requestId = execution.getVariable('DELVfModVol_requestId')
- def volOutputs = execution.getVariable('DELVfModVol_volumeOutputs')
- def statusMessage = "VolumeGroup successfully deleted"
- def progress = "100"
- def requestStatus = "COMPLETE"
-
- if (workflowExceptionObj != null) {
- statusMessage = (workflowExceptionObj.getErrorMessage()).replace("&", "&").replace("<", "<").replace(">", ">")
- execution.setVariable("DELVfModVol_WorkflowExceptionMessage", statusMessage)
- execution.setVariable("DELVfModVol_WorkflowExceptionCode", workflowExceptionObj.getErrorCode())
- requestStatus = "FAILURE"
- progress = ""
- }
-
- String updateInfraRequest = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:req="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateInfraRequest>
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <requestStatus>${requestStatus}</requestStatus>
- <progress>${progress}</progress>
- <vnfOutputs>${volOutputs}</vnfOutputs>
- </req:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
-
- updateInfraRequest = utils.formatXml(updateInfraRequest)
- execution.setVariable('DELVfModVol_updateInfraRequest', updateInfraRequest)
- logDebug('Request for Update Infra Request:\n' + updateInfraRequest, isDebugLogEnabled)
-
- }
-
-
- public void prepareCompletionHandlerRequest (DelegateExecution execution, isDebugLogEnabled) {
- def requestId = execution.getVariable("mso-request-id")
- def source = execution.getVariable("DELVfModVol_source")
-
- String msoCompletionRequest =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:status-message>Volume Group has been deleted successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>BPMN VF Module Volume action: DELETE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
- execution.setVariable('DELVfModVol_CompleteMsoProcessRequest', xmlMsoCompletionRequest)
- utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugLogEnabled)
-
- }
-
-
-
- public void prepareFalloutHandler (DelegateExecution execution, isDebugEnabled) {
-
- execution.setVariable("DELVfModVol_Success", false)
- String requestId = execution.getVariable("DELVfModVol_requestId")
- String source = execution.getVariable("DELVfModVol_source")
-
- WorkflowException workflowExceptionObj = execution.getVariable("WorkflowException")
- def errorMessage = workflowExceptionObj.getErrorMessage()
- def errorCode = workflowExceptionObj.getErrorCode()
-
- String falloutHandlerRequest =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:WorkflowException>
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- // Format Response
- String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest)
- utils.logAudit(xmlHandlerRequest)
-
- execution.setVariable("DELVfModVol_FalloutHandlerRequest", xmlHandlerRequest)
- utils.log("ERROR", " Overall Error Response going to FalloutHandler: " + "\n" + xmlHandlerRequest, isDebugEnabled)
-
- }
-
-
- /**
- * Create a WorkflowException for the error case where the Tenant Id from
- * AAI did not match the Tenant Id in the incoming request.
- *
- * @param execution The flow's execution instance.
- */
- public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
- def volumeGroupId = execution.getVariable('DELVfModVol_volumeGroupId')
- def aicCloudRegion = execution.getVariable('DELVfModVol_aicCloudRegion')
- def tenantId = execution.getVariable('DELVfModVol_tenantId')
- def volumeGroupTenantId = execution.getVariable('DELVfModVol_volumeGroupTenantId')
-
- def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId +
- ' retrieved from AAI for Volume Group Id ' + volumeGroupId
-
- logError('Error in DeleteVfModuleVolume: ' + errorMessage)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- exceptionUtil.buildWorkflowException(execution, 5000, errorMessage)
-
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy deleted file mode 100644 index c789769131..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteVnfInfra.groovy +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - - -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource - - -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; - - -/** - * This class supports the DeleteVnfInfra Flow - * with the Deletion of a generic vnf for - * infrastructure. - */ -class DeleteVnfInfra extends AbstractServiceTaskProcessor { - - String Prefix="DELVI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DeleteVnfInfra PreProcessRequest Process*** ", isDebugEnabled) - - execution.setVariable("DELVI_SuccessIndicator", false) - execution.setVariable("DELVI_vnfInUse", false) - - try{ - // Get Variables - String deleteVnfRequest = execution.getVariable("bpmnRequest") - execution.setVariable("DELVI_DeleteVnfRequest", deleteVnfRequest) - utils.logAudit("Incoming DeleteVnfInfra Request is: \n" + deleteVnfRequest) - - if(deleteVnfRequest != null){ - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("DELVI_requestId", requestId) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("DELVI_serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfId = execution.getVariable("vnfId") - execution.setVariable("DELVI_vnfId", vnfId) - utils.log("DEBUG", "Incoming Vnf(Instance) Id is: " + vnfId, isDebugEnabled) - - String source = jsonUtil.getJsonValue(deleteVnfRequest, "requestDetails.requestInfo.source") - execution.setVariable("DELVI_source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - def cloudConfiguration = jsonUtil.getJsonValue(deleteVnfRequest, "requestDetails.cloudConfiguration") - execution.setVariable("DELVI_cloudConfiguration", cloudConfiguration) - - boolean cascadeDelete = false - Boolean cascadeDeleteObj = jsonUtil.getJsonRawValue(deleteVnfRequest, "requestDetails.requestParameters.cascadeDelete") - if(cascadeDeleteObj!=null){ - cascadeDelete = cascadeDeleteObj.booleanValue() - } - execution.setVariable("DELVI_cascadeDelete", cascadeDelete) - utils.log("DEBUG", "Incoming cascadeDelete is: " + cascadeDelete, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>DELETE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable("DELVI_requestInfo", requestInfo) - - // Setting for sub flow calls - execution.setVariable("DELVI_type", "generic-vnf") - - }else{ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Incoming Bpmn Request is Null.") - } - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DeleteVnfInfra PreProcessRequest method!" + e, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DeleteVnfInfra PreProcessRequest Process ***", isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DeleteVnfInfra SendSyncResponse Process *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("DELVI_requestId") - String vnfId = execution.getVariable("DELVI_vnfId") - - String DeleteVnfResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " DeleteVnfInfra Sync Response is: \n" + DeleteVnfResponse, isDebugEnabled) - execution.setVariable("DELVI_sentSyncResponse", true) - - sendWorkflowResponse(execution, 202, DeleteVnfResponse) - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteVnfInfra SendSyncResponse Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra SendSyncResponse Process") - - } - utils.log("DEBUG", "*** COMPLETED DeleteVnfInfra SendSyncResponse Process ***", isDebugEnabled) - } - - public void prepareCompletionHandlerRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DeleteVnfInfra PrepareCompletionHandlerRequest Process *** ", isDebugEnabled) - - try { - String requestInfo = execution.getVariable("DELVI_requestInfo") - requestInfo = utils.removeXmlPreamble(requestInfo) - String vnfId = execution.getVariable("DELVI_vnfId") - - String request = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - ${requestInfo} - <status-message>Vnf has been deleted successfully.</status-message> - <vnfId>${vnfId}</vnfId> - <mso-bpel-name>DeleteVnfInfra</mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - execution.setVariable("DELVI_completionHandlerRequest", request) - utils.log("DEBUG", "Completion Handler Request is: " + request, isDebugEnabled) - - execution.setVariable("WorkflowResponse", "Success") // for junits - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteVnfInfra PrepareCompletionHandlerRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra PrepareCompletionHandlerRequest Process") - - } - utils.log("DEBUG", "*** COMPLETED DeleteVnfInfra PrepareCompletionHandlerRequest Process ***", isDebugEnabled) - } - - public void sendErrorResponse(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DeleteVnfInfra sendErrorResponse Process *** ", isDebugEnabled) - try { - def sentSyncResponse = execution.getVariable("DELVI_sentSyncResponse") - if(sentSyncResponse == false){ - utils.log("DEBUG", "Sending a Sync Error Response", isDebugEnabled) - WorkflowException wfex = execution.getVariable("WorkflowException") - String response = exceptionUtil.buildErrorResponseXml(wfex) - - utils.logAudit(response) - sendWorkflowResponse(execution, 500, response) - }else{ - utils.log("DEBUG", "A Sync Response has already been sent. Skipping Send Sync Error Response.", isDebugEnabled) - } - - } catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteVnfInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVnfInfra sendErrorResponse Process") - } - utils.log("DEBUG", "*** COMPLETED DeleteVnfInfra sendErrorResponse Process ***", isDebugEnabled) - } - - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy deleted file mode 100644 index 77b0657514..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelVersions.groovy +++ /dev/null @@ -1,254 +0,0 @@ -/*-
- * ============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.infrastructure.scripts;
-
-import static org.apache.commons.lang3.StringUtils.*;
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
-import org.openecomp.mso.bpmn.core.domain.ServiceInstance
-import org.openecomp.mso.bpmn.core.domain.ModelInfo
-import org.openecomp.mso.bpmn.core.domain.Resource
-import org.openecomp.mso.bpmn.core.domain.AllottedResource
-import org.openecomp.mso.bpmn.core.domain.NetworkResource
-import org.openecomp.mso.bpmn.core.domain.VnfResource
-import org.openecomp.mso.bpmn.common.recipe.ResourceInput
-import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils;
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import java.util.List;
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.runtime.Execution
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils;
-
-/**
- * This groovy class supports the <class>DoCompareModelVersions.bpmn</class> process.
- *
- * Inputs:
- * @param - model-invariant-id-target
- * @param - model-version-id-target
- * @param - model-invariant-id-original
- * @param - model-version-id-original
- *
- * Outputs:
- * @param - addResourceList
- * @param - delResourceList
- *
- */
-public class DoCompareModelVersions extends AbstractServiceTaskProcessor {
-
- String Prefix="DCMPMDV_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- CatalogDbUtils cutils = new CatalogDbUtils()
-
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- String msg = ""
- utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled)
-
- try {
- execution.setVariable("prefix", Prefix)
-
- //Inputs
- String modelInvariantUuid_target = execution.getVariable("model-invariant-id-target")
- if (isBlank(modelInvariantUuid_target)) {
- msg = "Input model-invariant-id-target is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- String modelUuid_target = execution.getVariable("model-version-id-target")
- if (isBlank(modelUuid_target)) {
- msg = "Input model-version-id-target is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- String modelInvariantUuid_original = execution.getVariable("model-invariant-id-original")
- if (isBlank(modelInvariantUuid_original)) {
- msg = "Input model-invariant-id-original is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- String modelUuid_original = execution.getVariable("model-version-id-original")
- if (isBlank(modelUuid_original)) {
- msg = "Input model-version-id-original is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- // Target and original modelInvariantUuid must to be the same
- if(modelInvariantUuid_target != modelInvariantUuid_original){
- msg = "Input model-invariant-id-target and model-invariant-id-original must to be the same"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- // Target and original modelUuid must not to be the same
- if(modelUuid_target == modelUuid_original){
- msg = "Input model-version-id-target and model-version-id-original must not to be the same"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- } 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)
- }
-
- public void prepareDecomposeService_Target(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- try {
- utils.log("DEBUG", " ***** Inside prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled)
- String modelInvariantUuid = execution.getVariable("model-invariant-id-target")
- String modelUuid = execution.getVariable("model-version-id-target")
- //here modelVersion is not set, we use modelUuid to decompose the service.
- String serviceModelInfo = """{
- "modelInvariantUuid":"${modelInvariantUuid}",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
-
- execution.setVariable("serviceModelInfo_Target", serviceModelInfo)
-
- utils.log("DEBUG", " ***** Completed prepareDecomposeService_Target of update generic e2e service ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Target() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void processDecomposition_Target(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ***** Inside processDecomposition_Target() of update generic e2e service flow ***** ", isDebugEnabled)
- try {
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- execution.setVariable("serviceDecomposition_Target", serviceDecomposition)
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method processDecomposition_Target() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void prepareDecomposeService_Original(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- try {
- utils.log("DEBUG", " ***** Inside prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled)
- String modelInvariantUuid = execution.getVariable("model-invariant-id-original")
- String modelUuid = execution.getVariable("model-version-id-original")
- //here modelVersion is not set, we use modelUuid to decompose the service.
- String serviceModelInfo = """{
- "modelInvariantUuid":"${modelInvariantUuid}",
- "modelUuid":"${modelUuid}",
- "modelVersion":""
- }"""
-
- execution.setVariable("serviceModelInfo_Original", serviceModelInfo)
-
- utils.log("DEBUG", " ***** Completed prepareDecomposeService_Original of update generic e2e service ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. Unexpected Error from method prepareDecomposeService_Original() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void processDecomposition_Original(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- utils.log("DEBUG", " ***** Inside processDecomposition_Original() of update generic e2e service flow ***** ", isDebugEnabled)
- try {
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- execution.setVariable("serviceDecomposition_Original", serviceDecomposition)
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in update generic e2e service flow. processDecomposition_Original() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void doCompareModelVersions(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", "======== Start doCompareModelVersions Process ======== ", isDebugEnabled)
-
- ServiceDecomposition serviceDecomposition_Target = execution.getVariable("serviceDecomposition_Target")
- ServiceDecomposition serviceDecomposition_Original = execution.getVariable("serviceDecomposition_Original")
-
- List<Resource> allSR_target = serviceDecomposition_Target.getServiceResources();
- List<Resource> allSR_original = serviceDecomposition_Original.getServiceResources();
-
- List<Resource> addResourceList = new ArrayList<String>()
- List<Resource> delResourceList = new ArrayList<String>()
-
- addResourceList.addAll(allSR_target)
- delResourceList.addAll(allSR_original)
-
- //Compare
- for (Resource rc_t : allSR_target){
- String muuid = rc_t.getModelInfo().getModelUuid()
- String mIuuid = rc_t.getModelInfo().getModelInvariantUuid()
- String mCuuid = rc_t.getModelInfo().getModelCustomizationUuid()
- for (Resource rc_o : allSR_original){
- if(rc_o.getModelInfo().getModelUuid() == muuid
- && rc_o.getModelInfo().getModelInvariantUuid() == mIuuid
- && rc_o.getModelInfo().getModelCustomizationUuid() == mCuuid) {
- addResourceList.remove(rc_t);
- delResourceList.remove(rc_o);
- }
- } - } -
- execution.setVariable("addResourceList", addResourceList)
- execution.setVariable("delResourceList", delResourceList)
- utils.log("INFO", "addResourceList: " + addResourceList, isDebugEnabled)
- utils.log("INFO", "delResourceList: " + delResourceList, isDebugEnabled)
-
- utils.log("INFO", "======== COMPLETED doCompareModelVersions Process ======== ", isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy deleted file mode 100644 index 0172402185..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCompareModelofE2EServiceInstance.groovy +++ /dev/null @@ -1,260 +0,0 @@ -/*- - * ============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.infrastructure.scripts; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.CompareModelsResult -import org.openecomp.mso.bpmn.core.domain.ResourceModelInfo -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - - -import java.util.List -import java.util.Map -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource -/** - * This groovy class supports the <class>DoCompareModelofE2EServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - * @param - subscriptionServiceType - * @param - serviceInstanceId - * @param - modelInvariantIdTarget - * @param - modelVersionIdTarget - * - * Outputs: - * @param - compareModelsResult CompareModelsResult - - */ -public class DoCompareModelofE2EServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DCMPMDSI_" - private static final String DebugFlag = "isDebugEnabled" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - - def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO","Entered " + method, isDebugEnabled) - String msg = "" - utils.log("INFO"," ***** Enter DoCompareModelofE2EServiceInstance preProcessRequest *****", isDebugEnabled) - - execution.setVariable("prefix", Prefix) - //Inputs - - //subscriberInfo. for AAI GET - String globalSubscriberId = execution.getVariable("globalSubscriberId") - utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled) - - String serviceType = execution.getVariable("serviceType") - utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled) - - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - if (isBlank(serviceType)) { - msg = "Input serviceType is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String modelInvariantUuid = execution.getVariable("modelInvariantIdTarget") - if (isBlank(modelInvariantUuid)){ - msg = "Input modelInvariantUuid is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String modelUuid = execution.getVariable("modelVersionIdTarget") - if (isBlank(modelUuid)){ - msg = "Input modelUuid is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - // Set Target Template info - execution.setVariable("model-invariant-id-target", modelInvariantUuid) - execution.setVariable("model-version-id-target", modelUuid) - - - utils.log("INFO", "Exited " + method, isDebugEnabled) - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - String serviceType = "" - - if(foundInAAI){ - utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) - - String siData = execution.getVariable("GENGS_service") - utils.log("INFO", "SI Data", isDebugEnabled) - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI, Id:" + serviceInstanceId - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - utils.log("INFO", "SI Data" + siData, isDebugEnabled) - - // Get Template uuid and version - if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { - utils.log("INFO", "SI Data model-invariant-id and model-version-id exist", isDebugEnabled) - - def modelInvariantId = utils.getNodeText1(siData, "model-invariant-id") - def modelVersionId = utils.getNodeText1(siData, "model-version-id") - - // Set Original Template info - execution.setVariable("model-invariant-id-original", modelInvariantId) - execution.setVariable("model-version-id-original", modelVersionId) - } - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - - utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) - } - }catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void postCompareModelVersions(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - - List<Resource> addResourceList = execution.getVariable("addResourceList") - List<Resource> delResourceList = execution.getVariable("delResourceList") - - CompareModelsResult cmpResult = new CompareModelsResult() - List<ResourceModelInfo> addedResourceList = new ArrayList<ResourceModelInfo>() - List<ResourceModelInfo> deletedResourceList = new ArrayList<ResourceModelInfo>() - - - String serviceModelUuid = execution.getVariable("model-version-id-target") - List<String> requestInputs = new ArrayList<String>() - ModelInfo mi = null; - for(Resource rc : addResourceList) { - mi = rc.getModelInfo() - String resourceCustomizationUuid = mi.getModelCustomizationUuid() - ResourceModelInfo rmodel = new ResourceModelInfo() - rmodel.setResourceName(mi.getModelName()) - rmodel.setResourceInvariantUuid(mi.getModelInvariantUuid()) - rmodel.setResourceUuid(mi.getModelUuid()) - rmodel.setResourceCustomizationUuid(resourceCustomizationUuid) - addedResourceList.add(rmodel) - - Map<String, Object> resourceParameters = ResourceRequestBuilder.buildResouceRequest(serviceModelUuid, resourceCustomizationUuid, null) - requestInputs.addAll(resourceParameters.keySet()) - } - - for(Resource rc : delResourceList) { - mi = rc.getModelInfo() - String resourceCustomizationUuid = mi.getModelCustomizationUuid() - ResourceModelInfo rmodel = new ResourceModelInfo() - rmodel.setResourceName(mi.getModelName()) - rmodel.setResourceInvariantUuid(mi.getModelInvariantUuid()) - rmodel.setResourceUuid(mi.getModelUuid()) - rmodel.setResourceCustomizationUuid(resourceCustomizationUuid) - deletedResourceList.add(rmodel) - } - - cmpResult.setAddedResourceList(addedResourceList) - cmpResult.setDeletedResourceList(deletedResourceList) - cmpResult.setRequestInputs(requestInputs) - - execution.setVariable("compareModelsResult", cmpResult) - } - -} - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy deleted file mode 100644 index eaec39b5fd..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstance.groovy +++ /dev/null @@ -1,479 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 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.infrastructure.scripts; - -import static org.apache.commons.lang3.StringUtils.*; -import org.apache.http.HttpResponse -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.AllottedResource -import org.openecomp.mso.bpmn.core.domain.NetworkResource -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.common.recipe.ResourceInput -import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder; -import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.infrastructure.workflow.service.ServicePluginFactory - -import java.util.List; -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - * @param - subscriptionServiceType - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceModelInfo - * @param - productFamilyId - * @param - disableRollback - * @param - failExists - TODO - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion ("1610") - * @param - serviceDecomposition - Decomposition for R1710 - * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored) - * - * Outputs: - * @param - rollbackData (localRB->null) - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * @param - WorkflowException - * @param - serviceInstanceName - (GET from AAI if null in input) - * - */ -public class DoCreateE2EServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DCRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils cutils = new CatalogDbUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String msg = "" - utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) - - try { - execution.setVariable("prefix", Prefix) - //Inputs - //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology - String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled) - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology - String serviceType = execution.getVariable("serviceType") - utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled) - //requestDetails.requestParameters. for SDNC assignTopology - String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId - - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - if (isBlank(serviceType)) { - msg = "Input serviceType is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - if (productFamilyId == null) { - execution.setVariable("productFamilyId", "") - } - - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - //requestDetails.modelInfo.for AAI PUT servieInstanceData - //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData - String serviceInstanceName = execution.getVariable("serviceInstanceName") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String uuiRequest = execution.getVariable("uuiRequest") - String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") - String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") - String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName") - execution.setVariable("serviceModelName", serviceModelName) - //aai serviceType and Role can be setted as fixed value now. - String aaiServiceType = "E2E Service" - String aaiServiceRole = "E2E Service" - - execution.setVariable("modelInvariantUuid", modelInvariantUuid) - execution.setVariable("modelUuid", modelUuid) - - //AAI PUT - String oStatus = execution.getVariable("initialStatus") ?: "" - if ("TRANSPORT".equalsIgnoreCase(serviceType)) - { - oStatus = "Created" - } - - String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${oStatus}</orchestration-status>" - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <service-instance-name>${serviceInstanceName}</service-instance-name> - <service-type>${aaiServiceType}</service-type> - <service-role>${aaiServiceRole}</service-role> - ${statusLine} - <model-invariant-id>${modelInvariantUuid}</model-invariant-id> - <model-version-id>${modelUuid}</model-version-id> - </service-instance>""".trim() - execution.setVariable("serviceInstanceData", serviceInstanceData) - utils.logAudit(serviceInstanceData) - utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled) - utils.log("INFO", " 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) - - } 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) - } - - public void prepareDecomposeService(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("INFO", " ***** Inside prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") - String modelUuid = execution.getVariable("modelUuid") - //here modelVersion is not set, we use modelUuid to decompose the service. - String serviceModelInfo = """{ - "modelInvariantUuid":"${modelInvariantUuid}", - "modelUuid":"${modelUuid}", - "modelVersion":"" - }""" - execution.setVariable("serviceModelInfo", serviceModelInfo) - - utils.log("DEBUG", " ***** Completed prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void processDecomposition(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ***** Inside processDecomposition() of create generic e2e service flow ***** ", isDebugEnabled) - try { - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage() - utils.log("INFO", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void doServicePreOperation(DelegateExecution execution){ - //we need a service plugin platform here. - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - String uuiRequest = execution.getVariable("uuiRequest") - String newUuiRequest = ServicePluginFactory.getInstance().preProcessService(serviceDecomposition, uuiRequest); - execution.setVariable("uuiRequest", newUuiRequest) - } - - public void doServiceHoming(DelegateExecution execution) { - //we need a service plugin platform here. - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - String uuiRequest = execution.getVariable("uuiRequest") - String newUuiRequest = ServicePluginFactory.getInstance().doServiceHoming(serviceDecomposition, uuiRequest); - execution.setVariable("uuiRequest", newUuiRequest) - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceName = execution.getVariable("serviceInstanceName") - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceName, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - else - { - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI){ - utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) - msg = "ServiceInstance already exists in AAI:" + serviceInstanceName - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void postProcessAAIPUT(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled) - } - - public void postProcessAAIGET2(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET2 ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceName = execution.getVariable("serviceInstanceName") - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - else - { - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI){ - String aaiService = execution.getVariable("GENGS_service") - if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) { - execution.setVariable("serviceInstanceName", utils.getNodeText1(aaiService, "service-instance-name")) - utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled) - } - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled) - } - - public void preProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - } - utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - execution.setVariable("rollbackData", null) - } catch (BpmnError b) { - utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - } - utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled) - } - - public void preInitResourcesOperStatus(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = execution.getVariable("operationType") - String resourceTemplateUUIDs = "" - String result = "processing" - String progress = "0" - String reason = "" - String operationContent = "Prepare service creation" - utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - List<Resource> resourceList = serviceDecomposition.getServiceResources() - - for(Resource resource : resourceList){ - resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" - } - - def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs> - </ns:initResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_initResOperStatusRequest", payload) - utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) - utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) - } - utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - } - - // prepare input param for using DoCreateResources.bpmn - public void preProcessForAddResource(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " ======== STARTED preProcessForAddResource Process ======== ", isDebugEnabled) - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - List<Resource> addResourceList = serviceDecomposition.getServiceResources() - execution.setVariable("addResourceList", addResourceList) - - utils.log("INFO", "======== COMPLETED preProcessForAddResource Process ======== ", isDebugEnabled) - } - - public void postProcessForAddResource(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - // do nothing now - - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy deleted file mode 100644 index 84dd0e4d73..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateE2EServiceInstanceRollback.groovy +++ /dev/null @@ -1,238 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 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.infrastructure.scripts
-
-
-import static org.apache.commons.lang3.StringUtils.*;
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONObject;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils;
-/**
- * This groovy class supports the <class>DoCreateServiceInstanceRollback.bpmn</class> process.
- *
- * Inputs:
- * @param - msoRequestId
- * @param - rollbackData with
- * globalCustomerId
- * subscriptionServiceType
- * serviceInstanceId
- * disableRollback
- * rollbackAAI
- * rollbackSDNC
- * sdncRollbackRequest
- *
- *
- * Outputs:
- * @param - rollbackError
- * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
- *
- */
-public class DoCreateE2EServiceInstanceRollback extends AbstractServiceTaskProcessor{
-
- String Prefix="DCRESIRB_"
-
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- String msg = ""
- utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
- execution.setVariable("rollbackAAI",false)
- execution.setVariable("rollbackSDNC",false)
-
- try {
- def rollbackData = execution.getVariable("rollbackData")
- utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled)
-
- if (rollbackData != null) {
- if (rollbackData.hasType("SERVICEINSTANCE")) {
-
- def serviceInstanceId = rollbackData.get("SERVICEINSTANCE", "serviceInstanceId")
- execution.setVariable("serviceInstanceId", serviceInstanceId)
-
- def subscriptionServiceType = rollbackData.get("SERVICEINSTANCE", "subscriptionServiceType")
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
-
- def globalSubscriberId = rollbackData.get("SERVICEINSTANCE", "globalSubscriberId")
- execution.setVariable("globalSubscriberId", globalSubscriberId)
-
- def rollbackAAI = rollbackData.get("SERVICEINSTANCE", "rollbackAAI")
- if ("true".equals(rollbackAAI))
- {
- execution.setVariable("rollbackAAI",true)
- }
-
- def rollbackSDNC = rollbackData.get("SERVICEINSTANCE", "rollbackSDNC")
- if ("true".equals(rollbackSDNC))
- {
- execution.setVariable("rollbackSDNC", true)
- }
-
- if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true)
- {
- execution.setVariable("skipRollback", true)
- }
-
- def sdncDelete = rollbackData.get("SERVICEINSTANCE", "sdncDelete")
- execution.setVariable("sdncDelete", sdncDelete)
- def sdncDeactivate = rollbackData.get("SERVICEINSTANCE", "sdncDeactivate")
- execution.setVariable("sdncDeactivate", sdncDeactivate)
- utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
- utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled)
- }
- else {
- execution.setVariable("skipRollback", true)
- }
- }
- else {
- execution.setVariable("skipRollback", true)
- }
- if (execution.getVariable("disableRollback").equals("true" ))
- {
- execution.setVariable("skipRollback", true)
- }
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- msg = "Exception in Create ServiceInstance Rollback preProcessRequest " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
- }
-
- public void validateSDNCResponse(DelegateExecution execution, String response, String method) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** validateSDNCResponse ***** ", isDebugEnabled)
- String msg = ""
- try {
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
- utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled)
- utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled)
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
-
- if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
- msg = "SDNC Adapter service-instance rollback successful for " + method
- utils.log("DEBUG", msg, isDebugEnabled)
- }else{
- execution.setVariable("rolledBack", false)
- msg = "Error Response from SDNC Adapter service-instance rollback for " + method
- execution.setVariable("rollbackError", msg)
- utils.log("DEBUG", msg, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- msg = "Exception in Create ServiceInstance rollback for " + method + " Exception:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit validateSDNCResponse ***** ", isDebugEnabled)
- }
-
- public void postProcessRequest(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled)
- String msg = ""
- try {
- execution.setVariable("rollbackData", null)
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- boolean rollbackAAI = execution.getVariable("rollbackAAI")
- boolean rollbackSDNC = execution.getVariable("rollbackSDNC")
- if (rollbackAAI || rollbackSDNC)
- {
- execution.setVariable("rolledBack", true)
- }
- if (rollbackAAI)
- {
- boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
- if(!succInAAI){
- execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful
- execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback")
- utils.log("DEBUG","Error deleting service-instance in AAI for rollback", + serviceInstanceId, isDebugEnabled)
- }
- }
- utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled)
-
- } catch (BpmnError e) {
- msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- } catch (Exception ex) {
- msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- }
-
- }
-
- public void processRollbackException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled)
- try{
- utils.log("DEBUG", "Caught an Exception in DoCreateServiceInstanceRollback", isDebugEnabled)
- execution.setVariable("rollbackData", null)
- execution.setVariable("rollbackError", "Caught exception in ServiceInstance Create Rollback")
- execution.setVariable("WorkflowException", null)
-
- }catch(BpmnError b){
- utils.log("DEBUG", "BPMN Error during processRollbackExceptions Method: ", isDebugEnabled)
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processRollbackExceptions Method: " + e.getMessage(), isDebugEnabled)
- }
-
- utils.log("DEBUG", " Exit processRollbackException", isDebugEnabled)
- }
-
- public void processRollbackJavaException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled)
- try{
- execution.setVariable("rollbackData", null)
- execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Create Rollback")
- utils.log("DEBUG", "Caught Exception in processRollbackJavaException", isDebugEnabled)
-
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception in processRollbackJavaException " + e.getMessage(), isDebugEnabled)
- }
- utils.log("DEBUG", "***** Exit processRollbackJavaException *****", isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy deleted file mode 100644 index ccbe9b8325..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy +++ /dev/null @@ -1,1703 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. - * - */ -public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { - String Prefix="CRENWKI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - def className = getClass().getSimpleName() - - /** - * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "networkRequest", "") - execution.setVariable(Prefix + "rollbackEnabled", null) - execution.setVariable(Prefix + "networkInputs", "") - //execution.setVariable(Prefix + "requestId", "") - execution.setVariable(Prefix + "messageId", "") - execution.setVariable(Prefix + "source", "") - execution.setVariable("BasicAuthHeaderValuePO", "") - execution.setVariable("BasicAuthHeaderValueSDNC", "") - execution.setVariable(Prefix + "serviceInstanceId","") - execution.setVariable("GENGS_type", "") - execution.setVariable(Prefix + "rsrc_endpoint", null) - execution.setVariable(Prefix + "networkOutputs", "") - execution.setVariable(Prefix + "networkId","") - execution.setVariable(Prefix + "networkName","") - - // AAI query Name - execution.setVariable(Prefix + "queryNameAAIRequest","") - execution.setVariable(Prefix + "queryNameAAIResponse", "") - execution.setVariable(Prefix + "aaiNameReturnCode", "") - execution.setVariable(Prefix + "isAAIqueryNameGood", false) - - // AAI query Cloud Region - execution.setVariable(Prefix + "queryCloudRegionRequest","") - execution.setVariable(Prefix + "queryCloudRegionReturnCode","") - execution.setVariable(Prefix + "queryCloudRegionResponse","") - execution.setVariable(Prefix + "cloudRegionPo","") - execution.setVariable(Prefix + "cloudRegionSdnc","") - execution.setVariable(Prefix + "isCloudRegionGood", false) - - // AAI query Id - execution.setVariable(Prefix + "queryIdAAIRequest","") - execution.setVariable(Prefix + "queryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiIdReturnCode", "") - - // AAI query vpn binding - execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") - execution.setVariable(Prefix + "vpnBindings", null) - execution.setVariable(Prefix + "vpnCount", 0) - execution.setVariable(Prefix + "routeCollection", "") - - // AAI query network policy - execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") - execution.setVariable(Prefix + "networkPolicyUriList", null) - execution.setVariable(Prefix + "networkPolicyCount", 0) - execution.setVariable(Prefix + "networkCollection", "") - - // AAI query route table reference - execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") - execution.setVariable(Prefix + "networkTableRefUriList", null) - execution.setVariable(Prefix + "networkTableRefCount", 0) - execution.setVariable(Prefix + "tableRefCollection", "") - - // AAI requery Id - execution.setVariable(Prefix + "requeryIdAAIRequest","") - execution.setVariable(Prefix + "requeryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") - - // AAI update contrail - execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") - execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") - execution.setVariable(Prefix + "updateContrailAAIResponse", "") - execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") - - execution.setVariable(Prefix + "createNetworkRequest", "") - execution.setVariable(Prefix + "createNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - //execution.setVariable(Prefix + "rollbackNetworkResponse", "") - execution.setVariable(Prefix + "networkReturnCode", "") - //execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") - execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) - - execution.setVariable(Prefix + "assignSDNCRequest", "") - execution.setVariable(Prefix + "assignSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - //execution.setVariable(Prefix + "rollbackSDNCResponse", "") - execution.setVariable(Prefix + "sdncReturnCode", "") - //execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") - execution.setVariable(Prefix + "isSdncRollbackNeeded", false) - execution.setVariable(Prefix + "sdncResponseSuccess", false) - - execution.setVariable(Prefix + "activateSDNCRequest", "") - execution.setVariable(Prefix + "activateSDNCResponse", "") - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "") - //execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "") - execution.setVariable(Prefix + "sdncActivateReturnCode", "") - //execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "") - execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", false) - execution.setVariable(Prefix + "sdncActivateResponseSuccess", false) - - execution.setVariable(Prefix + "orchestrationStatus", "") - execution.setVariable(Prefix + "isVnfBindingPresent", false) - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "isException", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of " + className + ".groovy ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request & validate 3 kinds of format. - execution.setVariable("action", "CREATE") - String networkRequest = execution.getVariable("bpmnRequest") - if (networkRequest != null) { - if (networkRequest.contains("requestDetails")) { - // JSON format request is sent, create xml - try { - def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) - utils.log("DEBUG", " Incoming message formatted . . . : " + '\n' + prettyJson, isDebugEnabled) - networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } else { - // XML format request is sent - - } - } else { - // vIPR format request is sent, create xml from individual variables - networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) - } - - networkRequest = utils.formatXml(networkRequest) - utils.logAudit(networkRequest) - execution.setVariable(Prefix + "networkRequest", networkRequest) - utils.log("DEBUG", Prefix + "networkRequest - " + '\n' + networkRequest, isDebugEnabled) - - // validate 'backout-on-failure' to override 'URN_mso_rollback' - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) - execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) - utils.log("DEBUG", Prefix + "rollbackEnabled - " + rollbackEnabled, isDebugEnabled) - - String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable(Prefix + "networkInputs", networkInputs) - utils.log("DEBUG", Prefix + "networkInputs - " + '\n' + networkInputs, isDebugEnabled) - - // prepare messageId - String messageId = execution.getVariable("testMessageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - utils.log("DEBUG", Prefix + "messageId, random generated: " + messageId, isDebugEnabled) - } else { - utils.log("DEBUG", Prefix + "messageId, pre-assigned: " + messageId, isDebugEnabled) - } - execution.setVariable(Prefix + "messageId", messageId) - - String source = utils.getNodeText1(networkRequest, "source") - execution.setVariable(Prefix + "source", source) - utils.log("DEBUG", Prefix + "source - " + source, isDebugEnabled) - - // validate cloud region - String lcpCloudRegionId = utils.getNodeText1(networkRequest, "aic-cloud-region") - if ((lcpCloudRegionId == null) || (lcpCloudRegionId == "") || (lcpCloudRegionId == "null")) { - String dataErrorMessage = "Missing value/element: 'lcpCloudRegionId' or 'cloudConfiguration' or 'aic-cloud-region'." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // validate service instance id - String serviceInstanceId = utils.getNodeText1(networkRequest, "service-instance-id") - if ((serviceInstanceId == null) || (serviceInstanceId == "") || (serviceInstanceId == "null")) { - String dataErrorMessage = "Missing value/element: 'serviceInstanceId'." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // Set variables for Generic Get Sub Flow use - execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", Prefix + "serviceInstanceId - " + serviceInstanceId, isDebugEnabled) - - execution.setVariable("GENGS_type", "service-instance") - utils.log("DEBUG", "GENGS_type - " + "service-instance", isDebugEnabled) - utils.log("DEBUG", " Url for SDNC adapter: " + execution.getVariable("URN_mso_adapters_sdnc_endpoint"), isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled) - - // build 'networkOutputs' - String networkId = utils.getNodeText1(networkRequest, "network-id") - if ((networkId == null) || (networkId == "null")) { - networkId = "" - } - String networkName = utils.getNodeText1(networkRequest, "network-name") - if ((networkName == null) || (networkName == "null")) { - networkName = "" - } - String networkOutputs = - """<network-outputs> - <network-id>${networkId}</network-id> - <network-name>${networkName}</network-name> - </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - utils.log("DEBUG", Prefix + "networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - execution.setVariable(Prefix + "networkId", networkId) - execution.setVariable(Prefix + "networkName", networkName) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkName (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkName() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - // get variables - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String networkName = utils.getNodeText1(networkInputs, "network-name") - networkName = UriUtils.encode(networkName,"UTF-8") - - // Prepare AA&I url with network-name - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryAAINameRequest = "${aai_endpoint}${aai_uri}" + "?network-name=" + networkName - utils.logAudit(queryAAINameRequest) - execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest) - utils.log("DEBUG", Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest, isDebugEnabled) - - try { - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAINameRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiNameReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI Query Name Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - utils.log("DEBUG", " ***** AAI Query Name Response : " +'\n'+ aaiResponseAsString, isDebugEnabled) - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryNameAAIResponse", aaiResponseAsString) - execution.setVariable(Prefix + "isAAIqueryNameGood", true) - String orchestrationStatus = "" - try { - // response is NOT empty - orchestrationStatus = utils.getNodeText1(aaiResponseAsString, "orchestration-status") - execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus.toUpperCase()) - utils.log("DEBUG", Prefix + "orchestrationStatus - " + orchestrationStatus.toUpperCase(), isDebugEnabled) - execution.setVariable("orchestrationStatus", orchestrationStatus) - - } catch (Exception ex) { - // response is empty - execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus) - utils.log("DEBUG", Prefix + "orchestrationStatus - " + orchestrationStatus, isDebugEnabled) - } - - } else { - if (returnCode=='404') { - utils.log("DEBUG", " QueryAAINetworkName return code = '404' (Not Found). Proceed with the Create !!! ", isDebugEnabled) - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Error Response from QueryAAINetworkName - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage) - - } - - } - - utils.log("DEBUG", Prefix + "isAAIqueryNameGood? : " + execution.getVariable(Prefix + "isAAIqueryNameGood"), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAINetworkName() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAICloudRegion (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String cloudRegion = utils.getNodeText1(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - utils.logAudit(queryCloudRegionRequest) - execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - utils.log("DEBUG", Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled) - - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) - execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) - execution.setVariable(Prefix + "isCloudRegionGood", true) - - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood"), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkId(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkId() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String networkId = "" - String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - if (execution.getVariable("sdncVersion") != "1610") { - String networkResponseInformation = "" - try { - networkResponseInformation = utils.getNodeXml(assignSDNCResponse, "network-response-information", false).replace("tag0:","").replace(":tag0","") - networkId = utils.getNodeText1(networkResponseInformation, "instance-id") - } catch (Exception ex) { - String dataErrorMessage = " SNDC Response network validation for 'instance-id' (network-id) failed: Empty <network-response-information>" - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } else { - networkId = utils.getNodeText1(assignSDNCResponse, "network-id") - } - if (networkId == null || networkId == "null") { - String dataErrorMessage = "SNDC Response did not contains 'instance-id' or 'network-id' element, or the value is null." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } else { - utils.log("DEBUG", " SNDC Response network validation for 'instance-id' (network-id)' is good: " + networkId, isDebugEnabled) - } - - - execution.setVariable(Prefix + "networkId", networkId) - String networkName = utils.getNodeText1(assignSDNCResponse, "network-name") - execution.setVariable(Prefix + "networkName", networkName) - - networkId = UriUtils.encode(networkId,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - utils.logAudit(queryIdAAIRequest) - execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) - utils.log("DEBUG", Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiIdReturnCode", returnCode) - - utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - - String netId = utils.getNodeText1(aaiResponseAsString, "network-id") - execution.setVariable(Prefix + "networkId", netId) - String netName = utils.getNodeText1(aaiResponseAsString, "network-name") - execution.setVariable(Prefix + "networkName", netName) - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." - utils.log("DEBUG", " AAI Query Failed. " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode - utils.log("DEBUG", "Unexpected Response from QueryAAINetworkId - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTReQueryAAINetworkId(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTReQueryAAINetworkId() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String networkId = execution.getVariable(Prefix + "networkId") - String netId = networkId - networkId = UriUtils.encode(networkId,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - utils.logAudit(requeryIdAAIRequest) - execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) - utils.log("DEBUG", Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI ReQuery Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - - String netName = utils.getNodeText1(aaiResponseAsString, "network-name") - String networkOutputs = - """<network-outputs> - <network-id>${netId}</network-id> - <network-name>${netName}</network-name> - </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - utils.log("DEBUG", " networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." - utils.log("DEBUG", " AAI ReQuery Failed. - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkVpnBinding() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - - // get variables - String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Vnf Binding is present, then build a List of vnfBinding - List vpnBindingUri = networkUtils.getVnfBindingObject(relationship) - int vpnCount = vpnBindingUri.size() - execution.setVariable(Prefix + "vpnCount", vpnCount) - utils.log("DEBUG", Prefix + "vpnCount - " + vpnCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (vpnCount > 0) { - execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) - utils.log("DEBUG", " vpnBindingUri List - " + vpnBindingUri, isDebugEnabled) - - String routeTargets = "" - // AII loop call using list vpnBindings - for (i in 0..vpnBindingUri.size()-1) { - - int counting = i+1 - - // prepare url using vpnBinding - String queryVpnBindingAAIRequest = "" - String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) - - // Note: By default, the vpnBinding url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" - } - - } else { - // using uri value in URN mapping - String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) - if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { - vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) - } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" - } - - utils.logAudit(queryVpnBindingAAIRequest) - execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - utils.log("DEBUG", Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String routeTarget = "" - String routeRole = "" - if (utils.nodeExists(aaiResponseAsString, "route-targets")) { - String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) - def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) - def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} - for (j in 0..aaiRouteTarget.size()-1) { - routeTarget = utils.getNodeText1(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") - routeRole = utils.getNodeText1(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") - routeTargets += "<routeTargets>" + '\n' + - " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + - " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + - "</routeTargets>" + '\n' - } - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable(Prefix + "routeCollection", routeTargets) - utils.log("DEBUG", Prefix + "routeCollection - " + '\n' + routeTargets, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <vpn-binding xmlns="${schemaVersion}"> - <global-route-target/> - </vpn-binding> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "routeCollection", "<routeTargets/>") - utils.log("DEBUG", " No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkPolicy() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Network Policy is present, then build a List of network policy - List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship) - int networkPolicyCount = networkPolicyUriList.size() - execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) - utils.log("DEBUG", Prefix + "networkPolicyCount - " + networkPolicyCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (networkPolicyCount > 0) { - execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList) - utils.log("DEBUG", " networkPolicyUri List - " + networkPolicyUriList, isDebugEnabled) - - String networkPolicies = "" - // AII loop call using list vpnBindings - for (i in 0..networkPolicyUriList.size()-1) { - - int counting = i+1 - - // prepare url using vpnBinding - String queryNetworkPolicyAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) - println " networkPolicyId - " + networkPolicyId - if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { - networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) - } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" - - } - - - utils.logAudit(queryNetworkPolicyAAIRequest) - execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) - utils.log("DEBUG", Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String networkPolicy = "" - if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) { - networkPolicy = utils.getNodeText1(aaiResponseAsString, "network-policy-fqdn") - networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable(Prefix + "networkCollection", networkPolicies) - utils.log("DEBUG", Prefix + "networkCollection - " + '\n' + networkPolicies, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <network-policy xmlns="${schemaVersion}"> - <network-policy-fqdn/> - </network-policy> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>") - utils.log("DEBUG", " No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkTableRef() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Network TableREf is present, then build a List of network policy - List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship) - int networkTableRefCount = networkTableRefUriList.size() - execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount) - utils.log("DEBUG", Prefix + "networkTableRefCount - " + networkTableRefCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (networkTableRefCount > 0) { - execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList) - utils.log("DEBUG", " networkTableRefUri List - " + networkTableRefUriList, isDebugEnabled) - - // AII loop call using list vpnBindings - String networkTableRefs = "" - for (i in 0..networkTableRefUriList.size()-1) { - - int counting = i+1 - - // prepare url using tableRef - String queryNetworkTableRefAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) - - if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { - networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) - } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" - - } - - - utils.logAudit(queryNetworkTableRefAAIRequest) - execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) - utils.log("DEBUG", Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String networkTableRef = "" - if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) { - networkTableRef = utils.getNodeText1(aaiResponseAsString, "route-table-reference-fqdn") - networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) - utils.log("DEBUG", Prefix + "tableRefCollection - " + '\n' + networkTableRefs, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <route-table-references xmlns="${schemaVersion}"> - <route-table-reference-fqdn/> - </route-table-references> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") - utils.log("DEBUG", " No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTUpdateContrailAAINetwork() of DoCreateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String networkId = execution.getVariable(Prefix + "networkId") - networkId = UriUtils.encode(networkId,"UTF-8") - String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") - - // Prepare url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - - utils.logAudit(updateContrailAAIUrlRequest) - execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) - utils.log("DEBUG", Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) - - //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) - String payloadXml = utils.formatXml(payload) - utils.logAudit(payloadXml) - execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml) - utils.log("DEBUG", " 'payload' to Update Contrail - " + "\n" + payloadXml, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payloadXml) - - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI Update Contrail Response Code : " + returnCode, isDebugEnabled) - String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() - if (returnCode=='200') { - utils.logAudit(aaiUpdateContrailResponseAsString) - execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString) - utils.log("DEBUG", " AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString, isDebugEnabled) - // Point-of-no-return is set to false, rollback not needed. - String rollbackEnabled = execution.getVariable(Prefix + "rollbackEnabled") - if (rollbackEnabled == "true") { - execution.setVariable(Prefix + "isPONR", false) - } else { - execution.setVariable(Prefix + "isPONR", true) - } - utils.log("DEBUG", Prefix + "isPONR" + ": " + execution.getVariable(Prefix + "isPONR"), isDebugEnabled) - } else { - if (returnCode=='404') { - String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiUpdateContrailResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode - utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareCreateNetworkRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareCreateNetworkRequest() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String requestId = execution.getVariable("msoRequestId") - if (requestId == null) { - requestId = execution.getVariable("mso-request-id") - } - String messageId = execution.getVariable(Prefix + "messageId") - String source = execution.getVariable(Prefix + "source") - - String requestInput = execution.getVariable(Prefix + "networkRequest") - String queryIdResponse = execution.getVariable(Prefix + "queryIdAAIResponse") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") - String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") - - // Prepare Network request - String routeCollection = execution.getVariable(Prefix + "routeCollection") - String policyCollection = execution.getVariable(Prefix + "networkCollection") - String tableCollection = execution.getVariable(Prefix + "tableRefCollection") - String createNetworkRequest = networkUtils.CreateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) - // Format Response - String buildDeleteNetworkRequestAsString = utils.formatXml(createNetworkRequest) - buildDeleteNetworkRequestAsString = buildDeleteNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") - utils.logAudit(buildDeleteNetworkRequestAsString) - - execution.setVariable(Prefix + "createNetworkRequest", buildDeleteNetworkRequestAsString) - utils.log("DEBUG", Prefix + "createNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareCreateNetworkRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareSDNCRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRequest() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - - String networkId = execution.getVariable(Prefix + "networkId") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyCreateRequesAsString) - execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) - utils.log("DEBUG", Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCRequest() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - - String networkId = execution.getVariable(Prefix + "networkId") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) - - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyCreateRequesAsString) - execution.setVariable(Prefix + "assignSDNCRequest", sndcTopologyCreateRequesAsString) - utils.log("DEBUG", Prefix + "assignSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCActivateRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCActivateRequest() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String networkId = execution.getVariable(Prefix + "networkId") - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) - - String sndcTopologyCreateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyCreateRequesAsString) - execution.setVariable(Prefix + "activateSDNCRequest", sndcTopologyCreateRequesAsString) - utils.log("DEBUG", Prefix + "activateSDNCRequest - " + "\n" + sndcTopologyCreateRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void validateCreateNetworkResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside validateNetworkResponse() of DoCreateNetworkInstance *****", isDebugEnabled) - - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "createNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } - - utils.log("DEBUG", " Network Adapter create responseCode: " + returnCode, isDebugEnabled) - - String errorMessage = "" - if (returnCode == "200") { - execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) - utils.logAudit(networkResponse) - execution.setVariable(Prefix + "createNetworkResponse", networkResponse) - utils.log("DEBUG", " Network Adapter create Success Response - " + "\n" + networkResponse, isDebugEnabled) - - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - rollbackData = rollbackData.replace("rollback>", "networkRollback>") - String rollbackNetwork = - """<rollbackNetworkRequest> - ${rollbackData} - </rollbackNetworkRequest>""" - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) - utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled) - - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("createNetworkError")) { - networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '') - errorMessage = utils.getNodeText1(networkResponse, "message") - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } else { // CatchAll exception - if (returnCode == "500") { - errorMessage = "JBWEB000065: HTTP Status 500." - } else { - errorMessage = "Return code is " + returnCode - } - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } - - } else { // CatchAll exception - String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. validateCreateNetworkResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void validateSDNCResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside validateSDNCResponse() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - String response = execution.getVariable(Prefix + "assignSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "assignSDNCResponse")) - assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "assignSDNCResponse", assignSDNCResponseDecodeXml) - - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncRollbackNeeded", true) - utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled) - - } else { - utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } - - public void validateRpcSDNCActivateResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside validateRpcSDNCActivateResponse() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - String response = execution.getVariable(Prefix + "activateSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "activateSDNCResponse")) - assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "activateSDNCResponse", assignSDNCResponseDecodeXml) - - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncActivateRollbackNeeded", true) - utils.log("DEBUG", "Successfully Validated Rpc SDNC Activate Response", isDebugEnabled) - - } else { - utils.log("DEBUG", "Did NOT Successfully Validated Rpc SDNC Activate Response", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } - - - public void prepareSDNCRollbackRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRollbackRequest() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - String networkId = execution.getVariable(Prefix + "networkId") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, createNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) - utils.log("DEBUG", " Preparing request for SDNC Topology 'rollback-NetworkActivateRequest' rollback . . . - " + "\n" + sndcTopologyRollbackRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCRollbackRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCRollbackRequest() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String assignSDNCResponse = execution.getVariable(Prefix + "assignSDNCResponse") - String networkId = execution.getVariable(Prefix + "networkId") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - utils.log("DEBUG", " Preparing request for SDNC Topology 'unassign-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCRollbackRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCActivateRollback(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCActivateRollback() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String createNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String activateSDNCResponse = execution.getVariable(Prefix + "activateSDNCResponse") - String networkId = execution.getVariable(Prefix + "networkId") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, createNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "rollbackActivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'deactivate-DeleteNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRollbackData(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") - if (rollbackActivateSDNCRequest != null) { - if (rollbackActivateSDNCRequest != "") { - rollbackData.put("rollbackActivateSDNCRequest", execution.getVariable(Prefix + "rollbackActivateSDNCRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled) - - execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) - utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void postProcessResponse(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - - //Conditions: - // 1. Silent Success: execution.getVariable("CRENWKI_orchestrationStatus") == "ACTIVE" - // 2. Success: execution.getVariable("WorkflowException") == null (NULL) - // 3. WorkflowException: execution.getVariable("WorkflowException") != null (NOT NULL) - - utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled) - // successful flow - if (execution.getVariable(Prefix + "isException") == false) { - // set rollback data - execution.setVariable("orchestrationStatus", "") - execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) - execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) - prepareSuccessRollbackData(execution) // populate rollbackData - execution.setVariable("WorkflowException", null) - execution.setVariable(Prefix + "Success", true) - utils.log("DEBUG", " ***** postProcessResponse(), GOOD !!!", isDebugEnabled) - } else { - // inside sub-flow logic - execution.setVariable(Prefix + "Success", false) - execution.setVariable("rollbackData", null) - String exceptionMessage = " Exception encountered in MSO Bpmn. " - if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. - utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled) - WorkflowException wfex = execution.getVariable("workflowException") - exceptionMessage = wfex.getErrorMessage() - } else { - if (execution.getVariable(Prefix + "WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } - } - // going to the Main flow: a-la-carte or macro - utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } - - } catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - - } - - - - } - - public void prepareSuccessRollbackData(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - - if (execution.getVariable("sdncVersion") != '1610') { - prepareRpcSDNCRollbackRequest(execution) - prepareRpcSDNCActivateRollback(execution) - } else { - prepareSDNCRollbackRequest(execution) - } - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - } - } - String rollbackActivateSDNCRequest = execution.getVariable(Prefix + "rollbackActivateSDNCRequest") - if (rollbackActivateSDNCRequest != null) { - if (rollbackActivateSDNCRequest != "") { - rollbackData.put("rollbackActivateSDNCRequest", rollbackActivateSDNCRequest) - } - } - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG", "** 'rollbackData' for Full Rollback : " + rollbackData, isDebugEnabled) - execution.setVariable("WorkflowException", null) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void setExceptionFlag(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoCreateNetworkInstance ***** ", isDebugEnabled) - - try { - - execution.setVariable(Prefix + "isException", true) - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled) - - } catch(Exception ex){ - String exceptionMessage = "Bpmn error encountered in DoCreateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - try{ - utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy deleted file mode 100644 index 760389ef43..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstanceRollback.groovy +++ /dev/null @@ -1,387 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-
-/**
- * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process.
- *
- */
-public class DoCreateNetworkInstanceRollback extends AbstractServiceTaskProcessor {
- String Prefix="CRENWKIR_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils(this)
- NetworkUtils networkUtils = new NetworkUtils()
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
-
- def className = getClass().getSimpleName()
-
- /**
- * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process.
- * @param execution
- */
- public InitializeProcessVariables(DelegateExecution execution){
- /* Initialize all the process variables in this block */
-
- execution.setVariable(Prefix + "rollbackNetworkRequest", null)
- execution.setVariable(Prefix + "rollbackSDNCRequest", null)
- execution.setVariable(Prefix + "rollbackActivateSDNCRequest", null)
- execution.setVariable(Prefix + "WorkflowException", null)
-
- execution.setVariable(Prefix + "rollbackNetworkRequest", "")
- execution.setVariable(Prefix + "rollbackNetworkResponse", "")
- execution.setVariable(Prefix + "rollbackNetworkReturnCode", "")
-
- execution.setVariable(Prefix + "rollbackSDNCRequest", "")
- execution.setVariable(Prefix + "rollbackSDNCResponse", "")
- execution.setVariable(Prefix + "rollbackSDNCReturnCode", "")
-
- execution.setVariable(Prefix + "rollbackActivateSDNCRequest", "")
- execution.setVariable(Prefix + "rollbackActivateSDNCResponse", "")
- execution.setVariable(Prefix + "rollbackActivateSDNCReturnCode", "")
-
- execution.setVariable(Prefix + "Success", false)
- execution.setVariable(Prefix + "fullRollback", false)
- execution.setVariable(Prefix + "networkId", "")
- execution.setVariable(Prefix + "urlRollbackPoNetwork", "")
-
- }
-
- // **************************************************
- // Pre or Prepare Request Section
- // **************************************************
- /**
- * This method is executed during the preProcessRequest task of the <class>DoCreateNetworkInstanceRollback.bpmn</class> process.
- * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside preProcessRequest() of " + className + ".groovy ***** ", isDebugEnabled)
-
- try {
- // initialize flow variables
- InitializeProcessVariables(execution)
-
- // GET Incoming request/variables
- String rollbackNetworkRequest = null
- String rollbackSDNCRequest = null
- String rollbackActivateSDNCRequest = null
-
- // Partial Rollback
- Map<String, String> rollbackData = execution.getVariable("rollbackData")
- if (rollbackData != null && rollbackData instanceof Map) {
-
- if(rollbackData.containsKey("rollbackSDNCRequest")) {
- rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"]
- }
-
- if(rollbackData.containsKey("rollbackNetworkRequest")) {
- rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"]
- }
-
- if(rollbackData.containsKey("rollbackActivateSDNCRequest")) {
- rollbackActivateSDNCRequest = rollbackData["rollbackActivateSDNCRequest"]
- }
-
- }
-
- execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest)
- execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest)
- execution.setVariable(Prefix + "rollbackActivateSDNCRequest", rollbackActivateSDNCRequest)
- utils.log("DEBUG", "'rollbackData': " + '\n' + execution.getVariable("rollbackData"), isDebugEnabled)
-
- String sdncVersion = execution.getVariable("sdncVersion")
- utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled)
-
- // PO Authorization Info / headers Authorization=
- String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth")
- utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled)
- try {
- def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey"))
- execution.setVariable("BasicAuthHeaderValuePO",encodedString)
- execution.setVariable("BasicAuthHeaderValueSDNC", encodedString)
-
- } catch (IOException ex) {
- String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - "
- String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage()
- utils.log("DEBUG", dataErrorMessage , isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- }
-
- if (execution.getVariable("SavedWorkflowException1") != null) {
- execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
- } else {
- execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
- }
- utils.log("DEBUG", "*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled)
- if(execution.getVariable(Prefix + "WorkflowException") != null) {
- // called by: DoCreateNetworkInstance, partial rollback
- execution.setVariable(Prefix + "fullRollback", false)
-
- } else {
- // called by: Macro - Full Rollback, WorkflowException = null
- execution.setVariable(Prefix + "fullRollback", true)
-
- }
- utils.log("DEBUG", "*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"), isDebugEnabled)
-
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- // caught exception
- String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- public void callPONetworkAdapter (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside callPONetworkAdapter() of " + className + " ***** ", isDebugEnabled)
-
- try {
- String poUrl = execution.getVariable("URN_mso_adapters_network_rest_endpoint")
- String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest")
- String networkId = utils.getNodeText1(rollbackSDNCRequest, "network-id")
-
- String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest")
-
- String urlRollbackPoNetwork = poUrl+ "/" + networkId + "/rollback"
- utils.log("DEBUG", "'urlRollbackPoNetwork': " + urlRollbackPoNetwork, isDebugEnabled)
- execution.setVariable(Prefix + "urlRollbackPoNetwork", urlRollbackPoNetwork)
-
- RESTConfig config = new RESTConfig(urlRollbackPoNetwork)
- RESTClient client = new RESTClient(config).
- addHeader("Content-Type", "application/xml").
- addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO"));
-
- APIResponse response = client.httpDelete(rollbackNetworkRequest)
- String responseCode = response.getStatusCode()
- String responseBody = response.getResponseBodyAsString()
-
- execution.setVariable(Prefix + "rollbackNetworkReturnCode", responseCode)
- execution.setVariable(Prefix + "rollbackNetworkResponse", responseBody)
-
- utils.log("DEBUG", " Network Adapter rollback responseCode: " + responseCode, isDebugEnabled)
- utils.log("DEBUG", " Network Adapter rollback responseBody: " + responseBody, isDebugEnabled)
-
-
- } catch (Exception ex) {
- String exceptionMessage = "Exception Encountered in callPONetworkAdapter() of DoCreateNetworkInstanceRollback flow - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
-
- }
-
-
- public void validateRollbackResponses (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside validateRollbackResponses() of DoCreateNetworkInstanceRollback ***** ", isDebugEnabled)
-
- try {
- // validate PO network rollback response
- String rollbackNetworkErrorMessages = ""
- String rollbackNetworkReturnCode = "200"
- if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) {
- rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode")
- String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse")
- utils.log("DEBUG", " NetworkRollback Code - " + rollbackNetworkReturnCode, isDebugEnabled)
- utils.log("DEBUG", " NetworkRollback Response - " + rollbackNetworkResponse, isDebugEnabled)
- if (rollbackNetworkReturnCode != "200") {
- rollbackNetworkErrorMessages = " + PO Network rollback failed. "
- } else {
- rollbackNetworkErrorMessages = " + PO Network rollback completed."
- }
- }
-
- // validate SDNC rollback response
- String rollbackSdncErrorMessages = ""
- String rollbackSDNCReturnCode = "200"
- if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) {
- rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode")
- String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse")
- String rollbackSDNCReturnInnerCode = ""
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- rollbackSDNCResponse = sdncAdapterUtils.decodeXML(rollbackSDNCResponse)
- rollbackSDNCResponse = rollbackSDNCResponse.replace("&", "&").replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- if (rollbackSDNCReturnCode == "200") {
- if (utils.nodeExists(rollbackSDNCResponse, "response-code")) {
- rollbackSDNCReturnInnerCode = utils.getNodeText1(rollbackSDNCResponse, "response-code")
- if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") {
- rollbackSdncErrorMessages = " + SNDC assign rollback completed."
- } else {
- rollbackSdncErrorMessages = " + SDNC assign rollback failed. "
- }
- } else {
- rollbackSdncErrorMessages = " + SNDC assign rollback completed."
- }
- } else {
- rollbackSdncErrorMessages = " + SDNC assign rollback failed. "
- }
- utils.log("DEBUG", " SDNC assign rollback Code - " + rollbackSDNCReturnCode, isDebugEnabled)
- utils.log("DEBUG", " SDNC assign rollback Response - " + rollbackSDNCResponse, isDebugEnabled)
- }
-
- // validate SDNC activate rollback response
- String rollbackActivateSdncErrorMessages = ""
- String rollbackActivateSDNCReturnCode = "200"
- if (execution.getVariable(Prefix + "rollbackActivateSDNCRequest") != null) {
- rollbackActivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackActivateSDNCReturnCode")
- String rollbackActivateSDNCResponse = execution.getVariable(Prefix + "rollbackActivateSDNCResponse")
- String rollbackActivateSDNCReturnInnerCode = ""
- rollbackActivateSDNCResponse = sdncAdapterUtils.decodeXML(rollbackActivateSDNCResponse)
- rollbackActivateSDNCResponse = rollbackActivateSDNCResponse.replace("&", "&").replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- if (rollbackActivateSDNCReturnCode == "200") {
- if (utils.nodeExists(rollbackActivateSDNCResponse, "response-code")) {
- rollbackActivateSDNCReturnInnerCode = utils.getNodeText1(rollbackActivateSDNCResponse, "response-code")
- if (rollbackActivateSDNCReturnInnerCode == "200" || rollbackActivateSDNCReturnInnerCode == "" || rollbackActivateSDNCReturnInnerCode == "0") {
- rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed."
- } else {
- rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. "
- }
- } else {
- rollbackActivateSdncErrorMessages = " + SNDC activate rollback completed."
- }
- } else {
- rollbackActivateSdncErrorMessages = " + SDNC activate rollback failed. "
- }
- utils.log("DEBUG", " SDNC activate rollback Code - " + rollbackActivateSDNCReturnCode, isDebugEnabled)
- utils.log("DEBUG", " SDNC activate rollback Response - " + rollbackActivateSDNCResponse, isDebugEnabled)
- }
-
-
- String statusMessage = ""
- int errorCode = 7000
- utils.log("DEBUG", "*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"), isDebugEnabled)
- if (execution.getVariable(Prefix + "fullRollback") == false) {
- // original WorkflowException,
- WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException")
- if (wfe != null) {
- // rollback due to failure in DoCreate - Partial rollback
- statusMessage = wfe.getErrorMessage()
- errorCode = wfe.getErrorCode()
- } else {
- statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception."
- errorCode = '7000'
- }
-
- // set if all rolledbacks are successful
- if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") {
- execution.setVariable("rolledBack", true)
- execution.setVariable("wasDeleted", true)
-
- } else {
- execution.setVariable("rolledBack", false)
- execution.setVariable("wasDeleted", true)
- }
-
- statusMessage = statusMessage + rollbackActivateSdncErrorMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages
- utils.log("DEBUG", "Final DoCreateNetworkInstanceRollback status message: " + statusMessage, isDebugEnabled)
- String processKey = getProcessKey(execution);
- WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage);
- execution.setVariable("workflowException", exception);
-
- } else {
- // rollback due to failures in Main flow (Macro) - Full rollback
- // WorkflowException = null
- if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200" && rollbackActivateSDNCReturnCode == "200") {
- execution.setVariable("rollbackSuccessful", true)
- execution.setVariable("rollbackError", false)
- } else {
- String exceptionMessage = "Network Create Rollback was not Successful. "
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- execution.setVariable("rollbackSuccessful", false)
- execution.setVariable("rollbackError", true)
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
- throw new BpmnError("MSOWorkflowException")
- }
-
- }
-
-
- } catch (Exception ex) {
- String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception."
- String exceptionMessage = " Bpmn error encountered in DoCreateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- // *******************************
- // Build Error Section
- // *******************************
-
-
-
- public void processJavaException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- try{
- utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled)
- utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
- utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
- execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
-
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
- execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix)
- }
- utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy deleted file mode 100644 index ab84168007..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateResources.groovy +++ /dev/null @@ -1,270 +0,0 @@ -/*- - * ============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.infrastructure.scripts - -import org.codehaus.jackson.map.ObjectMapper -import org.openecomp.mso.bpmn.infrastructure.properties.BPMNProperties - -import java.util.ArrayList -import java.util.Iterator -import java.util.List -import org.apache.commons.lang3.StringUtils -import org.apache.http.HttpResponse -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.codehaus.groovy.runtime.ArrayUtil -import org.codehaus.groovy.runtime.ScriptBytecodeAdapter -import org.codehaus.groovy.runtime.callsite.CallSite -import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation -import org.codehaus.groovy.runtime.typehandling.ShortTypeHandling -import org.json.JSONArray -import org.json.JSONObject -import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient -import org.openecomp.mso.bpmn.common.recipe.ResourceInput -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.domain.AllottedResource -import org.openecomp.mso.bpmn.core.domain.NetworkResource -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder - -/** - * This groovy class supports the <class>DoCreateResources.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - O - * @param - subscriptionServiceType - O - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion - * - * @param - addResourceList - * - * Outputs: - * @param - WorkflowException - - */ -public class DoCreateResources extends AbstractServiceTaskProcessor -{ - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils cutils = new CatalogDbUtils() - - public void preProcessRequest(DelegateExecution execution) - { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) - String msg = "" - - List addResourceList = execution.getVariable("addResourceList") - if (addResourceList == null) - { - msg = "Input addResourceList is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else if (addResourceList.size() == 0) - { - msg = "No resource in addResourceList" - utils.log("INFO", msg, isDebugEnabled) - } - utils.log("INFO", " ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void sequenceResoure(DelegateExecution execution) - { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start sequenceResoure Process ======== ", isDebugEnabled) - - String serviceModelUUID = execution.getVariable("modelUuid") - - List<Resource> addResourceList = execution.getVariable("addResourceList") - List<NetworkResource> networkResourceList = new ArrayList<NetworkResource>() - - List<Resource> sequencedResourceList = new ArrayList<Resource>() - - String serviceDecompose = execution.getVariable("serviceDecomposition") - String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") - def resourceSequence = BPMNProperties.getResourceSequenceProp(serviceModelName) - - if(resourceSequence != null) { - // sequence is defined in config file - for (resourceType in resourceSequence) { - for (resource in addResourceList) { - if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { - sequencedResourceList.add(resource) - - if (resource instanceof NetworkResource) { - networkResourceList.add(resource) - } - } - } - } - } else { - - //define sequenced resource list, we deploy vf first and then network and then ar - //this is defaule sequence - List<VnfResource> vnfResourceList = new ArrayList<VnfResource>() - List<AllottedResource> arResourceList = new ArrayList<AllottedResource>() - - for (Resource rc : addResourceList){ - if (rc instanceof VnfResource) { - vnfResourceList.add(rc) - } else if (rc instanceof NetworkResource) { - networkResourceList.add(rc) - } else if (rc instanceof AllottedResource) { - arResourceList.add(rc) - } - } - sequencedResourceList.addAll(vnfResourceList) - sequencedResourceList.addAll(networkResourceList) - sequencedResourceList.addAll(arResourceList) - } - - String isContainsWanResource = networkResourceList.isEmpty() ? "false" : "true" - execution.setVariable("isContainsWanResource", isContainsWanResource) - execution.setVariable("currentResourceIndex", 0) - execution.setVariable("sequencedResourceList", sequencedResourceList) - utils.log("INFO", "sequencedResourceList: " + sequencedResourceList, isDebugEnabled) - utils.log("INFO", "======== COMPLETED sequenceResoure Process ======== ", isDebugEnabled) - } - - public prepareServiceTopologyRequest(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start prepareServiceTopologyRequest Process ======== ", isDebugEnabled) - - String serviceDecompose = execution.getVariable("serviceDecomposition") - - execution.setVariable("operationType", "create") - execution.setVariable("resourceType", "") - - String serviceInvariantUuid = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelInvariantUuid") - String serviceUuid = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelUuid") - String serviceModelName = jsonUtil.getJsonValue(serviceDecompose, "serviceResources.modelInfo.modelName") - - execution.setVariable("modelInvariantUuid", serviceInvariantUuid) - execution.setVariable("modelUuid", serviceUuid) - execution.setVariable("serviceModelName", serviceModelName) - - utils.log("INFO", "======== End prepareServiceTopologyRequest Process ======== ", isDebugEnabled) - } - - public void getCurrentResoure(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") - Resource currentResource = sequencedResourceList.get(currentIndex) - execution.setVariable("resourceType", currentResource.getModelInfo().getModelName()) - utils.log("INFO", "Now we deal with resouce:" + currentResource.getModelInfo().getModelName(), isDebugEnabled) - utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) - } - - public void parseNextResource(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - def nextIndex = currentIndex + 1 - execution.setVariable("currentResourceIndex", nextIndex) - List<String> sequencedResourceList = execution.getVariable("sequencedResourceList") - if(nextIndex >= sequencedResourceList.size()){ - execution.setVariable("allResourceFinished", "true") - }else{ - execution.setVariable("allResourceFinished", "false") - } - utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) - } - - public void prepareResourceRecipeRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start prepareResourceRecipeRequest Process ======== ", isDebugEnabled) - ResourceInput resourceInput = new ResourceInput() - String serviceInstanceName = execution.getVariable("serviceInstanceName") - String resourceType = execution.getVariable("resourceType") - String resourceInstanceName = resourceType + "_" + serviceInstanceName - resourceInput.setResourceInstanceName(resourceInstanceName) - utils.log("INFO", "Prepare Resource Request resourceInstanceName:" + resourceInstanceName, isDebugEnabled) - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String serviceType = execution.getVariable("serviceType") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = "createInstance" - resourceInput.setGlobalSubscriberId(globalSubscriberId) - resourceInput.setServiceType(serviceType) - resourceInput.setServiceInstanceId(serviceInstanceId) - resourceInput.setOperationId(operationId) - resourceInput.setOperationType(operationType); - def currentIndex = execution.getVariable("currentResourceIndex") - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") - Resource currentResource = sequencedResourceList.get(currentIndex) - resourceInput.setResourceModelInfo(currentResource.getModelInfo()); - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); - def String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid(); - - String incomingRequest = execution.getVariable("uuiRequest") - //set the requestInputs from tempalte To Be Done - String serviceModelUuid = jsonUtil.getJsonValue(incomingRequest,"service.serviceUuid") - String serviceParameters = jsonUtil.getJsonValue(incomingRequest, "service.parameters") - String resourceParameters = ResourceRequestBuilder.buildResourceRequestParameters(execution, serviceModelUuid, resourceCustomizationUuid, serviceParameters) - resourceInput.setResourceParameters(resourceParameters) - execution.setVariable("resourceInput", resourceInput) - utils.log("INFO", "======== COMPLETED prepareResourceRecipeRequest Process ======== ", isDebugEnabled) - } - - public void executeResourceRecipe(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start executeResourceRecipe Process ======== ", isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceType = execution.getVariable("serviceType") - ResourceInput resourceInput = execution.getVariable("resourceInput") - - // requestAction is action, not opertiontype - //String requestAction = resourceInput.getOperationType() - String requestAction = "createInstance" - JSONObject resourceRecipe = cutils.getResourceRecipe(execution, resourceInput.getResourceModelInfo().getModelUuid(), requestAction) - - if (resourceRecipe != null) { - String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + resourceRecipe.getString("orchestrationUri") - int recipeTimeOut = resourceRecipe.getInt("recipeTimeout") - String recipeParamXsd = resourceRecipe.get("paramXSD") - HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeOut, requestAction, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) - } else { - String exceptionMessage = "Resource receipe is not found for resource modeluuid: " + - resourceInput.getResourceModelInfo().getModelUuid() - utils.log("ERROR", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, exceptionMessage) - } - - utils.log("INFO", "======== end executeResourceRecipe Process ======== ", isDebugEnabled) - } - - public void postConfigRequest(DelegateExecution execution){ - //now do noting - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy deleted file mode 100644 index c142532794..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy +++ /dev/null @@ -1,798 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.infrastructure.aai.AAICreateResources -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.client.aai.AAIResourcesClient - -import java.util.logging.Logger; -import java.net.URI; - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the <class>DoCreateServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - * @param - subscriptionServiceType - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceModelInfo - * @param - productFamilyId - * @param - disableRollback - * @param - failExists - TODO - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion ("1610") - * @param - serviceDecomposition - Decomposition for R1710 - * (if macro provides serviceDecompsition then serviceModelInfo, serviceInstanceId & serviceInstanceName will be ignored) - * - * Outputs: - * @param - rollbackData (localRB->null) - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * @param - WorkflowException - * @param - serviceInstanceName - (GET from AAI if null in input) - * - * This BB processes Macros(except TRANSPORT all sent to sdnc) and Alacartes(sdncSvcs && nonSdncSvcs) - */ -public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DCRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils cutils = new CatalogDbUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("prefix", Prefix) - - //Inputs - //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology - String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - - //requestDetails.requestParameters. for SDNC assignTopology - String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId - - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - if (productFamilyId == null) { - execution.setVariable("productFamilyId", "") - } - - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - //requestDetails.modelInfo.for AAI PUT servieInstanceData & SDNC assignTopology - String modelInvariantUuid = "" - String modelVersion = "" - String modelUuid = "" - String modelName = "" - String serviceInstanceName = "" - //Generated in parent.for AAI PUT - String serviceInstanceId = "" - String serviceType = "" - String serviceRole = "" - - ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition") - if (serviceDecomp != null) - { - serviceType = serviceDecomp.getServiceType() ?: "" - utils.log("DEBUG", "serviceType:" + serviceType, isDebugEnabled) - serviceRole = serviceDecomp.getServiceRole() ?: "" - - ServiceInstance serviceInstance = serviceDecomp.getServiceInstance() - if (serviceInstance != null) - { - serviceInstanceId = serviceInstance.getInstanceId() ?: "" - serviceInstanceName = serviceInstance.getInstanceName() ?: "" - execution.setVariable("serviceInstanceId", serviceInstanceId) - execution.setVariable("serviceInstanceName", serviceInstanceName) - } - - ModelInfo modelInfo = serviceDecomp.getModelInfo() - if (modelInfo != null) - { - modelInvariantUuid = modelInfo.getModelInvariantUuid() ?: "" - modelVersion = modelInfo.getModelVersion() ?: "" - modelUuid = modelInfo.getModelUuid() ?: "" - modelName = modelInfo.getModelName() ?: "" - } - else - { - msg = "Input serviceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - } - else - { - //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData & SDNC assignToplology - serviceInstanceName = execution.getVariable("serviceInstanceName") ?: "" - serviceInstanceId = execution.getVariable("serviceInstanceId") ?: "" - - String serviceModelInfo = execution.getVariable("serviceModelInfo") - if (isBlank(serviceModelInfo)) { - msg = "Input serviceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") ?: "" - modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") ?: "" - modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") ?: "" - modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") ?: "" - //modelCustomizationUuid NA for SI - - } - - execution.setVariable("serviceType", serviceType) - execution.setVariable("serviceRole", serviceRole) - execution.setVariable("serviceInstanceName", serviceInstanceName) - - execution.setVariable("modelInvariantUuid", modelInvariantUuid) - execution.setVariable("modelVersion", modelVersion) - execution.setVariable("modelUuid", modelUuid) - execution.setVariable("modelName", modelName) - - //alacarte SIs are NOT sent to sdnc. exceptions are listed in config variable - String svcTypes = execution.getVariable("URN_sdnc_si_svc_types") ?: "" - utils.log("DEBUG", "SDNC SI serviceTypes:" + svcTypes, isDebugEnabled) - List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*")); - boolean isSdncService= false - for (String listEntry : svcList){ - if (listEntry.equalsIgnoreCase(serviceType)){ - isSdncService = true - break; - } - } - - //All Macros are sent to SDNC, TRANSPORT(Macro) is sent to SDNW - //Alacartes are sent to SDNC if they are listed in config variable above - execution.setVariable("sendToSDNC", true) - if(execution.getVariable("sdncVersion").equals("1610")) //alacarte - { - if(!isSdncService){ - execution.setVariable("sendToSDNC", false) - //alacarte non-sdnc svcs must provide name (sdnc provides name for rest) - if (isBlank(execution.getVariable("serviceInstanceName" ))) - { - msg = "Input serviceInstanceName must be provided for alacarte" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - } - } - - utils.log("DEBUG", "isSdncService: " + isSdncService, isDebugEnabled) - utils.log("DEBUG", "Send To SDNC: " + execution.getVariable("sendToSDNC"), isDebugEnabled) - utils.log("DEBUG", "Service Type: " + execution.getVariable("serviceType"), isDebugEnabled) - - //macro may provide name and alacarte-portm may provide name - execution.setVariable("checkAAI", false) - if (!isBlank(execution.getVariable("serviceInstanceName" ))) - { - execution.setVariable("checkAAI", true) - } - - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - - StringBuilder sbParams = new StringBuilder() - Map<String, String> paramsMap = execution.getVariable("serviceInputParams") - if (paramsMap != null) - { - sbParams.append("<service-input-parameters>") - for (Map.Entry<String, String> entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ <param> - <name>${paramName}</name> - <value>${paramValue}</value> - </param> - """ - sbParams.append(paramsXml) - } - sbParams.append("</service-input-parameters>") - } - String siParamsXml = sbParams.toString() - if (siParamsXml == null) - siParamsXml = "" - execution.setVariable("siParamsXml", siParamsXml) - - //AAI PUT - String oStatus = execution.getVariable("initialStatus") ?: "Active" - if ("TRANSPORT".equalsIgnoreCase(serviceType)) - { - oStatus = "Created" - } - - String statusLine = isBlank(oStatus) ? "" : "<orchestration-status>${oStatus}</orchestration-status>" - String serviceTypeLine = isBlank(serviceType) ? "" : "<service-type>${serviceType}</service-type>" - String serviceRoleLine = isBlank(serviceRole) ? "" : "<service-role>${serviceRole}</service-role>" - - //QUERY CATALOG DB AND GET WORKLOAD / ENVIRONMENT CONTEXT - String environmentContext = "" - String workloadContext ="" - - try{ - String json = cutils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) - - utils.log("DEBUG", "JSON IS: "+json, isDebugEnabled) - - environmentContext = jsonUtil.getJsonValue(json, "serviceResources.environmentContext") ?: "" - workloadContext = jsonUtil.getJsonValue(json, "serviceResources.workloadContext") ?: "" - utils.log("DEBUG", "Env Context is: "+ environmentContext, isDebugEnabled) - utils.log("DEBUG", "Workload Context is: "+ workloadContext, isDebugEnabled) - }catch(BpmnError e){ - throw e - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - //Create AAI Payload - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-name>${serviceInstanceName}</service-instance-name> - ${serviceTypeLine} - ${serviceRoleLine} - ${statusLine} - <model-invariant-id>${modelInvariantUuid}</model-invariant-id> - <model-version-id>${modelUuid}</model-version-id> - <environment-context>${environmentContext}</environment-context> - <workload-context>${workloadContext}</workload-context> - </service-instance>""".trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - utils.logAudit(serviceInstanceData) - utils.log("DEBUG", " 'payload' to create Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - //TODO: Will be able to replace with call to GenericGetService - public void getAAICustomerById (DelegateExecution execution) { - // https://{aaiEP}/aai/v8/business/customers/customer/{globalCustomerId} - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String msg = "" - try { - - String globalCustomerId = execution.getVariable("globalSubscriberId") //VID to AAI name map - utils.log("DEBUG"," ***** getAAICustomerById ***** globalCustomerId:" + globalCustomerId, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - if (isBlank(aai_endpoint) || isBlank(aai_uri)) - { - msg = "AAI URL is invalid. Endpoint:" + aai_endpoint + aai_uri - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - String getAAICustomerUrl = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(globalCustomerId,"UTF-8") - - utils.logAudit(getAAICustomerUrl) - utils.log("DEBUG", "getAAICustomerById Url:" + getAAICustomerUrl, isDebugEnabled) - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, getAAICustomerUrl) - String returnCode = response.getStatusCode() - String aaiResponseAsString = response.getResponseBodyAsString() - - msg = "getAAICustomerById ResponseCode:" + returnCode + " ResponseString:" + aaiResponseAsString - utils.log("DEBUG",msg, isDebugEnabled) - utils.logAudit(msg) - - if (returnCode=='200') { - // Customer found by ID. FLow to proceed. - utils.log("DEBUG",msg, isDebugEnabled) - - //TODO Deferred - //we might verify that service-subscription with matching name exists - //and throw error if not. If not checked, we will get exception in subsequent step on Create call - //in 1610 we assume both customer & service subscription were pre-created - - } else { - if (returnCode=='404') { - msg = "GlobalCustomerId:" + globalCustomerId + " not found (404) in AAI" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - utils.log("ERROR", aaiResponseAsString) - WorkflowException workflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", workflowException) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - msg = "Error in getAAICustomerById ResponseCode:" + returnCode - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in getAAICustomerById. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit getAAICustomerById *****", isDebugEnabled) - - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceName = execution.getVariable("serviceInstanceName") - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("DEBUG","Error getting Service-instance from AAI", + serviceInstanceName, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - else - { - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI){ - utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled) - msg = "ServiceInstance already exists in AAI:" + serviceInstanceName - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void postProcessAAIPUT(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIPUT ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - utils.log("DEBUG","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString()) - rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true") - rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId) - rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType")) - rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId")) - execution.setVariable("rollbackData", rollbackData) - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIPUT *** ", isDebugEnabled) - } - - public void preProcessSDNCAssignRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCAssignRequest *****", isDebugEnabled) - - try { - def serviceInstanceId = execution.getVariable("serviceInstanceId") - def serviceInstanceName = execution.getVariable("serviceInstanceName") - def callbackURL = execution.getVariable("sdncCallbackUrl") - def requestId = execution.getVariable("msoRequestId") - def serviceId = execution.getVariable("productFamilyId") - def subscriptionServiceType = execution.getVariable("subscriptionServiceType") - def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - def msoAction = "" - - def modelInvariantUuid = execution.getVariable("modelInvariantUuid") - def modelVersion = execution.getVariable("modelVersion") - def modelUuid = execution.getVariable("modelUuid") - def modelName = execution.getVariable("modelName") - - def sdncRequestId = UUID.randomUUID().toString() - - def siParamsXml = execution.getVariable("siParamsXml") - - // special URL for SDNW, msoAction helps set diff url in SDNCA - if("TRANSPORT".equalsIgnoreCase(execution.getVariable("serviceType"))) - { - msoAction = "TRANSPORT" - } - - String sdncAssignRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>assign</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - <request-action>CreateServiceInstance</request-action> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> - <model-uuid>${modelUuid}</model-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalSubscriberId}</global-customer-id> - </service-information> - <service-request-input> - <service-instance-name>${serviceInstanceName}</service-instance-name> - ${siParamsXml} - </service-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG","sdncAssignRequest:\n" + sdncAssignRequest, isDebugEnabled) - sdncAssignRequest = utils.formatXml(sdncAssignRequest) - execution.setVariable("sdncAssignRequest", sdncAssignRequest) - utils.logAudit("sdncAssignRequest: " + sdncAssignRequest) - - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncDelete = sdncAssignRequest.replace(">assign<", ">delete<").replace(">CreateServiceInstance<", ">DeleteServiceInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def sdncRequestId3 = UUID.randomUUID().toString() - String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId2}<", ">${sdncRequestId3}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate) - rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCAssignRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCAssignRequest *****", isDebugEnabled) - } - - public void postProcessSDNCAssign (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessSDNCAssign ***** ", isDebugEnabled) - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - String response = execution.getVariable("sdncAdapterResponse") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG","Good response from SDNC Adapter for service-instance topology assign: \n" + response, isDebugEnabled) - - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put("SERVICEINSTANCE", "rollbackSDNC", "true") - execution.setVariable("rollbackData", rollbackData) - - }else{ - utils.log("DEBUG","Bad Response from SDNC Adapter for service-instance assign", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in postProcessSDNCAssign. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessSDNCAssign *** ", isDebugEnabled) - } - - public void postProcessAAIGET2(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIGET2 ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceName = execution.getVariable("serviceInstanceName") - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("DEBUG","Error getting Service-instance from AAI in postProcessAAIGET2", + serviceInstanceName, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET2 GENGS_SuccessIndicator:" + succInAAI - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - else - { - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI){ - String aaiService = execution.getVariable("GENGS_service") - if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "service-instance-name"))) { - execution.setVariable("serviceInstanceName", utils.getNodeText1(aaiService, "service-instance-name")) - utils.log("DEBUG","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled) - } - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIGET2 " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIGET2 *** ", isDebugEnabled) - } - - public void preProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - execution.setVariable("rollbackData", null) - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) - } - - public void createProject(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** createProject ***** ", isDebugEnabled) - - String bpmnRequest = execution.getVariable("requestJson") - String projectName = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.project.projectName") - String serviceInstance = execution.getVariable("serviceInstanceId") - - utils.log("DEBUG", "BPMN REQUEST IS: "+ bpmnRequest, isDebugEnabled) - utils.log("DEBUG","PROJECT NAME: " + projectName, isDebugEnabled) - utils.log("DEBUG","Service Instance: " + serviceInstance, isDebugEnabled) - - if(projectName == null||projectName.equals("")){ - utils.log("DEBUG", "Project Name was not found in input. Skipping task...", isDebugEnabled) - }else{ - try{ - AAICreateResources aaiCR = new AAICreateResources() - aaiCR.createAAIProject(projectName, serviceInstance) - }catch(Exception ex){ - String msg = "Exception in createProject. " + ex.getMessage(); - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - utils.log("DEBUG"," *** Exit createProject *** ", isDebugEnabled) - } - - public void createOwningEntity(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** createOwningEntity ***** ", isDebugEnabled) - String msg = ""; - String bpmnRequest = execution.getVariable("requestJson") - String owningEntityId = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.owningEntity.owningEntityId") - String owningEntityName = jsonUtil.getJsonValue(bpmnRequest,"requestDetails.owningEntity.owningEntityName"); - String serviceInstance = execution.getVariable("serviceInstanceId") - - utils.log("DEBUG","owningEntity: " + owningEntityId, isDebugEnabled) - utils.log("DEBUG", "OwningEntityName: "+ owningEntityName, isDebugEnabled) - utils.log("DEBUG","Service Instance: " + serviceInstance, isDebugEnabled) - - try{ - AAICreateResources aaiCR = new AAICreateResources() - if(owningEntityId==null||owningEntityId.equals("")){ - msg = "Exception in createOwningEntity. OwningEntityId is null in input."; - throw new IllegalStateException(); - }else{ - if(aaiCR.existsOwningEntity(owningEntityId)){ - aaiCR.connectOwningEntityandServiceInstance(owningEntityId,serviceInstance) - }else{ - if(owningEntityName==null||owningEntityName.equals("")){ - msg = "Exception in createOwningEntity. Can't create an owningEntity without an owningEntityName in input."; - throw new IllegalStateException(); - }else{ - aaiCR.createAAIOwningEntity(owningEntityId, owningEntityName, serviceInstance) - } - } - } - }catch(Exception ex){ - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit createOwningEntity *** ", isDebugEnabled) - } - - // ******************************* - // Build Error Section - // ******************************* - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try{ - utils.log("DEBUG", "Caught a Java Exception in DoCreateServiceInstance", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception in DoCreateServiceInstance") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception in DoCreateServiceInstance") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method in DoCreateServiceInstance", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy deleted file mode 100644 index cb69121e4e..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy +++ /dev/null @@ -1,237 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-
-import static org.apache.commons.lang3.StringUtils.*;
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONObject;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils;
-/**
- * This groovy class supports the <class>DoCreateServiceInstanceRollback.bpmn</class> process.
- *
- * Inputs:
- * @param - msoRequestId
- * @param - rollbackData with
- * globalCustomerId
- * subscriptionServiceType
- * serviceInstanceId
- * disableRollback
- * rollbackAAI
- * rollbackSDNC
- * sdncRollbackRequest
- *
- *
- * Outputs:
- * @param - rollbackError
- * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
- *
- */
-public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcessor{
-
- String Prefix="DCRESIRB_"
-
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- String msg = ""
- utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled)
- execution.setVariable("rollbackAAI",false)
- execution.setVariable("rollbackSDNC",false)
-
- try {
- def rollbackData = execution.getVariable("rollbackData")
- utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled)
-
- if (rollbackData != null) {
- if (rollbackData.hasType("SERVICEINSTANCE")) {
-
- def serviceInstanceId = rollbackData.get("SERVICEINSTANCE", "serviceInstanceId")
- execution.setVariable("serviceInstanceId", serviceInstanceId)
-
- def subscriptionServiceType = rollbackData.get("SERVICEINSTANCE", "subscriptionServiceType")
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
-
- def globalSubscriberId = rollbackData.get("SERVICEINSTANCE", "globalSubscriberId")
- execution.setVariable("globalSubscriberId", globalSubscriberId)
-
- def rollbackAAI = rollbackData.get("SERVICEINSTANCE", "rollbackAAI")
- if ("true".equals(rollbackAAI))
- {
- execution.setVariable("rollbackAAI",true)
- }
-
- def rollbackSDNC = rollbackData.get("SERVICEINSTANCE", "rollbackSDNC")
- if ("true".equals(rollbackSDNC))
- {
- execution.setVariable("rollbackSDNC", true)
- }
-
- if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true)
- {
- execution.setVariable("skipRollback", true)
- }
-
- def sdncDelete = rollbackData.get("SERVICEINSTANCE", "sdncDelete")
- execution.setVariable("sdncDelete", sdncDelete)
- def sdncDeactivate = rollbackData.get("SERVICEINSTANCE", "sdncDeactivate")
- execution.setVariable("sdncDeactivate", sdncDeactivate)
- utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
- utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled)
- }
- else {
- execution.setVariable("skipRollback", true)
- }
- }
- else {
- execution.setVariable("skipRollback", true)
- }
- if (execution.getVariable("disableRollback").equals("true" ))
- {
- execution.setVariable("skipRollback", true)
- }
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- msg = "Exception in Create ServiceInstance Rollback preProcessRequest " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled)
- }
-
- public void validateSDNCResponse(DelegateExecution execution, String response, String method) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** validateSDNCResponse ***** ", isDebugEnabled)
- String msg = ""
- try {
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
- utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled)
- utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled)
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
-
- if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
- msg = "SDNC Adapter service-instance rollback successful for " + method
- utils.log("DEBUG", msg, isDebugEnabled)
- }else{
- execution.setVariable("rolledBack", false)
- msg = "Error Response from SDNC Adapter service-instance rollback for " + method
- execution.setVariable("rollbackError", msg)
- utils.log("DEBUG", msg, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- msg = "Exception in Create ServiceInstance rollback for " + method + " Exception:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG"," ***** Exit validateSDNCResponse ***** ", isDebugEnabled)
- }
-
- public void postProcessRequest(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled)
- String msg = ""
- try {
- execution.setVariable("rollbackData", null)
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- boolean rollbackAAI = execution.getVariable("rollbackAAI")
- boolean rollbackSDNC = execution.getVariable("rollbackSDNC")
- if (rollbackAAI || rollbackSDNC)
- {
- execution.setVariable("rolledBack", true)
- }
- if (rollbackAAI)
- {
- boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
- if(!succInAAI){
- execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful
- execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback")
- utils.log("DEBUG","Error deleting service-instance in AAI for rollback", + serviceInstanceId, isDebugEnabled)
- }
- }
- utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled)
-
- } catch (BpmnError e) {
- msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- } catch (Exception ex) {
- msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- }
-
- }
-
- public void processRollbackException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled)
- try{
- utils.log("DEBUG", "Caught an Exception in DoCreateServiceInstanceRollback", isDebugEnabled)
- execution.setVariable("rollbackData", null)
- execution.setVariable("rollbackError", "Caught exception in ServiceInstance Create Rollback")
- execution.setVariable("WorkflowException", null)
-
- }catch(BpmnError b){
- utils.log("DEBUG", "BPMN Error during processRollbackExceptions Method: ", isDebugEnabled)
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processRollbackExceptions Method: " + e.getMessage(), isDebugEnabled)
- }
-
- utils.log("DEBUG", " Exit processRollbackException", isDebugEnabled)
- }
-
- public void processRollbackJavaException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled)
- try{
- execution.setVariable("rollbackData", null)
- execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Create Rollback")
- utils.log("DEBUG", "Caught Exception in processRollbackJavaException", isDebugEnabled)
-
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception in processRollbackJavaException " + e.getMessage(), isDebugEnabled)
- }
- utils.log("DEBUG", "***** Exit processRollbackJavaException *****", isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy deleted file mode 100644 index fa4250df13..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollbackV2.groovy +++ /dev/null @@ -1,51 +0,0 @@ -package org.openecomp.mso.bpmn.infrastructure.scripts
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
-import org.openecomp.mso.client.orchestration.AAIOrchestrator
-import org.openecomp.mso.client.orchestration.SDNCOrchestrator
-
-public class DoCreateServiceInstanceRollbackV2 extends AbstractServiceTaskProcessor{
-
- @Override
- public void preProcessRequest(DelegateExecution execution) {
-
- }
-
- public void aaiServiceInstanceRollback (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- def aaiServiceInstanceRollback = execution.getVariable("aaiServiceInstanceRollback")
- if(aaiServiceInstanceRollback){
- utils.log("DEBUG"," ***** Started aaiServiceInstanceRollback *****", isDebugEnabled)
- try{
- ServiceDecomposition serviceDecomp = execution.getVariable("ServiceDecomposition")
- AAIOrchestrator aaiO = new AAIOrchestrator()
- aaiO.deleteServiceInstance(serviceDecomp)
- }catch (Exception ex) {
- String msg = "Error Response from AAI for aaiServiceInstanceRollback"
- execution.setVariable("rollbackError", msg)
- utils.log("DEBUG", msg, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- utils.log("DEBUG"," ***** Completed aaiServiceInstanceRollback *****", isDebugEnabled)
- }else{
- utils.log("DEBUG", "***** SKIPPING A&AI ROLLBACK *****", isDebugEnabled)
- }
- }
-
- public void rollbackError (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("DEBUG"," ***** rollbackError ***** ", isDebugEnabled)
- try{
- utils.log("DEBUG", "Caught an Exception in DoCreateServiceInstanceRollbackV2", isDebugEnabled)
- }catch(BpmnError b){
- utils.log("DEBUG", "BPMN Error during rollbackError: " + b.getMessage(), isDebugEnabled)
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during rollbackError: " + e.getMessage(), isDebugEnabled)
- }
- utils.log("DEBUG", " Exit processRollbackException", isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy deleted file mode 100644 index c55ce547c2..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceV2.groovy +++ /dev/null @@ -1,101 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
-import org.openecomp.mso.client.orchestration.AAIOrchestrator
-import org.openecomp.mso.client.orchestration.SDNCOrchestrator
-
-import groovy.json.*
-
-/**
- * This groovy class supports the <class>DoCreateServiceInstanceV2.bpmn</class> process.
- *
-*/
-
-public class DoCreateServiceInstanceV2 extends AbstractServiceTaskProcessor {
-
- AAIOrchestrator aaiO = new AAIOrchestrator()
- SDNCOrchestrator sdncO = new SDNCOrchestrator()
-
- @Override
- public void preProcessRequest(DelegateExecution execution) {
- }
-
- public void createServiceInstance(DelegateExecution execution) {
- execution.setVariable("callSDNC",true)
- if(execution.getVariable("serviceType").equalsIgnoreCase("PORT-MIRROR")== false){
- if(execution.getVariable("sdncVersion").equals("1610")){
- execution.setVariable("callSDNC",false);
- }
- }
- ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition")
- try{
- aaiO.createServiceInstance(serviceDecomp)
- } catch (BpmnError e) {
- throw e
- }
- }
-
- public void createProject(DelegateExecution execution) {
- ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition")
- if (serviceDecomp.getServiceInstance() != null && serviceDecomp.getProject() != null) {
- try{
- aaiO.createProjectandConnectServiceInstance(serviceDecomp)
- } catch (BpmnError e) {
- throw e
- }
- }
- }
-
- public void createOwningEntity(DelegateExecution execution) {
- ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition")
- if (serviceDecomp.getServiceInstance() != null && serviceDecomp.getOwningEntity() != null) {
- try{
- aaiO.createOwningEntityandConnectServiceInstance(serviceDecomp)
- } catch (BpmnError e) {
- throw e
- }
- }
- }
-
- public void sdncAssignRequest(DelegateExecution execution) {
- ServiceDecomposition serviceDecomp = (ServiceDecomposition) execution.getVariable("serviceDecomposition")
- if (serviceDecomp != null) {
- try {
- sdncO.sendSyncResponse(serviceDecomp)
- } catch (BpmnError e) {
- throw e
- }
- }
-
- }
-
- public void rollback(DelegateExecution execution) {
- //TODO
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy deleted file mode 100644 index 95747d5a0b..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy +++ /dev/null @@ -1,2148 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import org.openecomp.mso.bpmn.core.domain.CloudFlavor - -import java.util.Map -import java.util.Currency.CurrencyNameGetter - -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONArray -import org.json.JSONObject -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VfModuleBase -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.DecomposeJsonUtil -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.client.aai.entities.AAIResultWrapper -import org.openecomp.mso.client.aai.entities.uri.AAIUri -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.NamedNodeMap -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource -import com.fasterxml.jackson.databind.ObjectMapper - -import com.fasterxml.jackson.databind.DeserializationFeature -import com.fasterxml.jackson.databind.ObjectMapper -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.AAIResourcesClient -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - - - -public class DoCreateVfModule extends VfModuleBase { - - String Prefix="DCVFM_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - CatalogDbUtils catalog = new CatalogDbUtils() - DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil() - - /** - * Validates the request message and sets up the workflow. - * @param execution the execution - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - execution.setVariable('prefix', Prefix) - try{ - def rollbackData = execution.getVariable("rollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - execution.setVariable("DCVFM_vnfParamsExistFlag", false) - execution.setVariable("DCVFM_oamManagementV4Address", "") - execution.setVariable("DCVFM_oamManagementV6Address", "") - - String request = execution.getVariable("DoCreateVfModuleRequest") - - if (request == null || request.isEmpty()) { - // Building Block-type request - - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - - def serviceModelInfo = execution.getVariable("serviceModelInfo") - logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled) - String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") - logDebug("modelInvariantUuid: " + modelInvariantUuid, isDebugLogEnabled) - - def vnfModelInfo = execution.getVariable("vnfModelInfo") - - //tenantId - def tenantId = execution.getVariable("tenantId") - execution.setVariable("DCVFM_tenantId", tenantId) - rollbackData.put("VFMODULE", "tenantid", tenantId) - //volumeGroupId - def volumeGroupId = execution.getVariable("volumeGroupId") - execution.setVariable("DCVFM_volumeGroupId", volumeGroupId) - //volumeGroupName - def volumeGroupName = execution.getVariable("volumeGroupName") - execution.setVariable("DCVFM_volumeGroupName", volumeGroupName) - //cloudSiteId - def cloudSiteId = execution.getVariable("lcpCloudRegionId") - execution.setVariable("DCVFM_cloudSiteId", cloudSiteId) - rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId) - logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled) - //vnfType - def vnfType = execution.getVariable("vnfType") - execution.setVariable("DCVFM_vnfType", vnfType) - rollbackData.put("VFMODULE", "vnftype", vnfType) - logDebug("vnfType: " + vnfType, isDebugLogEnabled) - //vnfName - def vnfName = execution.getVariable("vnfName") - execution.setVariable("DCVFM_vnfName", vnfName) - rollbackData.put("VFMODULE", "vnfname", vnfName) - logDebug("vnfName: " + vnfName, isDebugLogEnabled) - //vnfId - def vnfId = execution.getVariable("vnfId") - execution.setVariable("DCVFM_vnfId", vnfId) - rollbackData.put("VFMODULE", "vnfid", vnfId) - logDebug("vnfId: " + vnfId, isDebugLogEnabled) - //vfModuleName - def vfModuleName = execution.getVariable("vfModuleName") - execution.setVariable("DCVFM_vfModuleName", vfModuleName) - rollbackData.put("VFMODULE", "vfmodulename", vfModuleName) - logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled) - //vfModuleModelName - def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") - execution.setVariable("DCVFM_vfModuleModelName", vfModuleModelName) - rollbackData.put("VFMODULE", "vfmodulemodelname", vfModuleModelName) - logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled) - //modelCustomizationUuid - def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") - execution.setVariable("DCVFM_modelCustomizationUuid", modelCustomizationUuid) - rollbackData.put("VFMODULE", "modelcustomizationuuid", modelCustomizationUuid) - logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled) - //vfModuleId - def vfModuleId = execution.getVariable("vfModuleId") - execution.setVariable("DCVFM_vfModuleId", vfModuleId) - logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled) - def requestId = execution.getVariable("msoRequestId") - execution.setVariable("DCVFM_requestId", requestId) - logDebug("requestId: " + requestId, isDebugLogEnabled) - rollbackData.put("VFMODULE", "msorequestid", requestId) - // Set mso-request-id to request-id for VNF Adapter interface - execution.setVariable("mso-request-id", requestId) - //serviceId - def serviceId = execution.getVariable("serviceId") - execution.setVariable("DCVFM_serviceId", serviceId) - logDebug("serviceId: " + serviceId, isDebugLogEnabled) - //serviceInstanceId - def serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId) - rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId) - logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled) - //flavorList - ArrayList<CloudFlavor> flavorList = execution.getVariable(cloudSiteId + "_flavorList") - if (flavorList != null) { - execution.setVariable("DCVFM_flavorList", flavorList) - logDebug("flavorList is: " + flavorList, isDebugLogEnabled) - } - //source - HARDCODED - def source = "VID" - execution.setVariable("DCVFM_source", source) - rollbackData.put("VFMODULE", "source", source) - logDebug("source: " + source, isDebugLogEnabled) - //backoutOnFailure - def disableRollback = execution.getVariable("disableRollback") - def backoutOnFailure = true - if (disableRollback != null && disableRollback == true) { - backoutOnFailure = false - } - execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure) - logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled) - //isBaseVfModule - def isBaseVfModule = execution.getVariable("isBaseVfModule") - execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule) - logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) - //asdcServiceModelVersion - def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") - execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion) - logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) - //personaModelId - execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid")) - //personaModelVersion - execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelUuid")) - //vfModuleLabel - def vfModuleLabel = execution.getVariable("vfModuleLabel") - if (vfModuleLabel != null) { - execution.setVariable("DCVFM_vfModuleLabel", vfModuleLabel) - logDebug("vfModuleLabel: " + vfModuleLabel, isDebugLogEnabled) - } - //Get or Generate UUID - String uuid = execution.getVariable("DCVFM_uuid") - if(uuid == null){ - uuid = UUID.randomUUID() - logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled) - }else{ - logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled) - } - //isVidRequest - String isVidRequest = execution.getVariable("isVidRequest") - // default to true - if (isVidRequest == null || isVidRequest.isEmpty()) { - execution.setVariable("isVidRequest", "true") - } - //globalSubscriberId - String globalSubscriberId = execution.getVariable("globalSubscriberId") - execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId) - logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled) - Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams") - if (vfModuleInputParams != null) { - execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams) - execution.setVariable("DCVFM_vnfParamsExistFlag", true) - } - //usePreload - def usePreload = execution.getVariable("usePreload") - execution.setVariable("DCVFM_usePreload", usePreload) - logDebug("usePreload: " + usePreload, isDebugLogEnabled) - //aLaCarte - def aLaCarte = execution.getVariable("aLaCarte") - execution.setVariable("DCVFM_aLaCarte", aLaCarte) - logDebug("aLaCarte: " + aLaCarte, isDebugLogEnabled) - - //get workload and environment context from parent SI - String environmentContext = "" - String workloadContext ="" - String serviceType ="" - - try{ - String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) - serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") - }catch(BpmnError e){ - throw e - } catch (Exception ex){ - String msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - try{ - AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) - AAIResourcesClient aaiRC = new AAIResourcesClient() - AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI) - Map<String, Object> aaiJson = aaiRW.asMap() - environmentContext = aaiJson.getOrDefault("environment-context","") - workloadContext = aaiJson.getOrDefault("workload-context","") - - }catch (Exception ex) { - utils.log("DEBUG","Error retreiving parent service instance information", isDebugLogEnabled) - } - - execution.setVariable("DCVFM_environmentContext",environmentContext) - execution.setVariable("DCVFM_workloadContext",workloadContext) - - } - else { - // The info is inside the request - DEAD CODE - utils.logAudit("DoCreateVfModule request: " + request) - - //tenantId - def tenantId = "" - if (utils.nodeExists(request, "tenant-id")) { - tenantId = utils.getNodeText(request, "tenant-id") - } - execution.setVariable("DCVFM_tenantId", tenantId) - rollbackData.put("VFMODULE", "tenantid", tenantId) - //volumeGroupId - def volumeGroupId = "" - if (utils.nodeExists(request, "volume-group-id")) { - volumeGroupId = utils.getNodeText(request, "volume-group-id") - } - execution.setVariable("DCVFM_volumeGroupId", volumeGroupId) - //volumeGroupId - def volumeGroupName = "" - if (utils.nodeExists(request, "volume-group-name")) { - volumeGroupName = utils.getNodeText(request, "volume-group-name") - } - execution.setVariable("DCVFM_volumeGroupName", volumeGroupName) - //cloudSiteId - def cloudSiteId = "" - if (utils.nodeExists(request, "aic-cloud-region")) { - cloudSiteId = utils.getNodeText(request, "aic-cloud-region") - } - execution.setVariable("DCVFM_cloudSiteId", cloudSiteId) - rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId) - logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled) - //vnfType - def vnfType = "" - if (utils.nodeExists(request, "vnf-type")) { - vnfType = utils.getNodeText(request, "vnf-type") - } - execution.setVariable("DCVFM_vnfType", vnfType) - rollbackData.put("VFMODULE", "vnftype", vnfType) - logDebug("vnfType: " + vnfType, isDebugLogEnabled) - //vnfName - def vnfName = "" - if (utils.nodeExists(request, "vnf-name")) { - vnfName = utils.getNodeText(request, "vnf-name") - } - execution.setVariable("DCVFM_vnfName", vnfName) - rollbackData.put("VFMODULE", "vnfname", vnfName) - logDebug("vnfName: " + vnfName, isDebugLogEnabled) - //vnfId - def vnfId = "" - if (utils.nodeExists(request, "vnf-id")) { - vnfId = utils.getNodeText(request, "vnf-id") - } - execution.setVariable("DCVFM_vnfId", vnfId) - rollbackData.put("VFMODULE", "vnfid", vnfId) - logDebug("vnfId: " + vnfId, isDebugLogEnabled) - //vfModuleName - def vfModuleName = "" - if (utils.nodeExists(request, "vf-module-name")) { - vfModuleName = utils.getNodeText(request, "vf-module-name") - } - execution.setVariable("DCVFM_vfModuleName", vfModuleName) - rollbackData.put("VFMODULE", "vfmodulename", vfModuleName) - logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled) - //vfModuleModelName - def vfModuleModelName = "" - if (utils.nodeExists(request, "vf-module-model-name")) { - vfModuleModelName = utils.getNodeText(request, "vf-module-model-name") - } - execution.setVariable("DCVFM_vfModuleModelName", vfModuleModelName) - rollbackData.put("VFMODULE", "vfmodulemodelname", vfModuleModelName) - logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled) - //modelCustomizationUuid - def modelCustomizationUuid = "" - if (utils.nodeExists(request, "model-customization-id")) { - modelCustomizationUuid = utils.getNodeText(request, "model-customization-id") - } - execution.setVariable("DCVFM_modelCustomizationUuid", modelCustomizationUuid) - rollbackData.put("VFMODULE", "modelcustomizationuuid", modelCustomizationUuid) - logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled) - //vfModuleId - def vfModuleId = "" - if (utils.nodeExists(request, "vf-module-id")) { - vfModuleId = utils.getNodeText(request, "vf-module-id") - } - execution.setVariable("DCVFM_vfModuleId", vfModuleId) - logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled) - def requestId = "" - if (utils.nodeExists(request, "request-id")) { - requestId = utils.getNodeText(request, "request-id") - } - execution.setVariable("DCVFM_requestId", requestId) - logDebug("requestId: " + requestId, isDebugLogEnabled) - //serviceId - def serviceId = "" - if (utils.nodeExists(request, "service-id")) { - serviceId = utils.getNodeText(request, "service-id") - } - execution.setVariable("DCVFM_serviceId", serviceId) - logDebug("serviceId: " + serviceId, isDebugLogEnabled) - //serviceInstanceId - def serviceInstanceId = "" - if (utils.nodeExists(request, "service-instance-id")) { - serviceInstanceId = utils.getNodeText(request, "service-instance-id") - } - execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId) - rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId) - logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled) - //source - def source = "" - if (utils.nodeExists(request, "source")) { - source = utils.getNodeText(request, "source") - } - execution.setVariable("DCVFM_source", source) - rollbackData.put("VFMODULE", "source", source) - logDebug("source: " + source, isDebugLogEnabled) - //backoutOnFailure - NetworkUtils networkUtils = new NetworkUtils() - def backoutOnFailure = networkUtils.isRollbackEnabled(execution,request) - execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure) - logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled) - //isBaseVfModule - def isBaseVfModule = "false" - if (utils.nodeExists(request, "is-base-vf-module")) { - isBaseVfModule = utils.getNodeText(request, "is-base-vf-module") - } - execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule) - logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) - //asdcServiceModelVersion - def asdcServiceModelVersion = "" - if (utils.nodeExists(request, "asdc-service-model-version")) { - asdcServiceModelVersion = utils.getNodeText(request, "asdc-service-model-version") - } - execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion) - logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) - - //personaModelId - def personaModelId = "" - if (utils.nodeExists(request, "persona-model-id")) { - personaModelId = utils.getNodeText(request, "persona-model-id") - } - execution.setVariable("DCVFM_personaModelId", personaModelId) - logDebug("personaModelId: " + personaModelId, isDebugLogEnabled) - - //personaModelVersion - def personaModelVersion = "" - if (utils.nodeExists(request, "persona-model-version")) { - personaModelVersion = utils.getNodeText(request, "persona-model-version") - } - execution.setVariable("DCVFM_personaModelVersion", personaModelVersion) - logDebug("personaModelVersion: " + personaModelVersion, isDebugLogEnabled) - - // Process the parameters - - String vnfParamsChildNodes = utils.getChildNodes(request, "vnf-params") - if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){ - utils.log("DEBUG", "Request contains NO VNF Params", isDebugLogEnabled) - }else{ - utils.log("DEBUG", "Request does contain VNF Params", isDebugLogEnabled) - execution.setVariable("DCVFM_vnfParamsExistFlag", true) - - InputSource xmlSource = new InputSource(new StringReader(request)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document xml = docBuilder.parse(xmlSource) - //Get params, build map - Map<String, String> paramsMap = new HashMap<String, String>() - NodeList paramsList = xml.getElementsByTagNameNS("*", "param") - - for (int z = 0; z < paramsList.getLength(); z++) { - Node node = paramsList.item(z) - String paramValue = node.getTextContent() - NamedNodeMap e = node.getAttributes() - String paramName = e.getNamedItem("name").getTextContent() - paramsMap.put(paramName, paramValue) - } - execution.setVariable("DCVFM_vnfParamsMap", paramsMap) - } - } - - //Get or Generate UUID - String uuid = execution.getVariable("DCVFM_uuid") - if(uuid == null){ - uuid = UUID.randomUUID() - logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled) - }else{ - logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled) - } - // Get sdncVersion, default to empty - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null) { - sdncVersion = "" - } - logDebug("sdncVersion: " + sdncVersion, isDebugLogEnabled) - execution.setVariable("DCVFM_sdncVersion", sdncVersion) - - execution.setVariable("DCVFM_uuid", uuid) - execution.setVariable("DCVFM_baseVfModuleId", "") - execution.setVariable("DCVFM_baseVfModuleHeatStackId", "") - execution.setVariable("DCVFM_heatStackId", "") - execution.setVariable("DCVFM_contrailServiceInstanceFqdn", "") - execution.setVariable("DCVFM_volumeGroupStackId", "") - execution.setVariable("DCVFM_cloudRegionForVolume", "") - execution.setVariable("DCVFM_contrailNetworkPolicyFqdnList", "") - execution.setVariable("DCVFM_vnfTypeToQuery", "generic-vnf") - rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "false") - rollbackData.put("VFMODULE", "rollbackUpdateAAIVfModule", "false") - rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "false") - rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "false") - rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "false") - rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "false") - rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "false") - rollbackData.put("VFMODULE", "rollbackUpdateVnfAAI", "false") - rollbackData.put("VFMODULE", "heatstackid", "") - - String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - execution.setVariable("DCVFM_sdncCallbackUrl", sdncCallbackUrl) - utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) - logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugLogEnabled) - - - execution.setVariable("rollbackData", rollbackData) - }catch(BpmnError b){ - throw b - }catch(Exception e){ - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } - - /** - * Validates a workflow response. - * @param execution the execution - * @param responseVar the execution variable in which the response is stored - * @param responseCodeVar the execution variable in which the response code is stored - * @param errorResponseVar the execution variable in which the error response is stored - */ - public void validateWorkflowResponse(DelegateExecution execution, String responseVar, - String responseCodeVar, String errorResponseVar) { - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar) - } - - - /** - * Sends the empty, synchronous response back to the API Handler. - * @param execution the execution - */ - public void sendResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - sendWorkflowResponse(execution, 200, "") - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Internal Error') - } - } - - /** - * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. - * A 200 response is expected with the VNF info in the response body. Will find out the base module info - * and existing VNF's name for add-on modules - * - * @param execution The flow's execution instance. - */ - public void postProcessCreateAAIVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.getVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def createResponse = execution.getVariable('DCVFM_createVfModuleResponse') - utils.logAudit("createVfModule Response: " + createResponse) - - def rollbackData = execution.getVariable("rollbackData") - String vnfName = utils.getNodeText1(createResponse, 'vnf-name') - if (vnfName != null) { - execution.setVariable('DCVFM_vnfName', vnfName) - logDebug("vnfName retrieved from AAI is: " + vnfName, isDebugLogEnabled) - rollbackData.put("VFMODULE", "vnfname", vnfName) - } - String vnfId = utils.getNodeText1(createResponse, 'vnf-id') - execution.setVariable('DCVFM_vnfId', vnfId) - logDebug("vnfId is: " + vnfId, isDebugLogEnabled) - String vfModuleId = utils.getNodeText1(createResponse, 'vf-module-id') - execution.setVariable('DCVFM_vfModuleId', vfModuleId) - logDebug("vfModuleId is: " + vfModuleId, isDebugLogEnabled) - String vfModuleIndex= utils.getNodeText1(createResponse, 'vf-module-index') - execution.setVariable('DCVFM_vfModuleIndex', vfModuleIndex) - logDebug("vfModuleIndex is: " + vfModuleIndex, isDebugLogEnabled) - rollbackData.put("VFMODULE", "vnfid", vnfId) - rollbackData.put("VFMODULE", "vfmoduleid", vfModuleId) - rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "true") - rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "true") - execution.setVariable("rollbackData", rollbackData) - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while postProcessing CreateAAIVfModule request:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Bad response from CreateAAIVfModule' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } - - - /** - * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. - * A 200 response is expected with the VNF info in the response body. Will find out the base module info. - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModule(DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.getVfModule(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DCVFM_vnfId') - def vfModuleId = execution.getVariable('DCVFM_vfModuleId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - utils.logAudit("AAI endPoint: " + endPoint) - - try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - def aaiRequestId = UUID.randomUUID().toString() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/xml'). - addHeader('Accept','application/xml'); - logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - APIResponse response = client.httpGet() - utils.logAudit("createVfModule - invoking httpGet() to AAI") - - responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) - if (responseData != null) { - def vfModulesText = utils.getNodeXml(responseData, "vf-modules") - def xmlVfModules= new XmlSlurper().parseText(vfModulesText) - def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} - int vfModulesSize = 0 - for (i in 0..vfModules.size()-1) { - def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") - - if (isBaseVfModule == "true") { - String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") - execution.setVariable("DCVFM_baseVfModuleId", baseModuleId) - logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled) - String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id") - execution.setVariable("DCVFM_baseVfModuleHeatStackId", baseModuleHeatStackId) - logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled) - } - } - } - } - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) - } - } - - /** - * Using the vnfId and vfModuleName provided in the inputs, - * query AAI to get the corresponding VF Module info. - * A 200 response is expected with the VF Module info in the response body, - * or a 404 response if the module does not exist yet. Will determine VF Module's - * orchestration status if one exists - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModuleForStatus(DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - execution.setVariable('DCVFM_orchestrationStatus', '') - - try { - def vnfId = execution.getVariable('DCVFM_vnfId') - def vfModuleName = execution.getVariable('DCVFM_vfModuleName') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + - "/vf-modules/vf-module?vf-module-name=" + UriUtils.encode(vfModuleName, "UTF-8") - utils.logAudit("AAI endPoint: " + endPoint) - - try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - def aaiRequestId = UUID.randomUUID().toString() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/xml'). - addHeader('Accept','application/xml'); - logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - APIResponse response = client.httpGet() - utils.logAudit("createVfModule - invoking httpGet() to AAI") - - responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponseCode', response.getStatusCode()) - execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - // Retrieve VF Module info and its orchestration status; if not found, do nothing - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find orchestration status', isDebugLogEnabled) - if (responseData != null) { - def vfModuleText = utils.getNodeXml(responseData, "vf-module") - //def xmlVfModule= new XmlSlurper().parseText(vfModuleText) - def orchestrationStatus = utils.getNodeText1(vfModuleText, "orchestration-status") - execution.setVariable("DCVFM_orchestrationStatus", orchestrationStatus) - // Also retrieve vfModuleId - def vfModuleId = utils.getNodeText1(vfModuleText, "vf-module-id") - execution.setVariable("DCVFM_vfModuleId", vfModuleId) - logDebug("Received orchestration status from A&AI: " + orchestrationStatus, isDebugLogEnabled) - - } - } - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) - } - } - - - public void preProcessSDNCAssignRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - def vnfId = execution.getVariable("DCVFM_vnfId") - def vfModuleId = execution.getVariable("DCVFM_vfModuleId") - def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId") - logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled) - utils.logAudit("NEW VNF ID: " + vnfId) - - try{ - - //Build SDNC Request - - def svcInstId = "" - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - svcInstId = vfModuleId - } - else { - svcInstId = serviceInstanceId - } - - String assignSDNCRequest = buildSDNCRequest(execution, svcInstId, "assign") - - assignSDNCRequest = utils.formatXml(assignSDNCRequest) - execution.setVariable("DCVFM_assignSDNCRequest", assignSDNCRequest) - logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCGetRequest(DelegateExecution execution, String element){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - String sdncVersion = execution.getVariable("DCVFM_sdncVersion") - execution.setVariable("prefix", Prefix) - utils.log("DEBUG", " ======== STARTED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) - try{ - def serviceInstanceId = execution.getVariable('DCVFM_serviceInstanceId') - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() - } - - def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") - utils.logAudit("callbackUrl:" + callbackUrl) - - def vfModuleId = execution.getVariable('DCVFM_vfModuleId') - - def svcInstId = "" - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - svcInstId = vfModuleId - } - else { - svcInstId = serviceInstanceId - } - - def msoAction = "" - if (!sdncVersion.equals("1707")) { - msoAction = "mobility" - } - else { - msoAction = "vfmodule" - } - // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element - // in the response from GenericGetVnf - // For VF Module, in 1707 serviceOperation will be retrieved from "object-path" element - // in SDNC Assign Response - // For VF Module for older versions, serviceOperation is constructed using vfModuleId - - String serviceOperation = "" - if (element.equals("vnf")) { - def vnfQueryResponse = execution.getVariable("DCVFM_vnfQueryResponse") - serviceOperation = utils.getNodeText1(vnfQueryResponse, "selflink") - utils.log("DEBUG", "VNF - service operation: " + serviceOperation, isDebugLogEnabled) - } - else if (element.equals("vfmodule")) { - String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") - utils.logAudit("DCVFM_assignSDNCAdapterResponse is: \n" + response) - - if (!sdncVersion.equals("1707")) { - serviceOperation = "/VNF-API:vnfs/vnf-list/" + vfModuleId - utils.log("DEBUG", "VF Module with sdncVersion before 1707 - service operation: " + serviceOperation, isDebugLogEnabled) - } - else { - String data = utils.getNodeXml(response, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") - utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled) - serviceOperation = utils.getNodeText1(data, "object-path") - utils.log("DEBUG", "VF Module with sdncVersion of 1707 - service operation: " + serviceOperation, isDebugLogEnabled) - } - } - - //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE - sleep(5000) - - String SDNCGetRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>query</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest) - execution.setVariable("DCVFM_getSDNCRequest", SDNCGetRequest) - utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) - } - - - public void preProcessVNFAdapterRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.VNFAdapterCreateVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - //def xml = execution.getVariable("DoCreateVfModuleRequest") - //logDebug('VNF REQUEST is: ' + xml, isDebugLogEnabled) - - //Get variables - //cloudSiteId - def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId") - //tenantId - def tenantId = execution.getVariable("DCVFM_tenantId") - //vnfType - def vnfType = execution.getVariable("DCVFM_vnfType") - //vnfName - def vnfName = execution.getVariable("DCVFM_vnfName") - //vnfId - def vnfId = execution.getVariable("DCVFM_vnfId") - //vfModuleName - def vfModuleName = execution.getVariable("DCVFM_vfModuleName") - //vfModuleModelName - def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") - //vfModuleId - def vfModuleId = execution.getVariable("DCVFM_vfModuleId") - //vfModuleIndex - def vfModuleIndex = execution.getVariable("DCVFM_vfModuleIndex") - //requestId - def requestId = execution.getVariable("DCVFM_requestId") - //serviceId - def serviceId = execution.getVariable("DCVFM_serviceId") - //serviceInstanceId - def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId") - //flavorList - ArrayList<CloudFlavor> flavorList = execution.getVariable("DCVFM_flavorList") - //backoutOnFailure - def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure") - //volumeGroupId - def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId") - // baseVfModuleId - def baseVfModuleId = execution.getVariable("DCVFM_baseVfModuleId") - // baseVfModuleStackId - def baseVfModuleStackId = execution.getVariable("DCVFM_baseVfModuleHeatStackId") - // asdcServiceModelVersion - def asdcServiceModelVersion = execution.getVariable("DCVFM_asdcServiceModelVersion") - //volumeGroupStackId - def volumeGroupStackId = execution.getVariable("DCVFM_volumeGroupStackId") - //modelCustomizationUuid - def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid") - //environmentContext - String environmentContext = execution.getVariable("DCVFM_environmentContext") - //workloadContext - String workloadContext = execution.getVariable("DCVFM_workloadContext") - logDebug("workloadContext: " + workloadContext, isDebugLogEnabled) - logDebug("environmentContext: " + environmentContext, isDebugLogEnabled) - - def messageId = execution.getVariable('mso-request-id') + '-' + - System.currentTimeMillis() - - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - - utils.logAudit("notificationUrl: " + notificationUrl) - utils.logAudit("QualifiedHostName: " + useQualifiedHostName) - - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - Map<String, String> vnfParamsMap = execution.getVariable("DCVFM_vnfParamsMap") - // Add flavorLabel List to vnfParamsMap - flavorList.each { cloudFlavor -> - vnfParamsMap.put("label_" + cloudFlavor.getFlavorLabel(), cloudFlavor.getFlavor()) - } - String vfModuleParams = "" - //Get SDNC Response Data for VF Module Topology - String vfModuleSdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse') - utils.logAudit("sdncGetResponse: " + vfModuleSdncGetResponse) - def sdncVersion = execution.getVariable("sdncVersion") - - if (!sdncVersion.equals("1707")) { - - vfModuleParams = buildVfModuleParams(vnfParamsMap, vfModuleSdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) - } - else { - //Get SDNC Response Data for Vnf Topology - String vnfSdncGetResponse = execution.getVariable('DCVFM_getVnfSDNCAdapterResponse') - utils.logAudit("vnfSdncGetResponse: " + vnfSdncGetResponse) - - vfModuleParams = buildVfModuleParamsFromCombinedTopologies(vnfParamsMap, vnfSdncGetResponse, vfModuleSdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext) - } - - def svcInstId = "" - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - svcInstId = serviceId - } - else { - svcInstId = serviceInstanceId - } - - def createVnfARequest = """ - <createVfModuleRequest> - <cloudSiteId>${cloudSiteId}</cloudSiteId> - <tenantId>${tenantId}</tenantId> - <vnfId>${vnfId}</vnfId> - <vnfName>${vnfName}</vnfName> - <vfModuleName>${vfModuleName}</vfModuleName> - <vfModuleId>${vfModuleId}</vfModuleId> - <vnfType>${vnfType}</vnfType> - <vfModuleType>${vfModuleModelName}</vfModuleType> - <vnfVersion>${asdcServiceModelVersion}</vnfVersion> - <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid> - <requestType></requestType> - <volumeGroupId>${volumeGroupId}</volumeGroupId> - <volumeGroupStackId>${volumeGroupStackId}</volumeGroupStackId> - <baseVfModuleId>${baseVfModuleId}</baseVfModuleId> - <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId> - <skipAAI>true</skipAAI> - <backout>${backoutOnFailure}</backout> - <failIfExists>true</failIfExists> - <vfModuleParams> - ${vfModuleParams} - </vfModuleParams> - <msoRequest> - <requestId>${requestId}</requestId> - <serviceInstanceId>${svcInstId}</serviceInstanceId> - </msoRequest> - <messageId>${messageId}</messageId> - <notificationUrl>${notificationUrl}</notificationUrl> - </createVfModuleRequest>""" - - utils.logAudit("Create VfModule Request to VNF Adapter : " + createVnfARequest) - logDebug("Create VfModule Request to VNF Adapter: " + createVnfARequest, isDebugLogEnabled) - execution.setVariable("DCVFM_createVnfARequest", createVnfARequest) - } - - /** - * Validates the request, request id and service instance id. If a problem is found, - * a WorkflowException is generated and an MSOWorkflowException event is thrown. This - * method also sets up the log context for the workflow. - * @param execution the execution - * @return the validated request - */ - public String validateInfraRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.validateInfraRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String processKey = getProcessKey(execution); - def prefix = execution.getVariable("prefix") - - if (prefix == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null") - } - - try { - def request = execution.getVariable(prefix + 'Request') - - if (request == null) { - request = execution.getVariable(processKey + 'Request') - - if (request == null) { - request = execution.getVariable('bpmnRequest') - } - - setVariable(execution, processKey + 'Request', null); - setVariable(execution, 'bpmnRequest', null); - setVariable(execution, prefix + 'Request', request); - } - - if (request == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null") - } - utils.logAudit("DoCreateVfModule Request: " + request) - - /* - - def requestId = execution.getVariable("mso-request-id") - - if (requestId == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") - } - - def serviceInstanceId = execution.getVariable("mso-service-instance-id") - - if (serviceInstanceId == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") - } - - utils.logContext(requestId, serviceInstanceId) - */ - logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) - return request - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") - } - } - - public boolean isVolumeGroupIdPresent(DelegateExecution execution) { - - def method = getClass().getSimpleName() + '.isVolumeGroupIdPresent(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - def request = execution.getVariable('DoCreateVfModuleRequest') - String volumeGroupId = utils.getNodeText1(request, "volume-group-id") - if (volumeGroupId == null || volumeGroupId.isEmpty()) { - logDebug('No volume group id is present', isDebugLogEnabled) - return false - } - else { - logDebug('Volume group id is present', isDebugLogEnabled) - return true - } - - } - - public boolean isVolumeGroupNamePresent(DelegateExecution execution) { - - def method = getClass().getSimpleName() + '.isVolumeGroupNamePresent(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - def request = execution.getVariable('DoCreateVfModuleRequest') - String volumeGroupName = utils.getNodeText1(request, "volume-group-name") - if (volumeGroupName == null || volumeGroupName.isEmpty()) { - logDebug('No volume group name is present', isDebugLogEnabled) - return false - } - else { - logDebug('Volume group name is present', isDebugLogEnabled) - return true - } - - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("DCVFM_sdncCallbackUrl") - def requestId = execution.getVariable("DCVFM_requestId") - def serviceId = execution.getVariable("DCVFM_serviceId") - def vnfType = execution.getVariable("DCVFM_vnfType") - def vnfName = execution.getVariable("DCVFM_vnfName") - def tenantId = execution.getVariable("DCVFM_tenantId") - def source = execution.getVariable("DCVFM_source") - def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure") - def vfModuleId = execution.getVariable("DCVFM_vfModuleId") - def vfModuleName = execution.getVariable("DCVFM_vfModuleName") - def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") - def vnfId = execution.getVariable("DCVFM_vnfId") - def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId") - def sdncVersion = execution.getVariable("DCVFM_sdncVersion") - def serviceModelInfo = execution.getVariable("serviceModelInfo") - def vnfModelInfo = execution.getVariable("vnfModelInfo") - def vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) - String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) - String vfModuleEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vfModuleModelInfo) - def globalSubscriberId = execution.getVariable("DCVFM_globalSubscriberId") - boolean usePreload = execution.getVariable("DCVFM_usePreload") - String usePreloadToSDNC = usePreload ? "Y" : "N" - def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid") - def modelCustomizationUuidString = "" - if (!usePreload) { - modelCustomizationUuidString = "<model-customization-uuid>" + modelCustomizationUuid + "</model-customization-uuid>" - } - - String sdncVNFParamsXml = "" - - if(execution.getVariable("DCVFM_vnfParamsExistFlag") == true){ - sdncVNFParamsXml = buildSDNCParamsXml(execution) - }else{ - sdncVNFParamsXml = "" - } - - String sdncRequest = "" - - if (!sdncVersion.equals("1707")) { - - sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>VNFActivateRequest</request-action> - <source>${source}</source> - <notification-url/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <service-type>${serviceId}</service-type> - <service-instance-id>${svcInstId}</service-instance-id> - <subscriber-name>notsurewecare</subscriber-name> - </service-information> - <vnf-request-information> - <vnf-id>${vfModuleId}</vnf-id> - <vnf-type>${vfModuleModelName}</vnf-type> - <vnf-name>${vfModuleName}</vnf-name> - <generic-vnf-id>${vnfId}</generic-vnf-id> - <generic-vnf-name>${vnfName}</generic-vnf-name> - <generic-vnf-type>${vnfType}</generic-vnf-type> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - <tenant>${tenantId}</tenant> - ${modelCustomizationUuidString} - <use-preload>${usePreloadToSDNC}</use-preload> - ${sdncVNFParamsXml} - </vnf-request-information> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - } - else { - - sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>CreateVfModuleInstance</request-action> - <source>${source}</source> - <notification-url/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <subscription-service-type>${serviceId}</subscription-service-type> - ${serviceEcompModelInformation} - <service-instance-id>${svcInstId}</service-instance-id> - <global-customer-id>${globalSubscriberId}</global-customer-id> - </service-information> - <vnf-information> - <vnf-id>${vnfId}</vnf-id> - <vnf-type>${vnfType}</vnf-type> - ${vnfEcompModelInformation} - </vnf-information> - <vf-module-information> - <vf-module-id>${vfModuleId}</vf-module-id> - <vf-module-type>${vfModuleModelName}</vf-module-type> - ${vfModuleEcompModelInformation} - </vf-module-information> - <vf-module-request-input> - <vf-module-name>${vfModuleName}</vf-module-name> - <tenant>${tenantId}</tenant> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - ${sdncVNFParamsXml} - </vf-module-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - - /* - sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>CreateVfModuleInstance</request-action> - <source>${source}</source> - <notification-url/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <service-type>${serviceId}</service-type> - ${serviceEcompModelInformation} - <service-instance-id>${svcInstId}</service-instance-id> - <global-customer-id>${globalSubscriberId}</global-customer-id> - </service-information> - <vnf-information> - <vnf-id>${vnfId}</vnf-id> - <vnf-type>${vnfType}</vnf-type> - ${vnfEcompModelInformation} - </vnf-information> - <vf-module-information> - <vf-module-id>${vfModuleId}</vf-module-id> - <vf-module-type>${vfModuleModelName}</vf-module-type> - ${vfModuleEcompModelInformation} - </vf-module-information> - <vf-module-request-input> - <vf-module-name>${vfModuleName}</vf-module-name> - <tenant>${tenantId}</tenant> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - ${sdncVNFParamsXml} - </vf-module-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - */ - - } - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - - } - - public void preProcessSDNCActivateRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - try{ - String vnfId = execution.getVariable("DCVFM_vnfId") - String vfModuleId = execution.getVariable("DCVFM_vfModuleId") - String serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId") - - def svcInstId = "" - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - svcInstId = vfModuleId - } - else { - svcInstId = serviceInstanceId - } - String activateSDNCRequest = buildSDNCRequest(execution, svcInstId, "activate") - - execution.setVariable("DCVFM_activateSDNCRequest", activateSDNCRequest) - logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) - - }catch(Exception e){ - log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - } - - public void postProcessVNFAdapterRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix",Prefix) - try{ - logDebug(" *** STARTED postProcessVNFAdapterRequest Process*** ", isDebugLogEnabled) - - String vnfResponse = execution.getVariable("DCVFM_createVnfAResponse") - logDebug("VNF Adapter Response is: " + vnfResponse, isDebugLogEnabled) - utils.logAudit("createVnfAResponse is: \n" + vnfResponse) - - RollbackData rollbackData = execution.getVariable("rollbackData") - if(vnfResponse != null){ - - if(vnfResponse.contains("createVfModuleResponse")){ - logDebug("Received a Good Response from VNF Adapter for CREATE_VF_MODULE Call.", isDebugLogEnabled) - execution.setVariable("DCVFM_vnfVfModuleCreateCompleted", true) - String heatStackId = utils.getNodeText1(vnfResponse, "vfModuleStackId") - execution.setVariable("DCVFM_heatStackId", heatStackId) - logDebug("Received heat stack id from VNF Adapter: " + heatStackId, isDebugLogEnabled) - rollbackData.put("VFMODULE", "heatstackid", heatStackId) - // Parse vnfOutputs for network_fqdn - if (vnfResponse.contains("vfModuleOutputs")) { - def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") - InputSource source = new InputSource(new StringReader(vfModuleOutputsXml)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document outputsXml = docBuilder.parse(source) - - NodeList entries = outputsXml.getElementsByTagNameNS("*", "entry") - List contrailNetworkPolicyFqdnList = [] - for (int i = 0; i< entries.getLength(); i++) { - Node node = entries.item(i) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node - String key = element.getElementsByTagNameNS("*", "key").item(0).getTextContent() - if (key.equals("contrail-service-instance-fqdn")) { - String contrailServiceInstanceFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained contrailServiceInstanceFqdn: " + contrailServiceInstanceFqdn, isDebugLogEnabled) - execution.setVariable("DCVFM_contrailServiceInstanceFqdn", contrailServiceInstanceFqdn) - } - else if (key.endsWith("contrail_network_policy_fqdn")) { - String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn, isDebugLogEnabled) - contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) - } - else if (key.equals("oam_management_v4_address")) { - String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained oamManagementV4Address: " + oamManagementV4Address, isDebugLogEnabled) - execution.setVariable("DCVFM_oamManagementV4Address", oamManagementV4Address) - } - else if (key.equals("oam_management_v6_address")) { - String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained oamManagementV6Address: " + oamManagementV6Address, isDebugLogEnabled) - execution.setVariable("DCVFM_oamManagementV6Address", oamManagementV6Address) - } - - } - } - if (!contrailNetworkPolicyFqdnList.isEmpty()) { - execution.setVariable("DCVFM_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) - } - } - }else{ - logDebug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") - } - }else{ - logDebug("Response from VNF Adapter is Null for CREATE_VF_MODULE Call.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") - } - - rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "true") - execution.setVariable("rollbackData", rollbackData) - - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logDebug("Internal Error Occured in PostProcess Method", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") - } - logDebug(" *** COMPLETED postProcessVnfAdapterResponse Process*** ", isDebugLogEnabled) - } - - - public void preProcessUpdateAAIVfModuleRequestOrch(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestOrch(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessUpdateAAIVfModuleRequestOrch ======== ", isDebugLogEnabled) - - try{ - - //Build UpdateAAIVfModule Request - boolean setContrailServiceInstanceFqdn = false - def contrailServiceInstanceFqdn = execution.getVariable("DCVFM_contrailServiceInstanceFqdn") - if (!contrailServiceInstanceFqdn.equals("")) { - setContrailServiceInstanceFqdn = true - } - - execution.setVariable("DCVFM_orchestrationStatus", "Created") - - String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, true, setContrailServiceInstanceFqdn) - - updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) - execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest) - logDebug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest, isDebugLogEnabled) - utils.logAudit("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestOrch Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessUpdateAAIVfModuleRequestOrch ======== ", isDebugLogEnabled) - - } - - public void preProcessUpdateAAIVfModuleRequestStatus(DelegateExecution execution, String status) { - def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleStatus(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessUpdateAAIVfModuleStatus ======== ", isDebugLogEnabled) - - try{ - - //Build UpdateAAIVfModule Request - execution.setVariable("DCVFM_orchestrationStatus", status) - - String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, false, false) - - updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) - execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest) - logDebug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest, isDebugLogEnabled) - utils.logAudit("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessUpdateAAIVfModuleStatus. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleStatus Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessUpdateAAIVfModuleStatus ======== ", isDebugLogEnabled) - - } - - - public void preProcessUpdateAAIVfModuleRequestGroup(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestGroup(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessUpdateAAIVfModuleRequestGroup ======== ", isDebugLogEnabled) - - try{ - - //Build UpdateAAIVfModule Request - - String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, true, false, false, false) - - updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) - execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest) - logDebug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest, isDebugLogEnabled) - utils.logAudit("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestGroup Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessUpdateAAIVfModuleRequestGroup ======== ", isDebugLogEnabled) - - } - - public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - RollbackData rollbackData = execution.getVariable("rollbackData") - - if(method.equals("assign")){ - rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "true") - execution.setVariable("CRTGVNF_sdncAssignCompleted", true) - } - else if (method.equals("activate")) { - rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "true") - } - execution.setVariable("rollbackData", rollbackData) - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - public void preProcessUpdateAfterCreateRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - utils.log("DEBUG", " ======== STARTED preProcessRequest Process ======== ", isDebugLogEnabled) - try{ - String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse") - utils.logAudit("DCVFM_assignSDNCAdapterResponse: " + response) - - String data = utils.getNodeXml(response, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") - String vnfId = utils.getNodeText1(data, "vnf-id") - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() - } - - String serviceOperation = "/VNF-API:vnfs/vnf-list/" + vnfId - def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") - utils.logAudit("callbackUrl: " + callbackUrl) - - String SDNCGetRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcAction>query</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - execution.setVariable("DCVFM_getSDNCRequest", SDNCGetRequest) - utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled) - utils.logAudit("Outgoing GetSDNCRequest: " + SDNCGetRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) - } - - public String buildUpdateAAIVfModuleRequest(DelegateExecution execution, boolean updateVolumeGroupId, - boolean updateOrchestrationStatus, boolean updateHeatStackId, boolean updateContrailFqdn){ - - def vnfId = execution.getVariable("DCVFM_vnfId") - def vfModuleId = execution.getVariable("DCVFM_vfModuleId") - def volumeGroupIdString = "" - if (updateVolumeGroupId) { - volumeGroupIdString = "<volume-group-id>" + execution.getVariable("DCVFM_volumeGroupId") + - "</volume-group-id>" - } - def orchestrationStatusString = "" - if (updateOrchestrationStatus) { - orchestrationStatusString = "<orchestration-status>" + execution.getVariable("DCVFM_orchestrationStatus") + "</orchestration-status>" - } - def heatStackIdString = "" - if (updateHeatStackId) { - heatStackIdString = "<heat-stack-id>" + execution.getVariable("DCVFM_heatStackId") + "</heat-stack-id>" - } - def contrailFqdnString = "" - if (updateContrailFqdn) { - contrailFqdnString = "<contrail-service-instance-fqdn>" + execution.getVariable("DCVFM_contrailServiceInstanceFqdn") + - "</contrail-service-instance-fqdn>" - } - - String updateAAIVfModuleRequest = - """<UpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - ${heatStackIdString} - ${orchestrationStatusString} - ${volumeGroupIdString} - ${contrailFqdnString} - </UpdateAAIVfModuleRequest>""" - - utils.logAudit("updateAAIVfModule Request: " + updateAAIVfModuleRequest) - return updateAAIVfModuleRequest - - } - - public String buildSDNCParamsXml(DelegateExecution execution){ - - String params = "" - StringBuilder sb = new StringBuilder() - Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap") - - for (Map.Entry<String, String> entry : paramsMap.entrySet()) { - String paramsXml - String key = entry.getKey(); - if(key.endsWith("_network")){ - String requestKey = key.substring(0, key.indexOf("_network")) - String requestValue = entry.getValue() - paramsXml = -"""<vnf-networks> - <network-role>{ functx:substring-before-match(data($param/@name), '_network') }</network-role> - <network-name>{ $param/text() }</network-name> -</vnf-networks>""" - }else{ - paramsXml = "" - } - params = sb.append(paramsXml) - } - return params - } - - public void queryCloudRegion (DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - utils.log("DEBUG", " ======== STARTED queryCloudRegion ======== ", isDebugLogEnabled) - - try { - String cloudRegion = execution.getVariable("DCVFM_cloudSiteId") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - utils.logAudit("CloudRegion Request: " + queryCloudRegionRequest) - - execution.setVariable("DCVFM_queryCloudRegionRequest", queryCloudRegionRequest) - utils.log("DEBUG", "DCVFM_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugLogEnabled) - - cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - - if ((cloudRegion != "ERROR")) { - if(execution.getVariable("DCVFM_queryCloudRegionReturnCode") == "404"){ - execution.setVariable("DCVFM_cloudRegionForVolume", "AAIAIC25") - }else{ - execution.setVariable("DCVFM_cloudRegionForVolume", cloudRegion) - } - execution.setVariable("DCVFM_isCloudRegionGood", true) - } else { - String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable("DCVFM_queryCloudRegionReturnCode") - utils.log("DEBUG", errorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - execution.setVariable("DCVFM_isCloudRegionGood", false) - } - utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable("DCVFM_isCloudRegionGood"), isDebugLogEnabled) - - } catch(BpmnError b){ - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugLogEnabled) - throw b - }catch (Exception ex) { - // try error - String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + ex.getMessage() - utils.log("ERROR", " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during queryCloudRegion method") - } - } - - /** - * - *This method occurs when an MSOWorkflowException is caught. It logs the - *variables and ensures that the "WorkflowException" Variable is set. - * - */ - public void processBPMNException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a BPMN Exception", isDebugEnabled) - utils.log("DEBUG", "Started processBPMNException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - if(execution.getVariable("WorkflowException") == null){ - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during DoCreateVfModule Sub Process") - } - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processBPMNException Method: " + e, isDebugEnabled) - } - utils.log("DEBUG", "Completed processBPMNException Method", isDebugEnabled) - } - - public void prepareCreateAAIVfModuleVolumeGroupRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepareCreateAAIVfModuleVolumeGroupRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED prepareCreateAAIVfModuleVolumeGroupRequest ======== ", isDebugLogEnabled) - - try{ - - //Build CreateAAIVfModuleVolumeGroup Request - - def vnfId = execution.getVariable("DCVFM_vnfId") - def vfModuleId = execution.getVariable("DCVFM_vfModuleId") - def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId") - //def aicCloudRegion = execution.getVariable("DCVFM_cloudSiteId") - def aicCloudRegion = execution.getVariable("DCVFM_cloudRegionForVolume") - String createAAIVfModuleVolumeGroupRequest = - """<CreateAAIVfModuleVolumeGroupRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <volume-group-id>${volumeGroupId}</volume-group-id> - <aic-cloud-region>${aicCloudRegion}</aic-cloud-region> - </CreateAAIVfModuleVolumeGroupRequest>""" - - createAAIVfModuleVolumeGroupRequest = utils.formatXml(createAAIVfModuleVolumeGroupRequest) - execution.setVariable("DCVFM_createAAIVfModuleVolumeGroupRequest", createAAIVfModuleVolumeGroupRequest) - logDebug("Outgoing CreateAAIVfModuleVolumeGroupRequest is: \n" + createAAIVfModuleVolumeGroupRequest, isDebugLogEnabled) - utils.logAudit("Outgoing CreateAAIVfModuleVolumeGroupRequest is: \n" + createAAIVfModuleVolumeGroupRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing prepareCreateAAIVfModuleVolumeGroupRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareCreateAAIVfModuleVolumeGroupRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED prepareCreateAAIVfModuleVolumeGroupRequest ======== ", isDebugLogEnabled) - - } - - public void createNetworkPoliciesInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.createNetworkPoliciesInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED createNetworkPoliciesInAAI ======== ", isDebugLogEnabled) - - try { - // get variables - List fqdnList = execution.getVariable("DCVFM_contrailNetworkPolicyFqdnList") - int fqdnCount = fqdnList.size() - def rollbackData = execution.getVariable("rollbackData") - - execution.setVariable("DCVFM_networkPolicyFqdnCount", fqdnCount) - logDebug("DCVFM_networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - if (fqdnCount > 0) { - - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - - int counting = i+1 - String fqdn = fqdnList[i] - - // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") - utils.logAudit("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - - def aaiRequestId = UUID.randomUUID().toString() - RESTConfig config = new RESTConfig(queryNetworkPolicyByFqdnAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() - int returnCode = response.getStatusCode() - execution.setVariable("DCVFM_aaiQqueryNetworkPolicyByFqdnReturnCode", returnCode) - logDebug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugLogEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (isOneOf(returnCode, 200, 201)) { - logDebug("The return code is: " + returnCode, isDebugLogEnabled) - // This network policy FQDN already exists in AAI - utils.logAudit(aaiResponseAsString) - execution.setVariable("DCVFM_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) - logDebug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugLogEnabled) - - } else { - if (returnCode == 404) { - // This network policy FQDN is not in AAI yet. Add it now - logDebug("The return code is: " + returnCode, isDebugLogEnabled) - logDebug("This network policy FQDN is not in AAI yet: " + fqdn, isDebugLogEnabled) - utils.logAudit("Network policy FQDN is not in AAI yet") - // Add the network policy with this FQDN to AAI - def networkPolicyId = UUID.randomUUID().toString() - logDebug("Adding network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled) - - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - logDebug('AAI namespace is: ' + aaiNamespace, isDebugLogEnabled) - String payload = """<network-policy xmlns="${aaiNamespace}"> - <network-policy-id>${networkPolicyId}</network-policy-id> - <network-policy-fqdn>${fqdn}</network-policy-fqdn> - <heat-stack-id>${execution.getVariable("DCVFM_heatStackId")}</heat-stack-id> - </network-policy>""" as String - - execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload) - - String addNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") - utils.logAudit("AAI request endpoint: " + addNetworkPolicyAAIRequest) - logDebug("AAI request endpoint: " + addNetworkPolicyAAIRequest, isDebugLogEnabled) - - def aaiRequestIdPut = UUID.randomUUID().toString() - RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest); - RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - logDebug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload, isDebugLogEnabled) - utils.logAudit("Sending PUT call to AAI with Endpoint /n" + addNetworkPolicyAAIRequest + " with payload /n" + payload) - APIResponse responsePut = clientPut.httpPut(payload) - int returnCodePut = responsePut.getStatusCode() - execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut) - logDebug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut, isDebugLogEnabled) - - String aaiResponseAsStringPut = responsePut.getResponseBodyAsString() - if (isOneOf(returnCodePut, 200, 201)) { - logDebug("The return code from adding network policy is: " + returnCodePut, isDebugLogEnabled) - // This network policy was created in AAI successfully - utils.logAudit(aaiResponseAsStringPut) - execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut) - logDebug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut, isDebugLogEnabled) - rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true") - rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn) - execution.setVariable("rollbackData", rollbackData) - - } else { - // aai all errors - String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut - logDebug(putErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage) - } - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from createNetworkPoliciesInAAI - " + returnCode - logDebug(dataErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - - } else { - logDebug("No contrail network policies to query/create", isDebugLogEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateVfModule flow. createNetworkPoliciesInAAI() - " + ex.getMessage() - logDebug(exceptionMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def rollbackData = execution.getVariable("rollbackData") - def vnfId = execution.getVariable('DCVFM_vnfId') - def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address") - def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address") - def ipv4OamAddressElement = '' - def managementV6AddressElement = '' - - if (oamManagementV4Address != null && !oamManagementV4Address.isEmpty()) { - ipv4OamAddressElement = '<ipv4-oam-address>' + oamManagementV4Address + '</ipv4-oam-address>' - } - - if (oamManagementV6Address != null && !oamManagementV6Address.isEmpty()) { - managementV6AddressElement = '<management-v6-address>' + oamManagementV6Address + '</management-v6-address>' - } - - rollbackData.put("VFMODULE", "oamManagementV4Address", oamManagementV4Address) - - - String updateAAIGenericVnfRequest = """ - <UpdateAAIGenericVnfRequest> - <vnf-id>${vnfId}</vnf-id> - ${ipv4OamAddressElement} - ${managementV6AddressElement} - </UpdateAAIGenericVnfRequest> - """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable('DCVM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - /** - * Post process a result from invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void postProcessUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.postProcessUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def rollbackData = execution.getVariable("rollbackData") - - rollbackData.put("VFMODULE", "rollbackUpdateVnfAAI", "true") - - def vnfId = execution.getVariable('DCVFM_vnfId') - def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address") - def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address") - def ipv4OamAddressElement = '' - def managementV6AddressElement = '' - - if (oamManagementV4Address != null && !oamManagementV4Address.isEmpty()) { - rollbackData.put("VFMODULE", "oamManagementV4Address", oamManagementV4Address) - } - - if (oamManagementV6Address != null && !oamManagementV6Address.isEmpty()) { - rollbackData.put("VFMODULE", "oamManagementV6Address", oamManagementV6Address) - } - - execution.setVariable("rollbackData", rollbackData) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - public void queryCatalogDB (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String msg = "" - utils.log("DEBUG"," ***** queryCatalogDB *****", isDebugEnabled) - - try { - boolean twoPhaseDesign = false - // check for input - - String vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName") - utils.log("DEBUG", "vfModuleModelName: " + vfModuleModelName, isDebugEnabled) - def vnfModelInfo = execution.getVariable("vnfModelInfo") - def vnfModelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") - - utils.log("DEBUG", "vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugEnabled) - - JSONArray vnfs = catalog.getAllVnfsByVnfModelCustomizationUuid(execution, vnfModelCustomizationUuid, "v2") - - utils.log("DEBUG", "Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid, isDebugEnabled) - utils.logAudit("Incoming Query Catalog DB for Vf Module Response is: " + vnfModelCustomizationUuid) - - utils.log("DEBUG", "obtained VNF list") - // Only one match here - if (vnfs != null) { - JSONObject vnfObject = vnfs.get(0) - if (vnfObject != null) { - String vnfJson = vnfObject.toString() - // - ObjectMapper om = new ObjectMapper(); - VnfResource vnf = om.readValue(vnfJson, VnfResource.class); - - // Get multiStageDesign flag - - String multiStageDesignValue = vnf.getMultiStageDesign() - utils.log("DEBUG", "multiStageDesign value from Catalog DB is: " + multiStageDesignValue, isDebugEnabled) - if (multiStageDesignValue != null) { - if (multiStageDesignValue.equalsIgnoreCase("true")) { - twoPhaseDesign = true - } - } - } - } - - utils.log("DEBUG", "setting twoPhaseDesign flag to: " + twoPhaseDesign, isDebugEnabled) - - execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in queryCatalogDB()', e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryCatalogDB(): ' + e.getMessage()) - } - } - - - public void preProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - execution.setVariable("rollbackData", null) - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy deleted file mode 100644 index f862a00ac2..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy +++ /dev/null @@ -1,676 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils - - - -public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ - - def Prefix="DCVFMR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - } - - // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids - // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - initProcessVariables(execution) - - try { - - execution.setVariable("rolledBack", null) - execution.setVariable("rollbackError", null) - - def rollbackData = execution.getVariable("rollbackData") - utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) - - if (rollbackData != null) { - String vnfId = rollbackData.get("VFMODULE", "vnfid") - execution.setVariable("DCVFMR_vnfId", vnfId) - String vfModuleId = rollbackData.get("VFMODULE", "vfmoduleid") - execution.setVariable("DCVFMR_vfModuleId", vfModuleId) - String source = rollbackData.get("VFMODULE", "source") - execution.setVariable("DCVFMR_source", source) - String serviceInstanceId = rollbackData.get("VFMODULE", "serviceInstanceId") - execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) - String serviceId = rollbackData.get("VFMODULE", "service-id") - execution.setVariable("DCVFMR_serviceId", serviceId) - String vnfType = rollbackData.get("VFMODULE", "vnftype") - execution.setVariable("DCVFMR_vnfType", vnfType) - String vnfName = rollbackData.get("VFMODULE", "vnfname") - execution.setVariable("DCVFMR_vnfName", vnfName) - String tenantId = rollbackData.get("VFMODULE", "tenantid") - execution.setVariable("DCVFMR_tenantId", tenantId) - String vfModuleName = rollbackData.get("VFMODULE", "vfmodulename") - execution.setVariable("DCVFMR_vfModuleName", vfModuleName) - String vfModuleModelName = rollbackData.get("VFMODULE", "vfmodulemodelname") - execution.setVariable("DCVFMR_vfModuleModelName", vfModuleModelName) - String cloudSiteId = rollbackData.get("VFMODULE", "aiccloudregion") - execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) - String heatStackId = rollbackData.get("VFMODULE", "heatstackid") - execution.setVariable("DCVFMR_heatStackId", heatStackId) - String requestId = rollbackData.get("VFMODULE", "msorequestid") - execution.setVariable("DCVFMR_requestId", requestId) - // Set mso-request-id to request-id for VNF Adapter interface - execution.setVariable("mso-request-id", requestId) - List createdNetworkPolicyFqdnList = [] - int i = 0 - while (i < 100) { - String fqdn = rollbackData.get("VFMODULE", "contrailNetworkPolicyFqdn" + i) - if (fqdn == null) { - break - } - createdNetworkPolicyFqdnList.add(fqdn) - logDebug("got fqdn # " + i + ": " + fqdn, isDebugEnabled) - i = i + 1 - - } - - execution.setVariable("DCVFMR_createdNetworkPolicyFqdnList", createdNetworkPolicyFqdnList) - String oamManagementV4Address = rollbackData.get("VFMODULE", "oamManagementV4Address") - execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) - String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") - execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) - //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid") - //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) - execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) - execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) - execution.setVariable("DCVFMR_rollbackVnfAdapterCreate", rollbackData.get("VFMODULE", "rollbackVnfAdapterCreate")) - execution.setVariable("DCVFMR_rollbackSDNCRequestAssign", rollbackData.get("VFMODULE", "rollbackSDNCRequestAssign")) - execution.setVariable("DCVFMR_rollbackSDNCRequestActivate", rollbackData.get("VFMODULE", "rollbackSDNCRequestActivate")) - execution.setVariable("DCVFMR_rollbackCreateAAIVfModule", rollbackData.get("VFMODULE", "rollbackCreateAAIVfModule")) - execution.setVariable("DCVFMR_rollbackCreateNetworkPoliciesAAI", rollbackData.get("VFMODULE", "rollbackCreateNetworkPoliciesAAI")) - execution.setVariable("DCVFMR_rollbackUpdateVnfAAI", rollbackData.get("VFMODULE", "rollbackUpdateVnfAAI")) - - // formulate the request for PrepareUpdateAAIVfModule - String request = """<PrepareUpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <orchestration-status>pending-delete</orchestration-status> - </PrepareUpdateAAIVfModuleRequest>""" as String - utils.log("DEBUG", "PrepareUpdateAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("DoCreateVfModuleRollback PrepareUpdateAAIVfModule Request: " + request) - execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) - } else { - execution.setVariable("skipRollback", true) - } - - if (execution.getVariable("disableRollback").equals("true" )) { - execution.setVariable("skipRollback", true) - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - def msg = "Exception in DoCreateVfModuleRollback preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - } - - // build a SDNC vnf-topology-operation request for the specified action - // (note: the action passed is expected to be 'changedelete' or 'delete') - public void prepSDNCAdapterRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() - } - - def callbackUrl = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - - String source = execution.getVariable("DCVFMR_source") - String serviceId = execution.getVariable("DCVFMR_serviceId") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vnfType = execution.getVariable("DCVFMR_vnfType") - String vnfName = execution.getVariable("DCVFMR_vnfName") - String tenantId = execution.getVariable("DCVFMR_tenantId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - String vfModuleName = execution.getVariable("DCVFMR_vfModuleName") - String vfModuleModelName = execution.getVariable("DCVFMR_vfModuleModelName") - String cloudSiteId = execution.getVariable("DCVFMR_cloudSiteId") - String requestId = execution.getVariable("DCVFMR_requestId") - - String serviceInstanceIdToSdnc = "" - if (srvInstId != null && !srvInstId.isEmpty()) { - serviceInstanceIdToSdnc = srvInstId - } else { - serviceInstanceIdToSdnc = vfModuleId - } - - def doSDNCActivateRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestActivate") - def doSDNCAssignRollback = execution.getVariable("DCVFMR_rollbackSDNCRequestAssign") - - def action = "" - def requestAction = "" - - if (doSDNCActivateRollback.equals("true")) { - action = "delete" - requestAction = "DisconnectVNFRequest" - } - else if (doSDNCAssignRollback.equals("true")) { - action = "rollback" - requestAction = "VNFActivateRequest" - } - else - return - - - String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${vfModuleId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>${requestAction}</request-action> - <source>${source}</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <service-type>${serviceId}</service-type> - <service-instance-id>${serviceInstanceIdToSdnc}</service-instance-id> - <subscriber-name>notsurewecare</subscriber-name> - </service-information> - <vnf-request-information> - <vnf-id>${vfModuleId}</vnf-id> - <vnf-type>${vfModuleModelName}</vnf-type> - <vnf-name>${vfModuleName}</vnf-name> - <generic-vnf-id>${vnfId}</generic-vnf-id> - <generic-vnf-name>${vnfName}</generic-vnf-name> - <generic-vnf-type>${vnfType}</generic-vnf-type> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - <tenant>${tenantId}</tenant> - </vnf-request-information> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG", "sdncAdapterWorkflowRequest: " + request, isDebugEnabled) - utils.logAudit("DoCreateVfModuleRollback sdncAdapterWorkflow Request: " + request) - execution.setVariable("sdncAdapterWorkflowRequest", request) - } - - public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) - - def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") - - try{ - //Build SDNC Request - - String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") - - deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) - execution.setVariable("DCVFMR_deactivateSDNCRequest", deactivateSDNCRequest) - logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCUnassignRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) - try{ - String serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") - - String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") - - execution.setVariable("DCVFMR_unassignSDNCRequest", unassignSDNCRequest) - logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) - - }catch(Exception e){ - log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DCVFMR_requestId") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - def requestId = execution.getVariable("DCVFMR_requestId") - def serviceId = execution.getVariable("DCVFMR_serviceId") - def serviceInstanceId = execution.getVariable("DCVFMR_serviceInstanceId") - def vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - def source = execution.getVariable("DCVFMR_source") - def vnfId = execution.getVariable("DCVFMR_vnfId") - - def sdncVersion = execution.getVariable("sdncVersion") - - String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>DeleteVfModuleInstance</request-action> - <source>${source}</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id/> - <subscription-service-type/> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <global-customer-id/> - </service-information> - <vnf-information> - <vnf-id>${vnfId}</vnf-id> - <vnf-type/> - </vnf-information> - <vf-module-information> - <vf-module-id>${vfModuleId}</vf-module-id> - </vf-module-information> - <vf-module-request-input/> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing VnfAdapterDeleteV1 request - public void prepVNFAdapterRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - String requestId = UUID.randomUUID().toString() - String origRequestId = execution.getVariable("DCVFMR_requestId") - String srvInstId = execution.getVariable("DCVFMR_serviceInstanceId") - String aicCloudRegion = execution.getVariable("DCVFMR_cloudSiteId") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - String vfModuleStackId = execution.getVariable("DCVFMR_heatStackId") - String tenantId = execution.getVariable("DCVFMR_tenantId") - def messageId = execution.getVariable('mso-request-id') + '-' + - System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String request = """ - <deleteVfModuleRequest> - <cloudSiteId>${aicCloudRegion}</cloudSiteId> - <tenantId>${tenantId}</tenantId> - <vnfId>${vnfId}</vnfId> - <vfModuleId>${vfModuleId}</vfModuleId> - <vfModuleStackId>${vfModuleStackId}</vfModuleStackId> - <skipAAI>true</skipAAI> - <msoRequest> - <requestId>${origRequestId}</requestId> - <serviceInstanceId>${srvInstId}</serviceInstanceId> - </msoRequest> - <messageId>${messageId}</messageId> - <notificationUrl>${notificationUrl}</notificationUrl> - </deleteVfModuleRequest> - """ as String - - utils.log("DEBUG", "vnfAdapterRestV1Request: " + request, isDebugEnabled) - utils.logAudit("PrepareUpdateAAIVfModule vnfAdapterRestV1 Request: " + request) - execution.setVariable("vnfAdapterRestV1Request", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing UpdateAAIVfModuleRequest request - public void prepUpdateAAIVfModule(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<UpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <heat-stack-id>DELETE</heat-stack-id> - <orchestration-status>deleted</orchestration-status> - </UpdateAAIVfModuleRequest>""" as String - utils.log("DEBUG", "UpdateAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("UpdateAAIVfModule Request: " + request) - execution.setVariable("UpdateAAIVfModuleRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing UpdateAAIVfModuleRequest request - public void prepUpdateAAIVfModuleToAssigned(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<UpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <heat-stack-id></heat-stack-id> - <orchestration-status>Assigned</orchestration-status> - </UpdateAAIVfModuleRequest>""" as String - utils.log("DEBUG", "UpdateAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("UpdateAAIVfModule Request: " + request) - execution.setVariable("UpdateAAIVfModuleRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing DeleteAAIVfModuleRequest request - public void prepDeleteAAIVfModule(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - String vnfId = execution.getVariable("DCVFMR_vnfId") - String vfModuleId = execution.getVariable("DCVFMR_vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<DeleteAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - </DeleteAAIVfModuleRequest>""" as String - utils.log("DEBUG", "DeleteAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("DeleteAAIVfModule Request: " + request) - execution.setVariable("DeleteAAIVfModuleRequest", request) - } - - // generates a WorkflowException if - // - - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: " - + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), isDebugEnabled) - String processKey = getProcessKey(execution); - exceptionUtil.buildWorkflowException(execution, 5000, "Failure in DoDeleteVfModule") - - } - - public void sdncValidateResponse(DelegateExecution execution, String response){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled) - }else{ - throw new BpmnError("MSOWorkflowException") - } - } - - public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED deleteNetworkPoliciesFromAAI ======== ", isDebugLogEnabled) - - try { - // get variables - List fqdnList = execution.getVariable(Prefix + "createdNetworkPolicyFqdnList") - if (fqdnList == null) { - logDebug("No network policies to delete", isDebugLogEnabled) - return - } - int fqdnCount = fqdnList.size() - - execution.setVariable(Prefix + "networkPolicyFqdnCount", fqdnCount) - logDebug("networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - if (fqdnCount > 0) { - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - - int counting = i+1 - String fqdn = fqdnList[i] - - // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") - utils.logAudit("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - logDebug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest, isDebugLogEnabled) - - def aaiRequestId = UUID.randomUUID().toString() - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) - int returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) - logDebug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugLogEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (isOneOf(returnCode, 200, 201)) { - logDebug("The return code is: " + returnCode, isDebugLogEnabled) - // This network policy FQDN exists in AAI - need to delete it now - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) - logDebug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugLogEnabled) - // Retrieve the network policy id for this FQDN - def networkPolicyId = utils.getNodeText1(aaiResponseAsString, "network-policy-id") - logDebug("Deleting network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled) - - // Retrieve the resource version for this network policy - def resourceVersion = utils.getNodeText1(aaiResponseAsString, "resource-version") - logDebug("Deleting network-policy with resource-version " + resourceVersion, isDebugLogEnabled) - - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") - - utils.logAudit("AAI request endpoint: " + delNetworkPolicyAAIRequest) - logDebug("AAI request endpoint: " + delNetworkPolicyAAIRequest, isDebugLogEnabled) - - def aaiRequestIdDel = UUID.randomUUID().toString() - logDebug("invoking DELETE call to AAI", isDebugLogEnabled) - utils.logAudit("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest) - - APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest) - - int returnCodeDel = responseDel.getStatusCode() - execution.setVariable(Prefix + "aaiDeleteNetworkPolicyReturnCode", returnCodeDel) - logDebug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel, isDebugLogEnabled) - - if (isOneOf(returnCodeDel, 200, 201, 204)) { - logDebug("The return code from deleting network policy is: " + returnCodeDel, isDebugLogEnabled) - // This network policy was deleted from AAI successfully - logDebug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ", isDebugLogEnabled) - - } else { - // aai all errors - String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel - logDebug(delErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) - } - } else if (returnCode == 404) { - // This network policy FQDN is not in AAI. No need to delete. - logDebug("The return code is: " + returnCode, isDebugLogEnabled) - logDebug("This network policy FQDN is not in AAI: " + fqdn, isDebugLogEnabled) - utils.logAudit("Network policy FQDN is not in AAI") - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode - logDebug(dataErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - - - - } // end loop - - - } else { - logDebug("No contrail network policies to query/create", isDebugLogEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoCreateVfModuleRollback flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() - logDebug(exceptionMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void preProcessUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessUpdateAAIGenericVnf((' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DCVFMR_vnfId') - def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') - def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') - def ipv4OamAddressElement = '' - def managementV6AddressElement = '' - - if (oamManagementV4Address != null) { - ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>' - } - - if (oamManagementV6Address != null) { - managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>' - } - - - String updateAAIGenericVnfRequest = """ - <UpdateAAIGenericVnfRequest> - <vnf-id>${vnfId}</vnf-id> - ${ipv4OamAddressElement} - ${managementV6AddressElement} - </UpdateAAIGenericVnfRequest> - """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessUpdateAAIGenericVnf((): ' + e.getMessage()) - } - } - - public void setSuccessfulRollbackStatus (DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled) - - try{ - // Set rolledBack to true, rollbackError to null - execution.setVariable("rolledBack", true) - execution.setVariable("rollbackError", null) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing setSuccessfulRollbackStatus. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled) - } - - public void setFailedRollbackStatus (DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED setFailedRollbackStatus ======== ", isDebugLogEnabled) - - try{ - // Set rolledBack to false, rollbackError to actual value, rollbackData to null - execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", 'Caught exception in DoCreateVfModuleRollback') - execution.setVariable("rollbackData", null) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing setFailedRollbackStatus. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED setFailedRollbackStatus ======== ", isDebugLogEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy deleted file mode 100644 index e903a547f7..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeRollback.groovy +++ /dev/null @@ -1,238 +0,0 @@ -/*
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-import org.springframework.web.util.UriUtils
-
-
-public class DoCreateVfModuleVolumeRollback extends AbstractServiceTaskProcessor {
- String Prefix="DCVFMODVOLRBK_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils(this)
-
- def className = getClass().getSimpleName()
-
- /**
- * This method is executed during the preProcessRequest task of the <class>DoCreateVfModuleVolumeRollback.bpmn</class> process.
- * @param execution
- */
- public InitializeProcessVariables(DelegateExecution execution){
- /* Initialize all the process variables in this block */
-
- execution.setVariable(Prefix + "volumeGroupName", null)
- execution.setVariable(Prefix + "lcpCloudRegionId", null)
- execution.setVariable(Prefix + "rollbackVnfARequest", null)
-
- }
-
- // **************************************************
- // Pre or Prepare Request Section
- // **************************************************
- /**
- * This method is executed during the preProcessRequest task of the <class>DoCreateVfModuleVolumeRollback.bpmn</class> process.
- * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- InitializeProcessVariables(execution)
-// rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudSiteId)
- RollbackData rollbackData = execution.getVariable("rollbackData")
-
-// String vnfId = rollbackData.get("DCVFMODULEVOL", "vnfid")
-// execution.setVariable("DCVFMODVOLRBK_vnfId", vnfId)
-// String vfModuleId = rollbackData.get("DCVFMODULEVOL", "vfmoduleid")
-// execution.setVariable("DCVFMODVOLRBK_vfModuleId", vfModuleId)
-// String source = rollbackData.get("DCVFMODULEVOL", "source")
-// execution.setVariable("DCVFMODVOLRBK_source", source)
-// String serviceInstanceId = rollbackData.get("DCVFMODULEVOL", "serviceInstanceId")
-// execution.setVariable("DCVFMODVOLRBK_serviceInstanceId", serviceInstanceId)
-// String serviceId = rollbackData.get("DCVFMODULEVOL", "service-id")
-// execution.setVariable("DCVFMODVOLRBK_serviceId", serviceId)
-// String vnfType = rollbackData.get("DCVFMODULEVOL", "vnftype")
-// execution.setVariable("DCVFMODVOLRBK_vnfType", vnfType)
-// String vnfName = rollbackData.get("DCVFMODULEVOL", "vnfname")
-// execution.setVariable("DCVFMODVOLRBK_vnfName", vnfName)
-// String tenantId = rollbackData.get("DCVFMODULEVOL", "tenantid")
-// execution.setVariable("DCVFMODVOLRBK_tenantId", tenantId)
-// String vfModuleName = rollbackData.get("DCVFMODULEVOL", "vfmodulename")
-// execution.setVariable("DCVFMODVOLRBK_vfModuleName", vfModuleName)
-// String vfModuleModelName = rollbackData.get("DCVFMODULEVOL", "vfmodulemodelname")
-// execution.setVariable("DCVFMODVOLRBK_vfModuleModelName", vfModuleModelName)
-// String cloudSiteId = rollbackData.get("DCVFMODULEVOL", "aiccloudregion")
-// execution.setVariable("DCVFMODVOLRBK_cloudSiteId", cloudSiteId)
-// String heatStackId = rollbackData.get("DCVFMODULEVOL", "heatstackid")
-// execution.setVariable("DCVFMODVOLRBK_heatStackId", heatStackId)
-// String requestId = rollbackData.get("DCVFMODULEVOL", "msorequestid")
-// execution.setVariable("DCVFMODVOLRBK_requestId", requestId)
-
- String volumeGroupName = rollbackData.get("DCVFMODULEVOL", "volumeGroupName")
- execution.setVariable("DCVFMODVOLRBK_volumeGroupName", volumeGroupName)
-
- String lcpCloudRegionId = rollbackData.get("DCVFMODULEVOL", "aiccloudregion")
- execution.setVariable("DCVFMODVOLRBK_lcpCloudRegionId", lcpCloudRegionId)
-
- execution.setVariable("DCVFMODVOLRBK_rollbackVnfARequest", rollbackData.get("DCVFMODULEVOL", "rollbackVnfARequest"))
- execution.setVariable("DCVFMODVOLRBK_backoutOnFailure", rollbackData.get("DCVFMODULEVOL", "backoutOnFailure"))
- execution.setVariable("DCVFMODVOLRBK_isCreateVnfRollbackNeeded", rollbackData.get("DCVFMODULEVOL", "isCreateVnfRollbackNeeded"))
- execution.setVariable("DCVFMODVOLRBK_isAAIRollbackNeeded", rollbackData.get("DCVFMODULEVOL", "isAAIRollbackNeeded"))
-
- }
-
- /**
- * Query AAI volume group by name
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- def volumeGroupName = execution.getVariable('DCVFMODVOLRBK_volumeGroupName')
- def cloudRegion = execution.getVariable('DCVFMODVOLRBK_lcpCloudRegionId')
-
- // This is for stub testing
- def testVolumeGroupName = execution.getVariable('test-volume-group-name')
- if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) {
- volumeGroupName = testVolumeGroupName
- }
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8')
-
- utils.logAudit('Query AAI volume group by name: ' + queryAAIVolumeNameRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- //aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query volume group by name return code: " + returnCode)
- utils.logAudit("AAI query volume group by name response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString)
- execution.setVariable(prefix+'AaiReturnCode', returnCode)
-
- if (returnCode=='200') {
- // @TODO: verify error code
- // @TODO: create class of literals representing error codes
- execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString)
- utils.log("DEBUG", "Volume Group Name $volumeGroupName exists in AAI.", isDebugEnabled)
- } else {
- if (returnCode=='404') {
- utils.log("DEBUG", "Volume Group Name $volumeGroupName does not exist in AAI.", isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
-
- public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) {
-
- callRESTQueryAAIVolGrpName(execution, isDebugEnabled)
-
- def queryAaiVolumeGroupResponse = execution.getVariable(prefix+'queryAAIVolGrpNameResponse')
-
- def volumeGroupId = utils.getNodeText(queryAaiVolumeGroupResponse, "volume-group-id")
- def resourceVersion = utils.getNodeText(queryAaiVolumeGroupResponse, "resource-version")
-
- def cloudRegion = execution.getVariable("DCVFMODVOLRBK_lcpCloudRegionId")
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group" + '/' + volumeGroupId + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8")
-
- utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest)
-
- APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- //aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI delete volume group return code: " + returnCode)
- utils.logAudit("AAI delete volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- def volumeGroupNameFound = prefix+'volumeGroupNameFound'
- if (returnCode=='200' || returnCode=='204' ) {
- utils.log("DEBUG", "Volume group $volumeGroupId deleted.", isDebugEnabled)
- } else {
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
- // *******************************
- // Build Error Section
- // *******************************
-
-
-
- public void processJavaException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- try{
- utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled)
- utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
- utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
- execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
-
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
- execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix)
- }
- utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy deleted file mode 100644 index 13a7ffa498..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV2.groovy +++ /dev/null @@ -1,609 +0,0 @@ -package org.openecomp.mso.bpmn.infrastructure.scripts
-
-import static org.camunda.spin.Spin.XML;
-import groovy.json.JsonSlurper
-import groovy.lang.GroovyInterceptable;
-import groovy.xml.XmlUtil
-
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
-import org.openecomp.mso.bpmn.common.scripts.VfModuleBase;
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils;
-import org.openecomp.mso.rest.APIResponse
-import org.springframework.web.util.UriUtils
-
-
-
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-
-class DoCreateVfModuleVolumeV2 extends VfModuleBase {
-
- String prefix='DCVFMODVOLV2_'
- JsonUtils jsonUtil = new JsonUtils()
-
-
- /**
- * Perform initial processing, such as request validation, initialization of variables, etc.
- * * @param execution
- */
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- preProcessRequest(execution, isDebugEnabled)
- }
-
- public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
-
- execution.setVariable("prefix",prefix)
- execution.setVariable(prefix+'SuccessIndicator', false)
- execution.setVariable(prefix+'isPONR', false)
-
- displayInput(execution, isDebugLogEnabled)
- setRollbackData(execution, isDebugLogEnabled)
- setRollbackEnabled(execution, isDebugLogEnabled)
-
-
- def tenantId = execution.getVariable("tenantId")
- if (tenantId == null) {
- String cloudConfiguration = execution.getVariable("cloudConfiguration")
- tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")
- execution.setVariable("tenantId", tenantId)
- }
-
- def cloudSiteId = execution.getVariable("lcpCloudRegionId")
- if (cloudSiteId == null) {
- String cloudConfiguration = execution.getVariable("cloudConfiguration")
- cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")
- execution.setVariable("lcpCloudRegionId", cloudSiteId)
- }
-
- // Extract attributes from modelInfo
- String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
-
- //modelCustomizationUuid
- def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
- execution.setVariable("modelCustomizationId", modelCustomizationUuid)
- logDebug("modelCustomizationId: " + modelCustomizationUuid, isDebugLogEnabled)
-
- //modelName
- def modelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
- execution.setVariable("modelName", modelName)
- logDebug("modelName: " + modelName, isDebugLogEnabled)
-
- // The following is used on the get Generic Service Instance call
- execution.setVariable('GENGS_type', 'service-instance')
- }
-
-
- /**
- * Display input variables
- * @param execution
- * @param isDebugLogEnabled
- */
- public void displayInput(DelegateExecution execution, isDebugLogEnabled) {
- def input = ['mso-request-id', 'msoRequestId', 'isDebugLogEnabled', 'disableRollback', 'failIfExists', 'serviceInstanceId',
- 'vnfId', 'vnfName', 'tenantId', 'volumeGroupId', 'volumeGroupName', 'lcpCloudRegionId', 'vnfType', 'vfModuleModelInfo', 'asdcServiceModelVersion',
- 'test-volume-group-name', 'test-volume-group-id', 'vfModuleInputParams']
-
- logDebug('Begin input: ', isDebugLogEnabled)
- input.each {
- logDebug(it + ': ' + execution.getVariable(it), isDebugLogEnabled)
- }
- logDebug('End input.', isDebugLogEnabled)
- }
-
-
- /**
- * Define and set rollbackdata object
- * @param execution
- * @param isDebugEnabled
- */
- public void setRollbackData(DelegateExecution execution, isDebugEnabled) {
- def rollbackData = execution.getVariable("rollbackData")
- if (rollbackData == null) {
- rollbackData = new RollbackData()
- }
- def volumeGroupName = execution.getVariable('volumeGroupName')
- rollbackData.put("DCVFMODULEVOL", "volumeGroupName", volumeGroupName)
- execution.setVariable("rollbackData", rollbackData)
- }
-
-
- /**
- * validate getServiceInstance response
- * @param execution
- * @param isDebugEnabled
- */
- public void validateGetServiceInstanceCall(DelegateExecution execution, isDebugEnabled) {
- def found = execution.getVariable('GENGS_FoundIndicator')
- def success = execution.getVariable('GENGS_SuccessIndicator')
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- utils.log("DEBUG", "getServiceInstance success: " + success, isDebugEnabled)
- utils.log("DEBUG", "getServiceInstance found: " + found, isDebugEnabled)
- if(!found || !success) {
- String errorMessage = "Service instance id not found in AAI: ${serviceInstanceId}."
- utils.log("DEBUG", errorMessage, isDebugEnabled)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- }
-
- /**
- * Get cloud region
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) {
-
- def cloudRegion = execution.getVariable("lcpCloudRegionId")
- utils.log("DEBUG", 'Request cloud region is: ' + cloudRegion, isDebugEnabled)
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion
-
- utils.logAudit(queryCloudRegionRequest)
-
- cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
-
- def aaiCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
- if ((aaiCloudRegion != "ERROR")) {
- execution.setVariable("lcpCloudRegionId", aaiCloudRegion)
- utils.log("DEBUG", "AIC Cloud Region for AAI: " + aaiCloudRegion, isDebugEnabled)
- } else {
- String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
- utils.log("DEBUG", errorMessage, isDebugEnabled)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- def poCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
- if ((poCloudRegion != "ERROR")) {
- execution.setVariable("poLcpCloudRegionId", poCloudRegion)
- utils.log("DEBUG", "AIC Cloud Region for PO: " + poCloudRegion, isDebugEnabled)
- } else {
- String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
- utils.log("DEBUG", errorMessage, isDebugEnabled)
- (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- def rollbackData = execution.getVariable("rollbackData")
- rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudRegion)
- }
-
-
- /**
- * Query AAI volume group by name
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- def volumeGroupName = execution.getVariable('volumeGroupName')
- def cloudRegion = execution.getVariable('lcpCloudRegionId')
-
- // This is for stub testing
- def testVolumeGroupName = execution.getVariable('test-volume-group-name')
- if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) {
- volumeGroupName = testVolumeGroupName
- }
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8')
-
- utils.logAudit('Query AAI volume group by name: ' + queryAAIVolumeNameRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query volume group by name return code: " + returnCode)
- utils.logAudit("AAI query volume group by name response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString)
- execution.setVariable(prefix+'AaiReturnCode', returnCode)
-
- if (returnCode=='200') {
- execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString)
- utils.log("DEBUG", "Volume Group Name $volumeGroupName exists in AAI.", isDebugEnabled)
- } else {
- if (returnCode=='404') {
- utils.log("DEBUG", "Volume Group Name $volumeGroupName does not exist in AAI.", isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
- /**
- * Create a WorkflowException
- * @param execution
- * @param isDebugEnabled
- */
- public void buildWorkflowException(DelegateExecution execution, int errorCode, errorMessage, isDebugEnabled) {
- utils.log("DEBUG", errorMessage, isDebugEnabled)
- (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage)
- }
-
-
- /**
- * Create a WorkflowException
- * @param execution
- * @param isDebugEnabled
- */
- public void handleError(DelegateExecution execution, isDebugEnabled) {
- WorkflowException we = execution.getVariable('WorkflowException')
- if (we == null) {
- (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!")
- }
- throw new BpmnError("MSOWorkflowException")
- }
-
-
- /**
- * Create volume group in AAI
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTCreateAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- def vnfId = execution.getVariable('vnfId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- def volumeName = execution.getVariable("volumeGroupName")
- def modelCustomizationId = execution.getVariable("modelCustomizationId")
- def vnfType = execution.getVariable("vnfType")
- def tenantId = execution.getVariable("tenantId")
- def cloudRegion = execution.getVariable('lcpCloudRegionId')
-
- utils.log("DEBUG", "volumeGroupId: " + volumeGroupId, isDebugEnabled)
-
- def testGroupId = execution.getVariable('test-volume-group-id')
- if (testGroupId != null && testGroupId.trim() != '') {
- utils.log("DEBUG", "test volumeGroupId is present: " + testGroupId, isDebugEnabled)
- volumeGroupId = testGroupId
- execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
- }
-
- utils.log("DEBUG", "volumeGroupId to be used: " + volumeGroupId, isDebugEnabled)
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8")
-
- String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution))
- utils.log("DEBUG", "AAI namespace is: " + namespace, isDebugEnabled)
-
- utils.logAudit("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest)
-
- NetworkUtils networkUtils = new NetworkUtils()
- String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId)
- String payloadXml = utils.formatXml(payload)
- utils.logAudit("Request payload for PUT: " + payloadXml)
-
- APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI create volume group return code: " + returnCode)
- utils.logAudit("AAI create volume group response: " + aaiResponseAsString)
-
- execution.setVariable(prefix+"createAAIVolumeGrpNameReturnCode", returnCode)
- execution.setVariable(prefix+"createAAIVolumeGrpNameResponse", aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode =='201') {
- RollbackData rollbackData = execution.getVariable("rollbackData")
- rollbackData.put("DCVFMODULEVOL", "isAAIRollbackNeeded", "true")
- } else {
- execution.setVariable(prefix+"isErrorMessageException", true)
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
- /**
- * Prepare VNF adapter create request XML
- * @param execution
- */
- public void prepareVnfAdapterCreateRequest(DelegateExecution execution, isDebugEnabled) {
-
- def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
- def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id')
- def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name')
- def vnfType = utils.getNodeText1(aaiGenericVnfResponse, "vnf-type")
-
- def requestId = execution.getVariable('msoRequestId')
- def serviceId = execution.getVariable('serviceInstanceId')
- def cloudSiteId = execution.getVariable('poLcpCloudRegionId')
- def tenantId = execution.getVariable('tenantId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- def volumeGroupnName = execution.getVariable('volumeGroupName')
-
- def vnfVersion = execution.getVariable("asdcServiceModelVersion")
- def vnfModuleType = execution.getVariable("modelName")
-
- def modelCustomizationId = execution.getVariable("modelCustomizationId")
-
- // for testing
- utils.log("DEBUG", "volumeGroupId: " + volumeGroupId, isDebugEnabled)
- def testGroupId = execution.getVariable('test-volume-group-id')
- if (testGroupId != null && testGroupId.trim() != '') {
- utils.log("DEBUG", "test volumeGroupId is present: " + testGroupId, isDebugEnabled)
- volumeGroupId = testGroupId
- execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
- }
- utils.log("DEBUG", "volumeGroupId to be used: " + volumeGroupId, isDebugEnabled)
-
- // volume group parameters
-
- String volumeGroupParams = ''
- StringBuilder sbParams = new StringBuilder()
- Map<String, String> paramsMap = execution.getVariable("vfModuleInputParams")
- for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
- String paramsXml
- String paramName = entry.getKey();
- String paramValue = entry.getValue()
- paramsXml =
- """ <entry>
- <key>${paramName}</key>
- <value>${paramValue}</value>
- </entry>
- """
- sbParams.append(paramsXml)
- }
-
- volumeGroupParams = sbParams.toString()
- utils.log("DEBUG", "volumeGroupParams: "+ volumeGroupParams, isDebugEnabled)
-
- def backoutOnFailure = execution.getVariable(prefix+"backoutOnFailure")
- utils.log("DEBUG", "backoutOnFailure: "+ backoutOnFailure, isDebugEnabled)
-
- def failIfExists = execution.getVariable("failIfExists")
- if(failIfExists == null) {
- failIfExists = 'true'
- }
-
- String messageId = UUID.randomUUID()
- utils.log("DEBUG", "messageId to be used is generated: " + messageId, isDebugEnabled)
-
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
- utils.log("DEBUG", "CreateVfModuleVolume - notificationUrl: "+ notificationUrl, isDebugEnabled)
-
- // build request
- String vnfSubCreateWorkflowRequest =
- """
- <createVolumeGroupRequest>
- <cloudSiteId>${cloudSiteId}</cloudSiteId>
- <tenantId>${tenantId}</tenantId>
- <vnfId>${vnfId}</vnfId>
- <vnfName>${vnfName}</vnfName>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- <volumeGroupName>${volumeGroupnName}</volumeGroupName>
- <vnfType>${vnfType}</vnfType>
- <vnfVersion>${vnfVersion}</vnfVersion>
- <vfModuleType>${vnfModuleType}</vfModuleType>
- <modelCustomizationUuid>${modelCustomizationId}</modelCustomizationUuid>
- <volumeGroupParams>
- <entry>
- <key>vnf_id</key>
- <value>${vnfId}</value>
- </entry>
- <entry>
- <key>vnf_name</key>
- <value>${vnfName}</value>
- </entry>
- <entry>
- <key>vf_module_id</key>
- <value>${volumeGroupId}</value>
- </entry>
- <entry>
- <key>vf_module_name</key>
- <value>${volumeGroupnName}</value>
- </entry>
- ${volumeGroupParams}
- </volumeGroupParams>
- <skipAAI>true</skipAAI>
- <backout>${backoutOnFailure}</backout>
- <failIfExists>${failIfExists}</failIfExists>
- <msoRequest>
- <requestId>${requestId}</requestId>
- <serviceInstanceId>${serviceId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </createVolumeGroupRequest>
- """
-
- String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest)
- utils.logAudit(vnfSubCreateWorkflowRequestAsString)
- utils.log('DEBUG', vnfSubCreateWorkflowRequestAsString, isDebugEnabled)
- execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString)
-
- // build rollback request for use later if needed
- String vnfSubRollbackWorkflowRequest = buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl)
-
- utils.log("DEBUG", "Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest, isDebugEnabled)
-
- String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest)
- execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString)
- }
-
- public String buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl) {
-
- def request = """
- <rollbackVolumeGroupRequest>
- <volumeGroupRollback>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- <volumeGroupStackId>{{VOLUMEGROUPSTACKID}}</volumeGroupStackId>
- <tenantId>${tenantId}</tenantId>
- <cloudSiteId>${cloudSiteId}</cloudSiteId>
- <volumeGroupCreated>true</volumeGroupCreated>
- <msoRequest>
- <requestId>${requestId}</requestId>
- <serviceInstanceId>${serviceId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- </volumeGroupRollback>
- <skipAAI>true</skipAAI>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </rollbackVolumeGroupRequest>
- """
-
- return request
- }
-
- public String updateRollbackVolumeGroupRequestXml(String rollabackRequest, String heatStackId) {
- String newRequest = rollabackRequest.replace("{{VOLUMEGROUPSTACKID}}", heatStackId)
- return newRequest
- }
-
- /**
- * Validate VNF adapter response
- * @param execution
- */
- public void validateVnfResponse(DelegateExecution execution, isDebugEnabled) {
- def vnfSuccess = execution.getVariable('VNFREST_SuccessIndicator')
- utils.log("DEBUG", "vnfAdapterSuccessIndicator: "+ vnfSuccess, isDebugEnabled)
- if(vnfSuccess==true) {
- String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
- String heatStackID = utils.getNodeText1(createVnfAResponse, "volumeGroupStackId")
- String vnfRollbackRequest = execution.getVariable(prefix+"rollbackVnfARequest")
- String updatedVnfRollbackRequest = updateRollbackVolumeGroupRequestXml(vnfRollbackRequest, heatStackID)
- utils.log("DEBUG", "vnfAdapter rollback request: "+ updatedVnfRollbackRequest, isDebugEnabled)
- RollbackData rollbackData = execution.getVariable("rollbackData")
- rollbackData.put("DCVFMODULEVOL", "rollbackVnfARequest", updatedVnfRollbackRequest)
- rollbackData.put("DCVFMODULEVOL", "isCreateVnfRollbackNeeded", "true")
- }
- }
-
-
- /**
- * Update voulume group in AAI
- * @TODO: Can we re-use the create method??
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTUpdateCreatedVolGrpName(DelegateExecution execution, isDebugEnabled) {
-
- String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse")
- String volumeGroupId = utils.getNodeText1(requeryAAIVolGrpNameResponse, "volume-group-id")
- String modelCustomizationId = execution.getVariable("modelCustomizationId")
- String cloudRegion = execution.getVariable("lcpCloudRegionId")
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String updateAAIVolumeGroupUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, 'UTF-8')
-
- String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution))
-
- utils.logAudit(updateAAIVolumeGroupUrlRequest)
- utils.log("DEBUG", "updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest, isDebugEnabled)
-
- String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
- def heatStackID = utils.getNodeText1(createVnfAResponse, "volumeGroupStackId")
-
- execution.setVariable(prefix+"heatStackId", heatStackID)
-
- NetworkUtils networkUtils = new NetworkUtils()
- String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackID, namespace, modelCustomizationId)
- String payloadXml = utils.formatXml(payload)
-
- utils.logAudit("Payload to Update Created VolumeGroupName - " + "\n" + payloadXml)
-
- APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI create volume group return code: " + returnCode)
- utils.logAudit("AAI create volume group response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode =='200') {
- execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNameResponse", aaiResponseAsString)
- execution.setVariable(prefix+"isPONR", true)
- } else {
- execution.setVariable(prefix+"isErrorMessageException", true)
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
- /**
- * Query AAI Generic VNF
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) {
-
- def vnfId = execution.getVariable('vnfId')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution)
- def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8")
-
- utils.logAudit("AAI query generic vnf request: " + queryAAIRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query generic vnf return code: " + returnCode)
- utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode=='200') {
- utils.log("DEBUG", 'Generic vnf ' + vnfId + ' found in AAI.', isDebugEnabled)
- execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString)
- } else {
- if (returnCode=='404') {
- def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.'
- utils.log("DEBUG", message, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy deleted file mode 100644 index adc2b695ef..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy +++ /dev/null @@ -1,643 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import static org.apache.commons.lang3.StringUtils.* - -import org.openecomp.mso.bpmn.core.RollbackData -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.springframework.web.util.UriUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.JsonUtils - - -/** - * This class supports the DoCreateVnf building block subflow - * with the creation of a generic vnf for - * infrastructure. - * - */ -class DoCreateVnf extends AbstractServiceTaskProcessor { - - String Prefix="DoCVNF_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - * - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoCreateVnf PreProcessRequest Process*** ", isDebugEnabled) - - // DISABLE SDNC INTERACTION FOR NOW - execution.setVariable("SDNCInteractionEnabled", false) - - - /*******************/ - try{ - // Get Variables - - def rollbackData = execution.getVariable("rollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - String serviceModelInfo = execution.getVariable("serviceModelInfo") - - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("DoCVNF_requestId", requestId) - execution.setVariable("mso-request-id", requestId) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("DoCVNF_serviceInstanceId", serviceInstanceId) - rollbackData.put("VNF", "serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfType = execution.getVariable("vnfType") - execution.setVariable("DoCVNF_vnfType", vnfType) - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) - - String vnfName = execution.getVariable("vnfName") - if (vnfName.equals("") || vnfName.equals("null")) { - vnfName = null - } - execution.setVariable("DoCVNF_vnfName", vnfName) - utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) - - String serviceId = execution.getVariable("productFamilyId") - execution.setVariable("DoCVNF_serviceId", serviceId) - utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) - - String source = "VID" - execution.setVariable("DoCVNF_source", source) - rollbackData.put("VNF", "source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - String suppressRollback = execution.getVariable("disableRollback") - execution.setVariable("DoCVNF_suppressRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress Rollback is: " + suppressRollback, isDebugEnabled) - - String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantUuid") - execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) - utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) - - String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid") - if (modelVersionId == null) { - modelVersionId = "" - } - execution.setVariable("DoCVNF_modelVersionId", modelVersionId) - utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled) - - String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") - execution.setVariable("DoCVNF_modelVersion", modelVersion) - utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled) - - String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") - execution.setVariable("DoCVNF_modelName", modelName) - utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled) - - String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid") - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId) - utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) - - String cloudSiteId = execution.getVariable("lcpCloudRegionId") - execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId) - rollbackData.put("VNF", "cloudSiteId", cloudSiteId) - utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) - - String tenantId = execution.getVariable("tenantId") - execution.setVariable("DoCVNF_tenantId", tenantId) - rollbackData.put("VNF", "tenantId", tenantId) - utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) - - String globalSubscriberId = execution.getVariable("globalSubscriberId") - if (globalSubscriberId == null) { - globalSubscriberId = "" - } - execution.setVariable("DoCVNF_globalSubscriberId", globalSubscriberId) - utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null) { - sdncVersion = "1702" - } - execution.setVariable("DoCVNF_sdncVersion", sdncVersion) - utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable("DoCVNF_requestInfo", requestInfo) - //TODO: Orch Status - TBD, will come from SDN-C Response in 1702 - String orchStatus = "Created" - execution.setVariable("DoCVNF_orchStatus", orchStatus) - - //TODO: Equipment Role - Should come from SDN-C Response in 1702 - String equipmentRole = " " - execution.setVariable("DoCVNF_equipmentRole", equipmentRole) - String vnfId = execution.getVariable("testVnfId") // for junits - if(isBlank(vnfId)){ - vnfId = execution.getVariable("vnfId") - if (isBlank(vnfId)) { - vnfId = UUID.randomUUID().toString() - utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled) - } - } - execution.setVariable("DoCVNF_vnfId", vnfId) - - // Setting for Sub Flow Calls - execution.setVariable("DoCVNF_type", "generic-vnf") - execution.setVariable("GENGS_type", "service-instance") - - String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl) - rollbackData.put("VNF", "sdncCallbackUrl", sdncCallbackUrl) - utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) - logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) - - VnfResource vnfResource = (VnfResource) execution.getVariable((String)"vnfResourceDecomposition") - String nfRole = vnfResource.getNfRole() - - execution.setVariable("DoCVNF_nfRole", nfRole) - logDebug("NF Role is: " + nfRole, isDebugEnabled) - - String nfNamingCode = vnfResource.getNfNamingCode() - execution.setVariable("DoCVNF_nfNamingCode", nfNamingCode) - logDebug("NF Naming Code is: " + nfNamingCode, isDebugEnabled) - - String nfType = vnfResource.getNfType() - execution.setVariable("DoCVNF_nfType", nfType) - logDebug("NF Type is: " + nfType, isDebugEnabled) - - String nfFunction = vnfResource.getNfFunction() - execution.setVariable("DoCVNF_nfFunction", nfFunction) - logDebug("NF Function is: " + nfFunction, isDebugEnabled) - - rollbackData.put("VNF", "rollbackSDNCAssign", "false") - rollbackData.put("VNF", "rollbackSDNCActivate", "false") - rollbackData.put("VNF", "rollbackVnfCreate", "false") - - execution.setVariable("rollbackData", rollbackData) - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DoCreateVnf PreProcessRequest method!" + e.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnf PreProcessRequest Process ***", isDebugEnabled) - } - - private Object getVariableEnforced(DelegateExecution execution, String name){ - Object enforced = execution.getVariable(name) - if(!enforced){ - return ""; - } - return enforced; - } - - public void prepareCreateGenericVnf (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = getVariableEnforced(execution, "DoCVNF_vnfId") - String vnfName = getVariableEnforced(execution, "DoCVNF_vnfName") - if (vnfName == null) { - vnfName = "sdncGenerated" - utils.log("DEBUG", "Sending a dummy VNF name to AAI - the name will be generated by SDNC: " + vnfName, isDebugEnabled) - } - String vnfType = getVariableEnforced(execution, "DoCVNF_vnfType") - utils.log("DEBUG", "WE ARE HERE:" + vnfType, isDebugEnabled) - String serviceId = getVariableEnforced(execution, "DoCVNF_serviceId") - String orchStatus = getVariableEnforced(execution, "DoCVNF_orchStatus") - String modelInvariantId = getVariableEnforced(execution, "DoCVNF_modelInvariantId") - String modelVersionId = getVariableEnforced(execution, "DoCVNF_modelVersionId") - String modelCustomizationId = getVariableEnforced(execution, "DoCVNF_modelCustomizationId") - // TODO: 1702 Variable - String equipmentRole = getVariableEnforced(execution, "DoCVNF_equipmentRole") - String nfType = getVariableEnforced(execution, "DoCVNF_nfType") - String nfRole = getVariableEnforced(execution, "DoCVNF_nfRole") - String nfFunction = getVariableEnforced(execution, "DoCVNF_nfFunction") - String nfNamingCode = getVariableEnforced(execution, "DoCVNF_nfNamingCode") - - //Get Service Instance Info - String serviceInstanceId = getVariableEnforced(execution, "DoCVNF_serviceInstanceId") - String siRelatedLink = getVariableEnforced(execution, "GENGS_siResourceLink") - - int custStart = siRelatedLink.indexOf("customer/") - int custEnd = siRelatedLink.indexOf("/service-subscriptions") - String globalCustId = siRelatedLink.substring(custStart + 9, custEnd) - int serviceStart = siRelatedLink.indexOf("service-subscription/") - int serviceEnd = siRelatedLink.indexOf("/service-instances/") - String serviceType = siRelatedLink.substring(serviceStart + 21, serviceEnd) - serviceType = UriUtils.decode(serviceType,"UTF-8") - - //Get Namespace - AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - String namespace = aaiUtil.getNamespaceFromUri(execution, aai_uri) - - String payload = - """<generic-vnf xmlns="${namespace}"> - <vnf-id>${vnfId}</vnf-id> - <vnf-name>${vnfName}</vnf-name> - <service-id>${serviceId}</service-id> - <vnf-type>${vnfType}</vnf-type> - <prov-status>PREPROV</prov-status> - <orchestration-status>${orchStatus}</orchestration-status> - <model-invariant-id>${modelInvariantId}</model-invariant-id> - <model-version-id>${modelVersionId}</model-version-id> - <model-customization-id>${modelCustomizationId}</model-customization-id> - <nf-type>${nfType}</nf-type> - <nf-role>${nfRole}</nf-role> - <nf-function>${nfFunction}</nf-function> - <nf-naming-code>${nfNamingCode}</nf-naming-code> - <relationship-list> - <relationship> - <related-to>service-instance</related-to> - <related-link>${siRelatedLink}</related-link> - <relationship-data> - <relationship-key>customer.global-customer-id</relationship-key> - <relationship-value>${globalCustId}</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>service-subscription.service-type</relationship-key> - <relationship-value>${serviceType}</relationship-value> - </relationship-data> - <relationship-data> - <relationship-key>service-instance.service-instance-id</relationship-key> - <relationship-value>${serviceInstanceId}</relationship-value> - </relationship-data> - </relationship> - </relationship-list> - </generic-vnf>""" - - execution.setVariable("DoCVNF_genericVnfPayload", payload) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process") - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled) - } - - public void postProcessCreateGenericVnf (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnf PostProcessCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = execution.getVariable("DoCVNF_vnfId") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put("VNF", "vnfId", vnfId) - rollbackData.put("VNF", "rollbackVnfCreate", "true") - execution.setVariable("rollbackData", rollbackData) - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnf PostProcessCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PostProcessCreateGenericVnf Process") - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnf PostProcessCreateGenericVnf Process ***", isDebugEnabled) - } - - - public void preProcessSDNCAssignRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - def vnfId = execution.getVariable("DoCVNF_vnfId") - def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") - logDebug("NEW VNF ID: " + vnfId, isDebugLogEnabled) - utils.logAudit("NEW VNF ID: " + vnfId) - - try{ - //Build SDNC Request - - String assignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "assign") - - assignSDNCRequest = utils.formatXml(assignSDNCRequest) - execution.setVariable("DoCVNF_assignSDNCRequest", assignSDNCRequest) - logDebug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCAssignRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCAssignRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCActivateRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - try{ - String vnfId = execution.getVariable("DoCVNF_vnfId") - String serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") - - String activateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "activate") - - execution.setVariable("DoCVNF_activateSDNCRequest", activateSDNCRequest) - logDebug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest) - - }catch(Exception e){ - log.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCActivateRequest Process ======== ", isDebugLogEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DoCVNF_requestId") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("DoCVNF_sdncCallbackUrl") - def requestId = execution.getVariable("DoCVNF_requestId") - def serviceId = execution.getVariable("DoCVNF_serviceId") - def vnfType = execution.getVariable("DoCVNF_vnfType") - def vnfName = execution.getVariable("DoCVNF_vnfName") - // Only send vnfName to SDNC if it is not null, otherwise it will get generated by SDNC on Assign - String vnfNameString = "" - if (vnfName != null) { - vnfNameString = """<vnf-name>${vnfName}</vnf-name>""" - } - def tenantId = execution.getVariable("DoCVNF_tenantId") - def source = execution.getVariable("DoCVNF_source") - def vnfId = execution.getVariable("DoCVNF_vnfId") - def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId") - def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") - def serviceModelInfo = execution.getVariable("serviceModelInfo") - def vnfModelInfo = execution.getVariable("vnfModelInfo") - String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) - String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) - def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId") - def sdncVersion = execution.getVariable("DoCVNF_sdncVersion") - - String sdncVNFParamsXml = "" - - if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){ - sdncVNFParamsXml = buildSDNCParamsXml(execution) - }else{ - sdncVNFParamsXml = "" - } - - String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>CreateVnfInstance</request-action> - <source>${source}</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <subscription-service-type>${serviceId}</subscription-service-type> - ${serviceEcompModelInformation} - <service-instance-id>${svcInstId}</service-instance-id> - <global-customer-id>${globalSubscriberId}</global-customer-id> - </service-information> - <vnf-information> - <vnf-id>${vnfId}</vnf-id> - <vnf-type>${vnfType}</vnf-type> - ${vnfEcompModelInformation} - </vnf-information> - <vnf-request-input> - ${vnfNameString} - <tenant>${tenantId}</tenant> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - ${sdncVNFParamsXml} - </vnf-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - } - - public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - if(method.equals("get")){ - String topologyGetResponse = execution.getVariable("DoCVNF_getSDNCAdapterResponse") - String data = utils.getNodeXml(topologyGetResponse, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") - utils.log("DEBUG", "topologyGetResponseData: " + data, isDebugLogEnabled) - String vnfName = utils.getNodeText1(data, "vnf-name") - utils.log("DEBUG", "vnfName received from SDNC: " + vnfName, isDebugLogEnabled) - execution.setVariable("vnfName", vnfName) - execution.setVariable("DoCVNF_vnfName", vnfName) - } - def rollbackData = execution.getVariable("rollbackData") - if (method.equals("assign")) { - rollbackData.put("VNF", "rollbackSDNCAssign", "true") - } - else if (method.equals("activate")) { - rollbackData.put("VNF", "rollbackSDNCActivate", "true") - } - execution.setVariable("rollbackData", rollbackData) - - - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - public void preProcessSDNCGetRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - utils.log("DEBUG", " ======== STARTED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) - try{ - def serviceInstanceId = execution.getVariable('DoCVNF_serviceInstanceId') - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() - } - - def callbackUrl = execution.getVariable("DoCVFM_sdncCallbackUrl") - utils.logAudit("callbackUrl:" + callbackUrl) - - def vnfId = execution.getVariable('DCVFM_vnfId') - - def svcInstId = "" - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - svcInstId = vnfId - } - else { - svcInstId = serviceInstanceId - } - // serviceOperation will be retrieved from "object-path" element - // in SDNC Assign Response for VNF - String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse") - utils.logAudit("DoCVNF_assignSDNCAdapterResponse is: \n" + response) - - String serviceOperation = "" - - String data = utils.getNodeXml(response, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") - utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled) - serviceOperation = utils.getNodeText1(data, "object-path") - utils.log("DEBUG", "VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation, isDebugLogEnabled) - - - //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE - sleep(5000) - - String SDNCGetRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>query</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest) - execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest) - utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled) - } - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DoCVNF_vnfId') - logDebug("VNF ID: " + vnfId, isDebugLogEnabled) - - String updateAAIGenericVnfRequest = """ - <UpdateAAIGenericVnfRequest> - <vnf-id>${vnfId}</vnf-id> - <orchestration-status>Active</orchestration-status> - </UpdateAAIGenericVnfRequest> - """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy deleted file mode 100644 index 4e570f87a9..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy +++ /dev/null @@ -1,411 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import java.util.UUID; -import java.util.List - -import org.json.JSONObject; -import org.json.JSONArray; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ModuleResource -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.DecomposeJsonUtil -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; - -import static org.apache.commons.lang3.StringUtils.*; - - - -/** -* This class supports the macro VID Flow -* with the creation of a generic vnf and related VF modules. -*/ -class DoCreateVnfAndModules extends AbstractServiceTaskProcessor { - - String Prefix="DCVAM_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - CatalogDbUtils cutils = new CatalogDbUtils() - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules PreProcessRequest Process*** ", isDebugLogEnabled) - - setBasicDBAuthHeader(execution, isDebugLogEnabled) - try{ - // Get Variables - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("requestId", requestId) - execution.setVariable("mso-request-id", requestId) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugLogEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugLogEnabled) - - String vnfName = execution.getVariable("vnfName") - execution.setVariable("CREVI_vnfName", vnfName) - utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugLogEnabled) - - String productFamilyId = execution.getVariable("productFamilyId") - utils.log("DEBUG", "Incoming Product Family Id is: " + productFamilyId, isDebugLogEnabled) - - String source = "VID" - execution.setVariable("source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugLogEnabled) - - String lcpCloudRegionId = execution.getVariable("lcpCloudRegionId") - utils.log("DEBUG", "Incoming LCP Cloud Region Id is: " + lcpCloudRegionId) - - String tenantId = execution.getVariable("tenantId") - utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId) - - String disableRollback = execution.getVariable("disableRollback") - utils.log("DEBUG", "Incoming Disable Rollback is: " + disableRollback, isDebugLogEnabled) - - String asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") - utils.log("DEBUG", "Incoming asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) - - String vnfId = execution.getVariable("testVnfId") // for junits - if(isBlank(vnfId)){ - vnfId = execution.getVariable("vnfId") - if (isBlank(vnfId)) { - vnfId = UUID.randomUUID().toString() - utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugLogEnabled) - } - } - execution.setVariable("vnfId", vnfId) - - // Set aLaCarte to false - execution.setVariable("aLaCarte", false) - - def rollbackData = execution.getVariable("rollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - def isTest = execution.getVariable("isTest") - - if (isTest == null || isTest == false) { - execution.setVariable("isBaseVfModule", "true") - } - execution.setVariable("numOfCreatedAddOnModules", 0) - - rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0") - execution.setVariable("rollbackData", rollbackData) - - sleep (20000) - - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugLogEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules PreProcessRequest Process ***", isDebugLogEnabled) - } - - - public void queryCatalogDB (DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules QueryCatalogDB Process *** ", isDebugLogEnabled) - try { - VnfResource vnf = null - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - // if serviceDecomposition is specified, get info from serviceDecomposition - if (serviceDecomposition != null) { - utils.log("DEBUG", "Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString(), isDebugLogEnabled) - List<VnfResource> vnfs = serviceDecomposition.getServiceVnfs() - utils.log("DEBUG", "Read vnfs", isDebugLogEnabled) - if (vnfs == null) { - utils.log("DEBUG", "Error - vnfs are empty in serviceDecomposition object", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnfs are empty") - } - vnf = vnfs[0] - String serviceModelName = serviceDecomposition.getModelInfo().getModelName() - vnf.constructVnfType(serviceModelName) - String vnfType = vnf.getVnfType() - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugLogEnabled) - execution.setVariable("vnfType", vnfType) - } - else { - //Get Vnf Info - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: " + vnfModelInfo, isDebugLogEnabled) - String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") - if (vnfModelCustomizationUuid == null) { - vnfModelCustomizationUuid = "" - } - utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugLogEnabled) - - JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(execution, - vnfModelCustomizationUuid) - utils.log("DEBUG", "obtained VNF list") - // Only one match here - JSONObject vnfObject = vnfs[0] - vnf = DecomposeJsonUtil.jsonToVnfResource(vnfObject.toString()) - } - utils.log("DEBUG", "Read vnfResource", isDebugLogEnabled) - if (vnf == null) { - utils.log("DEBUG", "Error - vnf is empty in serviceDecomposition object", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnf is null") - } - execution.setVariable("vnfResourceDecomposition", vnf) - - List<ModuleResource> vfModules = vnf.getAllVfModuleObjects() - utils.log("DEBUG", "Read vfModules", isDebugLogEnabled) - if (vfModules == null) { - utils.log("DEBUG", "Error - vfModules are empty in serviceDecomposition object", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vf modules are empty") - } - - ModuleResource baseVfModule = null - - for (int i = 0; i < vfModules.size; i++) { - utils.log("DEBUG", "handling VF Module ", isDebugLogEnabled) - ModuleResource vfModule = vfModules[i] - boolean isBase = vfModule.getIsBase() - if (isBase) { - ModelInfo baseVfModuleModelInfoObject = vfModule.getModelInfo() - String baseVfModuleModelInfoWithRoot = baseVfModuleModelInfoObject.toString() - String baseVfModuleModelInfo = jsonUtil.getJsonValue(baseVfModuleModelInfoWithRoot, "modelInfo") - execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) - String baseVfModuleLabel = vfModule.getVfModuleLabel() - execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) - String basePersonaModelId = baseVfModuleModelInfoObject.getModelInvariantUuid() - execution.setVariable("basePersonaModelId", basePersonaModelId) - baseVfModule = vfModule - break - } - - } - - List<ModuleResource>addOnModules = vfModules - baseVfModule - - int addOnModulesToDeploy = 0 - if (addOnModules != null) { - addOnModulesToDeploy = addOnModules.size - } - - utils.log("DEBUG", "AddOnModulesToDeploy: " + addOnModulesToDeploy) - - execution.setVariable("addOnModules", addOnModules) - execution.setVariable("addOnModulesToDeploy", addOnModulesToDeploy) - execution.setVariable("addOnModulesDeployed", 0) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage(), isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnfAndModules QueryCatalogDB Process") - } - - // Generate vfModuleId for base VF Module - def baseVfModuleId = UUID.randomUUID().toString() - execution.setVariable("baseVfModuleId", baseVfModuleId) - // For JUnits - String requestId = execution.getVariable("requestId") - if (requestId.equals("testRequestId123")) { - execution.setVariable("vnfId", "skask") - } - - utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModules QueryCatalogDB Process ***", isDebugLogEnabled) - } - - public void preProcessAddOnModule(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) - - try { - List<ModuleResource>addOnModules = execution.getVariable("addOnModules") - int addOnIndex = (int) execution.getVariable("addOnModulesDeployed") - - ModuleResource addOnModule = addOnModules[addOnIndex] - - utils.log("DEBUG", "Got addon module", isDebugLogEnabled) - - def newVfModuleId = UUID.randomUUID().toString() - execution.setVariable("addOnVfModuleId", newVfModuleId) - execution.setVariable("isBaseVfModule", "false") - - execution.setVariable("instancesOfThisModuleDeployed", 0) - - ModelInfo addOnVfModuleModelInfoObject = addOnModule.getModelInfo() - String addOnVfModuleModelInfoWithRoot = addOnVfModuleModelInfoObject.toString() - String addOnVfModuleModelInfo = jsonUtil.getJsonValue(addOnVfModuleModelInfoWithRoot, "modelInfo") - execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) - String addOnVfModuleLabel = addOnModule.getVfModuleLabel() - execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) - String addOnPersonaModelId = addOnVfModuleModelInfoObject.getModelInvariantUuid() - execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) - int addOnInitialCount = addOnModule.getInitialCount() - execution.setVariable("initialCount", addOnInitialCount) - - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessAddOnModule ======== ", isDebugLogEnabled) - } - - public void postProcessAddOnModule(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED postProcessAddOnModule ======== ", isDebugLogEnabled) - - try { - int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") - execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing postProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED postProcessAddOnModule ======== ", isDebugLogEnabled) - } - - public void validateBaseModule(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED validateBaseModule ======== ", isDebugLogEnabled) - - try { - def baseRollbackData = execution.getVariable("DCVAM_baseRollbackData") - def rollbackData = execution.getVariable("rollbackData") - - def baseModuleMap = baseRollbackData.get("VFMODULE") - baseModuleMap.each{ k, v -> rollbackData.put("VFMODULE_BASE", "${k}","${v}") } - execution.setVariable("rollbackData", rollbackData) - logDebug("addOnModulesDeployed: " + execution.getVariable("addOnModulesDeployed"), isDebugLogEnabled) - logDebug("addOnModulesToDeploy: " + execution.getVariable("addOnModulesToDeploy"), isDebugLogEnabled) - if (execution.getVariable("addOnModulesDeployed") < execution.getVariable("addOnModulesToDeploy")) { - logDebug("More add on modules to deploy", isDebugLogEnabled) - } - else { - logDebug("No more add on modules to deploy", isDebugLogEnabled) - } - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing validateBaseModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during validateBaseModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED validateBaseModule ======== ", isDebugLogEnabled) - } - - public void validateAddOnModule(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED validateAddOnModule ======== ", isDebugLogEnabled) - - try { - int instancesOfThisModuleDeployed = execution.getVariable("instancesOfThisModuleDeployed") - int numOfCreatedAddOnModules = execution.getVariable("numOfCreatedAddOnModules") - def addOnRollbackData = execution.getVariable("DCVAM_addOnRollbackData") - def rollbackData = execution.getVariable("rollbackData") - - def addOnModuleMap = addOnRollbackData.get("VFMODULE") - numOfCreatedAddOnModules = numOfCreatedAddOnModules + 1 - addOnModuleMap.each{ k, v -> rollbackData.put("VFMODULE_ADDON_" + numOfCreatedAddOnModules, "${k}","${v}") } - - execution.setVariable("DCVAM_addOnRollbackData", null) - - execution.setVariable("instancesOfThisModuleDeployed", instancesOfThisModuleDeployed + 1) - - execution.setVariable("numOfCreatedAddOnModules", numOfCreatedAddOnModules) - rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "${numOfCreatedAddOnModules}") - execution.setVariable("rollbackData", rollbackData) - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED validateAddOnModule ======== ", isDebugLogEnabled) - } - - public void preProcessRollback (DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugLogEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugLogEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugLogEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugLogEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugLogEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugLogEnabled) - execution.setVariable("WorkflowException", workflowException); - } - execution.setVariable("rollbackData", null) - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugLogEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugLogEnabled) - } - - -}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy deleted file mode 100644 index e931903ea5..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModulesRollback.groovy +++ /dev/null @@ -1,366 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-import java.util.UUID;
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-
-/**
- * This class supports the macro VID Flow
- * with the rollback of a creation of a generic vnf and related VF modules.
- */
-class DoCreateVnfAndModulesRollback extends AbstractServiceTaskProcessor {
-
- String Prefix="DCVAMR_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
-
- /**
- * This method gets and validates the incoming
- * request.
- *
- * @param - execution
- *
- */
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- utils.log("DEBUG", " *** STARTED DoCreateVnfAndModulesRollback PreProcessRequest Process*** ", isDebugEnabled)
-
- try{
- // Get Rollback Variables
-
- def rollbackData = execution.getVariable("rollbackData")
- utils.log("DEBUG", "Incoming RollbackData is: " + rollbackData.toString(), isDebugEnabled)
- execution.setVariable("rolledBack", null)
- execution.setVariable("rollbackError", null)
-
- if (execution.getVariable("disableRollback").equals("true" ))
- {
- execution.setVariable("skipRollback", true)
- }
-
- String vnfId = rollbackData.get("VNF", "vnfId")
- utils.log("DEBUG", "Rollback vnfId is: " + vnfId, isDebugEnabled)
- execution.setVariable("DCVAMR_vnfId", vnfId)
-
- execution.setVariable("mso-request-id", execution.getVariable("msoRequestId"))
-
- execution.setVariable("DCVAMR_rollbackSDNCAssign", rollbackData.get("VNF", "rollbackSDNCAssign"))
- execution.setVariable("DCVAMR_rollbackSDNCActivate", rollbackData.get("VNF", "rollbackSDNCActivate"))
- execution.setVariable("DCVAMR_rollbackVnfCreate", rollbackData.get("VNF", "rollbackVnfCreate"))
-
- String sdncCallbackUrl = rollbackData.get("VNF", "sdncCallbackUrl")
- utils.log("DEBUG", "Rollback sdncCallbackUrl is: " + sdncCallbackUrl, isDebugEnabled)
- execution.setVariable("DCVAMR_sdncCallbackUrl", sdncCallbackUrl)
-
- String tenantId= rollbackData.get("VNF", "tenantId")
- utils.log("DEBUG", "Rollback tenantId is: " + tenantId, isDebugEnabled)
- execution.setVariable("DCVAMR_tenantId", tenantId)
-
- String source= rollbackData.get("VNF", "source")
- utils.log("DEBUG", "Rollback source is: " + source, isDebugEnabled)
- execution.setVariable("DCVAMR_source", source)
-
- String serviceInstanceId = rollbackData.get("VNF", "serviceInstanceId")
- utils.log("DEBUG", "Rollback serviceInstanceId is: " + serviceInstanceId, isDebugEnabled)
- execution.setVariable("DCVAMR_serviceInstanceId", serviceInstanceId)
-
- String cloudSiteId = rollbackData.get("VNF", "cloudSiteId")
- utils.log("DEBUG", "Rollback cloudSiteId is: " + cloudSiteId, isDebugEnabled)
- execution.setVariable("DCVAMR_cloudSiteId", cloudSiteId)
-
- def numOfAddOnModulesString = rollbackData.get("VNFANDMODULES", "numOfCreatedAddOnModules")
- int numOfAddOnModules = 0
- if (numOfAddOnModulesString != null) {
- numOfAddOnModules = Integer.parseInt(numOfAddOnModulesString)
- }
- execution.setVariable("DCVAMR_numOfAddOnModules", numOfAddOnModules)
-
- def baseVfModuleRollbackMap = rollbackData.get("VFMODULE_BASE")
- if (baseVfModuleRollbackMap == null) {
- // there are no VF Modules to delete
- execution.setVariable("DCVAMR_numOfModulesToDelete", 0)
- }
- else {
- execution.setVariable("DCVAMR_numOfModulesToDelete", numOfAddOnModules + 1)
- }
-
- // Set aLaCarte to false
- execution.setVariable("DCVAMR_aLaCarte", false)
-
- }catch(BpmnError b){
- utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
- throw b
- }catch(Exception e){
- utils.log("DEBUG", " Error Occured in DoCreateVnfAndModulesRollback PreProcessRequest method!" + e.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnfAndModulesRollback PreProcessRequest")
-
- }
- utils.log("DEBUG", "*** COMPLETED DoCreateVnfAndModulesRollback PreProcessRequest Process ***", isDebugEnabled)
- }
-
-
-
- public void preProcessCreateVfModuleRollback(DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED preProcessCreateVfModuleRollback ======== ", isDebugLogEnabled)
-
- try {
-
- def rollbackData = execution.getVariable("rollbackData")
-
- def vfModuleRollbackData = new RollbackData()
-
- def numOfModulesToDelete = execution.getVariable("DCVAMR_numOfModulesToDelete")
- logDebug("numOfModulesToDelete: " + numOfModulesToDelete, isDebugLogEnabled)
- def moduleMap = null
-
- if (numOfModulesToDelete > 1) {
- int addOnModuleIndex = numOfModulesToDelete - 1
- moduleMap = rollbackData.get("VFMODULE_ADDON_" + addOnModuleIndex)
- logDebug("Removing ADDON VF module # " + addOnModuleIndex, isDebugLogEnabled)
- }
- else {
- moduleMap = rollbackData.get("VFMODULE_BASE")
- logDebug("Removing BASE VF module", isDebugLogEnabled)
- }
- moduleMap.each{ k, v -> vfModuleRollbackData.put("VFMODULE", "${k}","${v}") }
- execution.setVariable("DCVAMR_RollbackData", vfModuleRollbackData)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preProcessCreateVfModuleRollback. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessCreateVfModuleRollback Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED preProcessCreateVfModuleRollback ======== ", isDebugLogEnabled)
- }
-
-
- public void postProcessCreateVfModuleRollback(DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED postProcessCreateVfModuleRollback ======== ", isDebugLogEnabled)
- def rolledBack = false
-
- try {
- rolledBack = execution.getVariable("DCVM_rolledBack")
- def numOfModulesToDelete = execution.getVariable("DCVAMR_numOfModulesToDelete")
- execution.setVariable("DCVAMR_numOfModulesToDelete", numOfModulesToDelete - 1)
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing postProcessCreateVfModuleRollback. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during postProcessCreateVfModuleRollback Method:\n" + e.getMessage())
- }
- if (!rolledBack) {
- logDebug("Failure on DoCreateVfModuleRollback", isDebugLogEnabled)
- utils.log("ERROR", "Unsuccessful rollback of DoCreateVfModule")
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during rollback of DoCreateVfModule")
- }
- logDebug("======== COMPLETED postProcessCreateVfModuleRollback ======== ", isDebugLogEnabled)
- }
-
-
- public void preProcessSDNCDeactivateRequest(DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled)
- def vnfId = execution.getVariable("vnfId")
- def serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- try{
- //Build SDNC Request
-
- String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate")
-
- deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest)
- execution.setVariable(Prefix + "deactivateSDNCRequest", deactivateSDNCRequest)
- logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled)
- utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled)
- }
-
- public void preProcessSDNCUnassignRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled)
- try{
- String vnfId = execution.getVariable("vnfId")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign")
-
- execution.setVariable(Prefix + "unassignSDNCRequest", unassignSDNCRequest)
- logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled)
- utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest)
-
- }catch(Exception e){
- log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled)
- }
-
- public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
-
- String uuid = execution.getVariable('testReqId') // for junits
- if(uuid==null){
- uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis()
- }
- def callbackURL = execution.getVariable(Prefix + "sdncCallbackUrl")
- def requestId = execution.getVariable("msoRequestId")
- def tenantId = execution.getVariable(Prefix + "tenantId")
- def source = execution.getVariable(Prefix + "source")
- def vnfId = execution.getVariable(Prefix + "vnfId")
- def serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId")
- def cloudSiteId = execution.getVariable(Prefix + "cloudSiteId")
-
- String sdncRequest =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
- <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <request-action>DeleteVnfInstance</request-action>
- <source>${source}</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- </request-information>
- <service-information>
- <service-id/>
- <subscription-service-type/>
- <service-instance-id>${serviceInstanceId}</service-instance-id>
- <global-customer-id/>
- </service-information>
- <vnf-information>
- <vnf-id>${vnfId}</vnf-id>
- <vnf-type/>
- </vnf-information>
- <vnf-request-input>
- <vnf-name/>
- <tenant>${tenantId}</tenant>
- <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
- </vnf-request-input>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
- utils.logAudit("sdncRequest: " + sdncRequest)
- return sdncRequest
- }
-
- public void validateSDNCResponse(DelegateExecution execution, String response, String method){
- def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
-
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
-
- utils.logAudit("workflowException: " + workflowException)
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
-
- utils.logAudit("SDNCResponse: " + response)
-
- String sdncResponse = response
- if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
- logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)
- }else{
- logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
- }
-
- public void setSuccessfulRollbackStatus (DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled)
-
- try{
- // Set rolledBack to true, rollbackError to null
- execution.setVariable("rolledBack", true)
- execution.setVariable("rollbackError", null)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing setSuccessfulRollbackStatus. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setSuccessfulRollbackStatus Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED setSuccessfulRollbackStatus ======== ", isDebugLogEnabled)
- }
-
- public void setFailedRollbackStatus (DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED setFailedRollbackStatus ======== ", isDebugLogEnabled)
-
- try{
- // Set rolledBack to false, rollbackError to actual value, rollbackData to null
- execution.setVariable("rolledBack", false)
- def rollbackError = execution.getVariable("rollbackError")
- if (rollbackError == null) {
- execution.setVariable("rollbackError", 'Caught exception in DoCreateVnfAndModulesRollback')
- }
- execution.setVariable("rollbackData", null)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing setFailedRollbackStatus. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during setFailedRollbackStatus Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED setFailedRollbackStatus ======== ", isDebugLogEnabled)
- }
-
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy deleted file mode 100644 index a32fd7b538..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstance.groovy +++ /dev/null @@ -1,661 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 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.infrastructure.scripts - -import org.json.JSONArray; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.List; -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource - -import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def; - -/** - * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - O - * @param - subscriptionServiceType - O - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion - * @param - failNotFound - TODO - * @param - serviceInputParams - TODO - * - * Outputs: - * @param - WorkflowException - * - * Rollback - Deferred - */ -public class DoCustomDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DDELSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) - String msg = "" - - try { - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("prefix",Prefix) - - //Inputs - //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology - String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - if (globalSubscriberId == null) - { - execution.setVariable("globalSubscriberId", "") - } - - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology - String serviceType = execution.getVariable("serviceType") - if (serviceType == null) - { - execution.setVariable("serviceType", "") - } - - //Generated in parent for AAI PUT - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - StringBuilder sbParams = new StringBuilder() - Map<String, String> paramsMap = execution.getVariable("serviceInputParams") - if (paramsMap != null) - { - sbParams.append("<service-input-parameters>") - for (Map.Entry<String, String> entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ <param> - <name>${paramName}</name> - <value>${paramValue}</value> - </param> - """ - sbParams.append(paramsXml) - } - sbParams.append("</service-input-parameters>") - } - String siParamsXml = sbParams.toString() - if (siParamsXml == null) - siParamsXml = "" - execution.setVariable("siParamsXml", siParamsXml) - - } 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) - } - - - public void preProcessVFCDelete (DelegateExecution execution) { - } - - public void postProcessVFCDelete(DelegateExecution execution, String response, String method) { - } - - public void preProcessSDNCDelete (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled) - String msg = "" - - try { - def serviceInstanceId = execution.getVariable("serviceInstanceId") - def serviceInstanceName = execution.getVariable("serviceInstanceName") - def callbackURL = execution.getVariable("sdncCallbackUrl") - def requestId = execution.getVariable("msoRequestId") - def serviceId = execution.getVariable("productFamilyId") - def subscriptionServiceType = execution.getVariable("subscriptionServiceType") - def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - - String serviceModelInfo = execution.getVariable("serviceModelInfo") - def modelInvariantUuid = "" - def modelVersion = "" - def modelUuid = "" - def modelName = "" - if (!isBlank(serviceModelInfo)) - { - modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") - modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") - modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") - modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") - - if (modelInvariantUuid == null) { - modelInvariantUuid = "" - } - if (modelVersion == null) { - modelVersion = "" - } - if (modelUuid == null) { - modelUuid = "" - } - if (modelName == null) { - modelName = "" - } - } - if (serviceInstanceName == null) { - serviceInstanceName = "" - } - if (serviceId == null) { - serviceId = "" - } - - def siParamsXml = execution.getVariable("siParamsXml") - def serviceType = execution.getVariable("serviceType") - if (serviceType == null) - { - serviceType = "" - } - - def sdncRequestId = UUID.randomUUID().toString() - - String sdncDelete = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>delete</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - <request-action>DeleteServiceInstance</request-action> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> - <model-uuid>${modelUuid}</model-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalSubscriberId}</global-customer-id> - </service-information> - <service-request-input> - <service-instance-name>${serviceInstanceName}</service-instance-name> - ${siParamsXml} - </service-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - sdncDelete = utils.formatXml(sdncDelete) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - execution.setVariable("sdncDelete", sdncDelete) - execution.setVariable("sdncDeactivate", sdncDeactivate) - utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled) - utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) - } - utils.log("INFO"," *****Exit preProcessSDNCDelete *****", isDebugEnabled) - } - - public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) { - - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessSDNC " + method + " *****", isDebugEnabled) - String msg = "" - - /*try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.log("INFO", "SDNCResponse: " + response, isDebugEnabled) - utils.log("INFO", "workflowException: " + workflowException, isDebugEnabled) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){ - utils.log("INFO","Good response from SDNC Adapter for service-instance " + method + "response:\n" + response, isDebugEnabled) - - }else{ - msg = "Bad Response from SDNC Adapter for service-instance " + method - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - }*/ - utils.log("INFO"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled) - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - String serviceType = "" - - if(foundInAAI){ - utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) - - String siData = execution.getVariable("GENGS_service") - utils.log("INFO", "SI Data", isDebugEnabled) - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - utils.log("INFO", "SI Data" + siData, isDebugEnabled) - //Confirm there are no related service instances (vnf/network or volume) - if (utils.nodeExists(siData, "relationship-list")) { - utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled) - InputSource source = new InputSource(new StringReader(siData)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document serviceXml = docBuilder.parse(source) - serviceXml.getDocumentElement().normalize() - //test(siData) - NodeList nodeList = serviceXml.getElementsByTagName("relationship") - JSONArray jArray = new JSONArray() - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns - if(e.equals("service-instance")){ - def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() - utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled) - NodeList dataList = node.getChildNodes() - if(null != dataList) { - JSONObject jObj = new JSONObject() - for (int i = 0; i < dataList.getLength(); i++) { - Node dNode = dataList.item(i) - if(dNode.getNodeName() == "relationship-data") { - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() - if(eKey.equals("service-instance.service-instance-id")){ - jObj.put("resourceInstanceId", eValue) - } - } - else if(dNode.getNodeName() == "related-to-property"){ - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() - if(eKey.equals("service-instance.service-instance-name")){ - jObj.put("resourceType", eValue) - } - } - } - utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) - jArray.put(jObj) - } - //for overlay/underlay - }else if (e.equals("configuration")){ - def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() - utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled) - NodeList dataList = node.getChildNodes() - if(null != dataList) { - JSONObject jObj = new JSONObject() - for (int i = 0; i < dataList.getLength(); i++) { - Node dNode = dataList.item(i) - if(dNode.getNodeName() == "relationship-data") { - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() - if(eKey.equals("configuration.configuration-id")){ - jObj.put("resourceInstanceId", eValue) - } - } - else if(dNode.getNodeName() == "related-to-property"){ - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() - if(eKey.equals("configuration.configuration-type")){ - jObj.put("resourceType", eValue) - } - } - } - utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) - jArray.put(jObj) - } - } - } - } - execution.setVariable("serviceRelationShip", jArray.toString()) - } - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - - utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) - } - }catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void postProcessAAIDEL(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") - if(!succInAAI){ - msg = "Error deleting Service-instance in AAI" + serviceInstanceId - utils.log("INFO", msg, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIDEL *** ", isDebugEnabled) - } - - public void preInitResourcesOperStatus(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = execution.getVariable("operationType") - String resourceTemplateUUIDs = "" - String result = "processing" - String progress = "0" - String reason = "" - String operationContent = "Prepare service creation" - utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - // we use resource instance ids for delete flow as resourceTemplateUUIDs - /*[ - { - "resourceInstanceId":"1111", - "resourceType":"vIMS" - }, - { - "resourceInstanceId":"222", - "resourceType":"vEPC" - }, - { - "resourceInstanceId":"3333", - "resourceType":"overlay" - }, - { - "resourceInstanceId":"4444", - "resourceType":"underlay" - } - ]*/ - String serviceRelationShip = execution.getVariable("serviceRelationShip") - - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - List relationShipList = jsonSlurper.parseText(serviceRelationShip) - - if (relationShipList != null) { - relationShipList.each { - resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":" - } - } - execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs> - </ns:initResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_initResOperStatusRequest", payload) - utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) - utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) - } - utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - } - - /** - * prepare delete parameters - */ - public void preResourceDelete(execution, resourceName){ - // we use resource instance ids for delete flow as resourceTemplateUUIDs - /*[ - { - "resourceInstanceId":"1111", - "resourceType":"vIMS" - }, - { - "resourceInstanceId":"222", - "resourceType":"vEPC" - }, - { - "resourceInstanceId":"3333", - "resourceType":"overlay" - }, - { - "resourceInstanceId":"4444", - "resourceType":"underlay" - } - ]*/ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preResourceDelete Process ======== ", isDebugEnabled) - String serviceRelationShip = execution.getVariable("serviceRelationShip") - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - List relationShipList = jsonSlurper.parseText(serviceRelationShip) - - if (relationShipList != null) { - relationShipList.each { - if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) { - String resourceInstanceUUID = it.resourceInstanceId - String resourceTemplateUUID = it.resourceInstanceId - execution.setVariable("resourceTemplateId", resourceTemplateUUID) - execution.setVariable("resourceInstanceId", resourceInstanceUUID) - execution.setVariable("resourceType", resourceName) - utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled) - } - } - } - utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled) - } - - public void sequenceResource(execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled) - List<String> nsResources = new ArrayList<String>() - List<String> wanResources = new ArrayList<String>() - List<String> resourceSequence = new ArrayList<String>() - - String serviceRelationShip = execution.getVariable("serviceRelationShip") - - - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - List relationShipList = jsonSlurper.parseText(serviceRelationShip) - - if (relationShipList != null) { - relationShipList.each { - if(StringUtils.containsIgnoreCase(it.resourceType, "overlay") || StringUtils.containsIgnoreCase(it.resourceType, "underlay")){ - wanResources.add(it.resourceType) - }else{ - nsResources.add(it.resourceType) - } - } - } - resourceSequence.addAll(wanResources) - resourceSequence.addAll(nsResources) - String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" - execution.setVariable("isContainsWanResource", isContainsWanResource) - execution.setVariable("currentResourceIndex", 0) - execution.setVariable("resourceSequence", resourceSequence) - utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) - execution.setVariable("wanResources", wanResources) - utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled) - } - - public void getCurrentResource(execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - List<String> resourceSequence = execution.getVariable("resourceSequence") - List<String> wanResources = execution.getVariable("wanResources") - String resourceName = resourceSequence.get(currentIndex) - execution.setVariable("resourceType",resourceName) - if(wanResources.contains(resourceName)){ - execution.setVariable("controllerInfo", "SDN-C") - }else{ - execution.setVariable("controllerInfo", "VF-C") - } - utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) - } - - public void parseNextResource(execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - def nextIndex = currentIndex + 1 - execution.setVariable("currentResourceIndex", nextIndex) - List<String> resourceSequence = execution.getVariable("resourceSequence") - if(nextIndex >= resourceSequence.size()){ - execution.setVariable("allResourceFinished", "true") - }else{ - execution.setVariable("allResourceFinished", "false") - } - utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) - } - -} -
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy deleted file mode 100644 index 03ba10a0c0..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCustomDeleteE2EServiceInstanceV2.groovy +++ /dev/null @@ -1,1169 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 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.infrastructure.scripts
-
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONArray;
-import org.json.JSONObject;
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse;
-import org.springframework.web.util.UriUtils;
-
-import groovy.json.*
-
-/**
- * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process.
- *
- * Inputs:
- * @param - msoRequestId
- * @param - globalSubscriberId - O
- * @param - subscriptionServiceType - O
- * @param - serviceInstanceId
- * @param - serviceInstanceName - O
- * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM)
- * @param - sdncVersion
- * @param - failNotFound - TODO
- * @param - serviceInputParams - TODO
- *
- * Outputs:
- * @param - WorkflowException
- *
- * Rollback - Deferred
- */
-public class DoCustomDeleteE2EServiceInstanceV2 extends AbstractServiceTaskProcessor {
-
- String Prefix="DDELSI_"
- private static final String DebugFlag = "isDebugEnabled"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
- public void preProcessRequest (DelegateExecution execution) {
-
- def method = getClass().getSimpleName() + '.buildAPPCRequest(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled)
- String msg = ""
-
- try {
- String requestId = execution.getVariable("msoRequestId")
- execution.setVariable("prefix",Prefix)
-
- //Inputs
- //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology
- String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
- if (globalSubscriberId == null)
- {
- execution.setVariable("globalSubscriberId", "")
- }
-
- //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology
- String serviceType = execution.getVariable("serviceType")
- if (serviceType == null)
- {
- execution.setVariable("serviceType", "")
- }
-
- //Generated in parent for AAI PUT
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- if (isBlank(serviceInstanceId)){
- msg = "Input serviceInstanceId is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback')
- if (isBlank(sdncCallbackUrl)) {
- msg = "URN_mso_workflow_sdncadapter_callback is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
- execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
- utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled)
-
- StringBuilder sbParams = new StringBuilder()
- Map<String, String> paramsMap = execution.getVariable("serviceInputParams")
- if (paramsMap != null)
- {
- sbParams.append("<service-input-parameters>")
- for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
- String paramsXml
- String paramName = entry.getKey()
- String paramValue = entry.getValue()
- paramsXml =
- """ <param>
- <name>${paramName}</name>
- <value>${paramValue}</value>
- </param>
- """
- sbParams.append(paramsXml)
- }
- sbParams.append("</service-input-parameters>")
- }
- String siParamsXml = sbParams.toString()
- if (siParamsXml == null)
- siParamsXml = ""
- execution.setVariable("siParamsXml", siParamsXml)
- execution.setVariable("operationStatus", "Waiting delete resource...")
- execution.setVariable("progress", "0")
-
- } 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", "Exited " + method, isDebugEnabled)
- }
-
-
-
- public void postProcessAAIGET(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.postProcessAAIGET(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- String msg = ""
-
- try {
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- utils.log("INFO","serviceInstanceId: "+serviceInstanceId, isDebugEnabled)
-
- boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
- utils.log("INFO","foundInAAI: "+foundInAAI, isDebugEnabled)
-
- String serviceType = ""
-
-
- if(foundInAAI){
- utils.log("INFO","Found Service-instance in AAI", isDebugEnabled)
-
- String siData = execution.getVariable("GENGS_service")
- utils.log("INFO", "SI Data", isDebugEnabled)
- if (isBlank(siData))
- {
- msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- }else{
- boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
- if(!succInAAI){
- utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled)
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- utils.logAudit("workflowException: " + workflowException)
- if(workflowException != null){
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
- }
- else
- {
- msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
- }
- }
-
- utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled)
- }
- }catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Bpmn error encountered in " + method + "--" + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- private void loadResourcesProperties(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.loadResourcesProperties(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- String loadFilePath = "/etc/mso/config.d/reources.json"
- try{
- def jsonPayload = new File(loadFilePath).text
- utils.log("INFO","jsonPayload: " + jsonPayload, isDebugEnabled)
-
- String resourcesProperties = jsonUtil.prettyJson(jsonPayload.toString())
- utils.log("INFO","resourcesProperties: " + resourcesProperties, isDebugEnabled)
-
- String createResourceSort = jsonUtil.getJsonValue(resourcesProperties, "CreateResourceSort")
- //utils.log("INFO","createResourceSort: " + createResourceSort, isDebugEnabled)
- execution.setVariable("createResourceSort", createResourceSort)
-
- String deleteResourceSort = jsonUtil.getJsonValue(resourcesProperties, "DeleteResourceSort")
- //utils.log("INFO","deleteResourceSort: " + deleteResourceSort, isDebugEnabled)
- execution.setVariable("deleteResourceSort", deleteResourceSort)
-
-
- String resourceControllerType = jsonUtil.getJsonValue(resourcesProperties, "ResourceControllerType")
- //utils.log("INFO","resourceControllerType: " + resourceControllerType, isDebugEnabled)
- execution.setVariable("resourceControllerType", resourceControllerType)
-
-
- }catch(Exception ex){
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
- private void sortDeleteResource(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.sortDeleteResource(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- String deleteResourceSortDef = """[
- {
- "resourceType":"GRE_SAR"
- },
- {
- "resourceType":"VPN_SAR"
- },
- {
- "resourceType":"APN_AAR"
- },
- {
- "resourceType":"GRE_AAR"
- },
- {
- "resourceType":"Overlay"
- },
- {
- "resourceType":"Underlay"
- },
- {
- "resourceType":"vIMS"
- },
- {
- "resourceType":"vCPE"
- },
- {
- "resourceType":"vFW"
- },
- {
- "resourceType":"vEPC"
- }
-
-
- ]""".trim()
-
- try{
- loadResourcesProperties(execution)
- String deleteResourceSort = execution.getVariable("deleteResourceSort")
- if (isBlank(deleteResourceSort)) {
- deleteResourceSort = deleteResourceSortDef;
- }
-
- List<String> sortResourceList = jsonUtil.StringArrayToList(execution, deleteResourceSort)
- utils.log("INFO", "sortResourceList : " + sortResourceList, isDebugEnabled)
-
- JSONArray newResourceList = new JSONArray()
- int resSortCount = sortResourceList.size()
-
- for ( int currentResource = 0 ; currentResource < resSortCount ; currentResource++ ) {
- String currentSortResource = sortResourceList[currentResource]
- String sortResourceType = jsonUtil.getJsonValue(currentSortResource, "resourceType")
- List<String> resourceList = execution.getVariable(Prefix+"resourceList")
-
- for (String resource : resourceList) {
- //utils.log("INFO", "resource : " + resource, isDebugEnabled)
- String resourceType = jsonUtil.getJsonValue(resource, "resourceType")
-
- if (StringUtils.containsIgnoreCase(resourceType, sortResourceType)) {
- JSONObject jsonObj = new JSONObject(resource)
- newResourceList.put(jsonObj)
- }
- utils.log("INFO", "Get next sort type " , isDebugEnabled)
- }
- }
-
- String newResourceStr = newResourceList.toString()
- List<String> newResourceListStr = jsonUtil.StringArrayToList(execution, newResourceStr)
-
- execution.setVariable(Prefix+"resourceList", newResourceListStr)
- utils.log("INFO", "newResourceList : " + newResourceListStr, isDebugEnabled)
-
- }catch(Exception ex){
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in " + method + " - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
-
- }
- public void prepareServiceDeleteResource(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.prepareServiceDeleteResource(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- try {
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- // confirm if ServiceInstance was found
- if ( !execution.getVariable("GENGS_FoundIndicator") )
- {
- String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
-
- execution.setVariable(Prefix+"resourceList", "")
- execution.setVariable(Prefix+"resourceCount", 0)
- execution.setVariable(Prefix+"nextResource", 0)
- execution.setVariable(Prefix+"resourceFinish", true)
-
- // get SI extracted by GenericGetService
- String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");
- utils.log("INFO", "serviceInstanceAaiRecord: " +serviceInstanceAaiRecord, isDebugEnabled)
-
- String aaiJsonRecord = jsonUtil.xml2json(serviceInstanceAaiRecord)
-
- //utils.log("INFO", "aaiJsonRecord: " +aaiJsonRecord, isDebugEnabled)
- def serviceInstanceName = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-instance-name")
- execution.setVariable("serviceInstanceName",serviceInstanceName)
-
- def serviceType = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.service-type")
- execution.setVariable("serviceType",serviceType)
-
-
- String relationshipList = jsonUtil.getJsonValue(aaiJsonRecord, "service-instance.relationship-list")
- //utils.log("INFO", "relationship-list:" + relationshipList, isDebugEnabled)
- if (! isBlank(relationshipList)){
- utils.log("INFO", "relationship-list exists" , isDebugEnabled)
- String relationShip = jsonUtil.getJsonValue(relationshipList, "relationship")
- utils.log("INFO", "relationship: " + relationShip, isDebugEnabled)
- JSONArray allResources = new JSONArray()
- JSONArray serviceResources = new JSONArray()
- JSONArray networkResources = new JSONArray()
- JSONArray allottedResources = new JSONArray()
-
-
- if (! isBlank(relationShip)){
- JSONArray jsonArray = new JSONArray();
- if (relationShip.startsWith("{") && relationShip.endsWith("}")) {
- JSONObject jsonObject = new JSONObject(relationShip);
- jsonArray.put(jsonObject);
- } else if (relationShip.startsWith("[") && relationShip.endsWith("]")) {
- jsonArray = new JSONArray(relationShip);
- } else {
- utils.log("INFO", "The relationShip fomart is error" , isDebugEnabled)
- }
-
- List<String> relationList = jsonUtil.StringArrayToList(execution, jsonArray.toString())
-
- utils.log("INFO", "relationList: " + relationList, isDebugEnabled)
-
- int relationNum =relationList.size()
- utils.log("INFO", "**************relationList size: " + relationNum, isDebugEnabled)
-
- for ( int currentRelation = 0 ; currentRelation < relationNum ; currentRelation++ ) {
- utils.log("INFO", "current Relation num: " + currentRelation, isDebugEnabled)
- String relation = relationList[currentRelation]
- utils.log("INFO", "relation: " + relation, isDebugEnabled)
-
- String relatedTo = jsonUtil.getJsonValue(relation, "related-to")
- utils.log("INFO", "relatedTo: " + relatedTo, isDebugEnabled)
-
- String relatedLink = jsonUtil.getJsonValue(relation, "related-link")
- utils.log("INFO", "relatedLink: " + relatedLink, isDebugEnabled)
-
- if (StringUtils.equalsIgnoreCase(relatedTo, "allotted-resource")) {
- utils.log("INFO", "allotted-resource exists ", isDebugEnabled)
-
- String aaiArRsp = getAaiAr(execution, relatedLink)
- utils.log("INFO", "aaiArRsp: " + aaiArRsp, isDebugEnabled)
- if (! isBlank(aaiArRsp)) {
- def type = utils.getNodeText1(aaiArRsp, "type")
- def id = utils.getNodeText1(aaiArRsp, "id")
- def role = utils.getNodeText1(aaiArRsp, "role")
- def resourceVersion = utils.getNodeText1(aaiArRsp, "resource-version")
-
- JSONObject jObject = new JSONObject()
- jObject.put("resourceType", type)
- jObject.put("resourceInstanceId", id)
- jObject.put("resourceRole", role)
- jObject.put("resourceVersion", resourceVersion)
-
- allResources.put(jObject)
- utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
- allottedResources.put(jObject)
- utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled)
- }
- }
- else if (StringUtils.equalsIgnoreCase(relatedTo, "service-instance")){
- utils.log("INFO", "service-instance exists ", isDebugEnabled)
- JSONObject jObject = new JSONObject()
-
- //relationship-data
- String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data")
- utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled)
- List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
- utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled)
- for(String rsData : rsDataList){
- utils.log("INFO", "rsData: " + rsData, isDebugEnabled)
- def eKey = jsonUtil.getJsonValue(rsData, "relationship-key")
- def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
- if(eKey.equals("service-instance.service-instance-id")){
- jObject.put("resourceInstanceId", eValue)
- }
- if(eKey.equals("service-subscription.service-type")){
- jObject.put("resourceType", eValue)
- }
- }
-
- //related-to-property
- String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property")
- utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled)
- if (rPropertyStr instanceof JSONArray){
- List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
- for (String rProperty : rPropertyList) {
- utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
- def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
- def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
- if(eKey.equals("service-instance.service-instance-name")){
- jObject.put("resourceName", eValue)
- }
- }
- }
- else {
- String rProperty = rPropertyStr
- utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
- def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
- def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
- if (eKey.equals("service-instance.service-instance-name")) {
- jObject.put("resourceName", eValue)
- }
- }
-
- allResources.put(jObject)
- utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
-
- serviceResources.put(jObject)
- utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled)
- }
- else if (StringUtils.equalsIgnoreCase(relatedTo, "configuration")) {
- utils.log("INFO", "configuration ", isDebugEnabled)
- JSONObject jObject = new JSONObject()
-
- //relationship-data
- String rsDataStr = jsonUtil.getJsonValue(relation, "relationship-data")
- utils.log("INFO", "rsDataStr: " + rsDataStr, isDebugEnabled)
- List<String> rsDataList = jsonUtil.StringArrayToList(execution, rsDataStr)
- utils.log("INFO", "rsDataList: " + rsDataList, isDebugEnabled)
- for (String rsData : rsDataList) {
- utils.log("INFO", "rsData: " + rsData, isDebugEnabled)
- def eKey = jsonUtil.getJsonValue(rsData, "relationship-key")
- def eValue = jsonUtil.getJsonValue(rsData, "relationship-value")
- if(eKey.equals("configuration.configuration-id")){
- jObject.put("resourceInstanceId", eValue)
- }
- }
-
-
- //related-to-property
- String rPropertyStr = jsonUtil.getJsonValue(relation, "related-to-property")
- utils.log("INFO", "related-to-property: " + rPropertyStr, isDebugEnabled)
- if (rPropertyStr instanceof JSONArray){
- List<String> rPropertyList = jsonUtil.StringArrayToList(execution, rPropertyStr)
- for(String rProperty : rPropertyList){
- utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
- def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
- def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
- if(eKey.equals("configuration.configuration-type")){
- jObject.put("resourceType", eValue)
- }
- }
- }
- else {
- String rProperty = rPropertyStr
- utils.log("INFO", "rProperty: " + rProperty, isDebugEnabled)
- def eKey = jsonUtil.getJsonValue(rProperty, "property-key")
- def eValue = jsonUtil.getJsonValue(rProperty, "property-value")
- if(eKey.equals("configuration.configuration-type")){
- jObject.put("resourceType", eValue)
- }
- }
- allResources.put(jObject)
- utils.log("INFO", "allResources: " + allResources, isDebugEnabled)
-
- networkResources.put(jObject)
- utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled)
- }
- utils.log("INFO", "Get Next releation resource " , isDebugEnabled)
-
- }
- utils.log("INFO", "Get releation finished. " , isDebugEnabled)
- }
-
- execution.setVariable("serviceRelationShip", allResources.toString())
- utils.log("INFO", "allResources: " + allResources.toString(), isDebugEnabled)
- String serviceRelationShip = execution.getVariable("serviceRelationShip")
- utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled)
- if ((! isBlank(serviceRelationShip)) && (! serviceRelationShip.isEmpty())) {
-
- List<String> relationShipList = jsonUtil.StringArrayToList(execution, serviceRelationShip)
- utils.log("INFO", "relationShipList: " + relationShipList, isDebugEnabled)
- execution.setVariable(Prefix+"resourceList", relationShipList)
-
- int resourceCount = relationShipList.size()
- utils.log("INFO", "resourceCount: " + resourceCount, isDebugEnabled)
- execution.setVariable(Prefix+"resourceCount",resourceCount )
-
- int resourceNum = 0
- execution.setVariable(Prefix+"nextResource", resourceNum)
- utils.log("INFO", "start sort delete resource: ", isDebugEnabled)
- sortDeleteResource(execution)
-
-
- if (resourceNum < resourceCount) {
- execution.setVariable(Prefix+"resourceFinish", false)
- }
- else {
- execution.setVariable(Prefix+"resourceFinish", true)
- }
- utils.log("INFO", "Resource list set end : " + resourceCount, isDebugEnabled)
- }
-
- execution.setVariable("serviceResources", serviceResources.toString())
- utils.log("INFO", "serviceResources: " + serviceResources, isDebugEnabled)
- String serviceResourcesShip = execution.getVariable("serviceResources")
- utils.log("INFO", "serviceResourcesShip: " + serviceResourcesShip, isDebugEnabled)
-
- if ((! isBlank(serviceResourcesShip)) && (! serviceResourcesShip.isEmpty())) {
- List<String> serviceResourcesList = jsonUtil.StringArrayToList(execution, serviceResourcesShip)
- utils.log("INFO", "serviceResourcesList: " + serviceResourcesList, isDebugEnabled)
- execution.setVariable(Prefix+"serviceResourceList", serviceResourcesList)
- execution.setVariable(Prefix+"serviceResourceCount", serviceResourcesList.size())
- execution.setVariable(Prefix+"nextServiceResource", 0)
- utils.log("INFO", "Service Resource list set end : " + serviceResourcesList.size(), isDebugEnabled)
-
- }
-
- execution.setVariable("allottedResources", allottedResources.toString())
- utils.log("INFO", "allottedResources: " + allottedResources, isDebugEnabled)
- String allottedResourcesShip = execution.getVariable("allottedResources")
- utils.log("INFO", "allottedResourcesShip: " + allottedResourcesShip, isDebugEnabled)
- if ((! isBlank(allottedResourcesShip)) && (! allottedResourcesShip.isEmpty())) {
- List<String> allottedResourcesList = jsonUtil.StringArrayToList(execution, allottedResourcesShip)
- utils.log("INFO", "allottedResourcesList: " + allottedResourcesList, isDebugEnabled)
- execution.setVariable(Prefix+"allottedResourcesList", allottedResourcesList)
- execution.setVariable(Prefix+"allottedResourcesListCount", allottedResourcesList.size())
- execution.setVariable(Prefix+"nextAllottedResourcesList", 0)
- utils.log("INFO", "Allotted Resource list set end : " + allottedResourcesList.size(), isDebugEnabled)
-
- }
- execution.setVariable("networkResources", networkResources.toString())
- utils.log("INFO", "networkResources: " + networkResources, isDebugEnabled)
- String networkResourcesShip = execution.getVariable("networkResources")
- utils.log("INFO", "networkResourcesShip: " + networkResourcesShip, isDebugEnabled)
- if ((! isBlank(networkResourcesShip)) && (! networkResourcesShip.isEmpty())) {
- List<String> networkResourcesList = jsonUtil.StringArrayToList(execution, networkResourcesShip)
- utils.log("INFO", "networkResourcesList: " + networkResourcesList, isDebugEnabled)
- execution.setVariable(Prefix+"networkResourcesList", networkResourcesList)
- execution.setVariable(Prefix+"networkResourcesListCount", networkResourcesList.size())
- execution.setVariable(Prefix+"nextNetworkResourcesList", 0)
- utils.log("INFO", "Network Resource list set end : " + networkResourcesList.size(), isDebugEnabled)
-
- }
- }
- } catch (BpmnError e){
- throw e;
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in DeleteMobileAPNCustService flow. prepareServiceDeleteResource() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- private String getAaiAr(DelegateExecution execution, String relink) {
- def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink
-
- utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled)
- APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)
-
- int responseCode = response.getStatusCode()
- utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled)
-
- String aaiResponse = response.getResponseBodyAsString()
- utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled)
-
- if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {
- return null
- }
-
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- return aaiResponse
- }
- /**
- * prepare Decompose next resource to create request
- */
- public void preProcessDecomposeNextResource(DelegateExecution execution){
- def method = getClass().getSimpleName() + '.getAaiAr(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- utils.log("INFO", " ======== STARTED preProcessDecomposeNextResource Process ======== ", isDebugEnabled)
- try{
- int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
- List<String> serviceResourceList = execution.getVariable(Prefix+"serviceResourceList")
- utils.log("INFO", "Service Resource List : " + serviceResourceList, isDebugEnabled)
-
- String serviceResource = serviceResourceList[resourceNum]
- execution.setVariable(Prefix+"serviceResource", serviceResource)
- utils.log("INFO", "Current Service Resource : " + serviceResource, isDebugEnabled)
-
- String resourceType = jsonUtil.getJsonValue(serviceResource, "resourceType")
- execution.setVariable("resourceType", resourceType)
- utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled)
-
- String resourceInstanceId = jsonUtil.getJsonValue(serviceResource, "resourceInstanceId")
- execution.setVariable("resourceInstanceId", resourceInstanceId)
- utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled)
-
- String resourceRole = jsonUtil.getJsonValue(serviceResource, "resourceRole")
- execution.setVariable("resourceRole", resourceRole)
- utils.log("INFO", "resourceRole : " + resourceRole, isDebugEnabled)
-
- String resourceVersion = jsonUtil.getJsonValue(serviceResource, "resourceVersion")
- execution.setVariable("resourceVersion", resourceVersion)
- utils.log("INFO", "resourceVersion : " + resourceVersion, isDebugEnabled)
-
- String resourceName = jsonUtil.getJsonValue(serviceResource, "resourceName")
- if (isBlank(resourceName)){
- resourceName = resourceInstanceId
- }
- execution.setVariable(Prefix+"resourceName", resourceName)
- utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled)
-
-
- execution.setVariable(Prefix+"nextServiceResource", resourceNum + 1)
-
- int serviceResourceCount = execution.getVariable(Prefix+"serviceResourceCount")
- if (serviceResourceCount >0 ){
- int progress = (resourceNum*100) / serviceResourceCount
- execution.setVariable("progress", progress.toString() )
- }
- execution.setVariable("operationStatus", resourceName )
-
- }catch(Exception e){
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method preProcessDecomposeNextResource() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
- /**
- * post Decompose next resource to create request
- */
- public void postProcessDecomposeNextResource(DelegateExecution execution){
- def method = getClass().getSimpleName() + '.postProcessDecomposeNextResource(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- utils.log("INFO", " ======== STARTED postProcessDecomposeNextResource Process ======== ", isDebugEnabled)
- try{
- String resourceName = execution.getVariable(Prefix+"resourceName")
- int resourceNum = execution.getVariable(Prefix+"nextServiceResource")
- utils.log("DEBUG", "Current Resource count:"+ execution.getVariable(Prefix+"nextServiceResource"), isDebugEnabled)
-
- int resourceCount = execution.getVariable(Prefix+"serviceResourceCount")
- utils.log("DEBUG", "Total Resource count:"+ execution.getVariable(Prefix+"serviceResourceCount"), isDebugEnabled)
-
- if (resourceNum < resourceCount) {
- execution.setVariable(Prefix+"resourceFinish", false)
- }
- else {
- execution.setVariable(Prefix+"resourceFinish", true)
- }
-
- utils.log("DEBUG", "Resource Finished:"+ execution.getVariable(Prefix+"resourceFinish"), isDebugEnabled)
-
- if (resourceCount >0 ){
- int progress = (resourceNum*100) / resourceCount
-
- execution.setVariable("progress", progress.toString() )
- utils.log("DEBUG", "progress :"+ execution.getVariable("progress"), isDebugEnabled)
- }
- execution.setVariable("operationStatus", resourceName )
-
-
- }catch(Exception e){
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in CreateMobileAPNCustService flow. Unexpected Error from method postProcessDecomposeNextResource() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
- /**
- * prepare post Unkown Resource Type
- */
- public void postOtherControllerType(DelegateExecution execution){
- def method = getClass().getSimpleName() + '.postOtherControllerType(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- try{
-
- String resourceName = execution.getVariable(Prefix+"resourceName")
- String resourceType = execution.getVariable(Prefix+"resourceType")
- String controllerType = execution.getVariable("controllerType")
-
- String msg = "Resource name: "+ resourceName + " resource Type: " + resourceType+ " controller Type: " + controllerType + " can not be processed n the workflow"
- utils.log("DEBUG", msg, isDebugEnabled)
-
- }catch(Exception e){
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DoCreateMobileAPNServiceInstance flow. Unexpected Error from method postOtherControllerType() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- /**
- * prepare delete parameters
- */
- public void preSDNCResourceDelete(execution, resourceName){
- // we use resource instance ids for delete flow as resourceTemplateUUIDs
-
- def method = getClass().getSimpleName() + '.preSDNCResourceDelete(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- utils.log("INFO", " ======== STARTED preSDNCResourceDelete Process ======== ", isDebugEnabled)
- String networkResources = execution.getVariable("networkResources")
-
-
- execution.setVariable("foundResource", false)
- if (networkResources != null) {
- def jsonSlurper = new JsonSlurper()
- List relationShipList = jsonSlurper.parseText(networkResources)
- relationShipList.each {
- if(StringUtils.containsIgnoreCase(it.resourceType, resourceName)) {
- String resourceInstanceUUID = it.resourceInstanceId
- String resourceTemplateUUID = it.resourceInstanceId
- execution.setVariable("resourceTemplateId", resourceTemplateUUID)
- execution.setVariable("resourceInstanceId", resourceInstanceUUID)
- execution.setVariable("resourceType", resourceName)
- execution.setVariable("foundResource", true)
- utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled)
- }
- }
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
- public void preProcessSDNCDelete (DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessSDNCDelete(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- utils.log("INFO"," ***** preProcessSDNCDelete *****", isDebugEnabled)
- String msg = ""
-
- try {
- def serviceInstanceId = execution.getVariable("serviceInstanceId")
- def serviceInstanceName = execution.getVariable("serviceInstanceName")
- def callbackURL = execution.getVariable("sdncCallbackUrl")
- def requestId = execution.getVariable("msoRequestId")
- def serviceId = execution.getVariable("productFamilyId")
- def subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- def globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
-
- String serviceModelInfo = execution.getVariable("serviceModelInfo")
- def modelInvariantUuid = ""
- def modelVersion = ""
- def modelUuid = ""
- def modelName = ""
- if (!isBlank(serviceModelInfo))
- {
- modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
- modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion")
- modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid")
- modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName")
-
- if (modelInvariantUuid == null) {
- modelInvariantUuid = ""
- }
- if (modelVersion == null) {
- modelVersion = ""
- }
- if (modelUuid == null) {
- modelUuid = ""
- }
- if (modelName == null) {
- modelName = ""
- }
- }
- if (serviceInstanceName == null) {
- serviceInstanceName = ""
- }
- if (serviceId == null) {
- serviceId = ""
- }
-
- def siParamsXml = execution.getVariable("siParamsXml")
- def serviceType = execution.getVariable("serviceType")
- if (serviceType == null)
- {
- serviceType = ""
- }
-
- def sdncRequestId = UUID.randomUUID().toString()
-
- String sdncDelete =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
- <sdncadapter:MsoAction>${serviceType}</sdncadapter:MsoAction>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <source>MSO</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- <request-action>DeleteServiceInstance</request-action>
- </request-information>
- <service-information>
- <service-id>${serviceId}</service-id>
- <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
- <onap-model-information>
- <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid>
- <model-uuid>${modelUuid}</model-uuid>
- <model-version>${modelVersion}</model-version>
- <model-name>${modelName}</model-name>
- </onap-model-information>
- <service-instance-id>${serviceInstanceId}</service-instance-id>
- <subscriber-name/>
- <global-customer-id>${globalSubscriberId}</global-customer-id>
- </service-information>
- <service-request-input>
- <service-instance-name>${serviceInstanceName}</service-instance-name>
- ${siParamsXml}
- </service-request-input>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
- sdncDelete = utils.formatXml(sdncDelete)
- def sdncRequestId2 = UUID.randomUUID().toString()
- String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
- execution.setVariable("sdncDelete", sdncDelete)
- execution.setVariable("sdncDeactivate", sdncDeactivate)
- utils.log("INFO","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
- utils.log("INFO","sdncDelete:\n" + sdncDelete, isDebugEnabled)
-
- } catch (BpmnError e) {
- throw e;
- } catch(Exception ex) {
- msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- public void postProcessSDNCDelete(DelegateExecution execution, String response, String action) {
-
- def method = getClass().getSimpleName() + '.postProcessSDNCDelete(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- utils.log("INFO"," ***** postProcessSDNC " + action + " *****", isDebugEnabled)
- String msg = ""
-
- /*try {
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
- utils.log("INFO", "SDNCResponse: " + response, isDebugEnabled)
- utils.log("INFO", "workflowException: " + workflowException, isDebugEnabled)
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
- if(execution.getVariable(Prefix + 'sdncResponseSuccess') == "true"){
- utils.log("INFO","Good response from SDNC Adapter for service-instance " + action + "response:\n" + response, isDebugEnabled)
-
- }else{
- msg = "Bad Response from SDNC Adapter for service-instance " + action
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg)
- }
- } catch (BpmnError e) {
- throw e;
- } catch(Exception ex) {
- msg = "Exception in postProcessSDNC " + action + " Exception:" + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }*/
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- public void postProcessAAIDEL(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.postProcessAAIDEL(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled)
- String msg = ""
- try {
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator")
- if(!succInAAI){
- msg = "Error deleting Service-instance in AAI" + serviceInstanceId
- utils.log("INFO", msg, isDebugEnabled)
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- utils.logAudit("workflowException: " + workflowException)
- if(workflowException != null){
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
- }
- else
- {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
- }
- }
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
- /**
- * Init the service Operation Status
- */
- public void preUpdateServiceOperationStatus(DelegateExecution execution){
- def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = execution.getVariable("operationId")
- String serviceName = execution.getVariable("serviceInstanceName")
- String operationType = "DELETE"
- String userId = ""
- String result = "processing"
- String progress = execution.getVariable("progress")
- utils.log("INFO", "progress: " + progress , isDebugEnabled)
- if ("100".equalsIgnoreCase(progress))
- {
- result = "finished"
- }
- String reason = ""
- String operationContent = "Prepare service delete: " + execution.getVariable("operationStatus")
- utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceId)
- execution.setVariable("operationId", operationId)
- execution.setVariable("operationType", operationType)
-
- def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter")
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
- <serviceId>${serviceId}</serviceId>
- <operationId>${operationId}</operationId>
- <serviceName>${serviceName}</serviceName>
- <operationType>${operationType}</operationType>
- <userId>${userId}</userId>
- <result>${result}</result>
- <operationContent>${operationContent}</operationContent>
- <progress>${progress}</progress>
- <reason>${reason}</reason>
- </ns:updateServiceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload)
- utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled)
-
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage())
- }
- utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled)
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- public void preInitResourcesOperStatus(DelegateExecution execution){
- def method = getClass().getSimpleName() + '.preInitResourcesOperStatus(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
- String msg=""
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = execution.getVariable("operationId")
- String operationType = "DELETE"
- String resourceTemplateUUIDs = ""
- String result = "processing"
- String progress = "0"
- String reason = ""
- String operationContent = "Prepare service delete"
- utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceId)
- execution.setVariable("operationId", operationId)
- execution.setVariable("operationType", operationType)
-
- String serviceRelationShip = execution.getVariable("serviceRelationShip")
- utils.log("INFO", "serviceRelationShip: " + serviceRelationShip, isDebugEnabled)
- if (! isBlank(serviceRelationShip)) {
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
- List relationShipList = jsonSlurper.parseText(serviceRelationShip)
-
- if (relationShipList != null) {
- relationShipList.each {
- resourceTemplateUUIDs = resourceTemplateUUIDs + it.resourceInstanceId + ":"
- }
- }
- }
- def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
- <serviceId>${serviceId}</serviceId>
- <operationId>${operationId}</operationId>
- <operationType>${operationType}</operationType>
- <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
- </ns:initResourceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_initResOperStatusRequest", payload)
- utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
- utils.logAudit("DoCustomDeleteE2EServiceInstanceV2 Outgoing initResourceOperationStatus Request: " + payload)
-
- }catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Exception in DoCustomDeleteE2EServiceInstanceV2.preInitResourcesOperStatus. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
-
-
- /**
- * prepare delete parameters
- */
- public void preProcessVFCResourceDelete(execution){
- // we use resource instance ids for delete flow as resourceTemplateUUIDs
-
- def method = getClass().getSimpleName() + '.preProcessVFCResourceDelete(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- utils.log("INFO", " ======== STARTED preProcessVFCResourceDelete Process ======== ", isDebugEnabled)
- try{
- String serviceResource = execution.getVariable("serviceResource")
- utils.log("INFO", "serviceResource : " + serviceResource, isDebugEnabled)
-
- String resourceInstanceId = execution.getVariable("resourceInstanceId")
- utils.log("INFO", "resourceInstanceId : " + resourceInstanceId, isDebugEnabled)
-
- execution.setVariable("resourceTemplateId", resourceInstanceId)
- utils.log("INFO", "resourceTemplateId : " + resourceInstanceId, isDebugEnabled)
-
- String resourceType = execution.getVariable("resourceType")
- utils.log("INFO", "resourceType : " + resourceType, isDebugEnabled)
-
-
- String resourceName = execution.getVariable(Prefix+"resourceName")
- if (isBlank(resourceName)){
- resourceName = resourceInstanceId
- }
- execution.setVariable("resourceName", resourceName)
- utils.log("INFO", "resource Name : " + resourceName, isDebugEnabled)
-
- utils.log("INFO", "Delete Resource Info: resourceInstanceId :" + resourceInstanceId + " resourceTemplateId: " + resourceInstanceId + " resourceType: " + resourceType, isDebugEnabled)
- }catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Exception in DoDeleteE2EServiceInstance.preProcessVFCResourceDelete. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- public void postProcessVFCDelete(DelegateExecution execution, String response, String action) {
- def method = getClass().getSimpleName() + '.postProcessVFCDelete(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
-
- utils.log("INFO", " ======== STARTED postProcessVFCDelete Process ======== ", isDebugEnabled)
- try{
-
- }catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Exception in DoDeleteE2EServiceInstance.postProcessVFCDelete. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-}
-
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy deleted file mode 100644 index bbf61744a8..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteE2EServiceInstance.groovy +++ /dev/null @@ -1,486 +0,0 @@ -/*- - * ============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.infrastructure.scripts - -import org.apache.http.HttpResponse -import org.json.JSONArray -import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient -import org.openecomp.mso.bpmn.common.recipe.ResourceInput -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.List; -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource - -import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def; - -/** - * This groovy class supports the <class>DoDeleteE2EServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - O - * @param - subscriptionServiceType - O - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion - * @param - failNotFound - TODO - * @param - serviceInputParams - TODO - * - * @param - delResourceList - * @param - serviceRelationShip - * - * Outputs: - * @param - WorkflowException - * - * Rollback - Deferred - */ -public class DoDeleteE2EServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DDEESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) - String msg = "" - - try { - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("prefix",Prefix) - - //Inputs - //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology - String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - if (globalSubscriberId == null) - { - execution.setVariable("globalSubscriberId", "") - } - - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology - String serviceType = execution.getVariable("serviceType") - if (serviceType == null) - { - execution.setVariable("serviceType", "") - } - - //Generated in parent for AAI PUT - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - StringBuilder sbParams = new StringBuilder() - Map<String, String> paramsMap = execution.getVariable("serviceInputParams") - if (paramsMap != null) - { - sbParams.append("<service-input-parameters>") - for (Map.Entry<String, String> entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ <param> - <name>${paramName}</name> - <value>${paramValue}</value> - </param> - """ - sbParams.append(paramsXml) - } - sbParams.append("</service-input-parameters>") - } - String siParamsXml = sbParams.toString() - if (siParamsXml == null) - siParamsXml = "" - execution.setVariable("siParamsXml", siParamsXml) - - } 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) - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - String serviceType = "" - - if(foundInAAI){ - utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) - - String siData = execution.getVariable("GENGS_service") - utils.log("INFO", "SI Data", isDebugEnabled) - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - InputSource source = new InputSource(new StringReader(siData)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document serviceXml = docBuilder.parse(source) - serviceXml.getDocumentElement().normalize() - // get model invariant id - // Get Template uuid and version - if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { - utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled) - def modelInvariantId = serviceXml.getElementsByTagName("model-invariant-id").item(0).getTextContent() - def modelVersionId = serviceXml.getElementsByTagName("model-version-id").item(0).getTextContent() - - // Set Original Template info - execution.setVariable("model-invariant-id-original", modelInvariantId) - execution.setVariable("model-version-id-original", modelVersionId) - } - - utils.log("INFO", "SI Data" + siData, isDebugEnabled) - //Confirm there are no related service instances (vnf/network or volume) - if (utils.nodeExists(siData, "relationship-list")) { - utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled) - //test(siData) - NodeList nodeList = serviceXml.getElementsByTagName("relationship") - JSONArray jArray = new JSONArray() - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() //for ns - if(e.equals("service-instance")){ - def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() - utils.log("INFO", "ServiceInstance Related NS :" + relatedObject, isDebugEnabled) - NodeList dataList = node.getChildNodes() - if(null != dataList) { - JSONObject jObj = new JSONObject() - for (int i = 0; i < dataList.getLength(); i++) { - Node dNode = dataList.item(i) - if(dNode.getNodeName() == "relationship-data") { - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() - if(eKey.equals("service-instance.service-instance-id")){ - jObj.put("resourceInstanceId", eValue) - } - - } - else if(dNode.getNodeName() == "related-to-property"){ - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() - if(eKey.equals("service-instance.service-instance-name")){ - jObj.put("resourceType", eValue) - } - } - } - utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) - jArray.put(jObj) - } - //for overlay/underlay - }else if (e.equals("configuration")){ - def relatedObject = eElement.getElementsByTagName("related-link").item(0).getTextContent() - utils.log("INFO", "ServiceInstance Related Configuration :" + relatedObject, isDebugEnabled) - NodeList dataList = node.getChildNodes() - if(null != dataList) { - JSONObject jObj = new JSONObject() - for (int i = 0; i < dataList.getLength(); i++) { - Node dNode = dataList.item(i) - if(dNode.getNodeName() == "relationship-data") { - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("relationship-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("relationship-value").item(0).getTextContent() - if(eKey.equals("configuration.configuration-id")){ - jObj.put("resourceInstanceId", eValue) - } - } - else if(dNode.getNodeName() == "related-to-property"){ - Element rDataEle = (Element)dNode - def eKey = rDataEle.getElementsByTagName("property-key").item(0).getTextContent() - def eValue = rDataEle.getElementsByTagName("property-value").item(0).getTextContent() - if(eKey.equals("configuration.configuration-type")){ - jObj.put("resourceType", eValue) - } - } - } - utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) - jArray.put(jObj) - } - } - } - } - execution.setVariable("serviceRelationShip", jArray.toString()) - } - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - - utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) - } - }catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void getCurrentNS(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start getCurrentNS Process ======== ", isDebugEnabled) - - def currentIndex = execution.getVariable("currentNSIndex") - List<String> nsSequence = execution.getVariable("nsSequence") - String nsResourceType = nsSequence.get(currentIndex) - - // GET AAI by Name, not ID, for process convenient - execution.setVariable("GENGS_type", "service-instance") - execution.setVariable("GENGS_serviceInstanceId", "") - execution.setVariable("GENGS_serviceInstanceName", nsResourceType) - - utils.log("INFO", "======== COMPLETED getCurrentNS Process ======== ", isDebugEnabled) - } - - public void prepareDecomposeService(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) - String modelInvariantUuid = execution.getVariable("model-invariant-id-original") - String modelVersionId = execution.getVariable("model-version-id-original") - - String serviceModelInfo = """{ - "modelInvariantUuid":"${modelInvariantUuid}", - "modelUuid":"${modelVersionId}", - "modelVersion":"" - }""" - execution.setVariable("serviceModelInfo", serviceModelInfo) - - utils.log("DEBUG", " ***** Completed prepareDecomposeService of create generic e2e service ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void postDecomposeService(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside processDecomposition() of delete generic e2e service flow ***** ", isDebugEnabled) - try { - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - // service model info - execution.setVariable("serviceModelInfo", serviceDecomposition.getModelInfo()) - - List<Resource> deleteResourceList = serviceDecomposition.getServiceResources() - String serviceRelationShip = execution.getVariable("serviceRelationShip") - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - - List relationShipList = null - if (serviceRelationShip != null) { - relationShipList = jsonSlurper.parseText(serviceRelationShip) - } - - //Set the real resource instance id to the decomosed resource list - for (Resource resource: deleteResourceList) { - //reset the resource instance id , because in the decompose flow ,its a random one. - resource.setResourceId(""); - //match the resource-instance-name and the model name - if (relationShipList != null) { - relationShipList.each { - if (StringUtils.containsIgnoreCase(it.resourceType, resource.getModelInfo().getModelName())) { - resource.setResourceId(it.resourceInstanceId); - } - } - } - } - execution.setVariable("deleteResourceList", deleteResourceList) - utils.log("DEBUG", "delete resource list : " + deleteResourceList, isDebugEnabled) - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in create generic e2e service flow. processDecomposition() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - utils.log("DEBUG", " ***** exit processDecomposition() of delete generic e2e service flow ***** ", isDebugEnabled) - } - - public void preInitResourcesOperStatus(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = execution.getVariable("operationType") - String resourceTemplateUUIDs = "" - String result = "processing" - String progress = "0" - String reason = "" - String operationContent = "Prepare service creation" - utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - List<Resource> deleteResourceList = execution.getVariable("deleteResourceList") - - String serviceRelationShip = execution.getVariable("serviceRelationShip") - for(Resource resource : deleteResourceList){ - resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":" - } - - - execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs> - </ns:initResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_initResOperStatusRequest", payload) - utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) - utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) - } - utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - } - - public void postProcessAAIDEL(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIDEL ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") - if(!succInAAI){ - msg = "Error deleting Service-instance in AAI" + serviceInstanceId - utils.log("INFO", msg, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIDEL *** ", isDebugEnabled) - } - - /** - * post config request. - */ - public void postConfigRequest(execution){ - //to do - } - -} -
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy deleted file mode 100644 index 023c80b3ba..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy +++ /dev/null @@ -1,1076 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -import groovy.xml.XmlUtil -import groovy.json.* - -public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { - String Prefix= "DELNWKI_" - String groovyClassName = "DoDeleteNetworkInstance" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "networkRequest", "") - execution.setVariable(Prefix + "isSilentSuccess", false) - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "requestId", "") - execution.setVariable(Prefix + "source", "") - execution.setVariable(Prefix + "lcpCloudRegion", "") - execution.setVariable(Prefix + "networkInputs", "") - execution.setVariable(Prefix + "tenantId", "") - - execution.setVariable(Prefix + "queryAAIRequest","") - execution.setVariable(Prefix + "queryAAIResponse", "") - execution.setVariable(Prefix + "aaiReturnCode", "") - execution.setVariable(Prefix + "isAAIGood", false) - execution.setVariable(Prefix + "isVfRelationshipExist", false) - - // AAI query Cloud Region - execution.setVariable(Prefix + "queryCloudRegionRequest","") - execution.setVariable(Prefix + "queryCloudRegionReturnCode","") - execution.setVariable(Prefix + "queryCloudRegionResponse","") - execution.setVariable(Prefix + "cloudRegionPo","") - execution.setVariable(Prefix + "cloudRegionSdnc","") - - execution.setVariable(Prefix + "deleteNetworkRequest", "") - execution.setVariable(Prefix + "deleteNetworkResponse", "") - execution.setVariable(Prefix + "networkReturnCode", "") - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - - execution.setVariable(Prefix + "deleteSDNCRequest", "") - execution.setVariable(Prefix + "deleteSDNCResponse", "") - execution.setVariable(Prefix + "sdncReturnCode", "") - execution.setVariable(Prefix + "sdncResponseSuccess", false) - - execution.setVariable(Prefix + "deactivateSDNCRequest", "") - execution.setVariable(Prefix + "deactivateSDNCResponse", "") - execution.setVariable(Prefix + "deactivateSdncReturnCode", "") - execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", "") - - execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", "") - execution.setVariable(Prefix + "isException", false) - - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of " + groovyClassName + " Request ***** ", isDebugEnabled) - - // initialize flow variables - InitializeProcessVariables(execution) - - try { - // get incoming message/input - execution.setVariable("action", "DELETE") - String deleteNetwork = execution.getVariable("bpmnRequest") - if (deleteNetwork != null) { - if (deleteNetwork.contains("requestDetails")) { - // JSON format request is sent, create xml - try { - def prettyJson = JsonOutput.prettyPrint(deleteNetwork.toString()) - utils.log("DEBUG", " Incoming message formatted . . . : " + '\n' + prettyJson, isDebugEnabled) - deleteNetwork = vidUtils.createXmlNetworkRequestInfra(execution, deleteNetwork) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } else { - // XML format request is sent - - } - } else { - // vIPR format request is sent, create xml from individual variables - deleteNetwork = vidUtils.createXmlNetworkRequestInstance(execution) - } - - deleteNetwork = utils.formatXml(deleteNetwork) - utils.logAudit(deleteNetwork) - execution.setVariable(Prefix + "networkRequest", deleteNetwork) - utils.log("DEBUG", Prefix + "networkRequest - " + '\n' + deleteNetwork, isDebugEnabled) - - // validate 'backout-on-failure' to override 'URN_mso_rollback' - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, deleteNetwork) - execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) - utils.log("DEBUG", Prefix + "rollbackEnabled - " + rollbackEnabled, isDebugEnabled) - - String networkInputs = utils.getNodeXml(deleteNetwork, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable(Prefix + "networkInputs", networkInputs) - - // prepare messageId - String messageId = execution.getVariable("testMessageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - utils.log("DEBUG", Prefix + "messageId, random generated: " + messageId, isDebugEnabled) - } else { - utils.log("DEBUG", Prefix + "messageId, pre-assigned: " + messageId, isDebugEnabled) - } - execution.setVariable(Prefix + "messageId", messageId) - - String source = utils.getNodeText1(deleteNetwork, "source") - execution.setVariable(Prefix + "source", source) - utils.log("DEBUG", Prefix + "source - " + source, isDebugEnabled) - - String networkId = "" - if (utils.nodeExists(networkInputs, "network-id")) { - networkId = utils.getNodeText1(networkInputs, "network-id") - if (networkId == null || networkId == "" || networkId == 'null' ) { - sendSyncError(execution) - // missing value of network-id - String dataErrorMessage = "network-request has missing 'network-id' element/value." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - // lcpCloudRegion or tenantId not sent, will be extracted from query AA&I - def lcpCloudRegion = null - if (utils.nodeExists(networkInputs, "aic-cloud-region")) { - lcpCloudRegion = utils.getNodeText1(networkInputs, "aic-cloud-region") - if (lcpCloudRegion == 'null') { - lcpCloudRegion = null - } - } - execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) - utils.log("DEBUG", "lcpCloudRegion : " + lcpCloudRegion, isDebugEnabled) - - String tenantId = null - if (utils.nodeExists(networkInputs, "tenant-id")) { - tenantId = utils.getNodeText1(networkInputs, "tenant-id") - if (tenantId == 'null') { - tenantId = null - } - - } - execution.setVariable(Prefix + "tenantId", tenantId) - utils.log("DEBUG", "tenantId : " + tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled) - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - // caught exception - String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void callRESTQueryAAI (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAI() of DoDoDeleteNetworkInstance ***** " , isDebugEnabled) - - // get variables - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String networkId = utils.getNodeText(networkInputs, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - utils.logAudit(queryAAIRequest) - execution.setVariable(Prefix + "queryAAIRequest", queryAAIRequest) - utils.log("DEBUG", Prefix + "AAIRequest - " + "\n" + queryAAIRequest, isDebugEnabled) - - RESTConfig config = new RESTConfig(queryAAIRequest); - - ExceptionUtil exceptionUtil = new ExceptionUtil() - Boolean isVfRelationshipExist = false - try { - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiReturnCode", returnCode) - - utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString) - execution.setVariable(Prefix + "queryAAIResponse", aaiResponseAsString) - - if (returnCode=='200' || returnCode=='204') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "isAAIGood", true) - utils.log("DEBUG", " AAI Query Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - // verify if vf or vnf relationship exist - if (utils.nodeExists(aaiResponseAsString, "relationship")) { - NetworkUtils networkUtils = new NetworkUtils() - isVfRelationshipExist = networkUtils.isVfRelationshipExist(aaiResponseAsString) - execution.setVariable(Prefix + "isVfRelationshipExist", isVfRelationshipExist) - if (isVfRelationshipExist) { - String relationshipMessage = "AAI Query Success Response but 'vf-module' relationship exist, not allowed to delete: network Id: " + networkId - exceptionUtil.buildWorkflowException(execution, 2500, relationshipMessage) - - } else { - // verify if lcpCloudRegion was sent as input, if not get value from AAI Response - if (execution.getVariable(Prefix + "lcpCloudRegion") == null ) { - String lcpCloudRegion = networkUtils.getCloudRegion(aaiResponseAsString) - execution.setVariable(Prefix + "lcpCloudRegion", lcpCloudRegion) - utils.log("DEBUG", " Get AAI getCloudRegion() : " + lcpCloudRegion, isDebugEnabled) - } - if (execution.getVariable(Prefix + "tenantId") == null ) { - String tenantId = networkUtils.getTenantId(aaiResponseAsString) - execution.setVariable(Prefix + "tenantId", tenantId) - utils.log("DEBUG", " Get AAI getTenantId() : " + tenantId, isDebugEnabled) - } - - } - } - utils.log("DEBUG", Prefix + "isVfRelationshipExist - " + isVfRelationshipExist, isDebugEnabled) - - } else { - execution.setVariable(Prefix + "isAAIGood", false) - if (returnCode=='404' || aaiResponseAsString == "" || aaiResponseAsString == null) { - // not found // empty aai response - execution.setVariable(Prefix + "isSilentSuccess", true) - utils.log("DEBUG", " AAI Query is Silent Success", isDebugEnabled) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Error Response from callRESTQueryAAI() - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - utils.log("DEBUG", " AAI Query call, isAAIGood? : " + execution.getVariable(Prefix + "isAAIGood"), isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Exception Encountered in DoDeleteNetworkInstance, callRESTQueryAAI() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAICloudRegion (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of DoDeleteNetworkInstance ***** " , isDebugEnabled) - - try { - String networkInputs = execution.getVariable(Prefix + "networkInputs") - // String cloudRegion = utils.getNodeText(networkInputs, "aic-cloud-region") - String cloudRegion = execution.getVariable(Prefix + "lcpCloudRegion") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - utils.logAudit(queryCloudRegionRequest) - execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - utils.log("DEBUG", Prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled) - - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) - execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) - - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, callRESTQueryAAICloudRegion(). Unexpected Response from AAI - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareNetworkRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareNetworkRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled) - ExceptionUtil exceptionUtil = new ExceptionUtil() - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String cloudSiteId = execution.getVariable(Prefix + "cloudRegionPo") - String tenantId = execution.getVariable(Prefix + "tenantId") - - String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - String networkType = utils.getNodeText1(queryAAIResponse, "network-type") - String networkId = utils.getNodeText1(queryAAIResponse, "network-id") - String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") - - String networkStackId = "" - networkStackId = utils.getNodeText1(queryAAIResponse, "heat-stack-id") - if (networkStackId == 'null' || networkStackId == "" || networkStackId == null) { - networkStackId = "force_delete" - } - - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // Added new Elements - String messageId = execution.getVariable(Prefix + "messageId") - String notificationUrl = "" //TODO - is this coming from URN? What variable/value to use? - //String notificationUrl = execution.getVariable("URN_?????") //TODO - is this coming from URN? What variable/value to use? - - String modelCustomizationUuid = "" - if (utils.nodeExists(networkRequest, "networkModelInfo")) { - String networkModelInfo = utils.getNodeXml(networkRequest, "networkModelInfo", false).replace("tag0:","").replace(":tag0","") - modelCustomizationUuid = utils.getNodeText1(networkModelInfo, "modelCustomizationUuid") - } else { - modelCustomizationUuid = utils.getNodeText1(networkRequest, "modelCustomizationId") - } - - String deleteNetworkRequest = """ - <deleteNetworkRequest> - <cloudSiteId>${cloudSiteId}</cloudSiteId> - <tenantId>${tenantId}</tenantId> - <networkId>${networkId}</networkId> - <networkStackId>${networkStackId}</networkStackId> - <networkType>${networkType}</networkType> - <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid> - <skipAAI>true</skipAAI> - <msoRequest> - <requestId>${requestId}</requestId> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - </msoRequest> - <messageId>${messageId}</messageId> - <notificationUrl>${notificationUrl}</notificationUrl> - </deleteNetworkRequest> - """.trim() - - utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + deleteNetworkRequest, isDebugEnabled) - // Format Response - String buildDeleteNetworkRequestAsString = utils.formatXml(deleteNetworkRequest) - utils.logAudit(buildDeleteNetworkRequestAsString) - utils.log("DEBUG", Prefix + "deleteNetworkRequestAsString - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled) - - String restURL = execution.getVariable("URN_mso_adapters_network_rest_endpoint") - execution.setVariable("URN_mso_adapters_network_rest_endpoint", restURL + "/" + networkId) - utils.log("DEBUG", "URN_mso_adapters_network_rest_endpoint - " + "\n" + restURL + "/" + networkId, isDebugEnabled) - - execution.setVariable(Prefix + "deleteNetworkRequest", buildDeleteNetworkRequestAsString) - utils.log("DEBUG", Prefix + "deleteNetworkRequest - " + "\n" + buildDeleteNetworkRequestAsString, isDebugEnabled) - } - catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareNetworkRequest(). Unexpected Response from AAI - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - /** - * This method is used instead of an HTTP Connector task because the - * connector does not allow DELETE with a body. - */ - public void sendRequestToVnfAdapter(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + - 'execution=' + execution.getId() + - ')' - def isDebugEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugEnabled) - - try { - - String vnfAdapterUrl = execution.getVariable("URN_mso_adapters_network_rest_endpoint") - String vnfAdapterRequest = execution.getVariable(Prefix + "deleteNetworkRequest") - - RESTConfig config = new RESTConfig(vnfAdapterUrl) - RESTClient client = new RESTClient(config). - addHeader("Content-Type", "application/xml"). - addAuthorizationHeader(execution.getVariable("BasicAuthHeaderValuePO")); - - APIResponse response; - - response = client.httpDelete(vnfAdapterRequest) - - execution.setVariable(Prefix + "networkReturnCode", response.getStatusCode()) - execution.setVariable(Prefix + "deleteNetworkResponse", response.getResponseBodyAsString()) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, sendRequestToVnfAdapter() - " + ex.getMessage() - logError(exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - - public void prepareSDNCRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText1(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - - String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - utils.log("DEBUG", Prefix + "requestId " + requestId, isDebugEnabled) - String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "delete", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) - utils.logAudit(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) - utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() - logError(exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCRequest of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText1(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - - String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "unassign", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - utils.logAudit(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "deleteSDNCRequest", sndcTopologyDeleteRequesAsString) - utils.log("DEBUG", Prefix + "deleteSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRequest() - " + ex.getMessage() - logError(exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void prepareRpcSDNCDeactivate(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivate() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText1(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "deactivate", "DeleteNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "deactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - utils.log("DEBUG", " Preparing request for RPC SDNC Topology deactivate - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCActivateRollback() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void validateNetworkResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateNetworkResponse of DoDeleteNetworkInstance *****", isDebugEnabled) - - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "deleteNetworkResponse") - - utils.log("DEBUG", " Network Adapter responseCode: " + returnCode, isDebugEnabled) - utils.log("DEBUG", "Network Adapter Response - " + "\n" + networkResponse, isDebugEnabled) - utils.logAudit(networkResponse) - - String errorMessage = "" - if (returnCode == "200") { - utils.log("DEBUG", " Network Adapter Response is successful - " + "\n" + networkResponse, isDebugEnabled) - - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - if ((rollbackData == null) || (rollbackData.isEmpty())) { - utils.log("DEBUG", " Network Adapter 'rollback' data is not Sent: " + "\n" + networkResponse, isDebugEnabled) - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - } else { - String rollbackNetwork = - """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network"> - ${rollbackData} - </NetworkAdapter:rollbackNetwork>""" - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) - utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled) - } - - - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("deleteNetworkError") ) { - networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '') - errorMessage = utils.getNodeText1(networkResponse, "message") - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } else { // CatchAll exception - if (returnCode == "500") { - errorMessage = "JBWEB000065: HTTP Status 500." - } else { - errorMessage = "Return code is " + returnCode - } - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } - - } else { // CatchAll exception - String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, validateNetworkResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void validateSDNCResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateSDNCResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - String response = execution.getVariable(Prefix + "deleteSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String deleteSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deleteSDNCResponse")) - deleteSDNCResponseDecodeXml = deleteSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "deleteSDNCResponse", deleteSDNCResponseDecodeXml) - - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncRollbackNeeded", true) // - execution.setVariable(Prefix + "isPONR", true) - utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled) - } else { - utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } - - public void validateRpcSDNCDeactivateResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside validateRpcSDNCDeactivateResponse() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - String response = execution.getVariable(Prefix + "deactivateSDNCResponse") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - WorkflowException workflowException = execution.getVariable("WorkflowException") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String assignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "deactivateSDNCResponse")) - assignSDNCResponseDecodeXml = assignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "deactivateSDNCResponse", assignSDNCResponseDecodeXml) - - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, Prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncDeactivateRollbackNeeded", true) - utils.log("DEBUG", "Successfully Validated Rpc SDNC Activate Response", isDebugEnabled) - - } else { - utils.log("DEBUG", "Did NOT Successfully Validated Rpc SDNC Deactivate Response", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } - - public void prepareRpcSDNCDeactivateRollback(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCDeactivateRollback() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String deactivateSDNCResponse = execution.getVariable(Prefix + "deactivateSDNCResponse") - String networkId = utils.getNodeText1(deactivateSDNCResponse, "network-id") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "activate", "CreateNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyRollbackRpcRequestAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", sndcTopologyRollbackRpcRequestAsString) - utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'activate-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyRollbackRpcRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCDeactivateRollback() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRollbackData(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") - if (rollbackDeactivateSDNCRequest != null) { - if (rollbackDeactivateSDNCRequest != "") { - rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled) - - execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) - utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void postProcessResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled) - if (execution.getVariable(Prefix + "isException") == false) { - execution.setVariable(Prefix + "Success", true) - execution.setVariable("WorkflowException", null) - if (execution.getVariable(Prefix + "isSilentSuccess") == true) { - execution.setVariable("rolledBack", false) - } else { - execution.setVariable("rolledBack", true) - } - prepareSuccessRollbackData(execution) // populate rollbackData - - } else { - execution.setVariable(Prefix + "Success", false) - execution.setVariable("rollbackData", null) - String exceptionMessage = " Exception encountered in MSO Bpmn. " - if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. - utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled) - WorkflowException wfex = execution.getVariable("workflowException") - exceptionMessage = wfex.getErrorMessage() - } else { - if (execution.getVariable(Prefix + "WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } else { - if (execution.getVariable("WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable("WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } - } - } - - // going to the Main flow: a-la-carte or macro - utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - - } - - } catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - - } - - } - - public void prepareSuccessRollbackData(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - if (execution.getVariable("sdncVersion") != '1610') { - prepareRpcSDNCDeactivateRollback(execution) - prepareRpcSDNCUnassignRollback(execution) - } else { - prepareSDNCRollback(execution) - } - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - String rollbackDeactivateSDNCRequest = execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") - if (rollbackDeactivateSDNCRequest != null) { - if (rollbackDeactivateSDNCRequest != "") { - rollbackData.put("rollbackDeactivateSDNCRequest", execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled) - execution.setVariable("WorkflowException", null) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRpcSDNCUnassignRollback(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRpcSDNCUnassignRollbac() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String deleteSDNCResponse = execution.getVariable(Prefix + "deleteSDNCResponse") - String networkId = utils.getNodeText1(deleteSDNCResponse, "network-id") - if (networkId == 'null') {networkId = ""} - String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRpcRequest = sdncAdapterUtils.sdncTopologyRequestRsrc(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "assign", "CreateNetworkInstance", cloudRegionId, networkId, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyRollbackRpcRequest) - utils.logAudit(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) - utils.log("DEBUG", Prefix + "rollbackSDNCRequest" + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'assign-CreateNetworkInstance' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstance flow. prepareRpcSDNCUnassignRollback() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareSDNCRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRollback of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String deleteNetworkInput = execution.getVariable(Prefix + "networkRequest") - - String networkId = "" - if (utils.nodeExists(deleteNetworkInput, "network-id")) { - networkId = utils.getNodeText1(deleteNetworkInput, "network-id") - } - if (networkId == 'null') {networkId = ""} - - String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - - // get/set 'msoRequestId' and 'mso-request-id' - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - - String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - // 1. prepare delete topology via SDNC Adapter SUBFLOW call - String sndcTopologyDeleteRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, deleteNetworkInput, serviceInstanceId, sdncCallback, "rollback", "DisconnectNetworkRequest", cloudRegionId, networkId, queryAAIResponse, null) - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) - utils.logAudit(sndcTopologyDeleteRequesAsString) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyDeleteRequesAsString) - utils.log("DEBUG", Prefix + "rollbackSDNCRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - utils.log("DEBUG", " Preparing request for RPC SDNC Topology 'rollback-DisconnectNetworkRequest' rollback . . . - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - // caught exception - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance, prepareSDNCRollback() - " + ex.getMessage() - logError(exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void setExceptionFlag(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoDeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - execution.setVariable(Prefix + "isException", true) - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled) - - } catch(Exception ex){ - String exceptionMessage = "Bpmn error encountered in DoDeleteNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method of " + Prefix, isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy deleted file mode 100644 index c45b90f953..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstanceRollback.groovy +++ /dev/null @@ -1,335 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-
-/**
- * This groovy class supports the <class>DoCreateNetworkInstanceRollback.bpmn</class> process.
- *
- */
-public class DoDeleteNetworkInstanceRollback extends AbstractServiceTaskProcessor {
- String Prefix="DELNWKIR_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils(this)
- NetworkUtils networkUtils = new NetworkUtils()
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
-
- def className = getClass().getSimpleName()
-
- /**
- * This method is executed during the preProcessRequest task of the <class>DoDeleteNetworkInstanceRollback.bpmn</class> process.
- * @param execution
- */
- public InitializeProcessVariables(DelegateExecution execution){
- /* Initialize all the process variables in this block */
-
- execution.setVariable(Prefix + "WorkflowException", null)
-
- execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", null)
- execution.setVariable(Prefix + "rollbackDeactivateSDNCResponse", "")
- execution.setVariable(Prefix + "rollbackDeactivateSDNCReturnCode", "")
-
- execution.setVariable(Prefix + "rollbackSDNCRequest", "")
- execution.setVariable(Prefix + "rollbackSDNCResponse", "")
- execution.setVariable(Prefix + "rollbackSDNCReturnCode", "")
-
- execution.setVariable(Prefix + "rollbackNetworkRequest", null)
- execution.setVariable(Prefix + "rollbackNetworkResponse", "")
- execution.setVariable(Prefix + "rollbackNetworkReturnCode", "")
-
- execution.setVariable(Prefix + "Success", false)
- execution.setVariable(Prefix + "fullRollback", false)
-
- }
-
- // **************************************************
- // Pre or Prepare Request Section
- // **************************************************
- /**
- * This method is executed during the preProcessRequest task of the <class>DoDeleteNetworkInstanceRollback.bpmn</class> process.
- * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside preProcessRequest() of " + className + ".groovy ***** ", isDebugEnabled)
-
- try {
- // initialize flow variables
- InitializeProcessVariables(execution)
-
- // GET Incoming request/variables
- String rollbackDeactivateSDNCRequest = null
- String rollbackSDNCRequest = null
- String rollbackNetworkRequest = null
-
- Map<String, String> rollbackData = execution.getVariable("rollbackData")
- if (rollbackData != null && rollbackData instanceof Map) {
-
- if(rollbackData.containsKey("rollbackDeactivateSDNCRequest")) {
- rollbackDeactivateSDNCRequest = rollbackData["rollbackDeactivateSDNCRequest"]
- }
-
- if(rollbackData.containsKey("rollbackSDNCRequest")) {
- rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"]
- }
-
- if(rollbackData.containsKey("rollbackNetworkRequest")) {
- rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"]
- }
- }
-
- execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest)
- execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest)
- execution.setVariable(Prefix + "rollbackDeactivateSDNCRequest", rollbackDeactivateSDNCRequest)
- utils.log("DEBUG", "'rollbackData': " + '\n' + execution.getVariable("rollbackData"), isDebugEnabled)
-
- String sdncVersion = execution.getVariable("sdncVersion")
- utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled)
-
- // PO Authorization Info / headers Authorization=
- String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth")
- utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled)
- try {
- def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey"))
- execution.setVariable("BasicAuthHeaderValuePO",encodedString)
- execution.setVariable("BasicAuthHeaderValueSDNC", encodedString)
-
- } catch (IOException ex) {
- String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - "
- String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage()
- utils.log("DEBUG", dataErrorMessage , isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- }
-
- if (execution.getVariable("SavedWorkflowException1") != null) {
- execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1"))
- } else {
- execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException"))
- }
- utils.log("DEBUG", "*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled)
- if(execution.getVariable(Prefix + "WorkflowException") != null) {
- // called by: DoCreateNetworkInstance, partial rollback
- execution.setVariable(Prefix + "fullRollback", false)
-
- } else {
- // called by: Macro - Full Rollback, WorkflowException = null
- execution.setVariable(Prefix + "fullRollback", true)
-
- }
-
- utils.log("DEBUG", "*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"), isDebugEnabled)
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- sendSyncError(execution)
- // caught exception
- String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- public void validateRollbackResponses (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside validateRollbackResponses() of DoDeleteNetworkInstanceRollback ***** ", isDebugEnabled)
-
- try {
-
- // validate SDNC activate response
- String rollbackDeactivateSDNCMessages = ""
- String rollbackDeactivateSDNCReturnCode = "200"
- if (execution.getVariable(Prefix + "rollbackDeactivateSDNCRequest") != null) {
- rollbackDeactivateSDNCReturnCode = execution.getVariable(Prefix + "rollbackDeactivateSDNCReturnCode")
- String rollbackDeactivateSDNCResponse = execution.getVariable(Prefix + "rollbackDeactivateSDNCResponse")
- String rollbackDeactivateSDNCReturnInnerCode = ""
- rollbackDeactivateSDNCResponse = sdncAdapterUtils.decodeXML(rollbackDeactivateSDNCResponse)
- rollbackDeactivateSDNCResponse = rollbackDeactivateSDNCResponse.replace("&", "&").replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- if (rollbackDeactivateSDNCReturnCode == "200") {
- if (utils.nodeExists(rollbackDeactivateSDNCResponse, "response-code")) {
- rollbackDeactivateSDNCReturnInnerCode = utils.getNodeText1(rollbackDeactivateSDNCResponse, "response-code")
- if (rollbackDeactivateSDNCReturnInnerCode == "200" || rollbackDeactivateSDNCReturnInnerCode == "" || rollbackDeactivateSDNCReturnInnerCode == "0") {
- rollbackDeactivateSDNCMessages = " + SNDC deactivate rollback completed."
- } else {
- rollbackDeactivateSDNCMessages = " + SDNC deactivate rollback failed. "
- }
- } else {
- rollbackDeactivateSDNCMessages = " + SNDC deactivate rollback completed."
- }
- } else {
- rollbackDeactivateSDNCMessages = " + SDNC deactivate rollback failed. "
- }
- utils.log("DEBUG", " SDNC deactivate rollback Code - " + rollbackDeactivateSDNCReturnCode, isDebugEnabled)
- utils.log("DEBUG", " SDNC deactivate rollback Response - " + rollbackDeactivateSDNCResponse, isDebugEnabled)
- }
-
- // validate SDNC rollback response
- String rollbackSdncErrorMessages = ""
- String rollbackSDNCReturnCode = "200"
- if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) {
- rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode")
- String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse")
- String rollbackSDNCReturnInnerCode = ""
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- rollbackSDNCResponse = sdncAdapterUtils.decodeXML(rollbackSDNCResponse)
- rollbackSDNCResponse = rollbackSDNCResponse.replace("&", "&").replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- if (rollbackSDNCReturnCode == "200") {
- if (utils.nodeExists(rollbackSDNCResponse, "response-code")) {
- rollbackSDNCReturnInnerCode = utils.getNodeText1(rollbackSDNCResponse, "response-code")
- if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") {
- rollbackSdncErrorMessages = " + SNDC unassign rollback completed."
- } else {
- rollbackSdncErrorMessages = " + SDNC unassign rollback failed. "
- }
- } else {
- rollbackSdncErrorMessages = " + SNDC unassign rollback completed."
- }
- } else {
- rollbackSdncErrorMessages = " + SDNC unassign rollback failed. "
- }
- utils.log("DEBUG", " SDNC assign rollback Code - " + rollbackSDNCReturnCode, isDebugEnabled)
- utils.log("DEBUG", " SDNC assign rollback Response - " + rollbackSDNCResponse, isDebugEnabled)
- }
-
- // validate PO network rollback response
- String rollbackNetworkErrorMessages = ""
- String rollbackNetworkReturnCode = "200"
- if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) {
- rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode")
- String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse")
- if (rollbackNetworkReturnCode != "200") {
- rollbackNetworkErrorMessages = " + PO Network rollback failed. "
- } else {
- rollbackNetworkErrorMessages = " + PO Network rollback completed."
- }
-
- utils.log("DEBUG", " NetworkRollback Code - " + rollbackNetworkReturnCode, isDebugEnabled)
- utils.log("DEBUG", " NetworkRollback Response - " + rollbackNetworkResponse, isDebugEnabled)
- }
-
- String statusMessage = ""
- int errorCode = 7000
- utils.log("DEBUG", "*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"), isDebugEnabled)
- if (execution.getVariable(Prefix + "fullRollback") == false) {
- WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") // original WorkflowException
- if (wfe != null) {
- statusMessage = wfe.getErrorMessage()
- errorCode = wfe.getErrorCode()
- } else {
- statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception."
- errorCode = '7000'
- }
-
- // set if all rolledbacks are successful
- if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") {
- execution.setVariable("rolledBack", true)
- execution.setVariable("wasDeleted", true)
-
- } else {
- execution.setVariable("rolledBack", false)
- execution.setVariable("wasDeleted", true)
- }
-
- statusMessage = statusMessage + rollbackDeactivateSDNCMessages + rollbackNetworkErrorMessages + rollbackSdncErrorMessages
- utils.log("DEBUG", "Final DoDeleteNetworkInstanceRollback status message: " + statusMessage, isDebugEnabled)
- String processKey = getProcessKey(execution);
- WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage);
- execution.setVariable("workflowException", exception);
-
- } else {
- // rollback due to failures in Main flow (Macro or a-ala-carte) - Full rollback
- if (rollbackDeactivateSDNCReturnCode == "200" && rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") {
- execution.setVariable("rollbackSuccessful", true)
- execution.setVariable("rollbackError", false)
- } else {
- String exceptionMessage = "Network Delete Rollback was not Successful. "
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- execution.setVariable("rollbackSuccessful", false)
- execution.setVariable("rollbackError", true)
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
- throw new BpmnError("MSOWorkflowException")
- }
- }
-
- } catch (Exception ex) {
- String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception."
- String exceptionMessage = " Bpmn error encountered in DoDeleteNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- // *******************************
- // Build Error Section
- // *******************************
-
-
-
- public void processJavaException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
-
- try{
- utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled)
- utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
- utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
- execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception")
-
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
- execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix)
- }
- utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResources.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResources.groovy deleted file mode 100644 index dc4ce6878a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResources.groovy +++ /dev/null @@ -1,325 +0,0 @@ -/*- - * ============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.infrastructure.scripts - -import org.json.JSONArray; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.List; -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource - -import com.fasterxml.jackson.jaxrs.json.annotation.JSONP.Def; - -/** - * This groovy class supports the <class>DoDeleteResources.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - O - * @param - subscriptionServiceType - O - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion - * @param - failNotFound - TODO - * @param - serviceInputParams - TODO - * - * @param - delResourceList - * @param - serviceRelationShip - * - * Outputs: - * @param - WorkflowException - * - * Rollback - Deferred - */ -public class DoDeleteResources extends AbstractServiceTaskProcessor { - - String Prefix="DDELR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) - String msg = "" - - List<ServiceInstance> realNSRessources = new ArrayList<ServiceInstance>() - - // related ns from AAI - String serviceRelationShip = execution.getVariable("serviceRelationShip") - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - List<String> nsSequence = new ArrayList<String>() - List relationShipList = jsonSlurper.parseText(serviceRelationShip) - if (relationShipList != null) { - relationShipList.each { - String resourceType = it.resourceType - nsSequence.add(resourceType) - } - } - - execution.setVariable("currentNSIndex", 0) - execution.setVariable("nsSequence", nsSequence) - execution.setVariable("realNSRessources", realNSRessources) - utils.log("INFO", "nsSequence: " + nsSequence, isDebugEnabled) - - utils.log("INFO"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void getCurrentNS(execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start getCurrentNS Process ======== ", isDebugEnabled) - - def currentIndex = execution.getVariable("currentNSIndex") - List<String> nsSequence = execution.getVariable("nsSequence") - String nsResourceType = nsSequence.get(currentIndex) - - // GET AAI by Name, not ID, for process convenient - execution.setVariable("GENGS_type", "service-instance") - execution.setVariable("GENGS_serviceInstanceId", "") - execution.setVariable("GENGS_serviceInstanceName", nsResourceType) - - utils.log("INFO", "======== COMPLETED getCurrentNS Process ======== ", isDebugEnabled) - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET2 ***** ", isDebugEnabled) - String msg = "" - - try { - String nsResourceName = execution.getVariable("GENGS_serviceInstanceName") - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET", + nsResourceName, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - else - { - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI){ - String aaiService = execution.getVariable("GENGS_service") - if (!isBlank(aaiService)) { - String svcId = utils.getNodeText1(aaiService, "service-instance-id") - //String mn = utils.getNodeText1(aaiService, "model-name") - String mIuuid = utils.getNodeText1(aaiService, "model-invariant-id") - String muuid = utils.getNodeText1(aaiService, "model-version-id") - String mCuuid = utils.getNodeText1(aaiService, "model-customization-uuid") - ServiceInstance rc = new ServiceInstance() - ModelInfo modelInfo = new ModelInfo() - //modelInfo.setModelName(mn) - modelInfo.setModelUuid(muuid) - modelInfo.setModelInvariantUuid(mIuuid) - modelInfo.getModelCustomizationUuid(mCuuid) - rc.setModelInfo(modelInfo) - rc.setInstanceId(svcId) - rc.setInstanceName(nsResourceName) - - List<ServiceInstance> realNSRessources = execution.getVariable("realNSRessources") - realNSRessources.add(rc) - execution.setVariable("realNSRessources", realNSRessources) - - utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled) - } - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteResources.postProcessAAIGET " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void parseNextNS(execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start parseNextNS Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentNSIndex") - def nextIndex = currentIndex + 1 - execution.setVariable("currentNSIndex", nextIndex) - List<String> nsSequence = execution.getVariable("nsSequence") - if(nextIndex >= nsSequence.size()){ - execution.setVariable("allNsFinished", "true") - }else{ - execution.setVariable("allNsFinished", "false") - } - utils.log("INFO", "======== COMPLETED parseNextNS Process ======== ", isDebugEnabled) - } - - - public void sequenceResource(execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled) - List<String> nsResources = new ArrayList<String>() - List<String> wanResources = new ArrayList<String>() - List<String> resourceSequence = new ArrayList<String>() - - // get delete resource list and order list - List<Resource> delResourceList = execution.getVariable("delResourceList") - // existing resource list - List<ServiceInstance> existResourceList = execution.getVariable("realNSRessources") - - for(ServiceInstance rc_e : existResourceList){ - - String muuid = rc_e.getModelInfo().getModelUuid() - String mIuuid = rc_e.getModelInfo().getModelInvariantUuid() - String mCuuid = rc_e.getModelInfo().getModelCustomizationUuid() - rcType = rc_e.getInstanceName() - - for(Resource rc_d : delResourceList){ - - if(rc_d.getModelInfo().getModelUuid() == muuid - && rc_d.getModelInfo().getModelInvariantUuid() == mIuuid - && rc_d.getModelInfo().getModelCustomizationUuid() == mCuuid) { - - if(StringUtils.containsIgnoreCase(rcType, "overlay") - || StringUtils.containsIgnoreCase(rcType, "underlay")){ - wanResources.add(rcType) - }else{ - nsResources.add(rcType) - } - - } - } - - } - - resourceSequence.addAll(wanResources) - resourceSequence.addAll(nsResources) - String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" - execution.setVariable("isContainsWanResource", isContainsWanResource) - execution.setVariable("currentResourceIndex", 0) - execution.setVariable("resourceSequence", resourceSequence) - utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) - execution.setVariable("wanResources", wanResources) - utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled) - } - - public void getCurrentResource(execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start getCurrentResoure Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - List<String> resourceSequence = execution.getVariable("resourceSequence") - List<String> wanResources = execution.getVariable("wanResources") - String resourceName = resourceSequence.get(currentIndex) - execution.setVariable("resourceType",resourceName) - if(wanResources.contains(resourceName)){ - execution.setVariable("controllerInfo", "SDN-C") - }else{ - execution.setVariable("controllerInfo", "VF-C") - } - utils.log("INFO", "======== COMPLETED getCurrentResoure Process ======== ", isDebugEnabled) - } - - /** - * prepare delete parameters - */ - public void preResourceDelete(execution, resourceName){ - - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preResourceDelete Process ======== ", isDebugEnabled) - - List<ServiceInstance> existResourceList = execution.getVariable("realNSRessources") - - for(ServiceInstance rc_e : existResourceList){ - - if(StringUtils.containsIgnoreCase(rc_e.getInstanceName(), resourceName)) { - - String resourceInstanceUUID = rc_e.getInstanceId() - String resourceTemplateUUID = rc_e.getModelInfo().getModelUuid() - execution.setVariable("resourceInstanceId", resourceInstanceUUID) - execution.setVariable("resourceTemplateId", resourceTemplateUUID) - execution.setVariable("resourceType", resourceName) - utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " - + resourceInstanceUUID + " resourceType: " + resourceName, isDebugEnabled) - } - } - - utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled) - } - - public void parseNextResource(execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - def nextIndex = currentIndex + 1 - execution.setVariable("currentResourceIndex", nextIndex) - List<String> resourceSequence = execution.getVariable("resourceSequence") - if(nextIndex >= resourceSequence.size()){ - execution.setVariable("allResourceFinished", "true") - }else{ - execution.setVariable("allResourceFinished", "false") - } - utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) - } - - /** - * post config request. - */ - public void postConfigRequest(execution){ - //to do - } - -} -
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy deleted file mode 100644 index 1a36a4ea90..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteResourcesV1.groovy +++ /dev/null @@ -1,393 +0,0 @@ - -/*- - * ============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.infrastructure.scripts - -import groovy.json.JsonSlurper -import org.apache.commons.lang3.StringUtils -import org.apache.http.HttpResponse -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject -import org.openecomp.mso.bpmn.common.recipe.BpmnRestClient -import org.openecomp.mso.bpmn.common.recipe.ResourceInput -import org.openecomp.mso.bpmn.common.resource.ResourceRequestBuilder -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.domain.AllottedResource -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.NetworkResource -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.ServiceInstance -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.infrastructure.properties.BPMNProperties - -import static org.apache.commons.lang3.StringUtils.isBlank - -/** - * input for script : - * msoRequestId - * isDebugLogEnabled - * globalSubscriberId - * serviceType - * serviceInstanceId - * URN_mso_workflow_sdncadapter_callback - * serviceInputParams - * deleteResourceList - * resourceInstanceIDs - * - * output from script: - * - */ - -public class DoDeleteResourcesV1 extends AbstractServiceTaskProcessor { - - String Prefix="DDR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils cutils = new CatalogDbUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** preProcessRequest *****", isDebugEnabled) - String msg = "" - - try { - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("prefix",Prefix) - - //Inputs - //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology - String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - if (globalSubscriberId == null) - { - execution.setVariable("globalSubscriberId", "") - } - - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology - String serviceType = execution.getVariable("serviceType") - if (serviceType == null) - { - execution.setVariable("serviceType", "") - } - - //Generated in parent for AAI PUT - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("INFO","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - StringBuilder sbParams = new StringBuilder() - Map<String, String> paramsMap = execution.getVariable("serviceInputParams") - if (paramsMap != null) - { - sbParams.append("<service-input-parameters>") - for (Map.Entry<String, String> entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ <param> - <name>${paramName}</name> - <value>${paramValue}</value> - </param> - """ - sbParams.append(paramsXml) - } - sbParams.append("</service-input-parameters>") - } - String siParamsXml = sbParams.toString() - if (siParamsXml == null) - siParamsXml = "" - execution.setVariable("siParamsXml", siParamsXml) - - } 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) - } - - public void sequenceResource(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED sequenceResource Process ======== ", isDebugEnabled) - List<Resource> sequencedResourceList = new ArrayList<Resource>() - List<Resource> wanResources = new ArrayList<Resource>() - - // get delete resource list and order list - List<Resource> delResourceList = execution.getVariable("deleteResourceList") - - def resourceSequence = BPMNProperties.getResourceSequenceProp() - - if(resourceSequence != null) { - for (resourceType in resourceSequence.reverse()) { - for (resource in delResourceList) { - if (StringUtils.containsIgnoreCase(resource.getModelInfo().getModelName(), resourceType)) { - sequencedResourceList.add(resource) - - if (resource instanceof NetworkResource) { - wanResources.add(resource) - } - } - } - } - }else { - //define sequenced resource list, we deploy vf first and then network and then ar - //this is defaule sequence - List<VnfResource> vnfResourceList = new ArrayList<VnfResource>() - List<AllottedResource> arResourceList = new ArrayList<AllottedResource>() - for (Resource rc : delResourceList) { - if (rc instanceof VnfResource) { - vnfResourceList.add(rc) - } else if (rc instanceof NetworkResource) { - wanResources.add(rc) - } else if (rc instanceof AllottedResource) { - arResourceList.add(rc) - } - } - - sequencedResourceList.addAll(arResourceList) - sequencedResourceList.addAll(wanResources) - sequencedResourceList.addAll(vnfResourceList) - } - - String isContainsWanResource = wanResources.isEmpty() ? "false" : "true" - execution.setVariable("isContainsWanResource", isContainsWanResource) - execution.setVariable("currentResourceIndex", 0) - execution.setVariable("sequencedResourceList", sequencedResourceList) - utils.log("INFO", "resourceSequence: " + resourceSequence, isDebugEnabled) - utils.log("INFO", " ======== END sequenceResource Process ======== ", isDebugEnabled) - } - - /** - * prepare delete parameters - */ - public void preResourceDelete(DelegateExecution execution){ - - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preResourceDelete Process ======== ", isDebugEnabled) - - List<Resource> sequencedResourceList = execution.getVariable("sequencedResourceList") - - int currentIndex = execution.getVariable("currentResourceIndex") - Resource curResource = sequencedResourceList.get(currentIndex); - - String resourceInstanceUUID = curResource.getResourceId() - String resourceTemplateUUID = curResource.getModelInfo().getModelUuid() - execution.setVariable("resourceInstanceId", resourceInstanceUUID) - execution.setVariable("currentResource", curResource) - utils.log("INFO", "Delete Resource Info resourceTemplate Id :" + resourceTemplateUUID + " resourceInstanceId: " - + resourceInstanceUUID + " resourceModelName: " + curResource.getModelInfo().getModelName(), isDebugEnabled) - - utils.log("INFO", " ======== END preResourceDelete Process ======== ", isDebugEnabled) - } - - - /** - * Execute delete workflow for resource - */ - public void executeResourceDelete(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start executeResourceDelete Process ======== ", isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceType = execution.getVariable("serviceType") - - String resourceInstanceId = execution.getVariable("resourceInstanceId") - - Resource currentResource = execution.getVariable("currentResource") - String action = "deleteInstance" - JSONObject resourceRecipe = cutils.getResourceRecipe(execution, currentResource.getModelInfo().getModelUuid(), action) - String recipeUri = resourceRecipe.getString("orchestrationUri") - int recipeTimeout = resourceRecipe.getInt("recipeTimeout") - String recipeParamXsd = resourceRecipe.get("paramXSD") - - - ResourceInput resourceInput = new ResourceInput(); - resourceInput.setServiceInstanceId(serviceInstanceId) - resourceInput.setResourceInstanceName(currentResource.getResourceInstanceName()) - resourceInput.setResourceInstancenUuid(currentResource.getResourceId()) - resourceInput.setOperationId(execution.getVariable("operationId")) - resourceInput.setOperationType(execution.getVariable("operationType")) - String globalSubscriberId = execution.getVariable("globalSubscriberId") - resourceInput.setGlobalSubscriberId(globalSubscriberId) - resourceInput.setResourceModelInfo(currentResource.getModelInfo()); - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - resourceInput.setServiceModelInfo(serviceDecomposition.getModelInfo()); - resourceInput.setServiceType(serviceType) - - String recipeURL = BPMNProperties.getProperty("bpelURL", "http://mso:8080") + recipeUri - - HttpResponse resp = BpmnRestClient.post(recipeURL, requestId, recipeTimeout, action, serviceInstanceId, serviceType, resourceInput.toString(), recipeParamXsd) - utils.log("INFO", " ======== END executeResourceDelete Process ======== ", isDebugEnabled) - } - - - public void parseNextResource(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", "======== Start parseNextResource Process ======== ", isDebugEnabled) - def currentIndex = execution.getVariable("currentResourceIndex") - def nextIndex = currentIndex + 1 - execution.setVariable("currentResourceIndex", nextIndex) - List<String> sequencedResourceList = execution.getVariable("sequencedResourceList") - if(nextIndex >= sequencedResourceList.size()){ - execution.setVariable("allResourceFinished", "true") - }else{ - execution.setVariable("allResourceFinished", "false") - } - utils.log("INFO", "======== COMPLETED parseNextResource Process ======== ", isDebugEnabled) - } - - public void prepareFinishedProgressForResource(DelegateExecution execution) { - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceType = execution.getVariable("serviceType") - String resourceInstanceId = execution.getVariable("resourceInstanceId") - Resource currentResource = execution.getVariable("currentResource") - String resourceCustomizationUuid = currentResource.getModelInfo().getModelCustomizationUuid() - String resourceModelName = currentResource.getModelInfo().getModelName() - String operationType = execution.getVariable("operationType") - String progress = "100" - String status = "finished" - String statusDescription = "The resource instance does not exist for " + resourceModelName - String operationId = execution.getVariable("operationId") - - String body = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateResourceOperationStatus> - <operType>${operationType}</operType> - <operationId>${operationId}</operationId> - <progress>${progress}</progress> - <resourceTemplateUUID>${resourceCustomizationUuid}</resourceTemplateUUID> - <serviceId>${serviceInstanceId}</serviceId> - <status>${status}</status> - <statusDescription>${statusDescription}</statusDescription> - </ns:updateResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>"""; - - def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - execution.setVariable("CVFMI_updateResOperStatusRequest", body) - } - - public void prepareSDNCServiceDeactivateRequest (DelegateExecution execution) { - prepareSDNCServiceRequest (execution, "deactivate") - } - - public void prepareSDNCServiceDeleteRequest (DelegateExecution execution) { - prepareSDNCServiceRequest (execution, "delete") - } - - public void prepareSDNCServiceRequest (DelegateExecution execution, String svcAction) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** Started prepareSDNCServiceRequest for " + svcAction + "*****", isDebugEnabled) - - try { - // get variables - String sdnc_svcAction = svcAction - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String hdrRequestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String source = execution.getVariable("source") - String sdnc_service_id = serviceInstanceId - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - String serviceType = execution.getVariable("serviceType") - String globalCustomerId = execution.getVariable("globalSubscriberId") - String serviceModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid() - String serviceModelUuid = serviceDecomposition.getModelInfo().getModelUuid() - String serviceModelVersion = serviceDecomposition.getModelInfo().getModelVersion() - String serviceModelName = serviceDecomposition.getModelInfo().getModelName() - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyDeleteRequest = - """<aetgt:SDNCAdapterWorkflowRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${hdrRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${sdnc_svcAction}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>sdncCallback</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${hdrRequestId}</request-id> - <request-action>DeleteServiceInstance</request-action> - <source>${source}</source> - <notification-url></notification-url> - <order-number></order-number> - <order-version></order-version> - </request-information> - <service-information> - <service-id>${serviceInstanceId}</service-id> - <subscription-service-type>${serviceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${serviceModelInvariantUuid}</model-invariant-uuid> - <model-uuid>${serviceModelUuid}</model-uuid> - <model-version>${serviceModelVersion}</model-version> - <model-name>${serviceModelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <service-request-input> - </service-request-input> - </sdncadapterworkflow:SDNCRequestData> - </aetgt:SDNCAdapterWorkflowRequest>""".trim() - - String sndcTopologyDeleteRequesAsString = utils.formatXml(sndcTopologyDeleteRequest) - utils.logAudit(sndcTopologyDeleteRequesAsString) - execution.setVariable("sdncAdapterWorkflowRequest", sndcTopologyDeleteRequesAsString) - utils.log("INFO","sdncAdapterWorkflowRequest - " + "\n" + sndcTopologyDeleteRequesAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoDeleteResourcesV1 flow. prepareSDNCServiceRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - utils.log("INFO","***** Exit prepareSDNCServiceRequest for " + svcAction + "*****", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy deleted file mode 100644 index 802090b02a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy +++ /dev/null @@ -1,478 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.UUID; -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.w3c.dom.Node -import org.w3c.dom.NodeList -import org.xml.sax.InputSource - -/** - * This groovy class supports the <class>DoDeleteServiceInstance.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - O - * @param - subscriptionServiceType - O - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceModelInfo - O - * @param - productFamilyId - * @param - serviceInputParams (should contain aic_zone for serviceTypes TRANSPORT,ATM) - * @param - sdncVersion - * @param - failNotFound - TODO - * @param - serviceInputParams - TODO - * - * Outputs: - * @param - WorkflowException - * - * Rollback - Deferred - */ -public class DoDeleteServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DDELSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - String msg = "" - - try { - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("prefix",Prefix) - - //Inputs - //requestDetails.subscriberInfo. for AAI GET & PUT & SDNC assignToplology - String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId - if (globalSubscriberId == null) - { - execution.setVariable("globalSubscriberId", "") - } - - //requestDetails.requestParameters. for AAI PUT & SDNC assignTopology - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - if (subscriptionServiceType == null) - { - execution.setVariable("subscriptionServiceType", "") - } - - //Generated in parent for AAI PUT - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - StringBuilder sbParams = new StringBuilder() - Map<String, String> paramsMap = execution.getVariable("serviceInputParams") - if (paramsMap != null) - { - sbParams.append("<service-input-parameters>") - for (Map.Entry<String, String> entry : paramsMap.entrySet()) { - String paramsXml - String paramName = entry.getKey() - String paramValue = entry.getValue() - paramsXml = - """ <param> - <name>${paramName}</name> - <value>${paramValue}</value> - </param> - """ - sbParams.append(paramsXml) - } - sbParams.append("</service-input-parameters>") - } - String siParamsXml = sbParams.toString() - if (siParamsXml == null) - siParamsXml = "" - execution.setVariable("siParamsXml", siParamsXml) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void preProcessSDNCDelete (DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) - String msg = "" - - try { - def serviceInstanceId = execution.getVariable("serviceInstanceId") ?: "" - def serviceInstanceName = execution.getVariable("serviceInstanceName") ?: "" - def callbackURL = execution.getVariable("sdncCallbackUrl") ?: "" - def requestId = execution.getVariable("msoRequestId") ?: "" - def serviceId = execution.getVariable("productFamilyId") ?: "" - def subscriptionServiceType = execution.getVariable("subscriptionServiceType") ?: "" - def globalSubscriberId = execution.getVariable("globalSubscriberId") ?: "" //globalCustomerId - - String serviceModelInfo = execution.getVariable("serviceModelInfo") ?: "" - def modelInvariantUuid = "" - def modelVersion = "" - def modelUuid = "" - def modelName = "" - if (!isBlank(serviceModelInfo)) - { - modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") ?: "" - modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") ?: "" - modelUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelUuid") ?: "" - modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") ?: "" - - } - - def siParamsXml = execution.getVariable("siParamsXml") ?: "" - def msoAction = "" - // special URL for SDNW, msoAction helps set diff url in SDNCA - if("TRANSPORT".equalsIgnoreCase(execution.getVariable("serviceType"))) - { - msoAction = "TRANSPORT" - } - - def sdncRequestId = UUID.randomUUID().toString() - - String sdncDelete = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>delete</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - <request-action>DeleteServiceInstance</request-action> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information> - <model-invariant-uuid>${modelInvariantUuid}</model-invariant-uuid> - <model-uuid>${modelUuid}</model-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalSubscriberId}</global-customer-id> - </service-information> - <service-request-input> - <service-instance-name>${serviceInstanceName}</service-instance-name> - ${siParamsXml} - </service-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - sdncDelete = utils.formatXml(sdncDelete) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - execution.setVariable("sdncDelete", sdncDelete) - execution.setVariable("sdncDeactivate", sdncDeactivate) - utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled) - utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) - } - utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled) - } - - public void postProcessSDNCDelete(DelegateExecution execution, String response, String method) { - - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessSDNC " + method + " *****", isDebugEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.log("DEBUG", "SDNCResponse: " + response, isDebugEnabled) - utils.log("DEBUG", "workflowException: " + workflowException, isDebugEnabled) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG","Good response from SDNC Adapter for service-instance " + method + "response:\n" + response, isDebugEnabled) - - }else{ - msg = "Bad Response from SDNC Adapter for service-instance " + method - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in postProcessSDNC " + method + " Exception:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessSDNC " + method + " ***", isDebugEnabled) - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - String serviceType = "" - - if(foundInAAI){ - utils.log("DEBUG","Found Service-instance in AAI", isDebugEnabled) - - //Extract GlobalSubscriberId - String siRelatedLink = execution.getVariable("GENGS_siResourceLink") - if (isBlank(siRelatedLink)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - utils.log("DEBUG","Found Service-instance in AAI. link: " + siRelatedLink, isDebugEnabled) - String globalSubscriberId = execution.getVariable("globalSubscriberId") - if(isBlank(globalSubscriberId)){ - int custStart = siRelatedLink.indexOf("customer/") - int custEnd = siRelatedLink.indexOf("/service-subscriptions") - globalSubscriberId = siRelatedLink.substring(custStart + 9, custEnd) - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //Extract Service Type if not provided on request - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - if(isBlank(subscriptionServiceType)){ - int serviceStart = siRelatedLink.indexOf("service-subscription/") - int serviceEnd = siRelatedLink.indexOf("/service-instances/") - String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd) - subscriptionServiceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - if (isBlank(globalSubscriberId) || isBlank(subscriptionServiceType)) - { - msg = "Could not retrive global-customer-id & subscription-service-type from AAI to delete id:" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - } - - String siData = execution.getVariable("GENGS_service") - utils.log("DEBUG", "SI Data", isDebugEnabled) - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI to delete id:" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - else - { - utils.log("DEBUG", "SI Data" + siData, isDebugEnabled) - serviceType = utils.getNodeText1(siData,"service-type") - execution.setVariable("serviceType", serviceType) - execution.setVariable("serviceRole", utils.getNodeText1(siData,"service-role")) - String orchestrationStatus = utils.getNodeText1(siData,"orchestration-status") - - //Confirm there are no related service instances (vnf/network or volume) - if (utils.nodeExists(siData, "relationship-list")) { - utils.log("DEBUG", "SI Data relationship-list exists:", isDebugEnabled) - InputSource source = new InputSource(new StringReader(siData)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document serviceXml = docBuilder.parse(source) - - NodeList nodeList = serviceXml.getElementsByTagName("relationship") - for (int x = 0; x < nodeList.getLength(); x++) { - Node node = nodeList.item(x) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element eElement = (Element) node - def e = eElement.getElementsByTagName("related-to").item(0).getTextContent() - if(e.equals("generic-vnf") || e.equals("l3-network") || e.equals("allotted-resource") ){ - utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs, l3-networks or allotted-resources", isDebugEnabled) - execution.setVariable("siInUse", true) - //there are relationship dependencies to this Service Instance - msg = " Stopped deleting Service Instance, it has dependencies. Service instance id: " + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - }else{ - utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled) - } - } - } - } - - if ("TRANSPORT".equalsIgnoreCase(serviceType)) - { - if ("PendingDelete".equals(orchestrationStatus)) - { - execution.setVariable("skipDeactivate", true) - } - else - { - msg = "ServiceInstance of type TRANSPORT must in PendingDelete status to allow Delete. Orchestration-status:" + orchestrationStatus - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - } - - //alacarte SIs are NOT sent to sdnc. exceptions are listed in config variable - String svcTypes = execution.getVariable("URN_sdnc_si_svc_types") ?: "" - utils.log("DEBUG", "SDNC SI serviceTypes:" + svcTypes, isDebugEnabled) - List<String> svcList = Arrays.asList(svcTypes.split("\\s*,\\s*")); - boolean isSdncService= false - for (String listEntry : svcList){ - if (listEntry.equalsIgnoreCase(serviceType)){ - isSdncService = true - break; - } - } - - //All Macros are sent to SDNC, TRANSPORT(Macro) is sent to SDNW - //Alacartes are sent to SDNC if they are listed in config variable above - execution.setVariable("sendToSDNC", true) - if(execution.getVariable("sdncVersion").equals("1610")) //alacarte - { - if(!isSdncService){ - execution.setVariable("sendToSDNC", false) - } - } - - utils.log("DEBUG", "isSdncService: " + isSdncService, isDebugEnabled) - utils.log("DEBUG", "Send To SDNC: " + execution.getVariable("sendToSDNC"), isDebugEnabled) - utils.log("DEBUG", "Service Type: " + execution.getVariable("serviceType"), isDebugEnabled) - - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("DEBUG","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - - utils.log("DEBUG","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void postProcessAAIDEL(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessAAIDEL ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") - if(!succInAAI){ - msg = "Error deleting Service-instance in AAI" + serviceInstanceId - utils.log("DEBUG", msg, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *** Exit postProcessAAIDEL *** ", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy deleted file mode 100644 index d3e89df7bf..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVFCNetworkServiceInstance.groovy +++ /dev/null @@ -1,291 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * OPENECOMP - SO
- * ================================================================================
- * Copyright (C) 2017 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.infrastructure.scripts;
-
-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.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.rest.RESTClient
-
-
-
-/**
- * This groovy class supports the <class>DoDeleteVFCNetworkServiceInstance.bpmn</class> process.
- * flow for E2E ServiceInstance Delete
- */
-public class DoDeleteVFCNetworkServiceInstance extends AbstractServiceTaskProcessor {
-
-
- String vfcUrl = "/vfc/rest/v1/vfcadapter"
-
- String host = "http://mso.mso.testlab.openecomp.org:8080"
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- JsonUtils jsonUtil = new JsonUtils()
-
- /**
- * Pre Process the BPMN Flow Request
- * Inclouds:
- * generate the nsOperationKey
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- String msg = ""
- utils.log("INFO", " *** preProcessRequest() *** ", isDebugEnabled)
- try {
- //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("resourceTemplateId")
- utils.log("INFO", "nodeTemplateUUID:" + nodeTemplateUUID, isDebugEnabled)
- String nsInstanceId = execution.getVariable("resourceInstanceId")
- utils.log("INFO", "nsInstanceId:" + nsInstanceId, isDebugEnabled)
- execution.setVariable("nsInstanceId",nsInstanceId)
- String nsOperationKey = """{
- "globalSubscriberId":"${globalSubscriberId}",
- "serviceType":"${serviceType}",
- "serviceId":"${serviceId}",
- "operationId":"${operationId}",
- "nodeTemplateUUID":"${nodeTemplateUUID}"
- }"""
- execution.setVariable("nsOperationKey", nsOperationKey);
- utils.log("INFO", "nsOperationKey:" + nsOperationKey, isDebugEnabled)
- } 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)
- }
-
- /**
- * unwind NS from AAI relationship
- */
- public void deleteNSRelationship(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** deleteNSRelationship *****", isDebugEnabled)
- String nsInstanceId = execution.getVariable("resourceInstanceId")
- if(nsInstanceId == null || nsInstanceId == ""){
- utils.log("INFO"," Delete NS failed", isDebugEnabled)
- return
- }
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String serviceType = execution.getVariable("serviceType")
- String serviceId = execution.getVariable("serviceId")
- String deleteRelationPayload = """<relationship xmlns="http://org.openecomp.aai.inventory/v11">
- <related-to>service-instance</related-to>
- <related-link>/aai/v11/business/customers/customer/${globalSubscriberId}/service-subscriptions/service-subscription/${serviceType}/service-instances/service-instance/${nsInstanceId}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${globalSubscriberId}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${serviceType}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${nsInstanceId}</relationship-value>
- </relationship-data>
- </relationship>"""
- String endpoint = execution.getVariable("URN_aai_endpoint")
- utils.log("INFO","Delete Relationship req:\n" + deleteRelationPayload, isDebugEnabled)
- String url = endpoint + "/aai/v11/business/customers/customer/" + globalSubscriberId + "/service-subscriptions/service-subscription/" + serviceType + "/service-instances/service-instance/" + serviceId + "/relationship-list/relationship"
-
- APIResponse aaiRsp = executeAAIDeleteCall(execution, url, deleteRelationPayload)
- utils.log("INFO","aai response status code:" + aaiRsp.getStatusCode(), isDebugEnabled)
- utils.log("INFO","aai response content:" + aaiRsp.getResponseBodyAsString(), isDebugEnabled)
- utils.log("INFO"," *****Exit deleteNSRelationship *****", isDebugEnabled)
- }
-
- public APIResponse executeAAIDeleteCall(DelegateExecution execution, String url, String payload){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
- APIResponse apiResponse = null
- try{
- String uuid = utils.getRequestID()
- utils.log("INFO","Generated uuid is: " + uuid, isDebugEnabled)
- utils.log("INFO","URL to be used is: " + url, isDebugEnabled)
- String userName = execution.getVariable("URN_aai_auth")
- String password = execution.getVariable("URN_mso_msoKey")
- String basicAuthCred = utils.getBasicAuth(userName,password)
- RESTConfig config = new RESTConfig(url);
- RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
- if (basicAuthCred != null && !"".equals(basicAuthCred)) {
- client.addAuthorizationHeader(basicAuthCred)
- }
- apiResponse = client.httpDelete(payload)
- utils.log("INFO","======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
- }catch(Exception e){
- utils.log("ERROR","Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- return apiResponse
- }
-
- /**
- * delete NS task
- */
- public void deleteNetworkService(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** deleteNetworkService start *** ", isDebugEnabled)
- String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId")
- APIResponse apiResponse = deleteRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String apiResponseAsString = apiResponse.getResponseBodyAsString()
- String operationStatus = "error";
- if(returnCode== "200" || returnCode== "202"){
- operationStatus = "finished"
- }
- execution.setVariable("operationStatus", operationStatus)
-
- utils.log("INFO", " *** deleteNetworkService end *** ", isDebugEnabled)
- }
-
- /**
- * instantiate NS task
- */
- public void terminateNetworkService(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** terminateNetworkService start *** ", isDebugEnabled)
- String nsOperationKey = execution.getVariable("nsOperationKey")
- String url = host + vfcUrl + "/ns/" + execution.getVariable("nsInstanceId") + "/terminate"
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String aaiResponseAsString = apiResponse.getResponseBodyAsString()
- String jobId = "";
- if(returnCode== "200" || returnCode== "202"){
- jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId")
- }
- execution.setVariable("jobId", jobId)
- utils.log("INFO", " *** terminateNetworkService end *** ", isDebugEnabled)
- }
-
- /**
- * query NS task
- */
- public void queryNSProgress(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " *** queryNSProgress start *** ", isDebugEnabled)
- String jobId = execution.getVariable("jobId")
- String nsOperationKey = execution.getVariable("nsOperationKey");
- String url = host + vfcUrl + "/jobs/" + execution.getVariable("jobId")
- APIResponse apiResponse = postRequest(execution, url, nsOperationKey)
- String returnCode = apiResponse.getStatusCode()
- String apiResponseAsString = apiResponse.getResponseBodyAsString()
- String operationProgress = "100"
- if(returnCode== "200"){
- operationProgress = jsonUtil.getJsonValue(apiResponseAsString, "responseDescriptor.progress")
- }
- execution.setVariable("operationProgress", operationProgress)
- utils.log("INFO", " *** queryNSProgress end *** ", isDebugEnabled)
- }
-
- /**
- * delay 5 sec
- */
- public void timeDelay(DelegateExecution execution) {
- try {
- Thread.sleep(5000);
- } catch(InterruptedException e) {
- utils.log("INFO", "Time Delay exception" + e, isDebugEnabled)
- }
- }
-
- /**
- * finish NS task
- */
- public void finishNSDelete(DelegateExecution execution) {
- //no need to do anything util now
- }
-
- /**
- * 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 VF-C Post Call. Exception is: \n" + e, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- return apiResponse
- }
- /**
- * delete request
- * url: the url of the request
- * requestBody: the body of the request
- */
- private APIResponse deleteRequest(DelegateExecution execution, String url, String requestBody){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO", " ======== Started Execute VFC adapter Delete 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.httpDelete(requestBody)
- utils.log("INFO", "response code:"+ apiResponse.getStatusCode() +"\nresponse body:"+ apiResponse.getResponseBodyAsString(), isDebugEnabled)
- utils.log("INFO", "======== Completed Execute VF-C adapter Delete Process ======== ", isDebugEnabled)
- }catch(Exception e){
- utils.log("ERROR", "Exception occured while executing VF-C Post Call. Exception is: \n" + e, isDebugEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- return apiResponse
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy deleted file mode 100644 index a5c39b6998..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModule.groovy +++ /dev/null @@ -1,708 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VfModule -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils -import org.w3c.dom.Document -import org.w3c.dom.Element -import org.xml.sax.InputSource -import org.w3c.dom.Node -import org.w3c.dom.NodeList; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - - -/* Subflow for Delete VF Module. When no DoDeleteVfModuleRequest is specified on input, - * functions as a building block subflow - -* Inputs for building block interface: -* @param - requestId -* @param - isDebugLogEnabled -* @param - vnfId -* @param - vfModuleId -* @param - serviceInstanceId -* @param - vfModuleName O -* @param - vfModuleModelInfo -* @param - cloudConfiguration* -* @param - sdncVersion ("1610") -* @param - retainResources -* @param - aLaCarte -* -* Outputs: -* @param - WorkflowException -* -*/ -public class DoDeleteVfModule extends AbstractServiceTaskProcessor{ - - def Prefix="DoDVfMod_" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable("prefix",Prefix) - execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", null) - execution.setVariable("DoDVfMod_oamManagementV4Address", null) - execution.setVariable("DoDVfMod_oamManagementV6Address", null) - - } - - // parse the incoming DELETE_VF_MODULE request for the Generic Vnf and Vf Module Ids - // and formulate the outgoing request for PrepareUpdateAAIVfModuleRequest - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - initProcessVariables(execution) - - try { - def xml = execution.getVariable("DoDeleteVfModuleRequest") - String vnfId = "" - String vfModuleId = "" - - if (xml == null || xml.isEmpty()) { - // Building Block-type request - - // Set mso-request-id to request-id for VNF Adapter interface - String requestId = execution.getVariable("requestId") - execution.setVariable("mso-request-id", requestId) - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") - execution.setVariable("tenantId", tenantId) - String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") - execution.setVariable("cloudSiteId", cloudSiteId) - // Source is HARDCODED - String source = "VID" - execution.setVariable("source", source) - // SrvInstId is hardcoded to empty - execution.setVariable("srvInstId", "") - // ServiceId is hardcoded to empty - execution.setVariable("serviceId", "") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - vnfId = execution.getVariable("vnfId") - vfModuleId = execution.getVariable("vfModuleId") - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId) - } - else { - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId) - } - //vfModuleModelName - def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") - execution.setVariable("vfModuleModelName", vfModuleModelName) - // retainResources - def retainResources = execution.getVariable("retainResources") - if (retainResources == null) { - retainResources = false - } - execution.setVariable("retainResources", retainResources) - } - else { - - utils.logAudit("DoDeleteVfModule Request: " + xml) - - utils.log("DEBUG", "input request xml: " + xml, isDebugEnabled) - - vnfId = utils.getNodeText1(xml,"vnf-id") - execution.setVariable("vnfId", vnfId) - vfModuleId = utils.getNodeText1(xml,"vf-module-id") - execution.setVariable("vfModuleId", vfModuleId) - def srvInstId = execution.getVariable("mso-service-instance-id") - execution.setVariable("srvInstId", srvInstId) - String requestId = "" - try { - requestId = execution.getVariable("mso-request-id") - } catch (Exception ex) { - requestId = utils.getNodeText1(xml, "request-id") - } - execution.setVariable("requestId", requestId) - String source = utils.getNodeText1(xml, "source") - execution.setVariable("source", source) - String serviceId = utils.getNodeText1(xml, "service-id") - execution.setVariable("serviceId", serviceId) - String tenantId = utils.getNodeText1(xml, "tenant-id") - execution.setVariable("tenantId", tenantId) - - String serviceInstanceIdToSdnc = "" - if (xml.contains("service-instance-id")) { - serviceInstanceIdToSdnc = utils.getNodeText1(xml, "service-instance-id") - } else { - serviceInstanceIdToSdnc = vfModuleId - } - execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceIdToSdnc) - String vfModuleName = utils.getNodeText1(xml, "vf-module-name") - execution.setVariable("vfModuleName", vfModuleName) - String vfModuleModelName = utils.getNodeText1(xml, "vf-module-model-name") - execution.setVariable("vfModuleModelName", vfModuleModelName) - String cloudSiteId = utils.getNodeText1(xml, "aic-cloud-region") - execution.setVariable("cloudSiteId", cloudSiteId) - } - - // formulate the request for PrepareUpdateAAIVfModule - String request = """<PrepareUpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <orchestration-status>pending-delete</orchestration-status> - </PrepareUpdateAAIVfModuleRequest>""" as String - utils.log("DEBUG", "PrepareUpdateAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("UpdateAAIVfModule Request: " + request) - execution.setVariable("PrepareUpdateAAIVfModuleRequest", request) - execution.setVariable("vfModuleFromAAI", null) - }catch(BpmnError b){ - throw b - }catch(Exception e){ - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!") - } - } - - // build a SDNC vnf-topology-operation request for the specified action - // (note: the action passed is expected to be 'changedelete' or 'delete') - public void prepSDNCAdapterRequest(DelegateExecution execution, String action) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("requestId") + "-" + System.currentTimeMillis() - } - - def srvInstId = execution.getVariable("srvInstId") - def callbackUrl = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String requestId = execution.getVariable("requestId") - String source = execution.getVariable("source") - String serviceId = execution.getVariable("serviceId") - String vnfId = execution.getVariable("vnfId") - String tenantId = execution.getVariable("tenantId") - String vfModuleId = execution.getVariable("vfModuleId") - String serviceInstanceIdToSdnc = execution.getVariable(Prefix + "serviceInstanceIdToSdnc") - String vfModuleName = execution.getVariable("vfModuleName") - // Get vfModuleName from AAI response if it was not specified on the request - if (vfModuleName == null || vfModuleName.isEmpty()) { - if (execution.getVariable("vfModuleFromAAI") != null) { - VfModule vfModuleFromAAI = execution.getVariable("vfModuleFromAAI") - vfModuleName = vfModuleFromAAI.getElementText("vf-module-name") - } - } - String vfModuleModelName = execution.getVariable("vfModuleModelName") - String cloudSiteId = execution.getVariable("cloudSiteId") - boolean retainResources = execution.getVariable("retainResources") - String requestSubActionString = "" - if (retainResources) { - requestSubActionString = "<request-sub-action>RetainResource</request-sub-action>" - } - String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${vfModuleId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>DisconnectVNFRequest</request-action> - ${requestSubActionString} - <source>${source}</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id>${serviceId}</service-id> - <service-type>${serviceId}</service-type> - <service-instance-id>${serviceInstanceIdToSdnc}</service-instance-id> - <subscriber-name>notsurewecare</subscriber-name> - </service-information> - <vnf-request-information> - <vnf-id>${vfModuleId}</vnf-id> - <vnf-type>${vfModuleModelName}</vnf-type> - <vnf-name>${vfModuleName}</vnf-name> - <generic-vnf-id>${vnfId}</generic-vnf-id> - <generic-vnf-name></generic-vnf-name> - <generic-vnf-type></generic-vnf-type> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - <tenant>${tenantId}</tenant> - </vnf-request-information> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG", "sdncAdapterWorkflowRequest: " + request, isDebugEnabled) - utils.logAudit("DoDeleteVfModule - SDNCAdapterWorkflowRequest: " + request) - execution.setVariable("sdncAdapterWorkflowRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing VnfAdapterDeleteV1 request - public void prepVNFAdapterRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - def requestId = UUID.randomUUID().toString() - def origRequestId = execution.getVariable('requestId') - def srvInstId = execution.getVariable("serviceInstanceId") - def aicCloudRegion = execution.getVariable("cloudSiteId") - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - def vfModuleStackId = execution.getVariable('DoDVfMod_heatStackId') - def tenantId = execution.getVariable("tenantId") - def messageId = execution.getVariable('requestId') + '-' + - System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String request = """ - <deleteVfModuleRequest> - <cloudSiteId>${aicCloudRegion}</cloudSiteId> - <tenantId>${tenantId}</tenantId> - <vnfId>${vnfId}</vnfId> - <vfModuleId>${vfModuleId}</vfModuleId> - <vfModuleStackId>${vfModuleStackId}</vfModuleStackId> - <skipAAI>true</skipAAI> - <msoRequest> - <requestId>${origRequestId}</requestId> - <serviceInstanceId>${srvInstId}</serviceInstanceId> - </msoRequest> - <messageId>${messageId}</messageId> - <notificationUrl>${notificationUrl}</notificationUrl> - </deleteVfModuleRequest> - """ as String - - utils.log("DEBUG", "vnfAdapterRestV1Request: " + request, isDebugEnabled) - utils.logAudit("deleteVfModuleRequest: " + request) - execution.setVariable("vnfAdapterRestV1Request", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing UpdateAAIVfModuleRequest request - public void prepUpdateAAIVfModule(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<UpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <heat-stack-id>DELETE</heat-stack-id> - <orchestration-status>deleted</orchestration-status> - </UpdateAAIVfModuleRequest>""" as String - utils.log("DEBUG", "UpdateAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("UpdateAAIVfModuleRequest: " + request) - execution.setVariable("UpdateAAIVfModuleRequest", request) - } - - // parse the incoming DELETE_VF_MODULE request - // and formulate the outgoing DeleteAAIVfModuleRequest request - public void prepDeleteAAIVfModule(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - def vnfId = execution.getVariable("vnfId") - def vfModuleId = execution.getVariable("vfModuleId") - // formulate the request for UpdateAAIVfModule - String request = """<DeleteAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - </DeleteAAIVfModuleRequest>""" as String - utils.log("DEBUG", "DeleteAAIVfModuleRequest :" + request, isDebugEnabled) - utils.logAudit("DeleteAAIVfModuleRequest: " + request) - execution.setVariable("DeleteAAIVfModuleRequest", request) - } - - // generates a WorkflowException if - // - - public void handleDoDeleteVfModuleFailure(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: " - + execution.getVariable("DoDVfMod_deleteGenericVnfResponse"), isDebugEnabled) - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, 5000, - execution.getVariable("DoDVfMod_deleteGenericVnfResponse")) - execution.setVariable("WorkflowException", exception) - } - - public void sdncValidateResponse(DelegateExecution execution, String response){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled) - }else{ - throw new BpmnError("MSOWorkflowException") - } - } - - public void postProcessVNFAdapterRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix",Prefix) - try{ - logDebug(" *** STARTED postProcessVNFAdapterRequest Process*** ", isDebugLogEnabled) - - String vnfResponse = execution.getVariable("DoDVfMod_doDeleteVfModuleResponse") - logDebug("VNF Adapter Response is: " + vnfResponse, isDebugLogEnabled) - utils.logAudit("deleteVnfAResponse is: \n" + vnfResponse) - - if(vnfResponse != null){ - - if(vnfResponse.contains("deleteVfModuleResponse")){ - logDebug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.", isDebugLogEnabled) - execution.setVariable("DoDVfMod_vnfVfModuleDeleteCompleted", true) - - // Parse vnfOutputs for contrail network polcy FQDNs - if (vnfResponse.contains("vfModuleOutputs")) { - def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs") - InputSource source = new InputSource(new StringReader(vfModuleOutputsXml)); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - docFactory.setNamespaceAware(true) - DocumentBuilder docBuilder = docFactory.newDocumentBuilder() - Document outputsXml = docBuilder.parse(source) - - NodeList entries = outputsXml.getElementsByTagNameNS("*", "entry") - List contrailNetworkPolicyFqdnList = [] - for (int i = 0; i< entries.getLength(); i++) { - Node node = entries.item(i) - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node - String key = element.getElementsByTagNameNS("*", "key").item(0).getTextContent() - if (key.endsWith("contrail_network_policy_fqdn")) { - String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn, isDebugLogEnabled) - contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn) - } - else if (key.equals("oam_management_v4_address")) { - String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained oamManagementV4Address: " + oamManagementV4Address, isDebugLogEnabled) - execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address) - } - else if (key.equals("oam_management_v6_address")) { - String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent() - logDebug("Obtained oamManagementV6Address: " + oamManagementV6Address, isDebugLogEnabled) - execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address) - } - - } - } - if (!contrailNetworkPolicyFqdnList.isEmpty()) { - logDebug("Setting the fqdn list", isDebugLogEnabled) - execution.setVariable("DoDVfMod_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList) - } - } - }else{ - logDebug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error") - } - }else{ - logDebug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter") - } - - }catch(BpmnError b){ - throw b - }catch(Exception e){ - logDebug("Internal Error Occured in PostProcess Method", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method") - } - logDebug(" *** COMPLETED postProcessVnfAdapterResponse Process*** ", isDebugLogEnabled) - } - - public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED deleteNetworkPoliciesFromAAI ======== ", isDebugLogEnabled) - - try { - // get variables - List fqdnList = execution.getVariable("DoDVfMod_contrailNetworkPolicyFqdnList") - if (fqdnList == null) { - logDebug("No network policies to delete", isDebugLogEnabled) - return - } - int fqdnCount = fqdnList.size() - - execution.setVariable("DoDVfMod_networkPolicyFqdnCount", fqdnCount) - logDebug("DoDVfMod_networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - if (fqdnCount > 0) { - // AII loop call over contrail network policy fqdn list - for (i in 0..fqdnCount-1) { - - int counting = i+1 - String fqdn = fqdnList[i] - - // Query AAI for this network policy FQDN - - String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8") - utils.logAudit("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest) - logDebug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest, isDebugLogEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest) - int returnCode = response.getStatusCode() - execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode) - logDebug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugLogEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (isOneOf(returnCode, 200, 201)) { - logDebug("The return code is: " + returnCode, isDebugLogEnabled) - // This network policy FQDN exists in AAI - need to delete it now - utils.logAudit(aaiResponseAsString) - execution.setVariable("DoDVfMod_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString) - logDebug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugLogEnabled) - // Retrieve the network policy id for this FQDN - def networkPolicyId = utils.getNodeText1(aaiResponseAsString, "network-policy-id") - logDebug("Deleting network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled) - - // Retrieve the resource version for this network policy - def resourceVersion = utils.getNodeText1(aaiResponseAsString, "resource-version") - logDebug("Deleting network-policy with resource-version " + resourceVersion, isDebugLogEnabled) - - String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") + - "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8") - utils.logAudit("AAI request endpoint: " + delNetworkPolicyAAIRequest) - logDebug("AAI request endpoint: " + delNetworkPolicyAAIRequest, isDebugLogEnabled) - - logDebug("invoking DELETE call to AAI", isDebugLogEnabled) - utils.logAudit("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest) - APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest) - int returnCodeDel = responseDel.getStatusCode() - execution.setVariable("DoDVfMod_aaiDeleteNetworkPolicyReturnCode", returnCodeDel) - logDebug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel, isDebugLogEnabled) - - if (isOneOf(returnCodeDel, 200, 201, 204)) { - logDebug("The return code from deleting network policy is: " + returnCodeDel, isDebugLogEnabled) - // This network policy was deleted from AAI successfully - logDebug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ", isDebugLogEnabled) - - } else { - // aai all errors - String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel - logDebug(delErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage) - } - } else if (returnCode == 404) { - // This network policy FQDN is not in AAI. No need to delete. - logDebug("The return code is: " + returnCode, isDebugLogEnabled) - logDebug("This network policy FQDN is not in AAI: " + fqdn, isDebugLogEnabled) - utils.logAudit("Network policy FQDN is not in AAI") - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode - logDebug(dataErrorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - - - - } // end loop - - - } else { - logDebug("No contrail network policies to query/create", isDebugLogEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage() - logDebug(exceptionMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('vnfId') - def oamManagementV4Address = execution.getVariable(Prefix + 'oamManagementV4Address') - def oamManagementV6Address = execution.getVariable(Prefix + 'oamManagementV6Address') - def ipv4OamAddressElement = '' - def managementV6AddressElement = '' - - if (oamManagementV4Address != null) { - ipv4OamAddressElement = '<ipv4-oam-address>' + 'DELETE' + '</ipv4-oam-address>' - } - - if (oamManagementV6Address != null) { - managementV6AddressElement = '<management-v6-address>' + 'DELETE' + '</management-v6-address>' - } - - - String updateAAIGenericVnfRequest = """ - <UpdateAAIGenericVnfRequest> - <vnf-id>${vnfId}</vnf-id> - ${ipv4OamAddressElement} - ${managementV6AddressElement} - </UpdateAAIGenericVnfRequest> - """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable(Prefix + 'updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - /** - * Using the vnfId and vfModuleId provided in the inputs, - * query AAI to get the corresponding VF Module info. - * A 200 response is expected with the VF Module info in the response body, - * Will determine VF Module's orchestration status if one exists - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModuleForStatus(DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - execution.setVariable(Prefix + 'orchestrationStatus', '') - - try { - def vnfId = execution.getVariable('vnfId') - def vfModuleId = execution.getVariable('vfModuleId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + - "/vf-modules/vf-module/" + UriUtils.encode(vfModuleId, "UTF-8") - utils.logAudit("AAI endPoint: " + endPoint) - - try { - RESTConfig config = new RESTConfig(endPoint); - def responseData = '' - def aaiRequestId = UUID.randomUUID().toString() - RESTClient client = new RESTClient(config). - addHeader('X-TransactionId', aaiRequestId). - addHeader('X-FromAppId', 'MSO'). - addHeader('Content-Type', 'application/xml'). - addHeader('Accept','application/xml'); - logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - APIResponse response = client.httpGet() - utils.logAudit("createVfModule - invoking httpGet() to AAI") - - responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("deleteVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("deleteVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponseCode', response.getStatusCode()) - execution.setVariable(Prefix + 'queryAAIVfModuleForStatusResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - // Retrieve VF Module info and its orchestration status; if not found, do nothing - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find orchestration status', isDebugLogEnabled) - if (responseData != null) { - def vfModuleText = utils.getNodeXml(responseData, "vf-module") - //def xmlVfModule= new XmlSlurper().parseText(vfModuleText) - def orchestrationStatus = utils.getNodeText1(vfModuleText, "orchestration-status") - execution.setVariable(Prefix + "orchestrationStatus", orchestrationStatus) - logDebug("Received orchestration status from A&AI: " + orchestrationStatus, isDebugLogEnabled) - - } - } - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage()) - } - } - - - - - -}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy deleted file mode 100644 index 428f9aa1d9..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleFromVnf.groovy +++ /dev/null @@ -1,596 +0,0 @@ -package org.openecomp.mso.bpmn.infrastructure.scripts
-
-import javax.xml.parsers.DocumentBuilder
-import javax.xml.parsers.DocumentBuilderFactory
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.common.scripts.VfModule
-import org.openecomp.mso.bpmn.common.scripts.VfModuleBase
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.springframework.web.util.UriUtils
-import org.w3c.dom.Document
-import org.w3c.dom.Element
-import org.xml.sax.InputSource
-import static org.apache.commons.lang3.StringUtils.*
-
-public class DoDeleteVfModuleFromVnf extends VfModuleBase {
-
- def Prefix="DDVFMV_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
- public void initProcessVariables(DelegateExecution execution) {
- execution.setVariable("prefix",Prefix)
- execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", null)
- }
-
- // parse the incoming request
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- initProcessVariables(execution)
-
- try {
-
- // Building Block-type request
-
- // Set mso-request-id to request-id for VNF Adapter interface
- String requestId = execution.getVariable("msoRequestId")
- execution.setVariable("mso-request-id", requestId)
- execution.setVariable("requestId", requestId)
- utils.log("DEBUG", "msoRequestId: " + requestId, isDebugEnabled)
- String tenantId = execution.getVariable("tenantId")
- utils.log("DEBUG", "tenantId: " + tenantId, isDebugEnabled)
- String cloudSiteId = execution.getVariable("lcpCloudRegionId")
- execution.setVariable("cloudSiteId", cloudSiteId)
- utils.log("DEBUG", "cloudSiteId: " + cloudSiteId, isDebugEnabled)
- // Source is HARDCODED
- String source = "VID"
- execution.setVariable("source", source)
- // isVidRequest is hardcoded to "true"
- execution.setVariable("isVidRequest", "true")
- // SrvInstId is hardcoded to empty
- execution.setVariable("srvInstId", "")
- // ServiceId is hardcoded to empty
- execution.setVariable("serviceId", "")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- utils.log("DEBUG", "serviceInstanceId: " + serviceInstanceId, isDebugEnabled)
- String vnfId = execution.getVariable("vnfId")
- utils.log("DEBUG", "vnfId: " + vnfId, isDebugEnabled)
- String vfModuleId = execution.getVariable("vfModuleId")
- utils.log("DEBUG", "vfModuleId: " + vfModuleId, isDebugEnabled)
- if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
- execution.setVariable(Prefix + "serviceInstanceIdToSdnc", vfModuleId)
- }
- else {
- execution.setVariable(Prefix + "serviceInstanceIdToSdnc", serviceInstanceId)
- }
-
- String sdncVersion = execution.getVariable("sdncVersion")
- if (sdncVersion == null) {
- sdncVersion = "1707"
- }
- execution.setVariable(Prefix + "sdncVersion", sdncVersion)
- utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled)
-
- String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
- if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
- def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
- logError(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
- execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
- utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl)
- utils.log("DEBUG:", "SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled)
-
-
-
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- utils.log("DEBUG", "Exception is: " + e.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!")
- }
- }
-
- public void queryAAIForVfModule(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.queryAAIForVfModule(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def vnfId = execution.getVariable('vnfId')
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
- def aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
- logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)
-
- String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
-
- utils.logAudit("DoDeleteVfModuleFromVnf: AAI endPoint : " + endPoint)
-
- try {
- utils.logAudit("DoDeleteVfModuleFromVnf: - invoking httpGet to AAI")
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
-
- def responseData = response.getResponseBodyAsString()
- execution.setVariable('DDVMFV_getVnfResponseCode', response.getStatusCode())
- execution.setVariable('DDVMFV_getVnfResponse', responseData)
-
- utils.logAudit("DoDeleteVfModuleFromVnf: AAI Response : " + responseData)
- utils.logAudit("DoDeleteVfModuleFromVnf: AAI ResponseCode : " + response.getStatusCode())
-
- logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)
- logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)
-
- } catch (Exception ex) {
- ex.printStackTrace()
- logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(), isDebugLogEnabled)
- execution.setVariable('DDVMFV_getVnfResponseCode', 500)
- execution.setVariable('DDVFMV_getVnfResponse', 'AAI GET Failed:' + ex.getMessage())
- }
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVfModule(): ' + e.getMessage())
- }
- }
-
- /**
- * Validate the VF Module. That is, confirm that a VF Module with the input VF Module ID
- * exists in the retrieved Generic VNF. Then, check to make sure that if that VF Module
- * is the base VF Module and it's not the only VF Module for this Generic VNF, that we're not
- * attempting to delete it.
- *
- * @param execution The flow's execution instance.
- */
- public void validateVfModule(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.validateVfModule(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def genericVnf = execution.getVariable('DDVMFV_getVnfResponse')
- def vnfId = execution.getVariable('_vnfId')
- def vfModuleId = execution.getVariable('vfModuleId')
- def VfModule vfModule = findVfModule(genericVnf, vfModuleId)
- if (vfModule == null) {
- def String msg = 'VF Module \'' + vfModuleId + '\' does not exist in Generic VNF \'' + vnfId + '\''
- logDebug(msg, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, msg)
- } else {
-
- if (isDebugLogEnabled) {
- logDebug('VF Module \'' + vfModuleId + '\': isBaseVfModule=' + vfModule.isBaseVfModule() +
- ', isOnlyVfModule=' + vfModule.isOnlyVfModule(),
- isDebugLogEnabled)
- }
- if (vfModule.isBaseVfModule() && !vfModule.isOnlyVfModule()) {
- def String msg = 'Cannot delete VF Module \'' + vfModuleId +
- '\'since it is the base VF Module and it\'s not the only VF Module in Generic VNF \'' + vnfId + '\''
- logDebug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error")
- }
-
- def heatStackId = vfModule.getElementText('heat-stack-id')
- execution.setVariable('DDVMFV_heatStackId', heatStackId)
- logDebug('VF Module heatStackId retrieved from AAI: ' + heatStackId, isDebugLogEnabled)
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in validateVfModule(): ' + e.getMessage())
- }
- }
-
-
- public void preProcessSDNCDeactivateRequest(DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled)
-
- def serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- try{
- //Build SDNC Request
-
- String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate")
-
- deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest)
- execution.setVariable("DDVMFV_deactivateSDNCRequest", deactivateSDNCRequest)
- logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled)
- utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled)
- }
-
- public void preProcessSDNCUnassignRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled)
- try{
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign")
-
- execution.setVariable("DDVMFV_unassignSDNCRequest", unassignSDNCRequest)
- logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled)
- utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest)
-
- }catch(Exception e){
- log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled)
- }
-
- public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
-
- String uuid = execution.getVariable('testReqId') // for junits
- if(uuid==null){
- uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis()
- }
- def callbackURL = execution.getVariable("sdncCallbackUrl")
- def requestId = execution.getVariable("msoRequestId")
- def serviceId = execution.getVariable("serviceId")
- def serviceInstanceId = execution.getVariable("serviceInstanceId")
- def vfModuleId = execution.getVariable("vfModuleId")
- def source = execution.getVariable("source")
- def vnfId = execution.getVariable("vnfId")
-
- def sdncVersion = execution.getVariable(Prefix + "sdncVersion")
-
- String sdncRequest =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp.mso/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
- <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <request-action>DeleteVfModuleInstance</request-action>
- <source>${source}</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- </request-information>
- <service-information>
- <service-id/>
- <subscription-service-type/>
- <service-instance-id>${serviceInstanceId}</service-instance-id>
- <global-customer-id/>
- </service-information>
- <vnf-information>
- <vnf-id>${vnfId}</vnf-id>
- <vnf-type/>
- </vnf-information>
- <vf-module-information>
- <vf-module-id>${vfModuleId}</vf-module-id>
- </vf-module-information>
- <vf-module-request-input/>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
- utils.logAudit("sdncRequest: " + sdncRequest)
- return sdncRequest
- }
-
- public void validateSDNCResponse(DelegateExecution execution, String response, String method){
- def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
-
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
-
- utils.logAudit("workflowException: " + workflowException)
-
- SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
- sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
-
- utils.logAudit("SDNCResponse: " + response)
-
- String sdncResponse = response
- if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
- logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)
- }else{
- logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
- throw new BpmnError("MSOWorkflowException")
- }
- logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
- }
-
-
- // parse the incoming DELETE_VF_MODULE request
- // and formulate the outgoing VnfAdapterDeleteV1 request
- public void prepVNFAdapterRequest(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- def requestId = UUID.randomUUID().toString()
- def origRequestId = execution.getVariable('requestId')
- def srvInstId = execution.getVariable("serviceInstanceId")
- def aicCloudRegion = execution.getVariable("cloudSiteId")
- def vnfId = execution.getVariable("vnfId")
- def vfModuleId = execution.getVariable("vfModuleId")
- def vfModuleStackId = execution.getVariable('DDVMFV_heatStackId')
- def tenantId = execution.getVariable("tenantId")
- def messageId = execution.getVariable('requestId') + '-' +
- System.currentTimeMillis()
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
-
- String request = """
- <deleteVfModuleRequest>
- <cloudSiteId>${aicCloudRegion}</cloudSiteId>
- <tenantId>${tenantId}</tenantId>
- <vnfId>${vnfId}</vnfId>
- <vfModuleId>${vfModuleId}</vfModuleId>
- <vfModuleStackId>${vfModuleStackId}</vfModuleStackId>
- <skipAAI>true</skipAAI>
- <msoRequest>
- <requestId>${origRequestId}</requestId>
- <serviceInstanceId>${srvInstId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </deleteVfModuleRequest>
- """ as String
-
- utils.log("DEBUG", "vnfAdapterRestV1Request: " + request, isDebugEnabled)
- utils.logAudit("deleteVfModuleRequest: " + request)
- execution.setVariable("vnfAdapterRestV1Request", request)
- }
-
-
- // generates a WorkflowException if
- // -
- public void handleDoDeleteVfModuleFailure(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("ERROR", "AAI error occurred deleting the Generic Vnf: "
- + execution.getVariable("DDVFMV_deleteGenericVnfResponse"), isDebugEnabled)
- String processKey = getProcessKey(execution);
- WorkflowException exception = new WorkflowException(processKey, 5000,
- execution.getVariable("DDVFMV_deleteGenericVnfResponse"))
- execution.setVariable("WorkflowException", exception)
- }
-
- public void postProcessVNFAdapterRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("prefix",Prefix)
- try{
- logDebug(" *** STARTED postProcessVNFAdapterRequest Process*** ", isDebugLogEnabled)
-
- String vnfResponse = execution.getVariable("DDVMFV_doDeleteVfModuleResponse")
- logDebug("VNF Adapter Response is: " + vnfResponse, isDebugLogEnabled)
- utils.logAudit("deleteVnfAResponse is: \n" + vnfResponse)
-
- if(vnfResponse != null){
-
- if(vnfResponse.contains("deleteVfModuleResponse")){
- logDebug("Received a Good Response from VNF Adapter for DELETE_VF_MODULE Call.", isDebugLogEnabled)
- execution.setVariable("DDVFMV_vnfVfModuleDeleteCompleted", true)
-
- // Parse vnfOutputs for contrail network polcy FQDNs
- def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs")
- if(!isBlank(vfModuleOutputsXml)) {
- vfModuleOutputsXml = utils.removeXmlNamespaces(vfModuleOutputsXml)
- List contrailNetworkPolicyFqdnList = []
- for(Node node: utils.getMultNodeObjects(vfModuleOutputsXml, "entry")) {
- String key = utils.getChildNodeText(node, "key")
- if(key == null) {
-
- } else if (key.endsWith("contrail_network_policy_fqdn")) {
- String contrailNetworkPolicyFqdn = utils.getChildNodeText(node, "value")
- logDebug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn, isDebugLogEnabled)
- contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn)
- }
- else if (key.equals("oam_management_v4_address")) {
- String oamManagementV4Address = utils.getChildNodeText(node, "value")
- logDebug("Obtained oamManagementV4Address: " + oamManagementV4Address, isDebugLogEnabled)
- execution.setVariable(Prefix + "oamManagementV4Address", oamManagementV4Address)
- }
- else if (key.equals("oam_management_v6_address")) {
- String oamManagementV6Address = utils.getChildNodeText(node, "value")
- logDebug("Obtained oamManagementV6Address: " + oamManagementV6Address, isDebugLogEnabled)
- execution.setVariable(Prefix + "oamManagementV6Address", oamManagementV6Address)
- }
- }
- if (!contrailNetworkPolicyFqdnList.isEmpty()) {
- logDebug("Setting the fqdn list", isDebugLogEnabled)
- execution.setVariable("DDVFMV_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList)
- }
- }
- }else{
- logDebug("Received a BAD Response from VNF Adapter for DELETE_VF_MODULE Call.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error")
- }
- }else{
- logDebug("Response from VNF Adapter is Null for DELETE_VF_MODULE Call.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter")
- }
-
- }catch(BpmnError b){
- throw b
- }catch(Exception e){
- logDebug("Internal Error Occured in PostProcess Method", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method")
- }
- logDebug(" *** COMPLETED postProcessVnfAdapterResponse Process*** ", isDebugLogEnabled)
- }
-
- public void deleteNetworkPoliciesFromAAI(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.deleteNetworkPoliciesFromAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED deleteNetworkPoliciesFromAAI ======== ", isDebugLogEnabled)
-
- try {
- // get variables
- List fqdnList = execution.getVariable("DDVFMV_contrailNetworkPolicyFqdnList")
- if (fqdnList == null) {
- logDebug("No network policies to delete", isDebugLogEnabled)
- return
- }
- int fqdnCount = fqdnList.size()
-
- execution.setVariable("DDVFMV_networkPolicyFqdnCount", fqdnCount)
- logDebug("DDVFMV_networkPolicyFqdnCount - " + fqdnCount, isDebugLogEnabled)
-
- String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution)
-
- if (fqdnCount > 0) {
- // AII loop call over contrail network policy fqdn list
- for (i in 0..fqdnCount-1) {
-
- int counting = i+1
- String fqdn = fqdnList[i]
-
- // Query AAI for this network policy FQDN
-
- String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8")
- utils.logAudit("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest)
- logDebug("AAI request endpoint: " + queryNetworkPolicyByFqdnAAIRequest, isDebugLogEnabled)
-
- APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyByFqdnAAIRequest)
- int returnCode = response.getStatusCode()
- execution.setVariable("DCVFM_aaiQueryNetworkPolicyByFqdnReturnCode", returnCode)
- logDebug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugLogEnabled)
-
- String aaiResponseAsString = response.getResponseBodyAsString()
-
- if (isOneOf(returnCode, 200, 201)) {
- logDebug("The return code is: " + returnCode, isDebugLogEnabled)
- // This network policy FQDN exists in AAI - need to delete it now
- utils.logAudit(aaiResponseAsString)
- execution.setVariable("DDVFMV_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString)
- logDebug("QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugLogEnabled)
- // Retrieve the network policy id for this FQDN
- def networkPolicyId = utils.getNodeText1(aaiResponseAsString, "network-policy-id")
- logDebug("Deleting network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled)
-
- // Retrieve the resource version for this network policy
- def resourceVersion = utils.getNodeText1(aaiResponseAsString, "resource-version")
- logDebug("Deleting network-policy with resource-version " + resourceVersion, isDebugLogEnabled)
-
- String delNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8") +
- "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8")
- utils.logAudit("AAI request endpoint: " + delNetworkPolicyAAIRequest)
- logDebug("AAI request endpoint: " + delNetworkPolicyAAIRequest, isDebugLogEnabled)
-
- logDebug("invoking DELETE call to AAI", isDebugLogEnabled)
- utils.logAudit("Sending DELETE call to AAI with Endpoint /n" + delNetworkPolicyAAIRequest)
- APIResponse responseDel = aaiUriUtil.executeAAIDeleteCall(execution, delNetworkPolicyAAIRequest)
- int returnCodeDel = responseDel.getStatusCode()
- execution.setVariable("DDVFMV_aaiDeleteNetworkPolicyReturnCode", returnCodeDel)
- logDebug(" ***** AAI delete network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodeDel, isDebugLogEnabled)
-
- if (isOneOf(returnCodeDel, 200, 201, 204)) {
- logDebug("The return code from deleting network policy is: " + returnCodeDel, isDebugLogEnabled)
- // This network policy was deleted from AAI successfully
- logDebug(" DelAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : ", isDebugLogEnabled)
-
- } else {
- // aai all errors
- String delErrorMessage = "Unable to delete network-policy to AAI deleteNetworkPoliciesFromAAI - " + returnCodeDel
- logDebug(delErrorMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, delErrorMessage)
- }
- } else if (returnCode == 404) {
- // This network policy FQDN is not in AAI. No need to delete.
- logDebug("The return code is: " + returnCode, isDebugLogEnabled)
- logDebug("This network policy FQDN is not in AAI: " + fqdn, isDebugLogEnabled)
- utils.logAudit("Network policy FQDN is not in AAI")
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from deleteNetworkPoliciesFromAAI - " + returnCode
- logDebug(dataErrorMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
-
-
-
- } // end loop
-
-
- } else {
- logDebug("No contrail network policies to query/create", isDebugLogEnabled)
-
- }
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in DoDeletVfModule flow. deleteNetworkPoliciesFromAAI() - " + ex.getMessage()
- logDebug(exceptionMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
-
- }
-
- // and formulate the outgoing DeleteAAIVfModuleRequest request
- public void prepDeleteAAIVfModule(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
-
- def vnfId = execution.getVariable("vnfId")
- def vfModuleId = execution.getVariable("vfModuleId")
- // formulate the request for UpdateAAIVfModule
- String request = """<DeleteAAIVfModuleRequest>
- <vnf-id>${vnfId}</vnf-id>
- <vf-module-id>${vfModuleId}</vf-module-id>
- </DeleteAAIVfModuleRequest>""" as String
- utils.log("DEBUG", "DeleteAAIVfModuleRequest :" + request, isDebugEnabled)
- utils.logAudit("DeleteAAIVfModuleRequest: " + request)
- execution.setVariable("DeleteAAIVfModuleRequest", request)
- }
-}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy deleted file mode 100644 index 7784e08958..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVfModuleVolumeV2.groovy +++ /dev/null @@ -1,358 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-import groovy.json.JsonSlurper
-import groovy.util.XmlParser;
-
-import java.util.concurrent.ExecutionException;
-
-import org.springframework.web.util.UriUtils
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-import org.apache.commons.lang3.*
-
-class DoDeleteVfModuleVolumeV2 extends AbstractServiceTaskProcessor {
-
- String prefix="DDVMV_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- XmlParser xmlParser = new XmlParser()
- JsonUtils jsonUtil = new JsonUtils()
-
- @Override
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- preProcessRequest(execution, isDebugEnabled)
- }
-
- /**
- * Set default variable values
- * @param execution
- * @param isDebugLogEnabled
- */
- public void preProcessRequest (DelegateExecution execution, isDebugEnabled) {
-
- //Input:
- // msoRequestId
- // isDebugLogEnabled
- // failIfNotFound (Optional)
- // serviceInstanceId (Optional)
- // vnfId (Optional)
- // volumeGroupId
- // vfModuleModelInfo (Optional)
- // lcpCloudRegionId (Optional) @TODO: this is actually required
- // tenantId (Optional) @TODO: this is actually required
- // cloudConfiguration @TODO: temporary solution? this contains lcpCloudregion and tenantId
- //
- //Output:
- // workflowException @TODO: actual variable name is WorkflowException
- // rolledBack
- // wasDeleted
-
- execution.setVariable('prefix', prefix)
- execution.setVariable('wasDeleted', 'false')
-
- def tenantId = execution.getVariable("tenantId")
- def cloudSiteId = execution.getVariable("lcpCloudRegionId")
-
- // if tenantId or lcpCloudregionId is not passed, get it from cloudRegionConfiguration variable
- if(!tenantId || !cloudSiteId) {
- def cloudConfiguration = execution.getVariable("cloudConfiguration")
- utils.log("DEBUG", "Using cloudConfiguration variable to get tenantId and lcpCloudRegionId - " + cloudConfiguration, isDebugEnabled)
- tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId")
- execution.setVariable("tenantId", tenantId)
- cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId")
- execution.setVariable("lcpCloudRegionId", cloudSiteId)
- }
- }
-
-
- /**
- * Set out 'wasDeleted' variable to 'true'
- * @param execution
- * @param isDebugLogEnabled
- */
- public void postProcess(DelegateExecution execution, isDebugLogEnabled) {
- execution.setVariable('wasDeleted', 'true')
- }
-
-
- /**
- * Query and set cloud region to use for AAI calls
- * Output variables: prefix+'aicCloudRegion', prefix+'cloudRegion'
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAICloudRegion(DelegateExecution execution, isDebugEnabled) {
-
- String cloudRegion = execution.getVariable('lcpCloudRegionId')
- String aai_endpoint = execution.getVariable("URN_aai_endpoint")
- AaiUtil aaiUtil = new AaiUtil(this)
- String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
- String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
- utils.logAudit(queryCloudRegionRequest)
- utils.log("DEBUG", "AAI query cloud region URI - " + queryCloudRegionRequest, isDebugEnabled)
-
- cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
-
- if ((cloudRegion != "ERROR")) {
- if(execution.getVariable(prefix+"queryCloudRegionReturnCode") == "404") {
- execution.setVariable(prefix+"aicCloudRegion", "AAIAIC25")
- }
- else{
- execution.setVariable(prefix+"aicCloudRegion", cloudRegion)
- }
- }
- else {
- utils.log("DEBUG", "AAI Query Cloud Region Unsuccessful.", isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode"))
- }
- }
-
-
- /**
- * Query AAI Volume Group
- * Output variables: prefix+'queryAAIVolGrpResponse'; prefix+'volumeGroupHeatStackId'
- * @param execution
- * @param isDebugLogEnabled
- */
- public void callRESTQueryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) {
-
- def tenantId = execution.getVariable('tenantId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- if(volumeGroupId == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'volumeGroupId is not provided in the request')
- throw new Exception('volume-group-id is not provided in the request')
- }
- String cloudRegion = execution.getVariable(prefix+'aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8")
-
- utils.logAudit('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
- logDebug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest, isDebugLogEnabled)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query volume group by id return code: " + returnCode)
- utils.logAudit("AAI query volume group by id response: " + aaiResponseAsString)
- logDebug('AAI query volume group by id return code: ' + returnCode, isDebugLogEnabled)
- logDebug('AAI query volume group by id response: ' + aaiResponseAsString, isDebugLogEnabled)
-
- execution.setVariable(prefix+"queryAAIVolGrpResponse", aaiResponseAsString)
-
- if (returnCode=='200' || returnCode == '204') {
-
- def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
- execution.setVariable(prefix+'volumeGroupHeatStackId', heatStackId)
-
- logDebug('Heat stack id from AAI response: ' + heatStackId, isDebugLogEnabled)
-
- if(hasVfModuleRelationship(aaiResponseAsString)){
- utils.log("DEBUG", 'Volume Group ' + volumeGroupId + ' currently in use', isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} currently in use - found vf-module relationship.")
- }
-
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
- logDebug('Tenant ID from AAI response: ' + volumeGroupTenantId, isDebugLogEnabled)
-
- if (volumeGroupTenantId == null) {
- utils.log("DEBUG", "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id ${volumeGroupId}")
- }
-
- if (volumeGroupTenantId != tenantId) {
- def String errorMessage = 'TenantId ' + tenantId + ' in incoming request does not match Tenant Id ' + volumeGroupTenantId + ' retrieved from AAI for Volume Group Id ' + volumeGroupId
- utils.log("DEBUG", "Error in DeleteVfModuleVolume: " + errorMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, errorMessage)
- }
- logDebug('Received Tenant Id ' + volumeGroupTenantId + ' from AAI for Volume Group with Volume Group Id ' + volumeGroupId , isDebugLogEnabled)
- }
- else {
- if (returnCode=='404') {
- utils.log("DEBUG", "Volume Group ${volumeGroupId} not found in AAI", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group ${volumeGroupId} not found in AAI. Response code: 404")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
- /**
- * Format VNF Adapter subflow request XML
- * Variables: prefix+'deleteVnfARequest'
- * @param execution
- * @param isDebugLogEnabled
- */
- public void prepareVnfAdapterDeleteRequest(DelegateExecution execution, isDebugLogEnabled) {
- def cloudRegion = execution.getVariable(prefix+'aicCloudRegion')
- def tenantId = execution.getVariable('tenantId') // input parameter (optional) - see preProcessRequest
- def volumeGroupId = execution.getVariable('volumeGroupId') // input parameter (required)
- def volumeGroupHeatStackId = execution.getVariable(prefix+'volumeGroupHeatStackId') // from AAI query volume group
- def requestId = execution.getVariable('msoRequestId') // input parameter (required)
- def serviceId = execution.getVariable('serviceInstanceId') // imput parameter (optional)
-
- def messageId = UUID.randomUUID().toString()
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
-
- String vnfAdapterRestRequest = """
- <deleteVolumeGroupRequest>
- <cloudSiteId>${cloudRegion}</cloudSiteId>
- <tenantId>${tenantId}</tenantId>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- <volumeGroupStackId>${volumeGroupHeatStackId}</volumeGroupStackId>
- <skipAAI>true</skipAAI>
- <msoRequest>
- <requestId>${requestId}</requestId>
- <serviceInstanceId>${serviceId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </deleteVolumeGroupRequest>
- """
- vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
- execution.setVariable(prefix+'deleteVnfARequest', vnfAdapterRestRequest)
- logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
- }
-
-
- /**
- * Delete volume group in AAI
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTDeleteAAIVolumeGroup(DelegateExecution execution, isDebugEnabled) {
-
- // get variables
- String queryAAIVolGrpIdResponse = execution.getVariable(prefix+"queryAAIVolGrpResponse")
- String groupId = utils.getNodeText(queryAAIVolGrpIdResponse, "volume-group-id")
- String resourceVersion = utils.getNodeText(queryAAIVolGrpIdResponse, "resource-version")
-
- String messageId = UUID.randomUUID().toString()
- String cloudRegion = execution.getVariable(prefix+'aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + URLEncoder.encode(cloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8")
-
- if(resourceVersion !=null){
- deleteAAIVolumeGrpIdRequest = deleteAAIVolumeGrpIdRequest +'?resource-version=' + UriUtils.encode(resourceVersion, 'UTF-8')
- }
-
- utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest)
- utils.log("DEBUG", "Delete AAI volume group : " + deleteAAIVolumeGrpIdRequest, isDebugEnabled)
-
- APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI delete volume group return code: " + returnCode)
- utils.logAudit("AAI delete volume group response: " + aaiResponseAsString)
- utils.log("DEBUG", "AAI delete volume group return code: " + returnCode, isDebugEnabled)
- utils.log("DEBUG", "AAI delete volume group response: " + aaiResponseAsString, isDebugEnabled)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- if (returnCode=='200' || (returnCode == '204')) {
- utils.log("DEBUG", "Volume group $groupId deleted.", isDebugEnabled)
- } else {
- if (returnCode=='404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $groupId not found for delete in AAI Response code: 404")
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
-
- /**
- * Check if volume group has a relationship to vf-module
- * @param volumeGroupXml
- * @return
- */
- private boolean hasVfModuleRelationship(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('vf-module'))) {
- def Node relatedLink = utils.getChildNode(relationship, 'related-link')
- if (relatedLink !=null && relatedLink.text() != null){
- return true
- }
- }
- }
- }
- return false
- }
-
-
- /**
- * Extract the Tenant Id from the Volume Group information returned by AAI.
- * @param volumeGroupXml Volume Group XML returned by AAI.
- * @return the Tenant Id extracted from the Volume Group information. 'null' is returned if
- * the Tenant Id is missing or could not otherwise be extracted.
- */
- private String getTenantIdFromVolumeGroup(String volumeGroupXml) {
- def Node volumeGroupNode = xmlParser.parseText(volumeGroupXml)
- def Node relationshipList = utils.getChildNode(volumeGroupNode, 'relationship-list')
- if (relationshipList != null) {
- def NodeList relationships = utils.getIdenticalChildren(relationshipList, 'relationship')
- for (Node relationship in relationships) {
- def Node relatedTo = utils.getChildNode(relationship, 'related-to')
- if ((relatedTo != null) && (relatedTo.text().equals('tenant'))) {
- def NodeList relationshipDataList = utils.getIdenticalChildren(relationship, 'relationship-data')
- for (Node relationshipData in relationshipDataList) {
- def Node relationshipKey = utils.getChildNode(relationshipData, 'relationship-key')
- if ((relationshipKey != null) && (relationshipKey.text().equals('tenant.tenant-id'))) {
- def Node relationshipValue = utils.getChildNode(relationshipData, 'relationship-value')
- if (relationshipValue != null) {
- return relationshipValue.text()
- }
- }
- }
- }
- }
- }
- return null
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnf.groovy deleted file mode 100644 index 5e6fff2fd4..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnf.groovy +++ /dev/null @@ -1,136 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-
-import javax.xml.parsers.DocumentBuilder
-import javax.xml.parsers.DocumentBuilderFactory
-
-import org.apache.commons.lang3.*
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.w3c.dom.Document
-import org.w3c.dom.Element
-import org.w3c.dom.Node
-import org.w3c.dom.NodeList
-import org.xml.sax.InputSource
-
-
-/**
- * This class supports the DoDeleteVnf subFlow
- * with the Deletion of a generic vnf for
- * infrastructure.
- *
- */
-class DoDeleteVnf extends AbstractServiceTaskProcessor {
-
- String Prefix="DoDVNF_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils(this)
-
- /**
- * This method gets and validates the incoming
- * request.
- *
- * @param - execution
- *
- */
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- utils.log("DEBUG", " *** STARTED DoDeleteVnf PreProcessRequest Process*** ", isDebugEnabled)
-
- execution.setVariable("DoDVNF_SuccessIndicator", false)
- execution.setVariable("DoDVNF_vnfInUse", false)
-
- try{
- // Get Variables
-
- String vnfId = execution.getVariable("vnfId")
- execution.setVariable("DoDVNF_vnfId", vnfId)
- utils.log("DEBUG", "Incoming Vnf(Instance) Id is: " + vnfId, isDebugEnabled)
-
- // Setting for sub flow calls
- execution.setVariable("DoDVNF_type", "generic-vnf")
- }catch(BpmnError b){
- utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
- throw b
- }catch(Exception e){
- utils.log("DEBUG", " Error Occured in DoDeleteVnf PreProcessRequest method!" + e, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf PreProcessRequest")
-
- }
- utils.log("DEBUG", "*** COMPLETED DoDeleteVnf PreProcessRequest Process ***", isDebugEnabled)
- }
-
-
- public void processGetVnfResponse(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- utils.log("DEBUG", " *** STARTED DoDeleteVnf processGetVnfResponse Process *** ", isDebugEnabled)
- try {
- String vnf = execution.getVariable("DoDVNF_genericVnf")
- String resourceVersion = utils.getNodeText1(vnf, "resource-version")
- execution.setVariable("DoDVNF_resourceVersion", resourceVersion)
-
- if(utils.nodeExists(vnf, "relationship")){
- InputSource source = new InputSource(new StringReader(vnf));
- DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
- DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
- Document vnfXml = docBuilder.parse(source)
-
- NodeList nodeList = vnfXml.getElementsByTagName("relationship")
- for (int x = 0; x < nodeList.getLength(); x++) {
- Node node = nodeList.item(x)
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element eElement = (Element) node
- def e = eElement.getElementsByTagName("related-to").item(0).getTextContent()
- if(e.equals("volume-group") || e.equals("l3-network")){
- utils.log("DEBUG", "Generic Vnf still has relationship to OpenStack.", isDebugEnabled)
- execution.setVariable("DoDVNF_vnfInUse", true)
- }else{
- utils.log("DEBUG", "Relationship NOT related to OpenStack", isDebugEnabled)
- }
- }
- }
- }
-
- if(utils.nodeExists(vnf, "vf-module")){
- execution.setVariable("DoDVNF_vnfInUse", true)
- utils.log("DEBUG", "Generic Vnf still has vf-modules.", isDebugEnabled)
- }
-
-
- } catch (Exception ex) {
- utils.log("DEBUG", "Error Occured in DoDeleteVnf processGetVnfResponse Process " + ex.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoDeleteVnf processGetVnfResponse Process")
-
- }
- utils.log("DEBUG", "*** COMPLETED DoDeleteVnf processGetVnfResponse Process ***", isDebugEnabled)
- }
-
-
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy deleted file mode 100644 index 7074df5a91..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy +++ /dev/null @@ -1,539 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import java.awt.Component.BaselineResizeBehavior -import java.util.UUID; - -import org.json.JSONObject; -import org.json.JSONArray; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; - -import static org.apache.commons.lang3.StringUtils.*; - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ModuleResource -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.springframework.web.util.UriUtils; - -/** - * This class supports the macro VID Flow - * with the deletion of a generic vnf and related VF modules. - */ -class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor { - - String Prefix="DDVAM_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - * - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoDeleteVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) - - try{ - // Get Variables - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - utils.log("DEBUG", "Cloud Configuration: " + cloudConfiguration, isDebugEnabled) - - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("requestId", requestId) - execution.setVariable("mso-request-id", requestId) - utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) - - String vnfId = execution.getVariable("vnfId") - utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled) - - String source = "VID" - execution.setVariable("DDVAM_source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - execution.setVariable("DDVAM_isVidRequest", "true") - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null) { - sdncVersion = "1702" - } - execution.setVariable("DDVAM_sdncVersion", sdncVersion) - utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled) - - // Set aLaCarte flag to false - execution.setVariable("aLaCarte", false) - - String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) - logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) - - - if (!sdncVersion.equals("1702")) { - //String vnfModelInfo = execution.getVariable("vnfModelInfo") - //String serviceModelInfo = execution.getVariable("serviceModelInfo") - - String serviceId = execution.getVariable("productFamilyId") - execution.setVariable("DDVAM_serviceId", serviceId) - utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled) - - - //String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId") - //execution.setVariable("DDVAM_modelInvariantId", modelInvariantId) - //utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) - - //String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") - //if (modelVersionId == null) { - // modelVersionId = "" - //} - //execution.setVariable("DDVAM_modelVersionId", modelVersionId) - //utils.log("DEBUG", "Incoming Version Id is: " + modelVersionId, isDebugEnabled) - - //String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion") - //execution.setVariable("DDVAM_modelVersion", modelVersion) - //utils.log("DEBUG", "Incoming Model Version is: " + modelVersion, isDebugEnabled) - - //String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName") - //execution.setVariable("DDVAM_modelName", modelName) - //utils.log("DEBUG", "Incoming Model Name is: " + modelName, isDebugEnabled) - - //String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId") - //if (modelCustomizationId == null) { - // modelCustomizationId = "" - //} - //execution.setVariable("DDVAM_modelCustomizationId", modelCustomizationId) - //utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) - - String cloudSiteId = execution.getVariable("lcpCloudRegionId") - execution.setVariable("DDVAM_cloudSiteId", cloudSiteId) - utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) - - String tenantId = execution.getVariable("tenantId") - execution.setVariable("DDVAM_tenantId", tenantId) - utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled) - - String globalSubscriberId = execution.getVariable("globalSubscriberId") - if (globalSubscriberId == null) { - globalSubscriberId = "" - } - execution.setVariable("DDVAM_globalSubscriberId", globalSubscriberId) - utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled) - - } - execution.setVariable("DDVAM_vfModulesFromDecomposition", null) - // Retrieve serviceDecomposition if present - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - if (serviceDecomposition != null) { - utils.log("DEBUG", "Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString(), isDebugEnabled) - List<VnfResource> vnfs = serviceDecomposition.getServiceVnfs() - utils.log("DEBUG", "Read vnfs", isDebugEnabled) - if (vnfs == null) { - utils.log("DEBUG", "Error - vnfs are empty in serviceDecomposition object", isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnfs are empty") - } - VnfResource vnf = vnfs[0] - - if (vnf == null) { - utils.log("DEBUG", "Error - vnf is empty in serviceDecomposition object", isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnf is empty") - } - - List<ModuleResource> vfModules = vnf.getAllVfModuleObjects() - - execution.setVariable("DDVAM_vfModulesFromDecomposition", vfModules) - } - - execution.setVariable("DDVAM_moduleCount", 0) - execution.setVariable("DDVAM_nextModule", 0) - - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - }catch(Exception e){ - utils.log("DEBUG", " Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest") - - } - utils.log("DEBUG", "*** COMPLETED DoDeleteVnfAndModules PreProcessRequest Process ***", isDebugEnabled) - } - - - - public void preProcessAddOnModule(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessAddOnModule ======== ", isDebugLogEnabled) - - try { - JSONArray addOnModules = (JSONArray) execution.getVariable("addOnModules") - int addOnIndex = (int) execution.getVariable("addOnModulesDeployed") - - JSONObject addOnModule = addOnModules[addOnIndex] - - def newVfModuleId = UUID.randomUUID().toString() - execution.setVariable("addOnVfModuleId", newVfModuleId) - - execution.setVariable("instancesOfThisModelDeployed", 0) - - JSONObject addOnVfModuleModelInfoObject = jsonUtil.getJsonValueForKey(addOnModule, "modelInfo") - String addOnVfModuleModelInfo = addOnVfModuleModelInfoObject.toString() - execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) - String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel") - execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) - String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantUuid") - execution.setVariable("addOnPersonaModelId", addOnPersonaModelId) - String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount") - execution.setVariable("initialCount", addOnInitialCount) - - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - /** - * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. - * A 200 response is expected with the VNF info in the response body. Will find out the base module info. - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModule(DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.queryAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('vnfId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - utils.logAudit("AAI endPoint: " + endPoint) - - try { - utils.logAudit("createVfModule - invoking httpGet() to AAI") - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) - - def responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - //Map<String, String>[] vfModules = new HashMap<String,String>[] - List<ModuleResource> vfModulesFromDecomposition = execution.getVariable("DDVAM_vfModulesFromDecomposition") - def vfModulesList = new ArrayList<Map<String,String>>() - def vfModules = null - def vfModuleBaseEntry = null - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) - if (responseData != null) { - def vfModulesText = utils.getNodeXml(responseData, "vf-modules") - logDebug("vModulesText: " + vfModulesText, isDebugLogEnabled) - if (vfModulesText != null && !vfModulesText.trim().isEmpty()) { - def xmlVfModules= new XmlSlurper().parseText(vfModulesText) - vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} - execution.setVariable("DDVAM_moduleCount", vfModules.size()) - int vfModulesSize = 0 - ModelInfo vfModuleModelInfo = null - for (i in 0..vfModules.size()-1) { - def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - - Map<String, String> vfModuleEntry = new HashMap<String, String>() - def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") - vfModuleEntry.put("vfModuleId", vfModuleId) - def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name") - vfModuleEntry.put("vfModuleName", vfModuleName) - - // Find the model for this vf module in decomposition if specified - if (vfModulesFromDecomposition != null) { - logDebug("vfModulesFromDecomposition is not null", isDebugLogEnabled) - def vfModuleUuid = utils.getNodeText1(vfModuleXml, "model-version-id") - if (vfModuleUuid == null) { - vfModuleUuid = utils.getNodeText1(vfModuleXml, "persona-model-version") - } - logDebug("vfModule UUID is: " + vfModuleUuid, isDebugLogEnabled) - for (j in 0..vfModulesFromDecomposition.size()-1) { - ModuleResource mr = vfModulesFromDecomposition[j] - if (mr.getModelInfo().getModelUuid() == vfModuleUuid) { - logDebug("Found modelInfo", isDebugLogEnabled) - vfModuleModelInfo = mr.getModelInfo() - break - } - - } - } - if (vfModuleModelInfo != null) { - String vfModuleModelInfoString = vfModuleModelInfo.toString() - def vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfoString, "modelInfo") - vfModuleEntry.put("vfModuleModelInfo", vfModuleModelInfoValue) - } - else { - vfModuleEntry.put("vfModuleModelInfo", null) - } - - - def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") - // Save base vf module for last - if (isBaseVfModule == "true") { - vfModuleBaseEntry = vfModuleEntry - } - else { - vfModulesList.add(vfModuleEntry) - } - } - if (vfModuleBaseEntry != null) { - vfModulesList.add(vfModuleBaseEntry) - } - } - - } - } - execution.setVariable("DDVAM_vfModules", vfModulesList) - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) - } - } - - public void prepareNextModuleToDelete(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED prepareNextModuleToDelete ======== ", isDebugLogEnabled) - - try { - int i = execution.getVariable("DDVAM_nextModule") - def vfModules = execution.getVariable("DDVAM_vfModules") - def vfModule = vfModules[i] - - def vfModuleId = vfModule.get("vfModuleId") - execution.setVariable("DDVAM_vfModuleId", vfModuleId) - - def vfModuleName = vfModule.get("vfModuleName") - execution.setVariable("DDVAM_vfModuleName", vfModuleName) - - def vfModuleModelInfo = vfModule.get("vfModuleModelInfo") - logDebug("vfModuleModelInfo for module delete: " + vfModuleModelInfo, isDebugLogEnabled) - execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToDelete Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED prepareNextModuleToDelete ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCDeactivateRequest(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) - def vnfId = execution.getVariable("vnfId") - def serviceInstanceId = execution.getVariable("serviceInstanceId") - - try{ - //Build SDNC Request - - String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate") - - deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest) - execution.setVariable("DDVAM_deactivateSDNCRequest", deactivateSDNCRequest) - logDebug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preProcessSDNCDeactivateRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCDeactivateRequest ======== ", isDebugLogEnabled) - } - - public void preProcessSDNCUnassignRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) - try{ - String vnfId = execution.getVariable("vnfId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign") - - execution.setVariable("DDVAM_unassignSDNCRequest", unassignSDNCRequest) - logDebug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest, isDebugLogEnabled) - utils.logAudit("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest) - - }catch(Exception e){ - log.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCUnassignRequest Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCUnassignRequest Process ======== ", isDebugLogEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() - } - def callbackURL = execution.getVariable("sdncCallbackUrl") - def requestId = execution.getVariable("msoRequestId") - def serviceId = execution.getVariable("DDVAM_serviceId") - def tenantId = execution.getVariable("DDVAM_tenantId") - def source = execution.getVariable("DDVAM_source") - def vnfId = execution.getVariable("vnfId") - def serviceInstanceId = execution.getVariable("serviceInstanceId") - def cloudSiteId = execution.getVariable("DDVAM_cloudSiteId") - def modelCustomizationId = execution.getVariable("DDVAM_modelCustomizationId") - //def serviceModelInfo = execution.getVariable("serviceModelInfo") - //def vnfModelInfo = execution.getVariable("vnfModelInfo") - //String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo) - //String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo) - def globalSubscriberId = execution.getVariable("DDVAM_globalSubscriberId") - def sdncVersion = execution.getVariable("DDVAM_sdncVersion") - - String sdncRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>DeleteVnfInstance</request-action> - <source>${source}</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id/> - <subscription-service-type/> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <global-customer-id/> - </service-information> - <vnf-information> - <vnf-id>${vnfId}</vnf-id> - <vnf-type/> - </vnf-information> - <vnf-request-input> - <vnf-name/> - <tenant>${tenantId}</tenant> - <aic-cloud-region>${cloudSiteId}</aic-cloud-region> - </vnf-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - } - - public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - - - - - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy deleted file mode 100644 index b45a52b352..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleE2EServiceInstance.groovy +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 CMCC 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.infrastructure.scripts - -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONArray; -import static org.apache.commons.lang3.StringUtils.*; -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.json.JSONObject; -import org.springframework.web.util.UriUtils; - -/** - * This groovy class supports the <class>DoScaleServiceInstance.bpmn</class> process. - * - */ -public class DoScaleE2EServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix = "DCRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - String msg = "" - utils.log("DEBUG", " ***** preProcessRequest *****", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - execution.setVariable("prefix", Prefix) - - //Inputs - String globalSubscriberId = execution.getVariable("globalSubscriberId") - - String serviceType = execution.getVariable("serviceType") - String serviceInstanceName = execution.getVariable("serviceInstanceName") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - execution.setVariable("serviceType", serviceType) - - String resourceTemplateUUIDs = "" - String scaleNsRequest = execution.getVariable("bpmnRequest") - JSONObject jsonObject = new JSONObject(scaleNsRequest).getJSONObject("service") - JSONArray jsonArray = jsonObject.getJSONArray("resources") - - for (int i = 0; i < jsonArray.size(); i++) { - JSONObject reqBodyJsonObj = jsonArray.getJSONObject(i) - String nsInstanceId = reqBodyJsonObj.getString("resourceInstanceId") - resourceTemplateUUIDs = resourceTemplateUUIDs + nsInstanceId + ":" - } - - execution.setVariable("resourceTemplateUUIDs", resourceTemplateUUIDs) - - if (serviceInstanceName == null) { - execution.setVariable("serviceInstanceName", "") - } - if (isBlank(serviceInstanceId)) { - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", " ***** Exit preProcessRequest *****", isDebugEnabled) - } - - - public void preInitResourcesOperStatus(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = "SCALE" - - // resourceTemplateUUIDs should be created ?? - String resourceTemplateUUIDs = execution.getVariable("resourceTemplateUUIDs") - utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - - execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs> - </ns:initResourceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_initResOperStatusRequest", payload) - utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled) - utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage()) - } - utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy deleted file mode 100644 index c1ffc5abef..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoScaleVFCNetworkServiceInstance.groovy +++ /dev/null @@ -1,328 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 CMCC. 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.infrastructure.scripts - -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONArray -import org.json.JSONObject; - -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.json.JsonUtils - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -import org.codehaus.jackson.map.ObjectMapper - -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.rest.APIResponse; - -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.ScaleResource -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.ScaleNsByStepsData -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.ScaleNsData - -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.NSResourceInputParameter -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.NsOperationKey -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.NsScaleParameters -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.NsParameters -import org.openecomp.mso.bpmn.infrastructure.vfcmodel.LocationConstraint - - -/** - * This groovy class supports the <class>DoScaleVFCNetworkServiceInstance.bpmn</class> process. - * flow for VFC Network Service Scale - */ -public class DoScaleVFCNetworkServiceInstance extends AbstractServiceTaskProcessor { - - String host = "http://mso.mso.testlab.openecomp.org:8080" - - String scaleUrl = "/vfc/rest/v1/vfcadapter/ns/{nsInstanceId}/scale" - - String queryJobUrl = "/vfc/rest/v1/vfcadapter/jobs/{jobId}" - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - JsonUtils jsonUtil = new JsonUtils() - - /** - * Pre Process the BPMN Flow Request - * Inclouds: - * generate the nsOperationKey - * generate the nsParameters - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled) - - List<NSResourceInputParameter> nsRIPList = convertScaleNsReq2NSResInputParamList(execution) - String requestJsonStr = "" - int size = nsRIPList.size() - for (int i = 0; i < size; i++) { - NSResourceInputParameter nsRIP = nsRIPList.get(i) - - if (i == size - 1) { - requestJsonStr += objectToJsonStr(nsRIP) - } else { - requestJsonStr += objectToJsonStr(nsRIP) + "|" - } - } - - execution.setVariable("reqBody", requestJsonStr) - - utils.log("DEBUG", " ***** Exit preProcessRequest *****", isDebugEnabled) - } - - /** - * scale NS task - */ - public void scaleNetworkService(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - - String saleNsRequest = execution.getVariable("reqBody") - String[] nsReqStr = saleNsRequest.split("\\|") - - for (int i = 0; i < nsReqStr.length; i++) { - JSONObject reqBodyJsonObj = new JSONObject(nsReqStr[i]) - String nsInstanceId = reqBodyJsonObj.getJSONObject("nsScaleParameters").getString("nsInstanceId") - String nodeTemplateUUID = reqBodyJsonObj.getJSONObject("nsOperationKey").getString("nodeTemplateUUID") - reqBodyJsonObj.getJSONObject("nsScaleParameters").remove("nsInstanceId") - String reqBody = reqBodyJsonObj.toString() - - String url = host + scaleUrl.replaceAll("\\{nsInstanceId\\}", nsInstanceId) - - APIResponse apiResponse = postRequest(execution, url, reqBody) - - String returnCode = apiResponse.getStatusCode() - String aaiResponseAsString = apiResponse.getResponseBodyAsString() - String jobId = "" - if (returnCode == "200" || returnCode == "202") { - jobId = jsonUtil.getJsonValue(aaiResponseAsString, "jobId") - } - utils.log("INFO", "scaleNetworkService get a ns scale job Id:" + jobId, isDebugEnabled) - execution.setVariable("jobId", jobId) - execution.setVariable("nodeTemplateUUID", nodeTemplateUUID) - - String isScaleFinished = "" - - if(jobId =="" || jobId == null){ - continue - } - // query the requested network service scale status, if finished, then start the next one, otherwise, wait - while (isScaleFinished != "finished" && isScaleFinished != "error"){ - timeDelay() - queryNSProgress(execution) - isScaleFinished = execution.getVariable("operationStatus") - } - } - } - - /** - * query NS task - */ - private void queryNSProgress(DelegateExecution execution) { - String jobId = execution.getVariable("jobId") - String url = host + queryJobUrl.replaceAll("\\{jobId\\}", jobId) - - NsOperationKey nsOperationKey = new NsOperationKey() - // is this net work service ID or E2E service ID? - nsOperationKey.setServiceId(execution.getVariable("serviceId")) - nsOperationKey.setServiceType(execution.getVariable("serviceType")) - nsOperationKey.setGlobalSubscriberId(execution.getVariable("globalSubscriberId")) - nsOperationKey.setNodeTemplateUUID(execution.getVariable("nodeTemplateUUID")) - nsOperationKey.setOperationId(execution.getVariable("operationId")) - String queryReqBody = objectToJsonStr(nsOperationKey) - - APIResponse apiResponse = postRequest(execution,url, queryReqBody) - - String returnCode = apiResponse.getStatusCode() - String aaiResponseAsString = apiResponse.getResponseBodyAsString() - - String operationStatus = "error" - - if (returnCode == "200") { - operationStatus = jsonUtil.getJsonValue(aaiResponseAsString, "responseDescriptor.status") - } - - execution.setVariable("operationStatus", operationStatus) - } - - /** - * delay 5 sec - * - */ - private void timeDelay() { - try { - Thread.sleep(5000) - } catch (InterruptedException e) { - taskProcessor.utils.log("ERROR", "Time Delay exception" + e, isDebugEnabled) - } - } - - /** - * finish NS task - */ - public void finishNSScale(DelegateExecution execution) { - //no need to do anything util now - System.out.println("Scale finished.") - } - - /** - * 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("Authorization","Basic QlBFTENsaWVudDpwYXNzd29yZDEk") -// 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 VFC Post Call. Exception is: \n" + e, isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - return apiResponse - } - - /** - * create a Scale Resource object list from a NSScaleRequestJso nString - * This method is for the specific request from Scale Network Service BPMN workflow - * @param nsScaleRequestJsonString , a specific request Json string which conform to ?? class - * @return List < ScaleResource > - */ - private List<ScaleResource> jsonGetNsResourceList(String nsScaleRequestJsonString) { - List<ScaleResource> list = new ArrayList<ScaleResource>() - JSONObject jsonObject = new JSONObject(nsScaleRequestJsonString) - - JSONObject jsonResource = jsonObject.getJSONObject("service") - JSONArray arr = jsonResource.getJSONArray("resources") - - for (int i = 0; i < arr.length(); i++) { - JSONObject tempResource = arr.getJSONObject(i) - ScaleResource resource = new ScaleResource() - resource.setResourceInstanceId(tempResource.getString("resourceInstanceId")) - resource.setScaleType(tempResource.getString("scaleType")) - - JSONObject jsonScaleNsData = tempResource.getJSONObject("scaleNsData") - JSONObject jsonScaleNsByStepData = jsonScaleNsData.getJSONObject("scaleNsByStepsData") - - ScaleNsData scaleNsData = new ScaleNsData() - ScaleNsByStepsData stepsData = new ScaleNsByStepsData() - - stepsData.setAspectId(jsonScaleNsByStepData.getString("aspectId")) - stepsData.setScalingDirection(jsonScaleNsByStepData.getString("scalingDirection")) - stepsData.setNumberOfSteps(Integer.parseInt(jsonScaleNsByStepData.getString("numberOfSteps"))) - - scaleNsData.setScaleNsByStepsData(stepsData) - resource.setScaleNsData(scaleNsData) - list.add(resource) - } - - return list - } - - /** - * Convert a java class to JSON string - * @param obj - * @return - */ - private String objectToJsonStr(Object obj) { - ObjectMapper mapper = new ObjectMapper() - String jsonStr = null - try { - jsonStr = mapper.writeValueAsString(obj) - } catch (IOException ioe) { - System.out.println(ioe.getMessage()) - } - return jsonStr - - } - - /** - * create a NSResourceInputParameter list from a Scale Network request Json string - * @return - */ - private List<NSResourceInputParameter> convertScaleNsReq2NSResInputParamList(DelegateExecution execution) { - String saleNsRequest = execution.getVariable("bpmnRequest") - - //String requestId = execution.getVariable("msoRequestId") - //String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceInstanceName = execution.getVariable("serviceInstanceName") - //String nodeTemplateUUID = execution.getVariable("nodeTemplateUUID") - String serviceType = execution.getVariable("serviceType") - String globalSubscriberId = execution.getVariable("globalSubscriberId") - String operationId = execution.getVariable("operationId") - String serviceId = execution.getVariable("serviceId") - String nsServiceDescription = execution.getVariable("requestDescription") - - String resource = JsonUtils.getJsonValue(saleNsRequest, "service.resources") - - // set nsScaleParameters properties - List<ScaleResource> scaleResourcesList = jsonGetNsResourceList(saleNsRequest) - List<NSResourceInputParameter> nsResourceInputParameterList = new ArrayList<NSResourceInputParameter>() - - for (ScaleResource sr : scaleResourcesList) { - NSResourceInputParameter nsResourceInputParameter = new NSResourceInputParameter() - NsOperationKey nsOperationKey = new NsOperationKey() - NsParameters nsParameters = new NsParameters() - NsScaleParameters nsScaleParameters = new NsScaleParameters() - nsParameters.setLocationConstraints(new ArrayList<LocationConstraint>()) - nsParameters.setAdditionalParamForNs(new HashMap<String, Object>()) - - // set NsOperationKey properties - nsOperationKey.setGlobalSubscriberId(globalSubscriberId) - nsOperationKey.setServiceId(serviceId) - nsOperationKey.setServiceType(serviceType) - // for ns scale the resourceInstanceId is the nodeTemplateUUID - nsOperationKey.setNodeTemplateUUID(sr.getResourceInstanceId()) - nsOperationKey.setOperationId(operationId) - - nsScaleParameters.setScaleType(sr.getScaleType()) - nsScaleParameters.setNsInstanceId(sr.getResourceInstanceId()) - - ScaleNsByStepsData scaleNsByStepsData = new ScaleNsByStepsData() - scaleNsByStepsData.setScalingDirection(sr.getScaleNsData().getScaleNsByStepsData().getScalingDirection()) - scaleNsByStepsData.setNumberOfSteps(sr.getScaleNsData().getScaleNsByStepsData().getNumberOfSteps()) - scaleNsByStepsData.setAspectId(sr.getScaleNsData().getScaleNsByStepsData().getAspectId()) - - List<ScaleNsByStepsData> scaleNsByStepsDataList = new ArrayList<ScaleNsByStepsData>() - scaleNsByStepsDataList.add(scaleNsByStepsData) - nsScaleParameters.setScaleNsByStepsData(scaleNsByStepsDataList) - - nsResourceInputParameter.setNsOperationKey(nsOperationKey) - nsResourceInputParameter.setNsServiceName(serviceInstanceName) - nsResourceInputParameter.setNsServiceDescription(nsServiceDescription) - nsResourceInputParameter.setNsParameters(nsParameters) - nsResourceInputParameter.setNsScaleParameters(nsScaleParameters) - - nsResourceInputParameterList.add(nsResourceInputParameter) - } - return nsResourceInputParameterList - } -} - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy deleted file mode 100644 index 74c991e637..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstance.groovy +++ /dev/null @@ -1,465 +0,0 @@ -/*-
- * ============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.infrastructure.scripts;
-
-import static org.apache.commons.lang3.StringUtils.*;
-import groovy.xml.XmlUtil
-import groovy.json.*
-import groovy.util.XmlParser
-
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
-import org.openecomp.mso.bpmn.core.domain.ServiceInstance
-import org.openecomp.mso.bpmn.core.domain.ModelInfo
-import org.openecomp.mso.bpmn.core.domain.Resource
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse;
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-import java.util.UUID;
-import javax.xml.parsers.DocumentBuilder
-import javax.xml.parsers.DocumentBuilderFactory
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils;
-
-
-/**
- * This groovy class supports the <class>DoUpdateE2EServiceInstance.bpmn</class> process.
- *
- * Inputs:
- * @param - msoRequestId
- * @param - globalSubscriberId
- * @param - serviceType
- * @param - serviceInstanceId
- * @param - serviceInstanceName
- * @param - serviceModelInfo
- * @param - productFamilyId
- * @param - uuiRequest
- * @param - serviceDecomposition_Target
- * @param - serviceDecomposition_Original
- * @param - addResourceList
- * @param - delResourceList
- *
- * Outputs:
- * @param - rollbackData (localRB->null)
- * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true)
- * @param - WorkflowException
- */
-public class DoUpdateE2EServiceInstance extends AbstractServiceTaskProcessor {
-
- String Prefix="DUPDSI_"
- private static final String DebugFlag = "isDebugEnabled"
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** Enter DoUpdateE2EServiceInstance preProcessRequest *****", isDebugEnabled)
-
- String msg = ""
-
- try {
- execution.setVariable("prefix", Prefix)
- //Inputs
- //for AAI GET & PUT & SDNC assignToplology
- String globalSubscriberId = execution.getVariable("globalSubscriberId") //globalCustomerId
- utils.log("INFO"," ***** globalSubscriberId *****" + globalSubscriberId, isDebugEnabled)
-
- //for AAI PUT & SDNC assignTopology
- String serviceType = execution.getVariable("serviceType")
- utils.log("INFO"," ***** serviceType *****" + serviceType, isDebugEnabled)
-
- //for SDNC assignTopology
- String productFamilyId = execution.getVariable("productFamilyId") //AAI productFamilyId
-
- if (isBlank(globalSubscriberId)) {
- msg = "Input globalSubscriberId is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- if (isBlank(serviceType)) {
- msg = "Input serviceType is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- //Generated in parent for AAI
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- if (isBlank(serviceInstanceId)){
- msg = "Input serviceInstanceId is null"
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
- }
-
- String serviceInstanceName = execution.getVariable("serviceInstanceName")
-
- // user params
- String uuiRequest = execution.getVariable("uuiRequest")
-
- // target model Invariant uuid
- String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid")
- execution.setVariable("modelInvariantUuid", modelInvariantUuid)
- utils.log("INFO", "modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled)
-
- // target model uuid
- String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid")
- execution.setVariable("modelUuid", modelUuid)
- utils.log("INFO", "modelUuid: " + modelUuid, isDebugEnabled)
-
- } 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", "======== COMPLETED preProcessRequest Process ======== ", isDebugEnabled)
- }
-
-
- public void preInitResourcesOperStatus(DelegateExecution execution){
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
-
- utils.log("INFO", " ======== STARTED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
- try{
- String serviceId = execution.getVariable("serviceInstanceId")
- String operationId = execution.getVariable("operationId")
- String operationType = execution.getVariable("operationType")
- String resourceTemplateUUIDs = ""
- String result = "processing"
- String progress = "0"
- String reason = ""
- String operationContent = "Prepare service updating"
- utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId + " operationType:" + operationType, isDebugEnabled)
- serviceId = UriUtils.encode(serviceId,"UTF-8")
- execution.setVariable("serviceInstanceId", serviceId)
- execution.setVariable("operationId", operationId)
- execution.setVariable("operationType", operationType)
-
- List<Resource> resourceList = new ArrayList<String>()
- List<Resource> addResourceList = execution.getVariable("addResourceList")
- List<Resource> delResourceList = execution.getVariable("delResourceList")
- resourceList.addAll(addResourceList)
- resourceList.addAll(delResourceList)
- for(Resource resource : resourceList){
- resourceTemplateUUIDs = resourceTemplateUUIDs + resource.getModelInfo().getModelCustomizationUuid() + ":"
- }
-
- def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter"
- execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
- utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
-
- String payload =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:initResourceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb">
- <serviceId>${serviceId}</serviceId>
- <operationId>${operationId}</operationId>
- <operationType>${operationType}</operationType>
- <resourceTemplateUUIDs>${resourceTemplateUUIDs}</resourceTemplateUUIDs>
- </ns:initResourceOperationStatus>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- payload = utils.formatXml(payload)
- execution.setVariable("CVFMI_initResOperStatusRequest", payload)
- utils.log("INFO", "Outgoing initResourceOperationStatus: \n" + payload, isDebugEnabled)
- utils.logAudit("CreateVfModuleInfra Outgoing initResourceOperationStatus Request: " + payload)
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preInitResourcesOperStatus. Exception is:\n" + e, isDebugEnabled)
- execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preInitResourcesOperStatus Method:\n" + e.getMessage())
- }
- utils.log("INFO", "======== COMPLETED preInitResourcesOperStatus Process ======== ", isDebugEnabled)
- }
-
-
- public void preProcessForAddResource(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** preProcessForAddResource ***** ", isDebugEnabled)
-
- execution.setVariable("operationType", "create")
-
- execution.setVariable("hasResourcetoAdd", false)
- List<Resource> addResourceList = execution.getVariable("addResourceList")
- if(addResourceList != null && !addResourceList.isEmpty()) {
- execution.setVariable("hasResourcetoAdd", true)
- }
-
- utils.log("INFO"," *** Exit preProcessForAddResource *** ", isDebugEnabled)
- }
-
- public void postProcessForAddResource(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** postProcessForAddResource ***** ", isDebugEnabled)
-
- execution.setVariable("operationType", "update")
-
- utils.log("INFO"," *** Exit postProcessForAddResource *** ", isDebugEnabled)
- }
-
- public void preProcessForDeleteResource(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** preProcessForDeleteResource ***** ", isDebugEnabled)
-
- execution.setVariable("operationType", "delete")
-
- def hasResourcetoDelete = false
- List<Resource> delResourceList = execution.getVariable("delResourceList")
- if(delResourceList != null && !delResourceList.isEmpty()) {
- hasResourcetoDelete = true
- }
- execution.setVariable("hasResourcetoDelete", hasResourcetoDelete)
-
- if(hasResourcetoDelete) {
- def jsonSlurper = new JsonSlurper()
- String serviceRelationShip = execution.getVariable("serviceRelationShip")
- List relationShipList = jsonSlurper.parseText(serviceRelationShip)
-
- //Set the real resource instance id to the decomosed resource list
- for(Resource resource: delResourceList){
- //reset the resource instance id , because in the decompose flow ,its a random one.
- resource.setResourceId("");
- //match the resource-instance-name and the model name
- if (relationShipList != null) {
- relationShipList.each {
- if(StringUtils.containsIgnoreCase(it.resourceType, resource.getModelInfo().getModelName())){
- resource.setResourceId(it.resourceInstanceId);
- }
- }
- }
- }
- }
-
- execution.setVariable("deleteResourceList", delResourceList)
-
- utils.log("INFO"," *** Exit preProcessForDeleteResource *** ", isDebugEnabled)
- }
-
- public void postProcessForDeleteResource(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** postProcessForDeleteResource ***** ", isDebugEnabled)
-
- execution.setVariable("operationType", "update")
-
- utils.log("INFO"," *** Exit postProcessForDeleteResource *** ", isDebugEnabled)
- }
-
- public void preProcessAAIGET(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- }
-
- public void postProcessAAIGET(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled)
- String msg = ""
-
- try {
- String serviceInstanceName = execution.getVariable("serviceInstanceName")
- boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator")
- if(!succInAAI){
- utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET", + serviceInstanceName, isDebugEnabled)
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- utils.logAudit("workflowException: " + workflowException)
- if(workflowException != null){
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
- }
- else
- {
- msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
- }
- }
- else
- {
- boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator")
- if(foundInAAI){
- String aaiService = execution.getVariable("GENGS_service")
- if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "resource-version"))) {
- execution.setVariable("serviceInstanceVersion", utils.getNodeText1(aaiService, "resource-version"))
- utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled)
- }
- }
- }
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Exception in DoUpdateE2EServiceInstance.postProcessAAIGET " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled)
- }
-
- public void preProcessAAIPUT(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')'
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- utils.log("INFO","Entered " + method, isDebugEnabled)
- String msg = ""
- utils.log("INFO"," ***** preProcessAAIPUT *****", isDebugEnabled)
-
-
- String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion")
- //execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion)
-
- //requestDetails.modelInfo.for AAI PUT servieInstanceData
- //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData
- String serviceInstanceName = execution.getVariable("serviceInstanceName")
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- //aai serviceType and Role can be setted as fixed value now.
- String aaiServiceType = "E2E Service"
- String aaiServiceRole = "E2E Service"
- String modelInvariantUuid = execution.getVariable("modelInvariantUuid")
- String modelUuid = execution.getVariable("modelUuid")
-
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
- utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled)
- String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution)
- utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled)
- String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri)
- utils.log("INFO","namespace: " + namespace, isDebugEnabled)
-
- //update target model to aai
- String serviceInstanceData =
- """<service-instance xmlns=\"${namespace}\">
- <service-instance-id>${serviceInstanceId}</service-instance-id>
- <service-instance-name>${serviceInstanceName}</service-instance-name>
- <service-type>${aaiServiceType}</service-type>
- <service-role>${aaiServiceRole}</service-role>
- <resource-version>${serviceInstanceVersion}</resource-version>
- <model-invariant-id>${modelInvariantUuid}</model-invariant-id>
- <model-version-id>${modelUuid}</model-version-id>
- </service-instance>""".trim()
-
- execution.setVariable("serviceInstanceData", serviceInstanceData)
- utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled)
- utils.logAudit(serviceInstanceData)
- utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled)
- utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled)
-
- utils.log("INFO", "Exited " + method, isDebugEnabled)
- }
-
- public void postProcessAAIPUT(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled)
- String msg = ""
- try {
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator")
- if(!succInAAI){
- utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled)
- WorkflowException workflowException = execution.getVariable("WorkflowException")
- utils.logAudit("workflowException: " + workflowException)
- if(workflowException != null){
- exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage())
- }
- }
- else
- {
- //start rollback set up
- RollbackData rollbackData = new RollbackData()
- def disableRollback = execution.getVariable("disableRollback")
- rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
- rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
- rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", serviceInstanceId)
- rollbackData.put("SERVICEINSTANCE", "serviceType", execution.getVariable("serviceType"))
- rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
- execution.setVariable("rollbackData", rollbackData)
- }
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex) {
- msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled)
- }
-
- public void preProcessRollback (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** preProcessRollback ***** ", isDebugEnabled)
- try {
-
- Object workflowException = execution.getVariable("WorkflowException");
-
- if (workflowException instanceof WorkflowException) {
- utils.log("INFO", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled)
- execution.setVariable("prevWorkflowException", workflowException);
- //execution.setVariable("WorkflowException", null);
- }
- } catch (BpmnError e) {
- utils.log("INFO", "BPMN Error during preProcessRollback", isDebugEnabled)
- } catch(Exception ex) {
- String msg = "Exception in preProcessRollback. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- }
- utils.log("INFO"," *** Exit preProcessRollback *** ", isDebugEnabled)
- }
-
- public void postProcessRollback (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- utils.log("INFO"," ***** postProcessRollback ***** ", isDebugEnabled)
- String msg = ""
- try {
- Object workflowException = execution.getVariable("prevWorkflowException");
- if (workflowException instanceof WorkflowException) {
- utils.log("INFO", "Setting prevException to WorkflowException: ", isDebugEnabled)
- execution.setVariable("WorkflowException", workflowException);
- }
- execution.setVariable("rollbackData", null)
- } catch (BpmnError b) {
- utils.log("INFO", "BPMN Error during postProcessRollback", isDebugEnabled)
- throw b;
- } catch(Exception ex) {
- msg = "Exception in postProcessRollback. " + ex.getMessage()
- utils.log("INFO", msg, isDebugEnabled)
- }
- utils.log("INFO"," *** Exit postProcessRollback *** ", isDebugEnabled)
- }
-
-
- public void postConfigRequest(execution){
- //now do noting
- }
-
-
-}
-
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy deleted file mode 100644 index a55ca0225a..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateE2EServiceInstanceRollback.groovy +++ /dev/null @@ -1,368 +0,0 @@ -/*- - * ============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.infrastructure.scripts - - -import static org.apache.commons.lang3.StringUtils.*; -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.rest.APIResponse; -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; -/** - * This groovy class supports the <class>DoUpdateE2EServiceInstanceRollback.bpmn</class> process. - * - * Inputs: - * @param - msoRequestId - * @param - rollbackData with - * globalCustomerId - * subscriptionServiceType - * serviceInstanceId - * disableRollback - * rollbackAAI - * rollbackAdded - * rollbackDeleted - * - * - * Outputs: - * @param - rollbackError - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * - */ -public class DoUpdateE2EServiceInstanceRollback extends AbstractServiceTaskProcessor{ - - String Prefix="DUPDSIRB_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - execution.setVariable("rollbackAAI",false) - execution.setVariable("rollbackAdded",false) - execution.setVariable("rollbackDeleted",false) - - List addResourceList = execution.getVariable("addResourceList") - List delResourceList = execution.getVariable("delResourceList") - execution.setVariable("addResourceList_o", addResourceList) - execution.setVariable("delResourceList_o", delResourceList) - //exchange add and delete resource list - execution.setVariable("addResourceList", delResourceList) - execution.setVariable("delResourceList", addResourceList) - - try { - def rollbackData = execution.getVariable("rollbackData") - utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) - - if (rollbackData != null) { - if (rollbackData.hasType("SERVICEINSTANCE")) { - - def serviceInstanceId = rollbackData.get("SERVICEINSTANCE", "serviceInstanceId") - execution.setVariable("serviceInstanceId", serviceInstanceId) - - def subscriptionServiceType = rollbackData.get("SERVICEINSTANCE", "subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - - def globalSubscriberId = rollbackData.get("SERVICEINSTANCE", "globalSubscriberId") - execution.setVariable("globalSubscriberId", globalSubscriberId) - - def rollbackAAI = rollbackData.get("SERVICEINSTANCE", "rollbackAAI") - if ("true".equals(rollbackAAI)) - { - execution.setVariable("rollbackAAI",true) - } - - def rollbackAdded = rollbackData.get("SERVICEINSTANCE", "rollbackAdded") - if ("true".equals(rollbackAdded)) - { - execution.setVariable("rollbackAdded", true) - } - - def rollbackDeleted = rollbackData.get("SERVICEINSTANCE", "rollbackDeleted") - if ("true".equals(rollbackDeleted)) - { - execution.setVariable("rollbackDeleted", true) - } - - if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackAdded") != true - && execution.getVariable("rollbackDeleted") != true) - { - execution.setVariable("skipRollback", true) - } - - } - else { - execution.setVariable("skipRollback", true) - } - } - else { - execution.setVariable("skipRollback", true) - } - if (execution.getVariable("disableRollback").equals("true" )) - { - execution.setVariable("skipRollback", true) - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - msg = "Exception in Update ServiceInstance Rollback preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void postProcessRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled) - String msg = "" - try { - execution.setVariable("rollbackData", null) - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean rollbackAAI = execution.getVariable("rollbackAAI") - boolean rollbackAdded = execution.getVariable("rollbackAdded") - boolean rollbackDeleted = execution.getVariable("rollbackDeleted") - - List addResourceList = execution.getVariable("addResourceList_o") - List delResourceList = execution.getVariable("delResourceList_o") - execution.setVariable("addResourceList", addResourceList) - execution.setVariable("delResourceList", delResourceList) - - if (rollbackAAI || rollbackAdded || rollbackDeleted) - { - execution.setVariable("rolledBack", true) - } - if (rollbackAAI) - { - boolean succInAAI = execution.getVariable("GENDS_SuccessIndicator") - if(!succInAAI){ - execution.setVariable("rolledBack", false) //both sdnc and aai must be successful to declare rollback Succesful - execution.setVariable("rollbackError", "Error deleting service-instance in AAI for rollback") - utils.log("DEBUG","Error deleting service-instance in AAI for rollback", + serviceInstanceId, isDebugEnabled) - } - } - utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled) - - } catch (BpmnError e) { - msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + e.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } catch (Exception ex) { - msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - } - - - public void preProcessForAddResource(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - } - - public void postProcessForAddResource(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - } - - public void preProcessForDeleteResource(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - } - - public void postProcessForDeleteResource(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - } - - public void preProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - } - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceName = execution.getVariable("serviceInstanceName") - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI in postProcessAAIGET", + serviceInstanceName, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - else - { - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - if(foundInAAI){ - String aaiService = execution.getVariable("GENGS_service") - if (!isBlank(aaiService) && (utils.nodeExists(aaiService, "resource-version"))) { - execution.setVariable("serviceInstanceVersion_n", utils.getNodeText1(aaiService, "resource-version")) - utils.log("INFO","Found Service-instance in AAI.serviceInstanceName:" + execution.getVariable("serviceInstanceName"), isDebugEnabled) - } - } - } - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIGET " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - public void preProcessAAIPUT(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' +'execution=' + execution.getId() +')' - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO","Entered " + method, isDebugEnabled) - String msg = "" - utils.log("INFO"," ***** preProcessAAIPUT *****", isDebugEnabled) - - String serviceInstanceVersion = execution.getVariable("serviceInstanceVersion_n") -// execution.setVariable("GENPS_serviceResourceVersion", serviceInstanceVersion) - - //requestDetails.modelInfo.for AAI PUT servieInstanceData - //requestDetails.requestInfo. for AAI GET/PUT serviceInstanceData - String serviceInstanceName = execution.getVariable("serviceInstanceName") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - //aai serviceType and Role can be setted as fixed value now. - String aaiServiceType = "E2E Service" - String aaiServiceRole = "E2E Service" - String modelInvariantUuid = execution.getVariable("modelInvariantUuid") - String modelUuid = execution.getVariable("model-version-id-original") - - //AAI PUT - AaiUtil aaiUriUtil = new AaiUtil(this) - utils.log("INFO","start create aai uri: " + aaiUriUtil, isDebugEnabled) - String aai_uri = aaiUriUtil.getBusinessCustomerUri(execution) - utils.log("INFO","aai_uri: " + aai_uri, isDebugEnabled) - String namespace = aaiUriUtil.getNamespaceFromUri(aai_uri) - utils.log("INFO","namespace: " + namespace, isDebugEnabled) - - String serviceInstanceData = - """<service-instance xmlns=\"${namespace}\"> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <service-instance-name>${serviceInstanceName}</service-instance-name> - <service-type>${aaiServiceType}</service-type> - <service-role>${aaiServiceRole}</service-role> - <resource-version>${serviceInstanceVersion}</resource-version> - <model-invariant-id>${modelInvariantUuid}</model-invariant-id> - <model-version-id>${modelUuid}</model-version-id> - </service-instance>""".trim() - - execution.setVariable("serviceInstanceData", serviceInstanceData) - utils.log("INFO","serviceInstanceData: " + serviceInstanceData, isDebugEnabled) - utils.logAudit(serviceInstanceData) - utils.log("INFO", " aai_uri " + aai_uri + " namespace:" + namespace, isDebugEnabled) - utils.log("INFO", " 'payload' to update Service Instance in AAI - " + "\n" + serviceInstanceData, isDebugEnabled) - - utils.log("INFO", "Exited " + method, isDebugEnabled) - } - - public void postProcessAAIPUT(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIPUT ***** ", isDebugEnabled) - String msg = "" - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean succInAAI = execution.getVariable("GENPS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error putting Service-instance in AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - } - else - { - - } - - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoCreateServiceInstance.postProcessAAIDEL. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIPUT *** ", isDebugEnabled) - } - - public void processRollbackException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled) - try{ - utils.log("DEBUG", "Caught an Exception in DoUpdateE2EServiceInstanceRollback", isDebugEnabled) - execution.setVariable("rollbackData", null) - execution.setVariable("rollbackError", "Caught exception in ServiceInstance Update Rollback") - execution.setVariable("WorkflowException", null) - - }catch(BpmnError b){ - utils.log("DEBUG", "BPMN Error during processRollbackExceptions Method: ", isDebugEnabled) - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processRollbackExceptions Method: " + e.getMessage(), isDebugEnabled) - } - - utils.log("DEBUG", " Exit processRollbackException", isDebugEnabled) - } - - public void processRollbackJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled) - try{ - execution.setVariable("rollbackData", null) - execution.setVariable("rollbackError", "Caught Java exception in ServiceInstance Update Rollback") - utils.log("DEBUG", "Caught Exception in processRollbackJavaException", isDebugEnabled) - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception in processRollbackJavaException " + e.getMessage(), isDebugEnabled) - } - utils.log("DEBUG", "***** Exit processRollbackJavaException *****", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy deleted file mode 100644 index 829e4d9d4b..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy +++ /dev/null @@ -1,1403 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the <class>DoUpdateNetworkInstance.bpmn</class> process. - * - */ -public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { - String Prefix="UPDNETI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "messageId", "") - execution.setVariable("BasicAuthHeaderValuePO", "") - execution.setVariable("BasicAuthHeaderValueSDNC", "") - execution.setVariable(Prefix + "networkRequest", "") - execution.setVariable(Prefix + "networkInputs", "") - execution.setVariable(Prefix + "networkOutputs", "") - execution.setVariable(Prefix + "requestId", "") - execution.setVariable(Prefix + "source", "") - execution.setVariable(Prefix + "networkId", "") - - execution.setVariable(Prefix + "isPONR", false) // Point-of-no-return, means, rollback is not needed - - // AAI query Cloud Region - execution.setVariable(Prefix + "queryCloudRegionRequest","") - execution.setVariable(Prefix + "queryCloudRegionReturnCode","") - execution.setVariable(Prefix + "queryCloudRegionResponse","") - execution.setVariable(Prefix + "cloudRegionPo","") - execution.setVariable(Prefix + "cloudRegionSdnc","") - execution.setVariable(Prefix + "isCloudRegionGood", false) - - // AAI query Id - execution.setVariable(Prefix + "queryIdAAIRequest","") - execution.setVariable(Prefix + "queryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiIdReturnCode", "") - - // AAI query vpn binding - execution.setVariable(Prefix + "queryVpnBindingAAIRequest","") - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "") - execution.setVariable(Prefix + "vpnBindings", null) - execution.setVariable(Prefix + "vpnCount", 0) - execution.setVariable(Prefix + "routeCollection", "") - - // AAI query network policy - execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest","") - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "") - execution.setVariable(Prefix + "networkPolicyUriList", null) - execution.setVariable(Prefix + "networkPolicyCount", 0) - execution.setVariable(Prefix + "networkCollection", "") - - // AAI query route table reference - execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest","") - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", "") - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "") - execution.setVariable(Prefix + "networkTableRefUriList", null) - execution.setVariable(Prefix + "networkTableRefCount", 0) - execution.setVariable(Prefix + "tableRefCollection", "") - - // AAI requery Id - execution.setVariable(Prefix + "requeryIdAAIRequest","") - execution.setVariable(Prefix + "requeryIdAAIResponse", "") - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", "") - - // AAI update contrail - execution.setVariable(Prefix + "updateContrailAAIUrlRequest","") - execution.setVariable(Prefix + "updateContrailAAIPayloadRequest","") - execution.setVariable(Prefix + "updateContrailAAIResponse", "") - execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", "") - - execution.setVariable(Prefix + "updateNetworkRequest", "") - execution.setVariable(Prefix + "updateNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - execution.setVariable(Prefix + "networkReturnCode", "") - execution.setVariable(Prefix + "isNetworkRollbackNeeded", false) - - execution.setVariable(Prefix + "changeAssignSDNCRequest", "") - execution.setVariable(Prefix + "changeAssignSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - execution.setVariable(Prefix + "sdncReturnCode", "") - execution.setVariable(Prefix + "isSdncRollbackNeeded", false) - execution.setVariable(Prefix + "sdncResponseSuccess", false) - - execution.setVariable(Prefix + "isVnfBindingPresent", false) - execution.setVariable(Prefix + "Success", false) - execution.setVariable(Prefix + "serviceInstanceId", "") - - execution.setVariable(Prefix + "isException", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest DoUpdateNetworkInstance Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request & validate 3 kinds of format. - execution.setVariable("action", "UPDATE") - String networkRequest = execution.getVariable("bpmnRequest") - if (networkRequest != null) { - if (networkRequest.contains("requestDetails")) { - // JSON format request is sent, create xml - try { - def prettyJson = JsonOutput.prettyPrint(networkRequest.toString()) - utils.log("DEBUG", " Incoming message formatted . . . : " + '\n' + prettyJson, isDebugEnabled) - networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, networkRequest) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } else { - // XML format request is sent - - } - } else { - // vIPR format request is sent, create xml from individual variables - networkRequest = vidUtils.createXmlNetworkRequestInstance(execution) - } - - networkRequest = utils.formatXml(networkRequest) - utils.logAudit(networkRequest) - execution.setVariable(Prefix + "networkRequest", networkRequest) - utils.log("DEBUG", " network-request - " + '\n' + networkRequest, isDebugEnabled) - - // validate 'disableRollback' (aka, 'suppressRollback') - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) - execution.setVariable(Prefix + "rollbackEnabled", rollbackEnabled) - utils.log("DEBUG", Prefix + "rollbackEnabled - " + rollbackEnabled, isDebugEnabled) - - String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable(Prefix + "networkInputs", networkInputs) - utils.log("DEBUG", Prefix + "networkInputs - " + '\n' + networkInputs, isDebugEnabled) - - // prepare messageId - String messageId = execution.getVariable(Prefix + "messageId") // for testing - if (messageId == null || messageId == "") { - messageId = UUID.randomUUID() - utils.log("DEBUG", " UPDNETI_messageId, random generated: " + messageId, isDebugEnabled) - } else { - utils.log("DEBUG", " UPDNETI_messageId, pre-assigned: " + messageId, isDebugEnabled) - } - execution.setVariable(Prefix + "messageId", messageId) - - String source = utils.getNodeText1(networkRequest, "source") - execution.setVariable(Prefix + "source", source) - utils.log("DEBUG", Prefix + "source - " + source, isDebugEnabled) - - String networkId = "" - if (utils.nodeExists(networkRequest, "network-id")) { - networkId = utils.getNodeText1(networkRequest, "network-id") - if (networkId == 'null' || networkId == "") { - sendSyncError(execution) - // missing value of networkId - String dataErrorMessage = "Variable 'network-id' value/element is missing." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - - String lcpCloudRegion = "" - if (utils.nodeExists(networkRequest, "aic-cloud-region")) { - lcpCloudRegion = utils.getNodeText1(networkRequest, "aic-cloud-region") - if ((lcpCloudRegion == 'null') || (lcpCloudRegion == "")) { - sendSyncError(execution) - String dataErrorMessage = "requestDetails has missing 'aic-cloud-region' value/element." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - String serviceInstanceId = "" - if (utils.nodeExists(networkRequest, "service-instance-id")) { - serviceInstanceId = utils.getNodeText1(networkRequest, "service-instance-id") - if ((serviceInstanceId == 'null') || (lcpCloudRegion == "")) { - sendSyncError(execution) - String dataErrorMessage = "Variable 'serviceInstanceId' value/element is missing." - utils.log("DEBUG", " Invalid Request - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - } - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, , isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - // Set variables for Generic Get Sub Flow use - execution.setVariable(Prefix + "serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", Prefix + "serviceInstanceId - " + serviceInstanceId, isDebugEnabled) - - execution.setVariable("GENGS_type", "service-instance") - utils.log("DEBUG", "GENGS_type - " + "service-instance", isDebugEnabled) - utils.log("DEBUG", " Url for SDNC adapter: " + execution.getVariable("URN_mso_adapters_sdnc_endpoint"), isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled) - - // build 'networkOutputs' - networkId = utils.getNodeText1(networkRequest, "network-id") - if ((networkId == null) || (networkId == "null")) { - networkId = "" - } - String networkName = utils.getNodeText1(networkRequest, "network-name") - if ((networkName == null) || (networkName == "null")) { - networkName = "" - } - String networkOutputs = - """<network-outputs> - <network-id>${networkId}</network-id> - <network-name>${networkName}</network-name> - </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - utils.log("DEBUG", Prefix + "networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - execution.setVariable(Prefix + "networkId", networkId) - execution.setVariable(Prefix + "networkName", networkName) - - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in DoUpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - public void callRESTQueryAAICloudRegion (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - String networkInputs = execution.getVariable(Prefix + "networkInputs") - String cloudRegion = utils.getNodeText1(networkInputs, "aic-cloud-region") - cloudRegion = UriUtils.encode(cloudRegion,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - utils.logAudit(queryCloudRegionRequest) - execution.setVariable(Prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - utils.log("DEBUG", " UPDNETI_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugEnabled) - - String cloudRegionPo = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion) - String cloudRegionSdnc = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "SDNC", cloudRegion) - - if ((cloudRegionPo != "ERROR") && (cloudRegionSdnc != "ERROR")) { - execution.setVariable(Prefix + "cloudRegionPo", cloudRegionPo) - execution.setVariable(Prefix + "cloudRegionSdnc", cloudRegionSdnc) - execution.setVariable(Prefix + "isCloudRegionGood", true) - - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable(Prefix + "queryCloudRegionReturnCode") - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(Prefix + "isCloudRegionGood"), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkId(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkId of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String networkId = utils.getNodeText1(networkRequest, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - execution.setVariable(Prefix + "networkId", networkId) - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String queryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - utils.logAudit(queryIdAAIRequest) - execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) - utils.log("DEBUG", Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiIdReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryIdAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkId is 404 (Not Found)." - utils.log("DEBUG", " AAI Query Failed. " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from QueryAAINetworkId - " + returnCode - utils.log("DEBUG", "Unexpected Response from QueryAAINetworkId - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTReQueryAAINetworkId(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTReQueryAAINetworkId of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String networkId = utils.getNodeText1(networkRequest, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String requeryIdAAIRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - utils.logAudit(requeryIdAAIRequest) - execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) - utils.log("DEBUG", " UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI ReQuery Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "requeryIdAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " ReQueryAAINetworkId Success REST Response - " + "\n" + aaiResponseAsString, isDebugEnabled) - - String netId = utils.getNodeText1(aaiResponseAsString, "network-id") - String netName = utils.getNodeText1(aaiResponseAsString, "network-name") - String networkOutputs = - """<network-outputs> - <network-id>${netId}</network-id> - <network-name>${netName}</network-name> - </network-outputs>""" - execution.setVariable(Prefix + "networkOutputs", networkOutputs) - utils.log("DEBUG", " networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from ReQueryAAINetworkId is 404 (Not Found)." - utils.log("DEBUG", " AAI ReQuery Failed. - " + dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from ReQueryAAINetworkId - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkVpnBinding(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkVpnBinding of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - - // get variables - String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Vnf Binding is present, then build a List of vnfBinding - List vpnBindingUri = networkUtils.getVnfBindingObject(relationship) - int vpnCount = vpnBindingUri.size() - execution.setVariable(Prefix + "vpnCount", vpnCount) - utils.log("DEBUG", " UPDNETI_vpnCount - " + vpnCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (vpnCount > 0) { - execution.setVariable(Prefix + "vpnBindings", vpnBindingUri) - utils.log("DEBUG", " vpnBindingUri List - " + vpnBindingUri, isDebugEnabled) - - String routeTargets = "" - // AII loop call using list vpnBindings - for (i in 0..vpnBindingUri.size()-1) { - - int counting = i+1 - - // prepare url using vpnBinding - String queryVpnBindingAAIRequest = "" - String aai_uri = aaiUriUtil.getNetworkVpnBindingUri(execution) - - // Note: By default, the vpnBinding url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (vpnBindingUri[i].charAt(vpnBindingUri[i].length()-1) == '/') { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i].substring(0, vpnBindingUri[i].length()-1) + "?depth=all" - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] + "?depth=all" - } - - } else { - // using uri value in URN mapping - String vpnBindingId = vpnBindingUri[i].substring(vpnBindingUri[i].indexOf("/vpn-binding/")+13, vpnBindingUri[i].length()) - if (vpnBindingId.charAt(vpnBindingId.length()-1) == '/') { - vpnBindingId = vpnBindingId.substring(0, vpnBindingId.length()-1) - } - queryVpnBindingAAIRequest = "${aai_endpoint}${aai_uri}/" + vpnBindingId + "?depth=all" - } - - utils.logAudit(queryVpnBindingAAIRequest) - execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - utils.log("DEBUG", " UPDNETI_queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query vpn binding Response Code, vpnBinding #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String routeTarget = "" - String routeRole = "" - if (utils.nodeExists(aaiResponseAsString, "route-targets")) { - String aaiRouteTargets = utils.getNodeXml(aaiResponseAsString, "route-targets", false) - def aaiRouteTargetsXml = new XmlSlurper().parseText(aaiRouteTargets) - def aaiRouteTarget = aaiRouteTargetsXml.'**'.findAll {it.name() == "route-target"} - for (j in 0..aaiRouteTarget.size()-1) { - routeTarget = utils.getNodeText1(XmlUtil.serialize(aaiRouteTarget[j]), "global-route-target") - routeRole = utils.getNodeText1(XmlUtil.serialize(aaiRouteTarget[j]), "route-target-role") - routeTargets += "<routeTargets>" + '\n' + - " <routeTarget>" + routeTarget + "</routeTarget>" + '\n' + - " <routeTargetRole>" + routeRole + "</routeTargetRole>" + '\n' + - "</routeTargets>" + '\n' - } - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable(Prefix + "routeCollection", routeTargets) - utils.log("DEBUG", " UPDNETI_routeCollection - " + '\n' + routeTargets, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <vpn-binding xmlns="${schemaVersion}"> - <global-route-target/> - </vpn-binding> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "routeCollection", "<routeTargets/>") - utils.log("DEBUG", " No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkPolicy(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkPolicy of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Network Policy is present, then build a List of network policy - List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship) - int networkPolicyCount = networkPolicyUriList.size() - execution.setVariable(Prefix + "networkPolicyCount", networkPolicyCount) - utils.log("DEBUG", " UPDNETI_networkPolicyCount - " + networkPolicyCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (networkPolicyCount > 0) { - execution.setVariable(Prefix + "networkPolicyUriList", networkPolicyUriList) - utils.log("DEBUG", " networkPolicyUri List - " + networkPolicyUriList, isDebugEnabled) - - String networkPolicies = "" - // AII loop call using list vpnBindings - for (i in 0..networkPolicyUriList.size()-1) { - - int counting = i+1 - - // prepare url using vpnBinding - String queryNetworkPolicyAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkPolicyUriList[i].charAt(networkPolicyUriList[i].length()-1) == '/') { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i].substring(0, networkPolicyUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkPolicyId = networkPolicyUriList[i].substring(networkPolicyUriList[i].indexOf("/network-policy/")+16, networkPolicyUriList[i].length()) - println " networkPolicyId - " + networkPolicyId - if (networkPolicyId.charAt(networkPolicyId.length()-1) == '/') { - networkPolicyId = networkPolicyId.substring(0, networkPolicyId.length()-1) - } - queryNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + networkPolicyId + "?depth=all" - - } - - - utils.logAudit(queryNetworkPolicyAAIRequest) - execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) - utils.log("DEBUG", " UPDNETI_queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String networkPolicy = "" - if (utils.nodeExists(aaiResponseAsString, "network-policy-fqdn")) { - networkPolicy = utils.getNodeText1(aaiResponseAsString, "network-policy-fqdn") - networkPolicies += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable(Prefix + "networkCollection", networkPolicies) - utils.log("DEBUG", " UPDNETI_networkCollection - " + '\n' + networkPolicies, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <network-policy xmlns="${schemaVersion}"> - <network-policy-fqdn/> - </network-policy> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "networkCollection", "<policyFqdns/>") - utils.log("DEBUG", " No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkTableRef(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkTableRef of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") - utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) - - // Check if Network TableREf is present, then build a List of network policy - List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship) - int networkTableRefCount = networkTableRefUriList.size() - execution.setVariable(Prefix + "networkTableRefCount", networkTableRefCount) - utils.log("DEBUG", " UPDNETI_networkTableRefCount - " + networkTableRefCount, isDebugEnabled) - - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - - if (networkTableRefCount > 0) { - execution.setVariable(Prefix + "networkTableRefUriList", networkTableRefUriList) - utils.log("DEBUG", " networkTableRefUri List - " + networkTableRefUriList, isDebugEnabled) - - // AII loop call using list vpnBindings - String networkTableRefs = "" - for (i in 0..networkTableRefUriList.size()-1) { - - int counting = i+1 - - // prepare url using tableRef - String queryNetworkTableRefAAIRequest = "" - - String aai_uri = aaiUriUtil.getNetworkTableReferencesUri(execution) - - // Note: By default, the network policy url is found in 'related-link' of the response, - // so, the default in URN mappings for this is set to "" (ie, space), unless forced to use the URN mapping. - if (aai_uri == null || aai_uri == "") { - // using value of 'related-link' from response - if (networkTableRefUriList[i].charAt(networkTableRefUriList[i].length()-1) == '/') { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i].substring(0, networkTableRefUriList[i].length()-1) + "?depth=all" - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] + "?depth=all" - } - } else { - // using uri value in URN mapping - String networkTableRefId = networkTableRefUriList[i].substring(networkTableRefUriList[i].indexOf("/route-table-reference/")+23, networkTableRefUriList[i].length()) - - if (networkTableRefId.charAt(networkTableRefId.length()-1) == '/') { - networkTableRefId = networkTableRefId.substring(0, networkTableRefId.length()-1) - } - queryNetworkTableRefAAIRequest = "${aai_endpoint}${aai_uri}/" + networkTableRefId + "?depth=all" - - } - - - utils.logAudit(queryNetworkTableRefAAIRequest) - execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) - utils.log("DEBUG", " UPDNETI_queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI query network Table Reference Response Code, NetworkTableRef #" + counting + " : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " QueryAAINetworkTableRef Success REST Response, , NetworkTableRef #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String networkTableRef = "" - if (utils.nodeExists(aaiResponseAsString, "route-table-reference-fqdn")) { - networkTableRef = utils.getNodeText1(aaiResponseAsString, "route-table-reference-fqdn") - networkTableRefs += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n' - } - - } else { - if (returnCode=='404') { - String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - } - } - - } // end loop - - execution.setVariable(Prefix + "tableRefCollection", networkTableRefs) - utils.log("DEBUG", " UPDNETI_tableRefCollection - " + '\n' + networkTableRefs, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String aaiStubResponse = - """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"> - <route-table-references xmlns="${schemaVersion}"> - <route-table-reference-fqdn/> - </route-table-references> - </rest:payload>""" - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable(Prefix + "queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable(Prefix + "tableRefCollection", "<routeTableFqdns/>") - utils.log("DEBUG", " No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled) - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTUpdateContrailAAINetwork(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTUpdateContrailAAINetwork of DoUpdateNetworkInstance ***** " , isDebugEnabled) - - try { - // get variables - String networkRequest = execution.getVariable(Prefix + "networkRequest") - String networkId = utils.getNodeText1(networkRequest, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - - // Prepare url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String updateContrailAAIUrlRequest = "${aai_endpoint}${aai_uri}/" + networkId + "?depth=all" - - utils.logAudit(updateContrailAAIUrlRequest) - execution.setVariable(Prefix + "updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) - utils.log("DEBUG", " UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) - - //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) - String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) - String payloadXml = utils.formatXml(payload) - utils.logAudit(payloadXml) - execution.setVariable(Prefix + "updateContrailAAIPayloadRequest", payloadXml) - utils.log("DEBUG", " 'payload' to Update Contrail - " + "\n" + payloadXml, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payload) - String returnCode = response.getStatusCode() - String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() - - execution.setVariable(Prefix + "aaiUpdateContrailReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI Update Contrail Response Code : " + returnCode, isDebugEnabled) - - - if (returnCode=='200') { - utils.logAudit(aaiUpdateContrailResponseAsString) - execution.setVariable(Prefix + "updateContrailAAIResponse", aaiUpdateContrailResponseAsString) - utils.log("DEBUG", " AAI Update Contrail Success REST Response - " + "\n" + aaiUpdateContrailResponseAsString, isDebugEnabled) - // Point-of-no-return is set to false, rollback not needed. - execution.setVariable(Prefix + "isPONR", true) - - } else { - if (returnCode=='404') { - String dataErrorMessage = " Response Error from UpdateContrailAAINetwork is 404 (Not Found)." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - if (aaiUpdateContrailResponseAsString.contains("RESTFault")) { - WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiUpdateContrailResponseAsString, execution) - execution.setVariable("WorkflowException", exceptionObject) - throw new BpmnError("MSOWorkflowException") - - } else { - // aai all errors - String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode - utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - } - } - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareUpdateNetworkRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareUpdateNetworkRequest of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - // get variables - String requestId = execution.getVariable(Prefix + "requestId") - String messageId = execution.getVariable(Prefix + "messageId") - String source = execution.getVariable(Prefix + "source") - - String requestInput = execution.getVariable(Prefix + "networkRequest") - String queryIdResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionPo") - String backoutOnFailure = execution.getVariable(Prefix + "rollbackEnabled") - - // Prepare Network request - String routeCollection = execution.getVariable(Prefix + "routeCollection") - String policyCollection = execution.getVariable(Prefix + "networkCollection") - String tableCollection = execution.getVariable(Prefix + "tableRefCollection") - String updateNetworkRequest = networkUtils.UpdateNetworkRequestV2(execution, requestId, messageId, requestInput, queryIdResponse, routeCollection, policyCollection, tableCollection, cloudRegionId, backoutOnFailure, source ) - // Format Response - String buildUpdateNetworkRequestAsString = utils.formatXml(updateNetworkRequest) - buildUpdateNetworkRequestAsString = buildUpdateNetworkRequestAsString.replace(":w1aac13n0", "").replace("w1aac13n0:", "") - utils.logAudit(buildUpdateNetworkRequestAsString) - - execution.setVariable(Prefix + "updateNetworkRequest", buildUpdateNetworkRequestAsString) - utils.log("DEBUG", " UPDNETI_updateNetworkRequest - " + "\n" + buildUpdateNetworkRequestAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareUpdateNetworkRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareSDNCRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRequest of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - - String networkId = "" - if (utils.nodeExists(updateNetworkInput, "network-id")) { - networkId = utils.getNodeText1(updateNetworkInput, "network-id") - } - if (networkId == null) {networkId = ""} - - String serviceInstanceId = utils.getNodeText1(updateNetworkInput, "service-instance-id") - - // 1. prepare assign topology via SDNC Adapter SUBFLOW call - String sndcTopologyCreateRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "changeassign", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - - String sndcTopologyUpdateRequesAsString = utils.formatXml(sndcTopologyCreateRequest) - utils.logAudit(sndcTopologyUpdateRequesAsString) - execution.setVariable(Prefix + "changeAssignSDNCRequest", sndcTopologyUpdateRequesAsString) - utils.log("DEBUG", " UPDNETI_changeAssignSDNCRequest - " + "\n" + sndcTopologyUpdateRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void validateUpdateNetworkResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateUpdateNetworkResponse of DoUpdateNetworkInstance *****", isDebugEnabled) - - try { - String returnCode = execution.getVariable(Prefix + "networkReturnCode") - String networkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } - - utils.log("DEBUG", " Network Adapter update responseCode: " + returnCode, isDebugEnabled) - - String errorMessage = "" - if (returnCode == "200") { - execution.setVariable(Prefix + "isNetworkRollbackNeeded", true) - utils.logAudit(networkResponse) - execution.setVariable(Prefix + "updateNetworkResponse", networkResponse) - utils.log("DEBUG", " Network Adapter update Success Response - " + "\n" + networkResponse, isDebugEnabled) - - // prepare rollback data - String rollbackData = utils.getNodeXml(networkResponse, "rollback", false).replace("tag0:","").replace(":tag0","") - rollbackData = rollbackData.replace("rollback>", "networkRollback>") - String rollbackNetwork = - """<rollbackNetworkRequest> - ${rollbackData} - </rollbackNetworkRequest>""" - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkXml) - utils.log("DEBUG", " Network Adapter rollback data - " + "\n" + rollbackNetworkXml, isDebugEnabled) - - } else { // network error - if (returnCode.toInteger() > 399 && returnCode.toInteger() < 600) { //4xx, 5xx - if (networkResponse.contains("updateNetworkError")) { - networkResponse = networkResponse.replace('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '') - errorMessage = utils.getNodeText1(networkResponse, "message") - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } else { // CatchAll exception - if (returnCode == "500") { - errorMessage = "JBWEB000065: HTTP Status 500." - } else { - errorMessage = "Return code is " + returnCode - } - errorMessage = "Received error from Network Adapter: " + errorMessage - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } - - } else { // CatchAll exception - String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - } - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. validateUpdateNetworkResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void validateSDNCResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateSDNCResponse of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - String response = execution.getVariable(Prefix + "changeAssignSDNCResponse") - WorkflowException workflowException = null - try { - workflowException = execution.getVariable(Prefix + "WorkflowException") - //execution.setVariable("WorkflowException", workflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sdnc 'WorkflowException' object is empty or null. ", isDebugEnabled) - } - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - // reset variable - String changeAssignSDNCResponseDecodeXml = sdncAdapterUtils.decodeXML(execution.getVariable(Prefix + "changeAssignSDNCResponse")) - changeAssignSDNCResponseDecodeXml = changeAssignSDNCResponseDecodeXml.replace("&", "&").replace('<?xml version="1.0" encoding="UTF-8"?>', "") - execution.setVariable(Prefix + "changeAssignSDNCResponse", changeAssignSDNCResponseDecodeXml) - - if (execution.getVariable(Prefix + "sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' - execution.setVariable(Prefix + "isSdncRollbackNeeded", true) - utils.log("DEBUG", "Successfully Validated SDNC Response", isDebugEnabled) - - } else { - utils.log("DEBUG", "Did NOT Successfully Validated SDNC Response", isDebugEnabled) - throw new BpmnError("MSOWorkflowException") - } - - } - - - public void postProcessResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - utils.log("DEBUG", " ***** Is Exception Encountered (isException)? : " + execution.getVariable(Prefix + "isException"), isDebugEnabled) - if (execution.getVariable(Prefix + "isException") == false) { - // set rollback data - execution.setVariable("orchestrationStatus", "") - execution.setVariable("networkId", execution.getVariable(Prefix + "networkId")) - execution.setVariable("networkName", execution.getVariable(Prefix + "networkName")) - prepareSuccessRollbackData(execution) // populate rollbackData - execution.setVariable("WorkflowException", null) - execution.setVariable(Prefix + "Success", true) - utils.log("DEBUG", " ***** postProcessResponse(), GOOD !!!", isDebugEnabled) - } else { - execution.setVariable(Prefix + "Success", false) - execution.setVariable("rollbackData", null) - String exceptionMessage = " Exception encountered in MSO Bpmn. " - if (execution.getVariable("workflowException") != null) { // Output of Rollback flow. - utils.log("DEBUG", " ***** workflowException: " + execution.getVariable("workflowException"), isDebugEnabled) - WorkflowException wfex = execution.getVariable("workflowException") - exceptionMessage = wfex.getErrorMessage() - } else { - if (execution.getVariable(Prefix + "WorkflowException") != null) { - WorkflowException pwfex = execution.getVariable(Prefix + "WorkflowException") - exceptionMessage = pwfex.getErrorMessage() - } - } - // going to the Main flow: a-la-carte or macro - utils.log("DEBUG", " ***** postProcessResponse(), BAD !!!", isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } - - } catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void prepareSDNCRollbackRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRollbackRequest of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - // for some reason the WorkflowException object is null after the sdnc rollback call task, need to save WorkflowException. - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String updateNetworkInput = execution.getVariable(Prefix + "networkRequest") - String cloudRegionId = execution.getVariable(Prefix + "cloudRegionSdnc") - String changeAssignSDNCResponse = execution.getVariable(Prefix + "changeAssignSDNCResponse") - String networkId = utils.getNodeText1(changeAssignSDNCResponse, "network-id") - - String serviceInstanceId = utils.getNodeText1(updateNetworkInput, "service-instance-id") - - // 2. prepare rollback topology via SDNC Adapter SUBFLOW call - String sndcTopologyRollbackRequest = sdncAdapterUtils.sdncTopologyRequestV2(execution, updateNetworkInput, serviceInstanceId, sdncCallback, "rollback", "NetworkActivateRequest", cloudRegionId, networkId, null, null) - String sndcTopologyRollbackRequestAsString = utils.formatXml(sndcTopologyRollbackRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", sndcTopologyRollbackRequestAsString) - utils.log("DEBUG", " Preparing request for SDNC Topology assign's rollback/compensation . . . - " + "\n" + sndcTopologyRollbackRequestAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSDNCRollbackRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareRollbackData(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareRollbackData() of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", execution.getVariable(Prefix + "rollbackSDNCRequest")) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", execution.getVariable(Prefix + "rollbackNetworkRequest")) - } - } - execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG", "** rollbackData : " + rollbackData, isDebugEnabled) - - execution.setVariable("WorkflowException", execution.getVariable(Prefix + "WorkflowException")) - utils.log("DEBUG", "** WorkflowException : " + execution.getVariable("WorkflowException"), isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareRollbackData() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareSuccessRollbackData(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareSuccessRollbackData() of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - if (execution.getVariable("sdncVersion") != '1610') { - // skip: 1702 for 'changeassign' or equivalent not yet defined in SNDC, so no rollback. - } else { - prepareSDNCRollbackRequest(execution) - } - - Map<String, String> rollbackData = new HashMap<String, String>(); - String rollbackSDNCRequest = execution.getVariable(Prefix + "rollbackSDNCRequest") - if (rollbackSDNCRequest != null) { - if (rollbackSDNCRequest != "") { - rollbackData.put("rollbackSDNCRequest", rollbackSDNCRequest) - } - } - String rollbackNetworkRequest = execution.getVariable(Prefix + "rollbackNetworkRequest") - if (rollbackNetworkRequest != null) { - if (rollbackNetworkRequest != "") { - rollbackData.put("rollbackNetworkRequest", rollbackNetworkRequest) - } - } - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG", "** 'rollbackData' for Full Rollback : " + rollbackData, isDebugEnabled) - execution.setVariable("WorkflowException", null) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstance flow. prepareSuccessRollbackData() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void setExceptionFlag(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside setExceptionFlag() of DoUpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - execution.setVariable(Prefix + "isException", true) - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - utils.log("DEBUG", Prefix + "WorkflowException - " +execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled) - - } catch(Exception ex){ - String exceptionMessage = "Bpmn error encountered in DoUpdateNetworkInstance flow. setExceptionFlag(): " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy deleted file mode 100644 index 7d326382cb..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstanceRollback.groovy +++ /dev/null @@ -1,304 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the <class>DoCreateNetworkInstance.bpmn</class> process. - * - */ -public class DoUpdateNetworkInstanceRollback extends AbstractServiceTaskProcessor { - String Prefix="UPDNETIR_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils(this) - NetworkUtils networkUtils = new NetworkUtils() - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils() - - def className = getClass().getSimpleName() - - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable(Prefix + "rollbackNetworkRequest", null) - execution.setVariable(Prefix + "rollbackSDNCRequest", null) - execution.setVariable(Prefix + "WorkflowException", null) - - execution.setVariable(Prefix + "rollbackNetworkRequest", "") - execution.setVariable(Prefix + "rollbackNetworkResponse", "") - execution.setVariable(Prefix + "rollbackNetworkReturnCode", "") - - execution.setVariable(Prefix + "rollbackSDNCRequest", "") - execution.setVariable(Prefix + "rollbackSDNCResponse", "") - execution.setVariable(Prefix + "rollbackSDNCReturnCode", "") - - execution.setVariable(Prefix + "Success", false) - execution.setVariable(Prefix + "fullRollback", false) - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>DoUpdateNetworkInstanceRollback.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of " + className + ".groovy ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // GET Incoming request/variables - String rollbackNetworkRequest = null - String rollbackSDNCRequest = null - - // Partial Rollback - Map<String, String> rollbackData = execution.getVariable("rollbackData") - if (rollbackData != null && rollbackData instanceof Map) { - - if(rollbackData.containsKey("rollbackNetworkRequest")) { - rollbackNetworkRequest = rollbackData["rollbackNetworkRequest"] - } - - if(rollbackData.containsKey("rollbackSDNCRequest")) { - rollbackSDNCRequest = rollbackData["rollbackSDNCRequest"] - } - } - - execution.setVariable(Prefix + "rollbackNetworkRequest", rollbackNetworkRequest) - execution.setVariable(Prefix + "rollbackSDNCRequest", rollbackSDNCRequest) - utils.log("DEBUG", "'rollbackData': " + '\n' + execution.getVariable("rollbackData"), isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG", "sdncVersion? : " + sdncVersion, isDebugEnabled) - - // PO Authorization Info / headers Authorization= - String basicAuthValuePO = execution.getVariable("URN_mso_adapters_po_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for PO/SDNC adapter: " + basicAuthValuePO, isDebugEnabled) - try { - def encodedString = utils.getBasicAuth(basicAuthValuePO, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValuePO",encodedString) - execution.setVariable("BasicAuthHeaderValueSDNC", encodedString) - - } catch (IOException ex) { - String exceptionMessage = "Exception Encountered in DoCreateNetworkInstance, PreProcessRequest() - " - String dataErrorMessage = exceptionMessage + " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage , isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - if (execution.getVariable("SavedWorkflowException1") != null) { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("SavedWorkflowException1")) - } else { - execution.setVariable(Prefix + "WorkflowException", execution.getVariable("WorkflowException")) - } - utils.log("DEBUG", "*** WorkflowException : " + execution.getVariable(Prefix + "WorkflowException"), isDebugEnabled) - if(execution.getVariable(Prefix + "WorkflowException") != null) { - // called by: DoCreateNetworkInstance, partial rollback - execution.setVariable(Prefix + "fullRollback", false) - - } else { - // called by: Macro - Full Rollback, WorkflowException = null - execution.setVariable(Prefix + "fullRollback", true) - - } - utils.log("DEBUG", "*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"), isDebugEnabled) - - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in PreProcessRequest() of " + className + ".groovy ***** : " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void validateRollbackResponses (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside validateRollbackResponses() of DoUpdateNetworkInstanceRollback ***** ", isDebugEnabled) - - try { - // validate PO network rollback response - String rollbackNetworkErrorMessages = "" - String rollbackNetworkReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackNetworkRequest") != null) { - rollbackNetworkReturnCode = execution.getVariable(Prefix + "rollbackNetworkReturnCode") - String rollbackNetworkResponse = execution.getVariable(Prefix + "rollbackNetworkResponse") - utils.log("DEBUG", " NetworkRollback Code - " + rollbackNetworkReturnCode, isDebugEnabled) - utils.log("DEBUG", " NetworkRollback Response - " + rollbackNetworkResponse, isDebugEnabled) - if (rollbackNetworkReturnCode != "200") { - rollbackNetworkErrorMessages = " + PO Network rollback failed. " - } else { - rollbackNetworkErrorMessages = " + PO Network rollback completed." - } - } - - // validate SDNC rollback response - String rollbackSdncErrorMessages = "" - String rollbackSDNCReturnCode = "200" - if (execution.getVariable(Prefix + "rollbackSDNCRequest") != null) { - rollbackSDNCReturnCode = execution.getVariable(Prefix + "rollbackSDNCReturnCode") - String rollbackSDNCResponse = execution.getVariable(Prefix + "rollbackSDNCResponse") - String rollbackSDNCReturnInnerCode = "" - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - rollbackSDNCResponse = sdncAdapterUtils.decodeXML(rollbackSDNCResponse) - rollbackSDNCResponse = rollbackSDNCResponse.replace("&", "&").replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "") - if (rollbackSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { - rollbackSDNCReturnInnerCode = utils.getNodeText1(rollbackSDNCResponse, "response-code") - if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { - rollbackSdncErrorMessages = " + SNDC changeassign rollback completed." - } else { - rollbackSdncErrorMessages = " + SDNC changeassign rollback failed. " - } - } else { - rollbackSdncErrorMessages = " + SNDC changeassign rollback completed." - } - } else { - rollbackSdncErrorMessages = " + SDNC changeassign rollback failed. " - } - utils.log("DEBUG", " SDNC changeassign rollback Code - " + rollbackSDNCReturnCode, isDebugEnabled) - utils.log("DEBUG", " SDNC changeassign rollback Response - " + rollbackSDNCResponse, isDebugEnabled) - } - - String statusMessage = "" - int errorCode = 7000 - utils.log("DEBUG", "*** fullRollback? : " + execution.getVariable(Prefix + "fullRollback"), isDebugEnabled) - if (execution.getVariable(Prefix + "fullRollback") == false) { - // original WorkflowException, - WorkflowException wfe = execution.getVariable(Prefix + "WorkflowException") - if (wfe != null) { - // rollback due to failure in DoCreate - Partial rollback - statusMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - statusMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - errorCode = '7000' - } - - // set if all rolledbacks are successful - if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { - execution.setVariable("rolledBack", true) - - } else { - execution.setVariable("rolledBack", false) - - } - - statusMessage = statusMessage + rollbackNetworkErrorMessages + rollbackSdncErrorMessages - utils.log("DEBUG", "Final DoUpdateNetworkInstanceRollback status message: " + statusMessage, isDebugEnabled) - String processKey = getProcessKey(execution); - WorkflowException exception = new WorkflowException(processKey, errorCode, statusMessage); - execution.setVariable("workflowException", exception); - - } else { - // rollback due to failures in Main flow (Macro) - Full rollback - // WorkflowException = null - if (rollbackNetworkReturnCode == "200" && rollbackSDNCReturnCode == "200") { - execution.setVariable("rollbackSuccessful", true) - execution.setVariable("rollbackError", false) - } else { - String exceptionMessage = "Network Update Rollback was not Successful. " - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - execution.setVariable("rollbackSuccessful", false) - execution.setVariable("rollbackError", true) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - throw new BpmnError("MSOWorkflowException") - } - - } - - - } catch (Exception ex) { - execution.setVariable("WorkflowException", null) - String errorMessage = "See Previous Camunda flows for cause of Error: Undetermined Exception." - String exceptionMessage = " Bpmn error encountered in DoUpdateNetworkInstanceRollback flow. validateRollbackResponses() - " + errorMessage + ": " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - execution.setVariable("WorkflowException", execution.getVariable("WorkflowException")) - - } - - } - - // ******************************* - // Build Error Section - // ******************************* - - - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - try{ - utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy deleted file mode 100644 index a9a657eea1..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy +++ /dev/null @@ -1,1038 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.NetworkUtils -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.bpmn.common.scripts.VfModule -import org.openecomp.mso.bpmn.common.scripts.VfModuleBase -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.client.aai.AAIResourcesClient -import org.openecomp.mso.client.aai.entities.AAIResultWrapper -import org.openecomp.mso.client.aai.entities.uri.AAIUri -import org.openecomp.mso.rest.APIResponse -import org.springframework.web.util.UriUtils -import org.openecomp.mso.client.aai.AAIObjectType; -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory; - - -public class DoUpdateVfModule extends VfModuleBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - CatalogDbUtils catalog = new CatalogDbUtils() - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'DOUPVfMod_') - execution.setVariable('DOUPVfMod_requestInfo', null) - execution.setVariable('DOUPVfMod_serviceInstanceId', null) - execution.setVariable('DOUPVfMod_requestId', null) - execution.setVariable('DOUPVfMod_vnfInputs', null) - execution.setVariable('DOUPVfMod_vnfId', null) - execution.setVariable('DOUPVfMod_vnfName', null) - execution.setVariable('DOUPVfMod_vnfNameFromAAI', null) - execution.setVariable('DOUPVfMod_vfModuleName', null) - execution.setVariable('DOUPVfMod_vfModuleId', null) - execution.setVariable('DOUPVfMod_vnfType', null) - execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null) - execution.setVariable('DOUPVfMod_vfModuleModelName', null) - execution.setVariable('DOUPVfMod_modelCustomizationUuid', null) - execution.setVariable("DOUPVfMod_isBaseVfModule", "false") - execution.setVariable('DOUPVfMod_serviceId', null) - execution.setVariable('DOUPVfMod_aicCloudRegion', null) - execution.setVariable('DOUPVfMod_tenantId', null) - execution.setVariable('DOUPVfMod_volumeGroupId', null) - execution.setVariable("DOUPVfMod_volumeGroupStackId", "") - execution.setVariable('DOUPVfMod_vfModule', null) - execution.setVariable('DOUPVfMod_vnfParams', null) - execution.setVariable("DOUPVfMod_baseVfModuleId", "") - execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "") - execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null) - execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null) - execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null) - execution.setVariable('DOUPVfMod_sdncActivateRequest', null) - execution.setVariable('DOUPVfMod_sdncActivateResponse', null) - execution.setVariable('DOUPVfMod_sdncTopologyRequest', null) - execution.setVariable('DOUPVfMod_sdncTopologyResponse', null) - execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null) - execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null) - execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null) - execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false) - execution.setVariable('DoUpdateVfModuleSuccessIndicator', false) - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - initProcessVariables(execution) - def xml = getVariable(execution, 'DoUpdateVfModuleRequest') - utils.logAudit("DoUpdateVfModule request: " + xml) - logDebug('Received request xml:\n' + xml, isDebugLogEnabled) - - if (xml == null || xml.isEmpty()) { - // Building Block-type request - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo") - - def serviceModelInfo = execution.getVariable("serviceModelInfo") - logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled) - String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid") - logDebug("modelInvariantUuid: " + modelInvariantUuid, isDebugLogEnabled) - def vnfModelInfo = execution.getVariable("vnfModelInfo") - - //tenantId - def tenantId = execution.getVariable("tenantId") - execution.setVariable("DOUPVfMod_tenantId", tenantId) - - //volumeGroupId - def volumeGroupId = execution.getVariable("volumeGroupId") - execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) - - //cloudSiteId - def cloudSiteId = execution.getVariable("lcpCloudRegionId") - execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId) - - logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled) - //vnfType - def vnfType = execution.getVariable("vnfType") - execution.setVariable("DOUPVfMod_vnfType", vnfType) - - logDebug("vnfType: " + vnfType, isDebugLogEnabled) - //vnfName - def vnfName = execution.getVariable("vnfName") - execution.setVariable("DOUPVfMod_vnfName", vnfName) - - logDebug("vnfName: " + vnfName, isDebugLogEnabled) - //vnfId - def vnfId = execution.getVariable("vnfId") - execution.setVariable("DOUPVfMod_vnfId", vnfId) - - logDebug("vnfId: " + vnfId, isDebugLogEnabled) - //vfModuleName - def vfModuleName = execution.getVariable("vfModuleName") - execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName) - - logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled) - //vfModuleModelName - def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName") - execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName) - - logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled) - //modelCustomizationUuid - def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid") - if (modelCustomizationUuid == null) { - modelCustomizationUuid = "" - } - execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid) - - logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled) - //vfModuleId - def vfModuleId = execution.getVariable("vfModuleId") - execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId) - logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled) - def requestId = execution.getVariable("msoRequestId") - execution.setVariable("DOUPVfMod_requestId", requestId) - logDebug("requestId: " + requestId, isDebugLogEnabled) - // Set mso-request-id to request-id for VNF Adapter interface - execution.setVariable("mso-request-id", requestId) - //serviceId - def serviceId = execution.getVariable("serviceId") - execution.setVariable("DOUPVfMod_serviceId", serviceId) - logDebug("serviceId: " + serviceId, isDebugLogEnabled) - //serviceInstanceId - def serviceInstanceId = execution.getVariable("serviceInstanceId") - execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId) - - logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled) - //source - HARDCODED - def source = "VID" - execution.setVariable("DOUPVfMod_source", source) - - logDebug("source: " + source, isDebugLogEnabled) - //backoutOnFailure - def disableRollback = execution.getVariable("disableRollback") - def backoutOnFailure = true - if (disableRollback != null && disableRollback.equals("true")) { - backoutOnFailure = false - } - execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) - logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled) - //isBaseVfModule - def isBaseVfModule = execution.getVariable("isBaseVfModule") - execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) - logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) - //asdcServiceModelVersion - def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") - execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion) - logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled) - //personaModelId - execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid")) - //personaModelVersion - execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion")) - //Get or Generate UUID - String uuid = execution.getVariable("DOUPVfMod_uuid") - if(uuid == null){ - uuid = UUID.randomUUID() - logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled) - }else{ - logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled) - } - //isVidRequest - String isVidRequest = execution.getVariable("isVidRequest") - // default to true - if (isVidRequest == null || isVidRequest.isEmpty()) { - execution.setVariable("isVidRequest", "true") - } - //usePreload - def usePreload = execution.getVariable("usePreload") - execution.setVariable("DOUPVfMod_usePreload", usePreload) - logDebug("usePreload: " + usePreload, isDebugLogEnabled) - //globalSubscriberId - String globalSubscriberId = execution.getVariable("globalSubscriberId") - execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId) - logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled) - //vnfQueryPath - String vnfQueryPath = execution.getVariable("vnfQueryPath") - execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath) - logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled) - - Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams") - if (vfModuleInputParams != null) { - execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) - } - //get workload and environment context from parent SI - String environmentContext = "" - String workloadContext ="" - String serviceType ="" - - try{ - String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid ) - serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType") - }catch(BpmnError e){ - throw e - } catch (Exception ex){ - String msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - try{ - AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId) - AAIResourcesClient aaiRC = new AAIResourcesClient() - AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI) - Map<String, Object> aaiJson = aaiRW.asMap() - environmentContext = aaiJson.getOrDefault("environment-context","") - workloadContext = aaiJson.getOrDefault("workload-context","") - - }catch (Exception ex) { - utils.log("DEBUG","Error retreiving parent service instance information", isDebugLogEnabled) - } - - execution.setVariable("DCVFM_environmentContext",environmentContext) - execution.setVariable("DCVFM_workloadContext",workloadContext) - } - else { - - def requestInfo = getRequiredNodeXml(execution, xml, 'request-info') - execution.setVariable('DOUPVfMod_requestInfo', requestInfo) - execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) - def serviceInstanceId = execution.getVariable('mso-service-instance-id') - if (serviceInstanceId == null) { - serviceInstanceId = '' - } - execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId) - - def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs') - execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs) - execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) - execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) - execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name')) - execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type')) - execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name')) - execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version')) - execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name')) - execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id')) - execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id')) - execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region')) - execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) - //isBaseVfModule - def isBaseVfModule = "false" - if (utils.nodeExists(xml, "is-base-vf-module")) { - isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module") - execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule) - } - logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled) - - NetworkUtils networkUtils = new NetworkUtils() - def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml) - execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure) - - def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id') - execution.setVariable('DOUPVfMod_volumeGroupId', vgi) - - execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false)) - } - - def sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) { - def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing' - logError(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will - * set the orchestration-status to 'pending-update'. - * - * @param execution The flow's execution instance. - */ - public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - def orchestrationStatus = 'pending-update' - - String prepareUpdateAAIVfModuleRequest = """ - <PrepareUpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <orchestration-status>${orchestrationStatus}</orchestration-status> - </PrepareUpdateAAIVfModuleRequest> - """ - prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest) - execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest) - utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest) - logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. - * Determine cloud region id for the volume group. - * - * @param execution The flow's execution instance. - */ - public void prepConfirmVolumeGroupTenant(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + - 'execution=' + execution.getId() + - ')' - - def prefix = execution.getVariable("prefix") - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - String cloudRegion = execution.getVariable(prefix + "aicCloudRegion") - - // Prepare AA&I url - String aai_endpoint = execution.getVariable("URN_aai_endpoint") - AaiUtil aaiUtil = new AaiUtil(this) - String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution) - String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion - utils.logAudit("CloudRegion Request: " + queryCloudRegionRequest) - - execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest) - utils.log("DEBUG", prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugLogEnabled) - - cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion) - - if ((cloudRegion != "ERROR")) { - if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){ - execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25") - }else{ - execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion) - } - execution.setVariable(prefix + "isCloudRegionGood", true) - } else { - String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode") - utils.log("DEBUG", errorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - execution.setVariable(prefix + "isCloudRegionGood", false) - } - utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"), isDebugLogEnabled) - - } catch(BpmnError b){ - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugLogEnabled) - throw b - }catch (Exception e) { - // try error - String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage() - utils.log("ERROR", " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - - } - - /** - * Prepare a Request for invoking the SDNC Adapter subflow to perform - * a VNF topology 'changeassign' operation. - * - * @param execution The flow's execution instance. - */ - public void prepSDNCTopologyChg(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('DOUPVfMod_requestId') - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis() - } - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - def serviceId = execution.getVariable('DOUPVfMod_serviceId') - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vnfType = execution.getVariable('DOUPVfMod_vnfType') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') - def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule') - def vfModuleName = vfModule.getElementText('vf-module-name') - def tenantId = execution.getVariable('DOUPVfMod_tenantId') - def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion') - boolean usePreload = execution.getVariable("DOUPVfMod_usePreload") - String usePreloadToSDNC = usePreload ? "Y" : "N" - def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid") - def modelCustomizationUuidString = "" - if (!usePreload) { - modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>" - } - - // Retrieve vnf name from AAI response - def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI') - execution.setVariable('DOUPVfMod_vnfName', vnfName) - - def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') - def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) - - String sdncTopologyRequest = """ - <sdncadapterworkflow:SDNCAdapterWorkflowRequest - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>ChangeVNFActivateRequest</request-action> - <source>PORTAL</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-type>${serviceId}</service-type> - <service-instance-id>${vnfId}</service-instance-id> - <subscriber-name>dontcare</subscriber-name> - </service-information> - <vnf-request-information> - <vnf-id>${vfModuleId}</vnf-id> - <vnf-type>${vfModuleModelName}</vnf-type> - <vnf-name>${vfModuleName}</vnf-name> - <generic-vnf-id>${vnfId}</generic-vnf-id> - <generic-vnf-name>${vnfName}</generic-vnf-name> - <generic-vnf-type>${vnfType}</generic-vnf-type> - <tenant>${tenantId}</tenant> - <aic-cloud-region>${aicCloudRegion}</aic-cloud-region> - ${modelCustomizationUuidString} - <use-preload>${usePreloadToSDNC}</use-preload> - ${vnfNetworks} - </vnf-request-information> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest> - """ - sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) - execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest) - utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest) - logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the SDNC Adapter subflow to perform - * a VNF topology 'query' operation. - * - * @param execution The flow's execution instance. - */ - public void prepSDNCTopologyQuery(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis() - } - def requestId = execution.getVariable('DOUPVfMod_requestId') - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - - def svcInstId = "" - if (serviceInstanceId == null || serviceInstanceId.isEmpty()) { - svcInstId = vfModuleId - } - else { - svcInstId = serviceInstanceId - } - - //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE - sleep(5000) - - String sdncTopologyRequest = """ - <sdncadapterworkflow:SDNCAdapterWorkflowRequest - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>query</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest> - """ - sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) - execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest) - utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest) - logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the VnfAdapterRest subflow. - * - * @param execution The flow's execution instance. - */ - public void prepVnfAdapterRest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('DOUPVfMod_requestId') - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName') - def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') - def tenantId = execution.getVariable('DOUPVfMod_tenantId') - def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId') - def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId') - def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule') - def heatStackId = vfModule.getElementText('heat-stack-id') - def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion') - def vnfType = execution.getVariable('DOUPVfMod_vnfType') - def vnfName = execution.getVariable('DOUPVfMod_vnfName') - def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') - def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId") - def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId") - def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion') - def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid') - def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure") - - def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String environmentContext = execution.getVariable("DOUPVEnvironment_context") - String workloadContext = execution.getVariable("DOUPVWorkload_context") - logDebug("workloadContext: " + workloadContext, isDebugLogEnabled) - logDebug("environmentContext: " + environmentContext, isDebugLogEnabled) - - Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap") - - String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') - - String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, null, environmentContext, workloadContext) - - - String vnfAdapterRestRequest = """ - <updateVfModuleRequest> - <cloudSiteId>${cloudId}</cloudSiteId> - <tenantId>${tenantId}</tenantId> - <vnfId>${vnfId}</vnfId> - <vfModuleId>${vfModuleId}</vfModuleId> - <vfModuleStackId>${heatStackId}</vfModuleStackId> - <vnfType>${vnfType}</vnfType> - <vnfVersion>${asdcServiceModelVersion}</vnfVersion> - <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid> - <vfModuleType>${vfModuleModelName}</vfModuleType> - <volumeGroupId>${volumeGroupId}</volumeGroupId> - <volumeGroupStackId>${volumeGroupStackId}</volumeGroupStackId> - <baseVfModuleId>${baseVfModuleId}</baseVfModuleId> - <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId> - <skipAAI>true</skipAAI> - <backout>${backoutOnFailure}</backout> - <failIfExists>false</failIfExists> - <vfModuleParams> - ${vfModuleParams} - </vfModuleParams> - <msoRequest> - <requestId>${requestId}</requestId> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - </msoRequest> - <messageId>${messageId}</messageId> - <notificationUrl>${notificationUrl}</notificationUrl> - </updateVfModuleRequest> - """ - vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) - execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest) - utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest) - logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the UpdateAAIGenericVnf subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIGenericVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') - - def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id') - def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version') - if ((personaModelId == null) || (personaModelVersion == null)) { - logDebug('Skipping update for Generic VNF ' + vnfId + - ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled) - execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true) - } else { - def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>' - def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>' - - String updateAAIGenericVnfRequest = """ - <UpdateAAIGenericVnfRequest> - <vnf-id>${vnfId}</vnf-id> - ${personaModelIdElement} - ${personaModelVersionElement} - </UpdateAAIGenericVnfRequest> - """ - updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest) - execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest) - utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest) - logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the UpdateAAIVfModule subflow. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateAAIVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - def orchestrationStatus = 'updated' - def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs') - - def volumeGroupIdElement = '' - def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId') - if (volumeGroupId != null) { - volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>' - } - def personaModelIdElement = '' - def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id') - if (personaModelId != null) { - personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>' - } - def personaModelVersionElement = '' - def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version') - if (personaModelVersion != null) { - personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>' - } - def contrailServiceInstanceFqdnElement = '' - def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn') - if (contrailServiceInstanceFqdn != null) { - contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>' - } - def personaModelCustomizationIdElement = '' - def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid') - if (modelCustomizationId != null) { - personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>' - } - - String updateAAIVfModuleRequest = """ - <UpdateAAIVfModuleRequest> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <orchestration-status>${orchestrationStatus}</orchestration-status> - ${volumeGroupIdElement} - ${personaModelIdElement} - ${personaModelVersionElement} - ${contrailServiceInstanceFqdnElement} - ${personaModelCustomizationIdElement} - </UpdateAAIVfModuleRequest> - """ - - logDebug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest, isDebugLogEnabled) - updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest) - execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest) - utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest) - logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the SDNC Adapter subflow to perform - * a VNF topology 'activate' operation. - * - * @param execution The flow's execution instance. - */ - public void prepSDNCTopologyAct(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis() - } - def requestId = execution.getVariable('DOUPVfMod_requestId') - def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId') - def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback') - def serviceId = execution.getVariable('DOUPVfMod_serviceId') - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vnfName = execution.getVariable('DOUPVfMod_vnfName') - def vnfType = execution.getVariable('DOUPVfMod_vnfType') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName') - def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule') - def vfModuleName = vfModule.getElementText('vf-module-name') - def tenantId = execution.getVariable('DOUPVfMod_tenantId') - def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion') - - boolean usePreload = execution.getVariable("DOUPVfMod_usePreload") - String usePreloadToSDNC = usePreload ? "Y" : "N" - def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid") - def modelCustomizationUuidString = "" - if (!usePreload) { - modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>" - } - - def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') - def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) - - String sdncTopologyRequest = """ - <sdncadapterworkflow:SDNCAdapterWorkflowRequest - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>activate</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>ChangeVNFActivateRequest</request-action> - <source>PORTAL</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-type>${serviceId}</service-type> - <service-instance-id>${vnfId}</service-instance-id> - <subscriber-name>dontcare</subscriber-name> - </service-information> - <vnf-request-information> - <vnf-id>${vfModuleId}</vnf-id> - <vnf-type>${vfModuleModelName}</vnf-type> - <vnf-name>${vfModuleName}</vnf-name> - <generic-vnf-id>${vnfId}</generic-vnf-id> - <generic-vnf-name>${vnfName}</generic-vnf-name> - <generic-vnf-type>${vnfType}</generic-vnf-type> - <tenant>${tenantId}</tenant> - <aic-cloud-region>${aicCloudRegion}</aic-cloud-region> - ${modelCustomizationUuidString} - <use-preload>${usePreloadToSDNC}</use-preload> - </vnf-request-information> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest> - """ - sdncTopologyRequest = utils.formatXml(sdncTopologyRequest) - execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest) - utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest) - logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage()) - } - } - - /** - * Log a WorkflowException that has been created. - * - * @param execution The flow's execution instance. - */ - public void handleWorkflowException(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.handleWorkflowException(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException') - logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage()) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage()) - } - } - - public void validateSDNCResponse(DelegateExecution execution, String response, String method){ - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def prefix = execution.getVariable("prefix") - - logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - - WorkflowException workflowException = execution.getVariable("WorkflowException") - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - - utils.logAudit("workflowException: " + workflowException) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - utils.logAudit("SDNCResponse: " + response) - - String sdncResponse = response - if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){ - logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled) - }else{ - logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled) - } - - /** - * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info. - * A 200 response is expected with the VNF info in the response body. Will find out the base module info. - * - * @param execution The flow's execution instance. - */ - public void queryAAIVfModule(DelegateExecution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.getVfModule(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DOUPVfMod_vnfId') - def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId') - - AaiUtil aaiUriUtil = new AaiUtil(this) - String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution) - logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled) - - String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1" - utils.logAudit("AAI endPoint: " + endPoint) - - try { - def aaiRequestId = UUID.randomUUID().toString() - logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint) - utils.logAudit("createVfModule - invoking httpGet() to AAI") - - def responseData = response.getResponseBodyAsString() - if (responseData != null) { - logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled) - - } - - utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData) - utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode()) - - execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode()) - execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData) - logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - if (response.getStatusCode() == 200) { - // Parse the VNF record from A&AI to find base module info - logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled) - if (responseData != null) { - def vfModulesText = utils.getNodeXml(responseData, "vf-modules") - def xmlVfModules= new XmlSlurper().parseText(vfModulesText) - def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"} - int vfModulesSize = 0 - for (i in 0..vfModules.size()-1) { - def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module") - - if (isBaseVfModule == "true") { - String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") - execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId) - logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled) - String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id") - execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId) - logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled) - } - } - } - } - } catch (Exception ex) { - ex.printStackTrace() - logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage()) - } - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage()) - } - } - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy deleted file mode 100644 index 5d1bc01f1e..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVnfAndModules.groovy +++ /dev/null @@ -1,416 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-import java.io.ObjectInputStream.BlockDataInputStream
-import java.util.UUID;
-
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution;
-import org.hibernate.jpa.criteria.predicate.IsEmptyPredicate
-
-import static org.apache.commons.lang3.StringUtils.*;
-
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.core.domain.ModelInfo
-import org.openecomp.mso.bpmn.core.domain.ModuleResource
-import org.openecomp.mso.bpmn.core.domain.VnfResource
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.springframework.web.util.UriUtils;
-
-/**
- * This class supports the VID Flow
- * with the update of a generic vnf and related VF modules.
- */
-class DoUpdateVnfAndModules extends AbstractServiceTaskProcessor {
-
- String Prefix="DUVAM_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
- /**
- * This method gets and validates the incoming
- * request.
- *
- * @param - execution
- *
- */
- public void preProcessRequest(DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix",Prefix)
- utils.log("DEBUG", " *** STARTED DoUpdateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled)
-
- try{
- // Get Variables
-
- String requestId = execution.getVariable("msoRequestId")
- execution.setVariable("requestId", requestId)
- execution.setVariable("mso-request-id", requestId)
- utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled)
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled)
-
- String vnfId = execution.getVariable("vnfId")
- utils.log("DEBUG", "Incoming Vnf Id is: " + vnfId, isDebugEnabled)
-
- String source = "VID"
- execution.setVariable("DUVAM_source", source)
- utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled)
-
- String sdncVersion = execution.getVariable("sdncVersion")
- if (sdncVersion == null) {
- sdncVersion = "1702"
- }
- execution.setVariable("DUVAM_sdncVersion", sdncVersion)
- utils.log("DEBUG", "Incoming Sdnc Version is: " + sdncVersion, isDebugEnabled)
-
- VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
-
- String vnfModelInfo = execution.getVariable("vnfModelInfo")
- String serviceModelInfo = execution.getVariable("serviceModelInfo")
-
- String serviceId = execution.getVariable("productFamilyId")
- execution.setVariable("DUVAM_serviceId", serviceId)
- utils.log("DEBUG", "Incoming Service Id is: " + serviceId, isDebugEnabled)
-
- String modelUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelUuid")
- execution.setVariable("DUVAM_modelUuid", modelUuid)
- utils.log("DEBUG", "Incoming modelUuid is: " + modelUuid, isDebugEnabled)
-
- String modelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
- execution.setVariable("DUVAM_modelCustomizationUuid", modelCustomizationUuid)
- utils.log("DEBUG", "Incoming Model Customization Uuid is: " + modelCustomizationUuid, isDebugEnabled)
-
- String cloudSiteId = execution.getVariable("lcpCloudRegionId")
- execution.setVariable("DUVAM_cloudSiteId", cloudSiteId)
- utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled)
-
- String tenantId = execution.getVariable("tenantId")
- execution.setVariable("DUVAM_tenantId", tenantId)
- utils.log("DEBUG", "Incoming Tenant Id is: " + tenantId, isDebugEnabled)
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- if (globalSubscriberId == null) {
- globalSubscriberId = ""
- }
- execution.setVariable("DUVAM_globalSubscriberId", globalSubscriberId)
- utils.log("DEBUG", "Incoming Global Subscriber Id is: " + globalSubscriberId, isDebugEnabled)
-
- execution.setVariable("DUVAM_moduleCount", 0)
- execution.setVariable("DUVAM_nextModule", 0)
-
-
- }catch(BpmnError b){
- utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled)
- throw b
- }catch(Exception e){
- utils.log("DEBUG", " Error Occured in DoUpdateVnfAndModules PreProcessRequest method!" + e.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoUpdateVnfAndModules PreProcessRequest")
-
- }
- utils.log("DEBUG", "*** COMPLETED DoUpdateVnfAndModules PreProcessRequest Process ***", isDebugEnabled)
- }
-
- /**
- * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
- * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
- *
- * @param execution The flow's execution instance.
- */
- public void queryAAIVfModule(DelegateExecution execution) {
- def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
- def method = getClass().getSimpleName() + '.queryAAIVfModule(' +
- 'execution=' + execution.getId() +
- ')'
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def vnfId = execution.getVariable('vnfId')
-
- AaiUtil aaiUriUtil = new AaiUtil(this)
- String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
- logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)
-
- String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
- utils.logAudit("AAI endPoint: " + endPoint)
-
- try {
- RESTConfig config = new RESTConfig(endPoint);
- def responseData = ''
- def aaiRequestId = UUID.randomUUID().toString()
- RESTClient client = new RESTClient(config).
- addHeader('X-TransactionId', aaiRequestId).
- addHeader('X-FromAppId', 'MSO').
- addHeader('Content-Type', 'application/xml').
- addHeader('Accept','application/xml');
- logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled)
- APIResponse response = client.httpGet()
- utils.logAudit("createVfModule - invoking httpGet() to AAI")
-
- responseData = response.getResponseBodyAsString()
- if (responseData != null) {
- logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled)
-
- }
-
- utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData)
- utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
-
- execution.setVariable('DUVAM_queryAAIVfModuleResponseCode', response.getStatusCode())
- execution.setVariable('DUVAM_queryAAIVfModuleResponse', responseData)
- logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)
- logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)
- //Map<String, String>[] vfModules = new HashMap<String,String>[]
- def vfModulesList = new ArrayList<Map<String,String>>()
- def vfModules = null
- def vfModuleBaseEntry = null
- if (response.getStatusCode() == 200) {
- // Parse the VNF record from A&AI to find base module info
- logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)
- if (responseData != null) {
- def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
- logDebug("vModulesText: " + vfModulesText, isDebugLogEnabled)
- if (vfModulesText != null && !vfModulesText.trim().isEmpty()) {
- def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
- vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
- execution.setVariable("DUVAM_moduleCount", vfModules.size())
- int vfModulesSize = 0
- for (i in 0..vfModules.size()-1) {
- def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
-
- Map<String, String> vfModuleEntry = new HashMap<String, String>()
- def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")
- vfModuleEntry.put("vfModuleId", vfModuleId)
- def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name")
- vfModuleEntry.put("vfModuleName", vfModuleName)
- def modelInvariantUuid = utils.getNodeText1(vfModuleXml, "model-invariant-id")
- vfModuleEntry.put("modelInvariantUuid", modelInvariantUuid)
- def modelUuid = utils.getNodeText1(vfModuleXml, "model-version-id")
- vfModuleEntry.put("modelUuid", modelUuid)
- def modelCustomizationUuid = utils.getNodeText1(vfModuleXml, "model-customization-id")
- vfModuleEntry.put("modelCustomizationUuid", modelCustomizationUuid)
-
- def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
- vfModuleEntry.put("isBaseVfModule", isBaseVfModule)
-
- String volumeGroupId = ''
-
- logDebug("Next module!", isDebugLogEnabled)
- def vfModuleRelationships = vfModules[i].'**'.findAll {it.name() == 'relationship-data'}
- if (vfModuleRelationships.size() > 0) {
- for (j in 0..vfModuleRelationships.size()-1) {
- if (vfModuleRelationships[j] != null) {
-
- def relationshipKey = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-key'}
-
- if (relationshipKey[0] == 'volume-group.volume-group-id') {
- def relationshipValue = vfModuleRelationships[j].'**'.findAll {it.name() == 'relationship-value'}
- volumeGroupId = relationshipValue[0]
- break
- }
- }
- }
- }
-
- vfModuleEntry.put("volumeGroupId", volumeGroupId)
- logDebug("volumeGroupId is: " + volumeGroupId, isDebugLogEnabled)
-
- // Save base vf module to add it to the start of the list later
- if (isBaseVfModule == "true") {
- vfModuleBaseEntry = vfModuleEntry
- }
- else {
- vfModulesList.add(vfModuleEntry)
- }
- }
- // Start the list with the base module if any
- if (vfModuleBaseEntry != null) {
- vfModulesList.add(0, vfModuleBaseEntry)
- }
- }
-
- }
- }
- else {
- logDebug('Response code from AAI GET is: ' + response.getStatusCode(), isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Response code from AAI GET is: ' + response.getStatusCode())
- }
- execution.setVariable("DUVAM_vfModules", vfModulesList)
- } catch (Exception ex) {
- ex.printStackTrace()
- logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
- }
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
- }
- }
-
- public void prepareNextModuleToUpdate(DelegateExecution execution){
- def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled")
- execution.setVariable("prefix", Prefix)
- logDebug(" ======== STARTED prepareNextModuleToUpdate ======== ", isDebugLogEnabled)
-
- try {
- int i = execution.getVariable("DUVAM_nextModule")
- def vfModules = execution.getVariable("DUVAM_vfModules")
- def vfModule = vfModules[i]
-
- def vfModuleId = vfModule.get("vfModuleId")
- execution.setVariable("DUVAM_vfModuleId", vfModuleId)
-
- def vfModuleName = vfModule.get("vfModuleName")
- execution.setVariable("DUVAM_vfModuleName", vfModuleName)
-
- def isBaseVfModule = vfModule.get("isBaseVfModule")
- execution.setVariable("DUVAM_isBaseVfModule", isBaseVfModule)
-
- String modelInvariantUuid = vfModule.get("modelInvariantUuid")
- logDebug("ModelInvariantUuid: " + modelInvariantUuid, isDebugLogEnabled)
-
- def volumeGroupId = vfModule.get("volumeGroupId")
- execution.setVariable("DUVAM_volumeGroupId", volumeGroupId)
-
- execution.setVariable("DUVAM_volumeGroupName", "")
-
- VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
- List<ModuleResource> moduleResources = vnfResource.getVfModules()
-
- for (j in 0..moduleResources.size()-1) {
- ModelInfo modelInfo = moduleResources[j].getModelInfo()
- String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid()
- logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled)
-
- if (modelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) {
- String vfModuleModelInfo = modelInfo.toJsonString()
- String vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfo, "modelInfo")
- execution.setVariable("DUVAM_vfModuleModelInfo", vfModuleModelInfoValue)
- logDebug("vfModuleModelInfo: " + vfModuleModelInfoValue, isDebugLogEnabled)
- break
- }
-
- }
-
- }catch(Exception e){
- utils.log("ERROR", "Exception Occured Processing preProcessAddOnModule. Exception is:\n" + e, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToUpdate Method:\n" + e.getMessage())
- }
- logDebug("======== COMPLETED prepareNextModuleToUpdate ======== ", isDebugLogEnabled)
- }
-
-
- /**
- * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
- *
- * @param execution The flow's execution instance.
- */
- public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def vnfId = execution.getVariable('vnfId')
- VnfResource vnfResource = (VnfResource) execution.getVariable("vnfResourceDecomposition")
- ModelInfo vnfDecompModelInfo = vnfResource.getModelInfo()
- String vnfModelInfo = execution.getVariable("vnfModelInfo")
- String modelUuid = execution.getVariable("DUVAM_modelUuid")
- if (modelUuid == null || modelUuid.isEmpty()) {
- modelUuid = vnfDecompModelInfo.getModelUuid()
- }
- String modelCustomizationUuid = execution.getVariable("DUVAM_modelCustomizationUuid")
- if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) {
- modelCustomizationUuid = vnfDecompModelInfo.getModelCustomizationUuid()
- }
- String nfType = vnfResource.getNfType()
- String nfTypeString = ''
- if (nfType != null && !nfType.isEmpty()) {
- nfTypeString = "<nf-type>" + nfType + "</nf-type>"
- }
- String nfRole = vnfResource.getNfRole()
- String nfRoleString = ''
- if (nfRole != null && !nfRole.isEmpty()) {
- nfRoleString = "<nf-role>" + nfRole + "</nf-role>"
- }
- String nfFunction = vnfResource.getNfFunction()
- String nfFunctionString = ''
- if (nfFunction != null && !nfFunction.isEmpty()) {
- nfFunctionString = "<nf-function>" + nfFunction + "</nf-function>"
- }
- String nfNamingCode = vnfResource.getNfNamingCode()
- String nfNamingCodeString = ''
- if (nfNamingCode != null && !nfNamingCode.isEmpty()) {
- nfNamingCodeString = "<nf-naming-code>" + nfNamingCode + "</nf-naming-code>"
- }
-
- String updateAAIGenericVnfRequest = """
- <UpdateAAIGenericVnfRequest>
- <vnf-id>${vnfId}</vnf-id>
- <model-version-id>${modelUuid}</model-version-id>
- <model-customization-id>${modelCustomizationUuid}</model-customization-id>
- ${nfTypeString}
- ${nfRoleString}
- ${nfFunctionString}
- ${nfNamingCodeString}
- </UpdateAAIGenericVnfRequest>
- """
- updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
- execution.setVariable('DUVAM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
- utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
- logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
-
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
- }
- }
-
- /**
- * APP-C Call - placeholder.
- *
- * @param execution The flow's execution instance.
- */
- public void callAppCf(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.callAppC(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
- }
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/HealchCheckActivate.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/HealchCheckActivate.groovy deleted file mode 100644 index 3ab1b17392..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/HealchCheckActivate.groovy +++ /dev/null @@ -1,54 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
-import org.apache.commons.lang3.*
-
-public class HealthCheckActivate extends AbstractServiceTaskProcessor {
-
-
- /**
- * Validates the request message and sets up the workflow.
- * @param execution the execution
- */
- public void preProcessRequest(DelegateExecution execution) {
-
- }
-
-
- /**
- * Sends the synchronous response back to the API Handler.
- * @param execution the execution
- */
- public void sendResponse(DelegateExecution execution) {
- def status = execution.getVariable("healthyStatus")
- def healthcheckmessage = execution.getVariable("healthcheckmessage")
- if (status == "true") {
- sendWorkflowResponse(execution, 200, healthcheckmessage)
- }else{
- sendWorkflowResponse(execution, 503, healthcheckmessage)
- }
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy deleted file mode 100644 index a9cc776ab6..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ReplaceVnfInfra.groovy +++ /dev/null @@ -1,626 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
-import groovy.util.Node
-import groovy.util.XmlParser;
-import groovy.xml.QName
-
-import java.io.Serializable;
-import java.util.UUID;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
-import org.openecomp.mso.bpmn.common.scripts.VidUtils;
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.core.domain.ModelInfo
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
-import org.openecomp.mso.bpmn.core.domain.VnfResource
-import org.openecomp.mso.client.aai.*
-
-import org.openecomp.mso.client.appc.ApplicationControllerOrchestrator
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.appc.client.lcm.model.ActionIdentifiers;
-import org.onap.appc.client.lcm.model.LockInput
-import org.onap.appc.client.lcm.model.UnlockInput
-import org.onap.appc.client.lcm.model.HealthCheckInput
-import org.onap.appc.client.lcm.model.StartInput
-import org.onap.appc.client.lcm.model.Flags
-import org.onap.appc.client.lcm.model.Status
-
-
-
-public class ReplaceVnfInfra extends VnfCmBase {
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtils = new JsonUtils()
- def prefix = "RPLVnfI_"
-
- /**
- * Initialize the flow's variables.
- *
- * @param execution The flow's execution instance.
- */
- public void initProcessVariables(DelegateExecution execution) {
- execution.setVariable('prefix', 'RPLVnfI_')
- execution.setVariable('Request', null)
- execution.setVariable('requestInfo', null)
- execution.setVariable('source', null)
- execution.setVariable('vnfInputs', null)
- execution.setVariable('tenantId', null)
- execution.setVariable('vnfParams', null)
- execution.setVariable('controllerType', null)
- execution.setVariable('cloudConfiguration', null)
- execution.setVariable('ReplaceVnfSuccessIndicator', false)
- execution.setVariable('serviceType', null)
- execution.setVariable('nfRole', null)
- execution.setVariable('currentActivity', 'RPLVnfI')
- execution.setVariable('workStep', null)
- execution.setVariable('failedActivity', null)
- execution.setVariable('errorCode', "0")
- execution.setVariable('errorText', null)
- execution.setVariable('healthCheckIndex', 1)
- execution.setVariable('retainResources', true)
- execution.setVariable('productFamilyId', null)
- execution.setVariable('healthCheckIndex0', 0)
- execution.setVariable('healthCheckIndex1', 1)
- execution.setVariable("rollbackSetClosedLoopDisabledFlag", false)
- execution.setVariable("rollbackVnfStop", false)
- execution.setVariable("rollbackVnfLock", false)
- execution.setVariable("rollbackQuiesceTraffic", false)
- execution.setVariable("rollbackSetVnfInMaintenanceFlag", false)
- }
-
- /**
- * Check for missing elements in the received request.
- *
- * @param execution The flow's execution instance.
- */
- public void preProcessRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessRequest(' +
- 'execution=' + execution.getId() +
- ')'
- initProcessVariables(execution)
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- initProcessVariables(execution)
-
- def incomingRequest = execution.getVariable('bpmnRequest')
-
- utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
- try {
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
- Map reqMap = jsonSlurper.parseText(incomingRequest)
- utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
-
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def vnfId = execution.getVariable('vnfId')
-
- execution.setVariable('serviceInstanceId', serviceInstanceId)
- execution.setVariable("isVidRequest", "true")
- execution.setVariable('serviceType', 'Mobility')
- execution.setVariable('retainResources', true)
- execution.setVariable('disableRollback', true)
- execution.setVariable('payload', "")
- execution.setVariable('actionLock', Action.Lock)
- execution.setVariable('actionUnlock', Action.Unlock)
- execution.setVariable('actionHealthCheck', Action.HealthCheck)
- execution.setVariable('actionStart', Action.Start)
- execution.setVariable('actionStop', Action.Stop)
-
- def asdcServiceModelVersion = ''
- def serviceModelInfo = null
-
- def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
-
- if (relatedInstanceList != null) {
- relatedInstanceList.each {
- if (it.relatedInstance.modelInfo?.modelType == 'service') {
- utils.log("DEBUG", "PROCESSING SERVICE INFO", isDebugLogEnabled)
- asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
- serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
- utils.log("DEBUG", "ServiceModelInfo: " + serviceModelInfo, isDebugLogEnabled)
- def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")
- utils.log("DEBUG", "modelInvariant: " + modelInvariant, isDebugLogEnabled)
- }
-
- }
- }
-
- execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion)
- execution.setVariable('serviceModelInfo', serviceModelInfo)
- def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
- execution.setVariable('vnfModelInfo', vnfModelInfo)
- def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid")
- execution.setVariable('vnfModelInvariantUuid', vnfModelInvariantUuid)
- logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled)
-
- def vnfType = execution.getVariable('vnfType')
- execution.setVariable('vnfType', vnfType)
-
- def controllerType = reqMap.requestDetails?.requestParameters?.controllerType
- execution.setVariable('controllerType', controllerType)
-
- utils.log("DEBUG", 'Controller Type: ' + controllerType, isDebugLogEnabled)
-
- def userParams = reqMap.requestDetails?.requestParameters?.userParams
-
- Map<String, String> userParamsMap = [:]
- if (userParams != null) {
- userParams.each { userParam ->
- userParamsMap.put(userParam.name, userParam.value.toString())
- }
- }
-
- utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
-
- execution.setVariable('vfModuleInputParams', userParamsMap)
-
- def requestId = execution.getVariable("requestId")
- execution.setVariable('msoRequestId', requestId)
- utils.log("DEBUG", "requestId is: " + requestId, isDebugLogEnabled)
-
- def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
- execution.setVariable('vnfName', vnfName)
-
- def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null
- execution.setVariable('requestorId', requestorId)
-
- def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
- execution.setVariable('usePreload', usePreload)
-
- def productFamilyId = reqMap.requestDetails?.requestInfo?.productFamilyId ?: null
- execution.setVariable('productFamilyId', productFamilyId)
-
- def cloudConfiguration = jsonOutput.toJson(reqMap.requestDetails?.cloudConfiguration)
- execution.setVariable('cloudConfiguration', cloudConfiguration)
- def lcpCloudRegionId = jsonUtils.getJsonValue(cloudConfiguration, "lcpCloudRegionId")
- execution.setVariable('lcpCloudRegionId', lcpCloudRegionId)
- def tenantId = jsonUtils.getJsonValue(cloudConfiguration, "tenantId")
- execution.setVariable('tenantId', tenantId)
-
- def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
- execution.setVariable('globalSubscriberId', globalSubscriberId)
-
- execution.setVariable('sdncVersion', '1702')
-
- execution.setVariable("ReplaceVnfInfraSuccessIndicator", false)
-
- execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
-
- def source = reqMap.requestDetails?.requestInfo?.source
- execution.setVariable("source", source)
-
- //For Completion Handler & Fallout Handler
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>REPLACE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable("requestInfo", requestInfo)
-
- logDebug('RequestInfo: ' + execution.getVariable("requestInfo"), isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- }
- catch(groovy.json.JsonException je) {
- utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
-
- }
- catch(Exception e) {
- String restFaultMessage = e.getMessage()
- utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
- }
- }
-
- /**
- * Prepare and send the sychronous response for this flow.
- *
- * @param execution The flow's execution instance.
- */
- public void sendSynchResponse(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.sendSynchResponse(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
-
- try {
- def requestInfo = execution.getVariable('requestInfo')
- def requestId = execution.getVariable('requestId')
- def source = execution.getVariable('source')
- def progress = getNodeTextForce(requestInfo, 'progress')
- if (progress.isEmpty()) {
- progress = '0'
- }
- def startTime = getNodeTextForce(requestInfo, 'start-time')
- if (startTime.isEmpty()) {
- startTime = System.currentTimeMillis()
- }
-
- // RESTResponse (for API Handler (APIH) Reply Task)
- def vnfId = execution.getVariable("vnfId")
- String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
-
- sendWorkflowResponse(execution, 200, synchResponse)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
- }
- }
-
-
-
- /**
- * Get VnfResource decomposition object for this VNF.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void getVnfResourceDecomposition(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid')
- logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled)
- List<VnfResource> vnfResources = serviceDecomposition.getServiceVnfs()
-
- for (i in 0..vnfResources.size()-1) {
- ModelInfo modelInfo = vnfResources[i].getModelInfo()
- String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid()
- logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled)
-
- if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) {
- VnfResource vnfResourceDecomposition = vnfResources[i]
- execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition)
- def nfRole = vnfResourceDecomposition.getNfRole()
- execution.setVariable('nfRole', nfRole)
- logDebug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString(), isDebugLogEnabled)
- break
- }
- else {
- //exception!
- }
-
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage())
- }
- }
-
- /**
- * Check if this VNF is already in maintenance in A&AI.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void checkIfVnfInMaintInAAI(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- execution.setVariable("workStep", "checkIfVnfInMaintInAAI")
- execution.setVariable("failedActivity", "AAI")
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
- AAIRestClientImpl client = new AAIRestClientImpl()
- AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
- aaiValidator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
- boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid)
- logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled)
- execution.setVariable('isVnfInMaintenance', isInMaint)
-
- if (isInMaint) {
- execution.setVariable("errorCode", "1003")
- execution.setVariable("errorText", "VNF is in maintenance in A&AI")
- }
-
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
- }
- }
-
-
- /**
- * Check if this VNF's pservers are locked in A&AI.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void checkIfPserversInMaintInAAI(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("workStep", "checkIfPserversInMaintInAAI")
- execution.setVariable("failedActivity", "AAI")
-
- try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
- AAIRestClientImpl client = new AAIRestClientImpl()
- AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
- aaiValidator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
- boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid)
- logDebug("areLocked result: " + areLocked, isDebugLogEnabled)
- execution.setVariable('arePserversLocked', areLocked)
-
- if (areLocked) {
- execution.setVariable("errorCode", "1003")
- execution.setVariable("errorText", "pServers are locked in A&AI")
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage())
- }
- }
-
- /**
- * Set inMaint flag for this VNF to the specified value in A&AI.
- *
- *
- * @param execution The flow's execution instance.
- * @param inMaint The boolean value of the flag to set
- */
- public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) {
- def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- if (inMaint) {
- execution.setVariable("workStep", "setVnfInMaintFlagInAAI")
- }
- else {
- execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI")
- }
- execution.setVariable("failedActivity", "AAI")
-
- try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
- AAIRestClientImpl client = new AAIRestClientImpl()
- AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl()
- aaiUpdator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
- if (inMaint) {
- aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid)
- execution.setVariable("rollbackSetVnfInMaintenanceFlag", true)
- }
- else {
- aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid)
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage())
- }
- }
-
- /**
- * Call APP-C client to execute specified APP-C command for this VNF.
- *
- *
- * @param execution The flow's execution instance.
- * @param action The action to take in APP-C.
- */
- public void runAppcCommand(DelegateExecution execution, Action action) {
- def method = getClass().getSimpleName() + '.runAppcCommand(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled)
- String vnfId = execution.getVariable('vnfId')
- String msoRequestId = execution.getVariable('requestId')
- execution.setVariable('msoRequestId', msoRequestId)
- execution.setVariable("failedActivity", "APP-C")
- execution.setVariable("workStep", action.toString() + "VNF")
-
- ApplicationControllerOrchestrator appcClient = new ApplicationControllerOrchestrator()
- Status appcStatus = null
- switch(action) {
- case Action.Lock:
- execution.setVariable('workStep', "LockVNF")
- appcStatus = appcClient.runCommand(Action.Lock,msoRequestId,vnfId,null)
- break
- case Action.Unlock:
- execution.setVariable('workStep', "UnlockVNF")
- appcStatus = appcClient.runCommand(Action.Unlock,msoRequestId,vnfId,null)
- break
- case Action.HealthCheck:
- def healthCheckIndex = execution.getVariable('healthCheckIndex')
- execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex)
- execution.setVariable('healthCheckIndex', healthCheckIndex + 1)
- appcStatus = appcClient.runCommand(Action.HealthCheck,msoRequestId,vnfId,null)
- break
- case Action.Start:
- execution.setVariable('workStep', "StartVNF")
- appcStatus = appcClient.runCommand(Action.Start,msoRequestId,vnfId,null)
- break
- case Action.Stop:
- execution.setVariable('workStep', "StopVNF")
- appcStatus = appcClient.runCommand(Action.Stop,msoRequestId,vnfId,null)
- break
- default:
- break
- }
- logDebug("Completed AppC request", isDebugLogEnabled)
- int appcCode = appcStatus.getCode()
- logDebug("AppC status code is: " + appcCode, isDebugLogEnabled)
- logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled)
- if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) {
- execution.setVariable("errorCode", Integer.toString(appcCode))
- execution.setVariable("errorText", appcStatus.getMessage())
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- } catch (java.lang.NoSuchMethodError e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- }
- }
-
-
-
- /**
- * Prepare DoDeleteVnfAndModules call.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void prepDoDeleteVnfAndModules(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.prepDoDeleteVnfAndModules(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("workStep", "doDeleteVnfAndModules")
- execution.setVariable("failedActivity", "MSO Delete VNF")
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- }
-
- /**
- * Prepare DoCreateVnfAndModules call.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void prepDoCreateVnfAndModules(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.prepDoReplaceVnfAndModules(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("workStep", "doCreateVnfAndModules")
- execution.setVariable("failedActivity", "MSO Create VNF")
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- }
-
-
- /**
- * Handle Abort disposition from RainyDayHandler
- *
- * @param execution The flow's execution instance.
- */
- public void abortProcessing(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.abortProcessing(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- def errorText = execution.getVariable("errorText")
- def errorCode = execution.getVariable("errorCode")
-
- exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText)
- }
-
- /**
- * Handle Manual disposition from RainyDayHandler
- *
- * @param execution The flow's execution instance.
- */
- public void manualProcessing(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.manualProcessing(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- def taskId = execution.getVariable("taskId")
-
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Processing halted - manual task created: " + taskId)
- }
-
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/RollbackVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/RollbackVnf.groovy deleted file mode 100644 index 99248a92ad..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/RollbackVnf.groovy +++ /dev/null @@ -1,151 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.json.JsonOutput -import groovy.json.JsonSlurper -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import java.io.Serializable; -import java.util.UUID; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.client.aai.* - -import org.openecomp.mso.client.appc.ApplicationControllerClient; -import org.openecomp.mso.client.appc.ApplicationControllerSupport; -import org.openecomp.mso.client.aai.AAIResourcesClient -import org.openecomp.mso.client.aai.entities.AAIResultWrapper -import org.openecomp.mso.client.aai.entities.uri.AAIUri -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.LockInput -import org.onap.appc.client.lcm.model.UnlockInput -import org.onap.appc.client.lcm.model.HealthCheckInput -import org.onap.appc.client.lcm.model.StartInput -import org.onap.appc.client.lcm.model.StopInput -import org.onap.appc.client.lcm.model.Flags -import org.onap.appc.client.lcm.model.Status - - - -public class RollbackVnf extends VnfCmBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtils = new JsonUtils() - def prefix = "VnfIPU_" - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'RVnf_') - - execution.setVariable('rollbackSuccessful', false) - execution.setVariable('currentActivity', 'RVnf') - execution.setVariable('workStep', null) - execution.setVariable('failedActivity', null) - execution.setVariable('errorCode', "0") - execution.setVariable('actionUnlock', Action.Unlock) - execution.setVariable('actionStart', Action.Start) - execution.setVariable('actionResumeTraffic', Action.ResumeTraffic) - - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - initProcessVariables(execution) - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - initProcessVariables(execution) - - try { - - execution.setVariable("rollbackErrorCode", "0") - - if (execution.getVariable("rollbackSetClosedLoopDisabledFlag") == true) { - logDebug("Will call setClosedLoopDisabledFlag", isDebugLogEnabled) - } - - - logDebug('Exited ' + method, isDebugLogEnabled) - - } - catch(Exception e) { - String restFaultMessage = e.getMessage() - utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) - execution.setVariable("rollbackErrorCode", "1") - } - } - - /** - * Determine success of rollback execution. - * - * @param execution The flow's execution instance. - */ - public void setRollbackResult(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.setRollbackResult(' + - 'execution=' + execution.getId() + - ')' - initProcessVariables(execution) - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - def rollbackErrorCode = execution.getVariable('rollbackErrorCode') - if (rollbackErrorCode == "0") { - execution.setVariable('rollbackSuccessful', true) - logDebug("rollback successful", isDebugLogEnabled) - } - else { - execution.setVariable('rollbackSuccessful', false) - logDebug("rollback unsuccessful", isDebugLogEnabled) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy deleted file mode 100644 index 4eca37b304..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/ScaleCustomE2EServiceInstance.groovy +++ /dev/null @@ -1,302 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 CMCC. 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.infrastructure.scripts - -import org.camunda.bpm.engine.delegate.DelegateExecution - -import static org.apache.commons.lang3.StringUtils.* -import org.openecomp.mso.logger.MsoLogger -import org.openecomp.mso.utils.UUIDChecker -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution - -import org.springframework.web.util.UriUtils - - -/** - * This groovy class supports the <class>ScaleCustomE2EServiceInstance.bpmn</class> process. - * - */ -public class ScaleCustomE2EServiceInstance extends AbstractServiceTaskProcessor { - String Prefix = "CRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - private MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH); - - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - String msg = "" - utils.log("DEBUG", " *** preProcessRequest() *** ", isDebugEnabled) - - try { - - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("DEBUG", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)) { - serviceInstanceId = "NULL".toString() - } - utils.log("DEBUG", "Generated new Service Instance:" + serviceInstanceId, isDebugEnabled) - serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8") - execution.setVariable("serviceInstanceId", serviceInstanceId) - - // service instance ID is also service ID - execution.setVariable("serviceId", serviceInstanceId) - // service instance name - String serviceInstanceName = jsonUtil.getJsonValue(siRequest, "service.serviceInstanceName") - execution.setVariable("serviceInstanceName", serviceInstanceName) - - // service instance name - String serviceType = jsonUtil.getJsonValue(siRequest, "service.serviceType") - execution.setVariable("serviceType", serviceType) - - // operationa ID (key) - //String operationKey = UUIDChecker.generateUUID(msoLogger) - String operationId = jsonUtil.getJsonValue(siRequest, "operationId") - execution.setVariable("operationId", operationId) - utils.log("DEBUG", "Input Request:" + siRequest + " operationId:" + operationId, isDebugEnabled) - - - String resources = jsonUtil.getJsonValue(siRequest, "service.resources") - execution.setVariable("resources", resources) - - // node template UUID - String nodeTemplateUUID = UUIDChecker.generateUUID(msoLogger) - execution.setVariable("nodeTemplateUUID", nodeTemplateUUID) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "service.globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - String requestDescription = "request description for test" - execution.setVariable("requestDescription", requestDescription) - execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", " ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void sendSyncResponse(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String operationId = execution.getVariable("operationId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - // RESTResponse for API Handler (APIH) Reply Task - String scaleServiceRestRequest = """{"operationId":"${operationId}"}""".trim() - utils.log("DEBUG", " sendSyncResponse to APIH:" + "\n" + scaleServiceRestRequest, isDebugEnabled) - sendWorkflowResponse(execution, 202, scaleServiceRestRequest) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", " ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - - public void sendSyncError(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareCompletionRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String source = execution.getVariable("source") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>SCALE</action> - <source>${source}</source> - </request-info> - <status-message>Service Instance was scaled successfully.</status-message> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - <mso-bpel-name>ScaleGenericALaCarteServiceInstance</mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>SCALE</action> - <source>${source}</source> - </request-info>""" - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in ScaleGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>SCALE</action> - <source>UUI</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } - - - /** - * Init the service Operation Status - */ - public void prepareInitServiceOperationStatus(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - //String serviceName = execution.getVariable("serviceInstanceName") - String operationId = execution.getVariable("operationId") - String operationType = "SCALE" - String userId = "" - String result = "processing" - String progress = "0" - String reason = "" - String operationContent = "Prepare service scaling" - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - - def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <userId>${userId}</userId> - <result>${result}</result> - <operationContent>${operationContent}</operationContent> - <progress>${progress}</progress> - <reason>${reason}</reason> - </ns:updateServiceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) - utils.log("INFO", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled) - utils.logAudit("Scale network service updateServiceOperStatusRequest Request: " + payload) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) - } - utils.log("INFO", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) - } -}
\ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy deleted file mode 100644 index f3f1a96258..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateCustomE2EServiceInstance.groovy +++ /dev/null @@ -1,575 +0,0 @@ -/*- - * ============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.infrastructure.scripts; - -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.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.core.domain.Resource -import org.openecomp.mso.rest.APIResponse - -import java.util.List; -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject -import org.json.JSONArray -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the <class>UpdateCustomE2EServiceInstance.bpmn</class> process. - * AlaCarte flow for 1702 ServiceInstance Update - * - */ -public class UpdateCustomE2EServiceInstance extends AbstractServiceTaskProcessor { - String Prefix="UPDSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - String msg = "" - utils.log("INFO", " *** preProcessRequest() *** ", isDebugEnabled) - - try { - - String siRequest = execution.getVariable("bpmnRequest") - utils.logAudit(siRequest) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - utils.log("INFO", "Input Request:" + siRequest + " reqId:" + requestId, isDebugEnabled) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - if (isBlank(serviceInstanceId)) { - msg = "Input serviceInstanceId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - //subscriberInfo for aai - String globalSubscriberId = jsonUtil.getJsonValue(siRequest, "requestDetails.subscriberInfo.globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //requestDetails - execution.setVariable("source", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.source")) - execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.instanceName")) - execution.setVariable("disableRollback", jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.suppressRollback")) - String productFamilyId = jsonUtil.getJsonValue(siRequest, "requestDetails.requestInfo.productFamilyId") - if (isBlank(productFamilyId)) - { - msg = "Input productFamilyId is null" - utils.log("INFO", msg, isDebugEnabled) - } else { - execution.setVariable("productFamilyId", productFamilyId) - } - - //user params - String userParams = jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams") - utils.log("INFO", "userParams:" + userParams, isDebugEnabled) - List<String> paramList = jsonUtil.StringArrayToList(execution, userParams) - String uuiRequest = jsonUtil.getJsonValue(paramList.get(0), "UUIRequest") - if (isBlank(uuiRequest)) { - msg = "Input uuiRequest is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("uuiRequest", uuiRequest) - } - - utils.log("INFO", "uuiRequest:\n" + uuiRequest, isDebugEnabled) - - //serviceType for aai - String serviceType = jsonUtil.getJsonValue(uuiRequest, "service.serviceType") - if (isBlank(serviceType)) { - msg = "Input serviceType is null" - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("serviceType", serviceType) - } - - // target model info - String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceInvariantUuid") - utils.log("INFO","modelInvariantUuid: " + modelInvariantUuid, isDebugEnabled) - execution.setVariable("modelInvariantUuid", modelInvariantUuid) - execution.setVariable("model-invariant-id-target", modelInvariantUuid) - - String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.serviceUuid") - utils.log("INFO","modelUuid: " + modelUuid, isDebugEnabled) - execution.setVariable("modelUuid", modelUuid) - execution.setVariable("model-version-id-target", modelUuid) - - String serviceModelName = jsonUtil.getJsonValue(uuiRequest, "service.parameters.templateName") - utils.log("INFO","serviceModelName: " + serviceModelName, isDebugEnabled) - if(serviceModelName == null) { - serviceModelName = "" - } - execution.setVariable("serviceModelName", serviceModelName) - - //operationId - String operationId = jsonUtil.getJsonValue(siRequest, "operationId") - if (isBlank(operationId)) { - operationId = UUID.randomUUID().toString() - } - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", "update") - execution.setVariable("hasResourcetoUpdate", false) - - execution.setVariable("URN_mso_adapters_openecomp_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - - } 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) - } - - - public void postProcessAAIGET(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO"," ***** postProcessAAIGET ***** ", isDebugEnabled) - String msg = "" - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - boolean foundInAAI = execution.getVariable("GENGS_FoundIndicator") - String serviceType = "" - - if(foundInAAI){ - utils.log("INFO","Found Service-instance in AAI", isDebugEnabled) - - String siData = execution.getVariable("GENGS_service") - utils.log("INFO", "SI Data", isDebugEnabled) - if (isBlank(siData)) - { - msg = "Could not retrive ServiceInstance data from AAI, Id:" + serviceInstanceId - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - utils.log("INFO", "SI Data" + siData, isDebugEnabled) - - // serviceInstanceName - String serviceInstanceName = execution.getVariable("serviceInstanceName") - if(isBlank(serviceInstanceName) && utils.nodeExists(siData, "service-instance-name")) { - serviceInstanceName = utils.getNodeText1(siData, "service-instance-name") - execution.setVariable("serviceInstanceName", serviceInstanceName) - } - - // Get Template uuid and version - if (utils.nodeExists(siData, "model-invariant-id") && utils.nodeExists(siData, "model-version-id") ) { - utils.log("INFO", "SI Data model-invariant-id and model-version-id exist:", isDebugEnabled) - - def modelInvariantId = utils.getNodeText1(siData, "model-invariant-id") - def modelVersionId = utils.getNodeText1(siData, "model-version-id") - - // Set Original Template info - execution.setVariable("model-invariant-id-original", modelInvariantId) - execution.setVariable("model-version-id-original", modelVersionId) - } - - //get related service instances (vnf/network or volume) for delete - if (utils.nodeExists(siData, "relationship-list")) { - utils.log("INFO", "SI Data relationship-list exists:", isDebugEnabled) - - JSONArray jArray = new JSONArray() - - XmlParser xmlParser = new XmlParser() - Node root = xmlParser.parseText(siData) - def relation_list = utils.getChildNode(root, 'relationship-list') - def relationships = utils.getIdenticalChildren(relation_list, 'relationship') - - for (def relation: relationships) { - def jObj = getRelationShipData(relation, isDebugEnabled) - jArray.put(jObj) - } - - execution.setVariable("serviceRelationShip", jArray.toString()) - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(!succInAAI){ - utils.log("INFO","Error getting Service-instance from AAI", + serviceInstanceId, isDebugEnabled) - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - if(workflowException != null){ - exceptionUtil.buildAndThrowWorkflowException(execution, workflowException.getErrorCode(), workflowException.getErrorMessage()) - } - else - { - msg = "Failure in postProcessAAIGET GENGS_SuccessIndicator:" + succInAAI - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg) - } - } - - utils.log("INFO","Service-instance NOT found in AAI. Silent Success", isDebugEnabled) - } - }catch (BpmnError e) { - throw e; - } catch (Exception ex) { - msg = "Exception in DoDeleteE2EServiceInstance.postProcessAAIGET. " + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," *** Exit postProcessAAIGET *** ", isDebugEnabled) - } - - private JSONObject getRelationShipData(node, isDebugEnabled){ - JSONObject jObj = new JSONObject() - - def relation = utils.nodeToString(node) - def rt = utils.getNodeText1(relation, "related-to") - - def rl = utils.getNodeText1(relation, "related-link") - utils.log("INFO", "ServiceInstance Related NS/Configuration :" + rl, isDebugEnabled) - - def rl_datas = utils.getIdenticalChildren(node, "relationship-data") - for(def rl_data : rl_datas) { - def eKey = utils.getChildNodeText(rl_data, "relationship-key") - def eValue = utils.getChildNodeText(rl_data, "relationship-value") - - if ((rt == "service-instance" && eKey.equals("service-instance.service-instance-id")) - //for overlay/underlay - || (rt == "configuration" && eKey.equals("configuration.configuration-id"))){ - jObj.put("resourceInstanceId", eValue) - } - } - - def rl_props = utils.getIdenticalChildren(node, "related-to-property") - for(def rl_prop : rl_props) { - def eKey = utils.getChildNodeText(rl_prop, "property-key") - def eValue = utils.getChildNodeText(rl_prop, "property-value") - if((rt == "service-instance" && eKey.equals("service-instance.service-instance-name")) - //for overlay/underlay - || (rt == "configuration" && eKey.equals("configuration.configuration-type"))){ - jObj.put("resourceType", eValue) - } - } - - utils.log("INFO", "Relationship related to Resource:" + jObj.toString(), isDebugEnabled) - - return jObj - } - - - public void preCompareModelVersions(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - } - - public void postCompareModelVersions(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ======== STARTED postCompareModelVersions Process ======== ", isDebugEnabled) - - def hasResourcetoUpdate = false - def hasResourcetoAdd = false - def hasResourcetoDelete = false - List<Resource> addResourceList = execution.getVariable("addResourceList") - List<Resource> delResourceList = execution.getVariable("delResourceList") - - if(addResourceList != null && !addResourceList.isEmpty()) { - hasResourcetoAdd = true - } - - if(delResourceList != null && !delResourceList.isEmpty()) { - hasResourcetoDelete = true - } - - hasResourcetoUpdate = hasResourcetoAdd || hasResourcetoDelete - execution.setVariable("hasResourcetoUpdate", hasResourcetoUpdate) - - utils.log("DEBUG", "======== COMPLETED postCompareModelVersions Process ======== ", isDebugEnabled) - } - - /** - * Init the service Operation Status - */ - public void prepareInitServiceOperationStatus(DelegateExecution execution){ - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ======== STARTED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = execution.getVariable("operationType") - String userId = "" - String result = "processing" - String progress = "0" - String reason = "" - String operationContent = "Prepare service updating" - utils.log("DEBUG", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - - def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint") - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) - - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <userId>${userId}</userId> - <result>${result}</result> - <operationContent>${operationContent}</operationContent> - <progress>${progress}</progress> - <reason>${reason}</reason> - </ns:updateServiceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) - utils.log("DEBUG", "Outgoing updateServiceOperStatusRequest: \n" + payload, isDebugEnabled) - utils.logAudit("CreateVfModuleInfra Outgoing updateServiceOperStatusRequest Request: " + payload) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing prepareInitServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareInitServiceOperationStatus Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "======== COMPLETED prepareInitServiceOperationStatus Process ======== ", isDebugEnabled) - } - - /** - * Update the service Operation Status - */ - public void preUpdateServiceOperationStatus(DelegateExecution execution){ - def method = getClass().getSimpleName() + '.preUpdateServiceOperationStatus(' +'execution=' + execution.getId() +')' - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("INFO","Entered " + method, isDebugEnabled) - - try{ - String serviceId = execution.getVariable("serviceInstanceId") - String operationId = execution.getVariable("operationId") - String operationType = execution.getVariable("operationType") - String serviceName = execution.getVariable("serviceInstanceName") - String result = execution.getVariable("operationResult") - String progress = execution.getVariable("progress") - String reason = execution.getVariable("operationReason") - String userId = "" - utils.log("INFO", "progress: " + progress , isDebugEnabled) - - String operationContent = "Prepare service : " + execution.getVariable("operationStatus") - - utils.log("INFO", "Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId, isDebugEnabled) - serviceId = UriUtils.encode(serviceId,"UTF-8") - execution.setVariable("serviceInstanceId", serviceId) - execution.setVariable("operationId", operationId) - execution.setVariable("operationType", operationType) - - def dbAdapterEndpoint = "http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter" - execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) - utils.log("INFO", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled) - - execution.setVariable("URN_mso_openecomp_adapters_db_endpoint","http://mso.mso.testlab.openecomp.org:8080/dbadapters/RequestsDbAdapter") - String payload = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:ns="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateServiceOperationStatus xmlns:ns="http://org.openecomp.mso/requestsdb"> - <serviceId>${serviceId}</serviceId> - <operationId>${operationId}</operationId> - <operationType>${operationType}</operationType> - <userId>${userId}</userId> - <result>${result}</result> - <operationContent>${operationContent}</operationContent> - <progress>${progress}</progress> - <reason>${reason}</reason> - </ns:updateServiceOperationStatus> - </soapenv:Body> - </soapenv:Envelope>""" - - payload = utils.formatXml(payload) - execution.setVariable("CVFMI_updateServiceOperStatusRequest", payload) - utils.log("INFO", "Outgoing preUpdateServiceOperationStatus: \n" + payload, isDebugEnabled) - - - }catch(Exception e){ - utils.log("ERROR", "Exception Occured Processing preUpdateServiceOperationStatus. Exception is:\n" + e, isDebugEnabled) - execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during preUpdateServiceOperationStatus Method:\n" + e.getMessage()) - } - utils.log("INFO", "======== COMPLETED preUpdateServiceOperationStatus Process ======== ", isDebugEnabled) - utils.log("INFO", "Exited " + method, isDebugEnabled) - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** sendSyncResponse *** ", isDebugEnabled) - - try { - String operationId = execution.getVariable("operationId") - def hasResourcetoUpdate = execution.getVariable("hasResourcetoUpdate") - - String updateServiceResp = "" - if(hasResourcetoUpdate) { - // RESTResponse for API Handler (APIH) Reply Task - updateServiceResp = """{"operationId":"${operationId}"}""".trim() - } - else { - updateServiceResp = """{"OperationResult":"No Resource to Add or Delete or Service Instance not found in AAI."}""" - } - - utils.log("INFO", " sendSyncResponse to APIH:" + "\n" + updateServiceResp, isDebugEnabled) - sendWorkflowResponse(execution, 202, updateServiceResp) - execution.setVariable("sentSyncResponse", true) - - } catch (Exception ex) { - String msg = "Exceptuion in sendSyncResponse:" + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** sendSyncError *** ", isDebugEnabled) - - try { - String errorMessage = "" - int errorCode = 7000 - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - WorkflowException wfe = execution.getVariable("WorkflowException") - errorMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - - } catch (Exception ex) { - utils.log("INFO", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareCompletionRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String source = execution.getVariable("source") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>${source}</source> - </request-info> - <status-message>Service Instance was updated successfully.</status-message> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - <mso-bpel-name>UpdateCustomE2EServiceInstance</mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - execution.setVariable("completionRequest", xmlMsoCompletionRequest) - utils.log("INFO", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String msg = " Exception in prepareCompletion:" + ex.getMessage() - utils.log("INFO", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("INFO", "*** Exit prepareCompletionRequest ***", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("INFO", " *** prepareFalloutRequest *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("INFO", " Input Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>${source}</source> - </request-info>""" - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - execution.setVariable("falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("INFO", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled) - String errorException = " Bpmn error encountered in UpdateCustomE2EServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - String requestId = execution.getVariable("msoRequestId") - String falloutRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>UUI</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("INFO", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy deleted file mode 100644 index 33eb4f90bf..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstance.groovy +++ /dev/null @@ -1,455 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts; - -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.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the <class>UpdateNetworkInstance.bpmn</class> process. - * - */ -public class UpdateNetworkInstance extends AbstractServiceTaskProcessor { - String Prefix="UPDNI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public InitializeProcessVariables(DelegateExecution execution){ - - execution.setVariable(Prefix + "source", "") - execution.setVariable(Prefix + "Success", false) - - execution.setVariable(Prefix + "CompleteMsoProcessRequest", "") - execution.setVariable(Prefix + "FalloutHandlerRequest", "") - - } - - - /** - * This method is executed during the preProcessRequest task of the <class>UpdateNetworkInstance.bpmn</class> process. - * @param execution - */ - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>UpdateNetworkInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest() of UpdateNetworkInstance Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - String sdncVersion = execution.getVariable("sdncVersion") - if (sdncVersion == null || sdncVersion == "1610") { - // 'a-la-cart' default, sdncVersion = '1610' - execution.setVariable("sdncVersion", "1610") - String bpmnRequest = execution.getVariable("bpmnRequest") - if (bpmnRequest != null) { - String disableRollback = jsonUtil.getJsonValue(bpmnRequest, "requestDetails.requestInfo.suppressRollback") - if (disableRollback != null) { - execution.setVariable("disableRollback", disableRollback) - utils.log("DEBUG", "Received 'suppressRollback': " + disableRollback , isDebugEnabled) - } else { - execution.setVariable("disableRollback", false) - } - utils.log("DEBUG", " Set 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } else { - String dataErrorMessage = " Invalid 'bpmnRequest' request." - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - } else { - // 'macro' TEST ONLY, sdncVersion = '1702' - utils.log("DEBUG", " 'disableRollback' : " + execution.getVariable("disableRollback") , isDebugEnabled) - } - - String requestId = execution.getVariable("msoRequestId") - if (requestId != null) { - execution.setVariable("mso-request-id", requestId) - } else { - requestId = execution.getVariable("mso-request-id") - } - execution.setVariable(Prefix + "requestId", requestId) - - // get/set 'requestId' - if (execution.getVariable("requestId") == null) { - execution.setVariable("requestId", requestId) - } - - //Place holder for additional code. - - // TODO ??? - // userParams??? 1) pre-loads indicator, 2) 'auto-activation' - // Tag/Value parameters - // - // Map: 'networkInputParams': 'auto-activation'' - // Sample format? - // "requestParameters": { - // "userParams": [ - // { - // "name": "someUserParam1", - // "value": "someValue1" - // } - // ] - // } - // - // String userParams = //use json util to extract "userParams"// - // execution.setVariable("networkInputParams", userParams) - // else: execution.setVariable("networkInputParams", null) - // - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in UpdateNetworkInstance, PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - public void sendSyncResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncResponse() of UpdateNetworkInstance ***** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // RESTResponse (for API Handler (APIH) Reply Task) - String updateNetworkRestRequest = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - utils.log("DEBUG", " sendSyncResponse to APIH - " + "\n" + updateNetworkRestRequest, isDebugEnabled) - sendWorkflowResponse(execution, 202, updateNetworkRestRequest) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstance flow. sendSyncResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - - public void getNetworkModelInfo (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of UpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - // For Ala-Carte (sdnc = 1610): - // 1. the Network ModelInfo is expected to be sent - // via requestDetails.modelInfo (modelType = network), ex: modelCustomizationId - // 2. the Service ModelInfo is expected to be sent but will be IGNORE - // via requestDetails.relatedInstanceList.relatedInstance.modelInfo (modelType = service) - - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstance flow. getNetworkModelInfo() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - public void sendSyncError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncError() of UpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // REST Error (for API Handler (APIH) Reply Task) - String syncError = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim() - - sendWorkflowResponse(execution, 500, syncError) - - } catch (Exception ex) { - utils.log("DEBUG", " Bpmn error encountered in UpdateNetworkInstance flow. sendSyncError() - " + ex.getMessage(), isDebugEnabled) - } - - } - - public void prepareDBRequestError (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError() of UpdateNetworkInstance ***** ", isDebugEnabled) - - // set DB Header Authorization - setBasicDBAuthHeader(execution, isDebugEnabled) - - String statusMessage = "" - WorkflowException wfe = null - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - wfe = execution.getVariable("WorkflowException") - statusMessage = wfe.getErrorMessage() - } - - String requestId = execution.getVariable(Prefix + "requestId") - String networkName = execution.getVariable("networkName") !=null ? execution.getVariable("networkName") : "" - String networkId = execution.getVariable("networkId") !=null ? execution.getVariable("networkId") : "" - String dbRequest = - """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> - <soapenv:Header/> - <soapenv:Body> - <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb"> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPMN</lastModifiedBy> - <statusMessage>${statusMessage}</statusMessage> - <responseBody></responseBody> - <requestStatus>FAILED</requestStatus> - <vnfOutputs><network-id>${networkId}</network-id><network-name>${networkName}</network-names></vnfOutputs> - </ns:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope>""" - - execution.setVariable(Prefix + "createDBRequest", dbRequest) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - utils.logAudit(dbRequest) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstance flow. prepareDBRequestError() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareCompletion (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside prepareCompletion() of UpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - String requestId = execution.getVariable("mso-request-id") - String source = execution.getVariable(Prefix + "source") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>VID</source> - </request-info> - <aetgt:status-message>Network has been updated successfully.</aetgt:status-message> - <aetgt:mso-bpel-name>BPMN Network action: UPDATE</aetgt:mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - // normal path - execution.setVariable(Prefix + "Success", true) - execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstance flow. prepareCompletion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - - - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void postProcessResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse() of UpdateNetworkInstance ***** ", isDebugEnabled) - - try { - - if (execution.getVariable("CMSO_ResponseCode") == "200") { - execution.setVariable(Prefix + "Success", true) - utils.log("DEBUG", " ***** UpdateNetworkInstance Success ***** ", isDebugEnabled) - // Place holder for additional code. - - } else { - execution.setVariable(Prefix + "Success", false) - utils.log("DEBUG", " ***** UpdateNetworkInstance Failed in CompletionMsoProces flow!. ***** ", isDebugEnabled) - - } - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstance flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - // ******************************* - // Build Error Section - // ******************************* - - public void processRollbackData (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside processRollbackData() of UpdateNetworkInstance ***** ", isDebugEnabled) - - try { - //execution.getVariable("orchestrationStatus") - //execution.getVariable("networkId") - //execution.getVariable("networkName") - //networkOutputParams - //rollbackData - //rolledBack - - } catch (Exception ex) { - utils.log("DEBUG", " Bpmn error encountered in UpdateNetworkInstance flow. callDBCatalog() - " + ex.getMessage(), isDebugEnabled) - } - - } - - // Prepare for FalloutHandler - public void buildErrorResponse (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", "DB updateInfraRequest ResponseCode: " + execution.getVariable(Prefix + "dbReturnCode"), isDebugEnabled) - utils.log("DEBUG", "DB updateInfraRequest Response: " + execution.getVariable(Prefix + "createDBResponse"), isDebugEnabled) - - utils.log("DEBUG", " ***** Prepare for FalloutHandler. FAILURE - prepare request for sub-process FalloutHandler. *****", isDebugEnabled) - - String falloutHandlerRequest = "" - String requestId = execution.getVariable("mso-request-id") - - try { - - WorkflowException wfe = execution.getVariable("WorkflowException") - String errorCode = String.valueOf(wfe.getErrorCode()) - String errorMessage = wfe.getErrorMessage() - falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>VID</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - utils.logAudit(falloutHandlerRequest) - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } catch (Exception ex) { - String errorException = " Bpmn error encountered in UpdateNetworkInstance flow. FalloutHandlerRequest, buildErrorResponse() - " - utils.log("DEBUG", "Exception error in UpdateNetworkInstance flow, buildErrorResponse(): " + ex.getMessage(), isDebugEnabled) - falloutHandlerRequest = - """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1" - xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>VID</source> - </request-info> - <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException> - </aetgt:FalloutHandlerRequest>""" - - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } - - } - - public void processJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - try{ - utils.log("DEBUG", "Caught a Java Exception in " + Prefix, isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable("UnexpectedError", "Caught a Java Lang Exception - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Caught a Java Lang Exception") - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable("UnexpectedError", "Exception in processJavaException method - " + Prefix) // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildWorkflowException(execution, 500, "Exception in processJavaException method" + Prefix) - } - utils.log("DEBUG", "Completed processJavaException Method in " + Prefix, isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy deleted file mode 100644 index 2acc550318..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy +++ /dev/null @@ -1,331 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import java.io.Serializable; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.core.RollbackData - - -public class UpdateVfModule extends AbstractServiceTaskProcessor { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'UPDVfMod_') - execution.setVariable('UPDVfMod_Request', null) - execution.setVariable('UPDVfMod_requestInfo', null) - execution.setVariable('UPDVfMod_requestId', null) - execution.setVariable('UPDVfMod_source', null) - execution.setVariable('UPDVfMod_vnfInputs', null) - execution.setVariable('UPDVfMod_vnfId', null) - execution.setVariable('UPDVfMod_vfModuleId', null) - execution.setVariable('UPDVfMod_tenantId', null) - execution.setVariable('UPDVfMod_volumeGroupId', null) - execution.setVariable('UPDVfMod_vnfParams', null) - execution.setVariable('UPDVfMod_updateInfraRequest', null) - execution.setVariable('UpdateVfModuleSuccessIndicator', false) - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - initProcessVariables(execution) - String request = validateRequest(execution) - - utils.logAudit("UpdateVfModule request: " + request) - def requestInfo = getRequiredNodeXml(execution, request, 'request-info') - execution.setVariable('UPDVfMod_requestInfo', requestInfo) - execution.setVariable('UPDVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) - execution.setVariable('UPDVfMod_source', getNodeTextForce(requestInfo, 'source')) - - def vnfInputs = getRequiredNodeXml(execution, request, 'vnf-inputs') - execution.setVariable('UPDVfMod_vnfInputs', vnfInputs) - execution.setVariable('UPDVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id')) - execution.setVariable('UPDVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id')) - execution.setVariable('UPDVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id')) - execution.setVariable('UPDVfMod_volumeGroupId', getNodeTextForce(vnfInputs, 'volume-group-id')) - - def vnfParams = utils.getNodeXml(request, 'vnf-params') - execution.setVariable('UPDVfMod_vnfParams', vnfParams) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) - } - } - - /** - * Prepare and send the synchronous response for this flow. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendSynchResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = execution.getVariable('UPDVfMod_requestInfo') - def requestId = execution.getVariable('UPDVfMod_requestId') - def source = execution.getVariable('UPDVfMod_source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - def vnfInputs = execution.getVariable('UPDVfMod_vnfInputs') - - String synchResponse = """ - <vnf-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-info> - <request-id>${requestId}</request-id> - <action>UPDATE_VF_MODULE</action> - <request-status>IN_PROGRESS</request-status> - <progress>${progress}</progress> - <start-time>${startTime}</start-time> - <source>${source}</source> - </request-info> - ${vnfInputs} - </vnf-request> - """ - - synchResponse = utils.formatXml(synchResponse) - sendWorkflowResponse(execution, 200, synchResponse) - - utils.logAudit("UpdateVfModule Synch Response: " + synchResponse) - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendSynchResponse(): ' + e.getMessage()) - } - } - - /** - * Prepare the Request for invoking the DoUpdateVfModule subflow. - * - * NOTE: Currently, the method just logs passing through as the - * incoming Request to this main flow is used as the Request to - * the DoUpdateVfModule subflow. No preparation processing is - * necessary. - * - * @param execution The flow's execution instance. - */ - public void prepDoUpdateVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) - } - } - - /** - * Prepare the Request for updating the DB for this Infra Request. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateInfraRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateInfraRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('UPDVfMod_requestId') - def vnfId = execution.getVariable('UPDVfMod_vnfId') - def vfModuleId = execution.getVariable('UPDVfMod_vfModuleId') - def tenantId = execution.getVariable('UPDVfMod_tenantId') - def volumeGroupId = execution.getVariable('UPDVfMod_volumeGroupId') - - String updateInfraRequest = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:req="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <req:updateInfraRequest> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPEL</lastModifiedBy> - <requestStatus>COMPLETE</requestStatus> - <progress>100</progress> - <vnfOutputs> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <tenant-id>${tenantId}</tenant-id> - <volume-group-id>${volumeGroupId}</volume-group-id> - </vnfOutputs> - </req:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope> - """ - - updateInfraRequest = utils.formatXml(updateInfraRequest) - execution.setVariable('UPDVfMod_updateInfraRequest', updateInfraRequest) - logDebug('Request for Update Infra Request:\n' + updateInfraRequest, isDebugLogEnabled) - - utils.logAudit("UpdateVfModule Infra Request: " + updateInfraRequest) - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateInfraRequest(): ' + e.getMessage()) - } - } - - /** - * Builds a "CompletionHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void completionHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.completionHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = getVariable(execution, 'UPDVfMod_requestInfo') - - String content = """ - <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1"> - ${requestInfo} - <sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name> - </sdncadapterworkflow:MsoCompletionRequest> - """ - - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - utils.logAudit("UpdateVfModule CompletionHandler Request: " + content) - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') - } - } - - /** - * Builds a "FalloutHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void falloutHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def prefix = execution.getVariable('prefix') - def request = getVariable(execution, prefix+'Request') - def requestInformation = utils.getNodeXml(request, 'request-information', false) - - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def errorResponseCode = workflowException.getErrorCode() - def errorResponseMsg = workflowException.getErrorMessage() - def encErrorResponseMsg = "" - if (errorResponseMsg != null) { - encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") - } - - String content = """ - <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1" - xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1" - xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1"> - ${requestInformation} - <sdncadapterworkflow:WorkflowException> - <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage> - <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode> - </sdncadapterworkflow:WorkflowException> - </sdncadapterworkflow:FalloutHandlerRequest> - """ - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - utils.logAudit("UpdateVfModule fallOutHandler Request: " + content) - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') - } - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy deleted file mode 100644 index 60e8ca4b88..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfra.groovy +++ /dev/null @@ -1,510 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.json.JsonOutput -import groovy.json.JsonSlurper -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import java.io.Serializable; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException - - -public class UpdateVfModuleInfra extends AbstractServiceTaskProcessor { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'UPDVfModI_') - execution.setVariable('UPDVfModI_Request', null) - execution.setVariable('UPDVfModI_requestInfo', null) - execution.setVariable('UPDVfModI_requestId', null) - execution.setVariable('UPDVfModI_source', null) - execution.setVariable('UPDVfModI_vnfInputs', null) - execution.setVariable('UPDVfModI_vnfId', null) - execution.setVariable('UPDVfModI_vfModuleId', null) - execution.setVariable('UPDVfModI_tenantId', null) - execution.setVariable('UPDVfModI_volumeGroupId', null) - execution.setVariable('UPDVfModI_vnfParams', null) - execution.setVariable('UPDVfModI_updateInfraRequest', null) - execution.setVariable('UpdateVfModuleSuccessIndicator', false) - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - initProcessVariables(execution) - - def prefix = "UPDVfModI_" - - def incomingRequest = execution.getVariable('bpmnRequest') - - utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) - try { - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - Map reqMap = jsonSlurper.parseText(incomingRequest) - utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - def vnfId = execution.getVariable('vnfId') - - execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId) - execution.setVariable(prefix+'vnfId', vnfId) - execution.setVariable("isVidRequest", "true") - - def vnfName = '' - def asdcServiceModelVersion = '' - def serviceModelInfo = null - def vnfModelInfo = null - - def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList - - if (relatedInstanceList != null) { - relatedInstanceList.each { - if (it.relatedInstance.modelInfo?.modelType == 'service') { - asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion - serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) - - } - if (it.relatedInstance.modelInfo.modelType == 'vnf') { - vnfName = it.relatedInstance.instanceName ?: '' - vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo) - } - } - } - - execution.setVariable(prefix + 'vnfName', vnfName) - execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion) - execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo) - execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo) - - def vnfType = execution.getVariable('vnfType') - execution.setVariable(prefix + 'vnfType', vnfType) - def vfModuleId = execution.getVariable('vfModuleId') - execution.setVariable(prefix + 'vfModuleId', vfModuleId) - def volumeGroupId = execution.getVariable('volumeGroupId') - execution.setVariable(prefix + 'volumeGroupId', volumeGroupId) - def userParams = reqMap.requestDetails?.requestParameters?.userParams - - Map<String, String> userParamsMap = [:] - if (userParams != null) { - userParams.each { userParam -> - userParamsMap.put(userParam.name, userParam.value.toString()) - } - } - - utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled) - - execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap) - - def isBaseVfModule = "false" - if (execution.getVariable('isBaseVfModule') == true) { - isBaseVfModule = "true" - } - - execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule) - - def requestId = execution.getVariable("mso-request-id") - execution.setVariable(prefix + 'requestId', requestId) - - def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo) - execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo) - - def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback - - - def backoutOnFailure = "" - if(suppressRollback != null){ - if ( suppressRollback == true) { - backoutOnFailure = "false" - } else if ( suppressRollback == false) { - backoutOnFailure = "true" - } - } - - execution.setVariable('disableRollback', suppressRollback) - - def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null - execution.setVariable(prefix + 'vfModuleName', vfModuleName) - - def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: '' - execution.setVariable(prefix + 'serviceId', serviceId) - - def usePreload = reqMap.requestDetails?.requestParameters?.usePreload - execution.setVariable(prefix + 'usePreload', usePreload) - - def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration - def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId - execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId) - def tenantId = cloudConfiguration.tenantId - execution.setVariable(prefix + 'tenantId', tenantId) - - def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: '' - execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId) - - execution.setVariable(prefix + 'sdncVersion', '1702') - - execution.setVariable("UpdateVfModuleInfraSuccessIndicator", false) - - execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) - - - def source = reqMap.requestDetails?.requestInfo?.source - execution.setVariable(prefix + "source", source) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable(prefix + "requestInfo", requestInfo) - - //backoutOnFailure - - logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - - } - catch(groovy.json.JsonException je) { - utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") - - } - catch(Exception e) { - String restFaultMessage = e.getMessage() - utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) - } - } - - /** - * Prepare and send the sychronous response for this flow. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendSynchResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - - try { - def requestInfo = execution.getVariable('UPDVfModI_requestInfo') - def requestId = execution.getVariable('UPDVfModI_requestId') - def source = execution.getVariable('UPDVfModI_source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - - // RESTResponse (for API Handler (APIH) Reply Task) - def vfModuleId = execution.getVariable("vfModuleId") - String synchResponse = """{"requestReferences":{"instanceId":"${vfModuleId}","requestId":"${requestId}"}}""".trim() - - sendWorkflowResponse(execution, 200, synchResponse) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) - } - } - - /** - * Prepare the Request for invoking the DoUpdateVfModule subflow. - * - * NOTE: Currently, the method just logs passing through as the - * incoming Request to this main flow is used as the Request to - * the DoUpdateVfModule subflow. No preparation processing is - * necessary. - * - * @param execution The flow's execution instance. - */ - public void prepDoUpdateVfModule(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage()) - } - } - - /** - * Prepare the Request for updating the DB for this Infra Request. - * - * @param execution The flow's execution instance. - */ - public void prepUpdateInfraRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepUpdateInfraRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('UPDVfModI_requestId') - def vnfId = execution.getVariable('UPDVfModI_vnfId') - def vfModuleId = execution.getVariable('UPDVfModI_vfModuleId') - def tenantId = execution.getVariable('UPDVfModI_tenantId') - def volumeGroupId = execution.getVariable('UPDVfModI_volumeGroupId') - - String updateInfraRequest = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:req="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <req:updateInfraRequest> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPEL</lastModifiedBy> - <requestStatus>COMPLETE</requestStatus> - <progress>100</progress> - <vnfOutputs> - <vnf-id>${vnfId}</vnf-id> - <vf-module-id>${vfModuleId}</vf-module-id> - <tenant-id>${tenantId}</tenant-id> - <volume-group-id>${volumeGroupId}</volume-group-id> - </vnfOutputs> - </req:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope> - """ - - updateInfraRequest = utils.formatXml(updateInfraRequest) - execution.setVariable('UPDVfModI_updateInfraRequest', updateInfraRequest) - logDebug('Request for Update Infra Request:\n' + updateInfraRequest, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateInfraRequest(): ' + e.getMessage()) - } - } - - /** - * Builds a "CompletionHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void completionHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.completionHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = getVariable(execution, 'UPDVfModI_requestInfo') - - String content = """ - <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1"> - ${requestInfo} - <sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name> - </sdncadapterworkflow:MsoCompletionRequest> - """ - - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') - } - } - - /** - * Builds a "FalloutHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void falloutHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def prefix = execution.getVariable('prefix') - def request = getVariable(execution, prefix+'Request') - def requestInformation = execution.getVariable(prefix + "requestInfo") - - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def errorResponseCode = workflowException.getErrorCode() - def errorResponseMsg = workflowException.getErrorMessage() - def encErrorResponseMsg = "" - if (errorResponseMsg != null) { - encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") - } - - String content = """ - <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1" - xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1" - xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1"> - ${requestInformation} - <sdncadapterworkflow:WorkflowException> - <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage> - <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode> - </sdncadapterworkflow:WorkflowException> - </sdncadapterworkflow:FalloutHandlerRequest> - """ - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') - } - } - - /** - * Validates the request, request id and service instance id. If a problem is found, - * a WorkflowException is generated and an MSOWorkflowException event is thrown. This - * method also sets up the log context for the workflow. - * @param execution the execution - * @return the validated request - */ - public String validateInfraRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.validateInfraRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String processKey = getProcessKey(execution); - def prefix = execution.getVariable("prefix") - - if (prefix == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null") - } - - try { - def request = execution.getVariable(prefix + 'Request') - - if (request == null) { - request = execution.getVariable(processKey + 'Request') - - if (request == null) { - request = execution.getVariable('bpmnRequest') - } - - setVariable(execution, processKey + 'Request', null); - setVariable(execution, 'bpmnRequest', null); - setVariable(execution, prefix + 'Request', request); - } - - if (request == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null") - } - - /* - - def requestId = execution.getVariable("mso-request-id") - - if (requestId == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") - } - - setVariable(execution, prefix + 'requestId', requestId) - - def serviceInstanceId = execution.getVariable("mso-service-instance-id") - - if (serviceInstanceId == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") - } - - utils.logContext(requestId, serviceInstanceId) - */ - logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) - return request - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message") - } - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy deleted file mode 100644 index 18f36b879b..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleInfraV2.groovy +++ /dev/null @@ -1,470 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
-import groovy.util.Node
-import groovy.util.XmlParser;
-import groovy.xml.QName
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd
-import org.camunda.bpm.engine.delegate.DelegateExecution
-
-import java.io.Serializable;
-import java.util.List
-
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.springframework.beans.factory.annotation.Autowired
-
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.VidUtils
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.client.aai.AAIValidatorImpl
-import org.openecomp.mso.client.aai.AAIUpdatorImpl
-import org.openecomp.mso.client.appc.ApplicationControllerClient
-import org.openecomp.mso.client.sdno.SDNOValidatorImpl
-
-
-
-public class UpdateVfModuleInfraV2 {
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- boolean preProcessRequestCheck = true;
- boolean sendSynchResponseCheck = true;
- boolean checkPserverFlagCheck = true;
- boolean vfFlagCheckSetCheck = true;
- boolean lockAppCCheck = true;
- boolean healthDiagnosticSDNOCheck = true;
- boolean healthCheckAppCCheck = true;
- boolean stopVfModuleControllerCheck = true;
- boolean healthCheckControllerCheck = true;
- boolean doUpdateVfModulePrepCheck = true;
- boolean completionHandlerPrepCheck = true;
- boolean startVfModuleControllerCheck = true;
- boolean vFFlagUnsetCheck = true;
- boolean unlockAppCCheck = true;
- boolean postUpgradeHealthCheckControllerCheck = true;
-
-
-
- public void initProcessVariables(DelegateExecution execution) {
- execution.setVariable('prefix', 'UPDVfModI_')
- execution.setVariable('UPDVfModI_Request', null)
- execution.setVariable('UPDVfModI_requestInfo', null)
- execution.setVariable('UPDVfModI_requestId', null)
- execution.setVariable('UPDVfModI_source', null)
- execution.setVariable('UPDVfModI_vnfInputs', null)
- execution.setVariable('UPDVfModI_vnfId', null)
- execution.setVariable('UPDVFModI_moduleUuid', null)
- execution.setVariable('UPDVfModI_vfModuleId', null)
- execution.setVariable('UPDVfModI_tenantId', null)
- execution.setVariable('UPDVfModI_volumeGroupId', null)
- execution.setVariable('UPDVfModI_vnfParams', null)
- execution.setVariable('UPDVfModI_updateInfraRequest', null)
- execution.setVariable('UpdateVfModuleSuccessIndicator', false)
- }
-
- /**
- * Check for missing elements in the received request.
- *
- * @param execution The flow's execution instance.
- */
- public void preProcessRequest(DelegateExecution execution) {
- System.out.print("*****************************PreProcessRequest**************************")
-
- def method = getClass().getSimpleName() + '.preProcessRequest(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- //logDebug('Entered ' + method, isDebugLogEnabled)
-
- initProcessVariables(execution)
-
- def prefix = "UPDVfModI_"
-
- def incomingRequest = execution.getVariable('bpmnRequest')
-
- //utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
- try {
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
- Map reqMap = jsonSlurper.parseText(incomingRequest)
- //utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
-
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def vnfId = execution.getVariable('vnfId')
- def moduleUuid = execution.getVariable('moduleUuid')
- execution.setVariable(prefix + 'moduleUuid',moduleUuid)
- execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId)
- execution.setVariable(prefix+'vnfId', vnfId)
- execution.setVariable("isVidRequest", "true")
-
- def vnfName = ''
- def asdcServiceModelVersion = ''
- def serviceModelInfo = null
- def vnfModelInfo = null
-
- def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
-
- if (relatedInstanceList != null) {
- relatedInstanceList.each {
- if (it.relatedInstance.modelInfo?.modelType == 'service') {
- asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
- serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
- }
- if (it.relatedInstance.modelInfo.modelType == 'vnf') {
- vnfName = it.relatedInstance.instanceName ?: ''
- vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
- }
- }
- }
-
- execution.setVariable(prefix + 'vnfName', vnfName)
- execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion)
- execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo)
- execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo)
-
- def vnfType = execution.getVariable('vnfType')
- execution.setVariable(prefix + 'vnfType', vnfType)
- def vfModuleId = execution.getVariable('vfModuleId')
- execution.setVariable(prefix + 'vfModuleId', vfModuleId)
- def volumeGroupId = execution.getVariable('volumeGroupId')
- execution.setVariable(prefix + 'volumeGroupId', volumeGroupId)
- def userParams = reqMap.requestDetails?.requestParameters?.userParams
-
- Map<String, String> userParamsMap = [:]
- if (userParams != null) {
- userParams.each { userParam ->
- userParamsMap.put(userParam.name, userParam.value.toString())
- }
- }
-
- //utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
-
- execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap)
-
- def isBaseVfModule = "false"
- if (execution.getVariable('isBaseVfModule') == true) {
- isBaseVfModule = "true"
- }
-
- execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule)
-
- def requestId = execution.getVariable("mso-request-id")
- execution.setVariable(prefix + 'requestId', requestId)
-
- def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
- execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo)
-
- def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback
-
-
- def backoutOnFailure = ""
- if(suppressRollback != null){
- if ( suppressRollback == true) {
- backoutOnFailure = "false"
- } else if ( suppressRollback == false) {
- backoutOnFailure = "true"
- }
- }
-
- execution.setVariable('disableRollback', suppressRollback)
-
- def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
- execution.setVariable(prefix + 'vfModuleName', vfModuleName)
-
- def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: ''
- execution.setVariable(prefix + 'serviceId', serviceId)
-
- def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
- execution.setVariable(prefix + 'usePreload', usePreload)
-
- def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
- def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId
- execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId)
- def tenantId = cloudConfiguration.tenantId
- execution.setVariable(prefix + 'tenantId', tenantId)
-
- def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
- execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId)
-
- execution.setVariable(prefix + 'sdncVersion', '1702')
-
- execution.setVariable("UpdateVfModuleInfraSuccessIndicator", false)
-
- execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
-
-
- def source = reqMap.requestDetails?.requestInfo?.source
- execution.setVariable(prefix + "source", source)
-
- //For Completion Handler & Fallout Handler
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable(prefix + "requestInfo", requestInfo)
-
- //backoutOnFailure
-
- //logDebug('RequestInfo: ' + execution.getVariable(prefix + "requestInfo"), isDebugLogEnabled)
-
- //logDebug('Exited ' + method, isDebugLogEnabled)
-
- }
- catch(groovy.json.JsonException je) {
- //utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
- }
- catch(Exception e) {
- String restFaultMessage = e.getMessage()
- //utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
- }
- }
-
- /**
- * Prepare and send the synchronous response for this flow.
- *
- * @param execution The flow's execution instance.
- */
- public void sendSynchResponse(DelegateExecution execution) {
- System.out.print("*****************************SendSynchResponse**************************")
-
- def method = getClass().getSimpleName() + '.sendSynchResponse(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- //logDebug('Entered ' + method, isDebugLogEnabled)
-
-
- try {
- def requestInfo = execution.getVariable('UPDVfModI_requestInfo')
- def requestId = execution.getVariable('UPDVfModI_requestId')
- def source = execution.getVariable('UPDVfModI_source')
-
- def progress = getNodeTextForce(requestInfo, 'progress')
- if (progress.isEmpty()) {
- progress = '0'
- }
- def startTime = getNodeTextForce(requestInfo, 'start-time')
- if (startTime.isEmpty()) {
- startTime = System.currentTimeMillis()
- }
- // RESTResponse (for API Handler (APIH) Reply Task)
- def vfModuleId = execution.getVariable("vfModuleId")
- String synchResponse = """{"requestReferences":{"instanceId":"${vfModuleId}","requestId":"${requestId}"}}""".trim()
- sendWorkflowResponse(execution, 200, synchResponse)
- //logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- //logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
- }
- }
-
- //check to see if the Pserver Flag is locked
- public void checkPserverFlag(DelegateExecution execution) {
-
- System.out.println("*****************************CheckingPserverFlag*************************")
- String vnfId = (String)execution.getVariable('vnfId')
- String uuid = (String)execution.getVariable('moduleUuid')
- AAIValidatorImpl aaiVI = new AAIValidatorImpl()
- boolean flag = aaiVI.isPhysicalServerLocked(vnfId, uuid)
- }
-
- //check to see if the VFFlag is locked
- public void vfFlagCheck(DelegateExecution execution) {
-
- System.out.print("*****************************VfFlagCheck*************************")
- String vnfId = (String)execution.getVariable('vnfId')
- String uuid = (String)execution.getVariable('moduleUuid')
- AAIValidatorImpl aaiVI = new AAIValidatorImpl()
- boolean flag = aaiVI.isVNFLocked(vnfId, uuid)
-
- }
- //lock the VF Flag
- public void vfFlagSet(DelegateExecution execution) {
-
- System.out.print("*****************************VfFlagSet*************************")
- String vnfId = (String)execution.getVariable('vnfId')
- String uuid = (String)execution.getVariable('moduleUuid')
- AAIValidatorImpl aaiVI = new AAIValidatorImpl()
- aaiVI.updateVnfToLocked(vnfId,uuid);
-
- }
-
- //Lock AppC
- public void lockAppC(DelegateExecution execution) {
-
- System.out.print("*****************************lockAppC*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("Lock",vfModuleId)
-
-
- }
- //run health check
- public void healthCheckAppC(DelegateExecution execution) {
-
- System.out.print("*****************************healthCheckAppC*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("HealthCheck",vfModuleId)
-
- }
- //SDNO health diagnostic
- public void healthDiagnosticSDNO(DelegateExecution execution) {
-
- System.out.print("*****************************healthDiagnosticSDNO is currently ignored*************************")
- //SDNOValidatorImpl.healthDiagnostic("","");
-
- }
- //stop VF module controller
- public void stopVfModuleController(DelegateExecution execution) {
-
- System.out.print("*****************************stopVfModuleController*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("Stop",vfModuleId)
-
-
- }
-
- public void doUpdateVfModulePrep(DelegateExecution execution) {
-
- System.out.print("*****************************doUpdateVfModulePrep*************************")
- def method = getClass().getSimpleName() + '.prepDoUpdateVfModule(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- //logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
-
- //logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- //logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepDoUpdateVfModule(): ' + e.getMessage())
-
- }
-
- }
-
- public void completionHandlerPrep(DelegateExecution execution,String resultVar) {
-
- System.out.print("*****************************completionHandlerPrep*************************")
- def method = getClass().getSimpleName() + '.completionHandlerPrep(' +
- 'execution=' + execution.getId() +
- ', resultVar=' + resultVar +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- //logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def requestInfo = getVariable(execution, 'UPDVfModI_requestInfo')
-
- String content = """
- <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1">
- ${requestInfo}
- <sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name>
- </sdncadapterworkflow:MsoCompletionRequest>
- """
-
- content = utils.formatXml(content)
- //logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
- execution.setVariable(resultVar, content)
-
- //logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- //logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error')
-
- }
-
- }
-
- public void healthCheckController(DelegateExecution execution) {
-
- System.out.print("*****************************healthCheckController*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("HealthCheck",vfModuleId)
-
- }
-
- public void startVfModuleController(DelegateExecution execution) {
-
- System.out.print("*****************************startVfModuleController*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("Start",vfModuleId)
-
- }
-
- public void vFFlagUnset(DelegateExecution execution) {
-
- System.out.print("*****************************vFFlagUnset*************************")
- String vnfId = (String)execution.getVariable('vnfId')
- String uuid = (String)execution.getVariable('moduleUuid')
- AAIValidatorImpl aaiVI = new AAIValidatorImpl()
- aaiVI.updateVnfToUnLocked(vnfId,uuid);
-
-
- }
-
- public void unlockAppC(DelegateExecution execution) {
-
- System.out.print("*****************************unlockAppC*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("Unlock",vfModuleId)
-
- }
-
- public void postUpgradeHealthCheckController(DelegateExecution execution) {
-
- System.out.print("*****************************postUpgradeHealthCheckController*************************")
- def vfModuleId = ""
- ApplicationControllerClient aCC = new ApplicationControllerClient();
- def status = aCC.runCommand("HealthCheck",vfModuleId)
-
- }
-
-}
-
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy deleted file mode 100644 index c68b04f3b1..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy +++ /dev/null @@ -1,443 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import java.util.concurrent.ExecutionException; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.VfModuleBase -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils; -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil - -class UpdateVfModuleVolume extends VfModuleBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - private void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'UPDVfModVol_') - execution.setVariable('UPDVfModVol_Request', null) - execution.setVariable('UPDVfModVol_requestInfo', null) - execution.setVariable('UPDVfModVol_requestId', null) - execution.setVariable('UPDVfModVol_source', null) - execution.setVariable('UPDVfModVol_volumeInputs', null) - execution.setVariable('UPDVfModVol_volumeGroupId', null) - execution.setVariable('UPDVfModVol_vnfType', null) - execution.setVariable('UPDVfModVol_serviceId', null) - execution.setVariable('UPDVfModVol_aicCloudRegion', null) - execution.setVariable('UPDVfModVol_tenantId', null) - execution.setVariable('UPDVfModVol_volumeParams', null) - execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', null) - execution.setVariable('UPDVfModVol_volumeGroupTenantId', null) - execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false) - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - @Override - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - initProcessVariables(execution) - String request = validateRequest(execution) - - def requestInfo = getRequiredNodeXml(execution, request, 'request-info') - execution.setVariable('UPDVfModVol_requestInfo', requestInfo) - execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id')) - execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source')) - - def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs') - execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs) - execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id')) - execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type')) - execution.setVariable('UPDVfModVol_serviceId', getRequiredNodeText(execution, volumeInputs, 'service-id')) - execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region')) - execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id')) - - def volumeParams = utils.getNodeXml(request, 'volume-params') - execution.setVariable('UPDVfModVol_volumeParams', volumeParams) - - logDebug('Exited ' + method, isDebugLogEnabled) - utils.logAudit("UpdateVfModuleVolume request: " + request) - } catch (BpmnError bpmnError) { - throw bpmnError - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage()) - } - } - - /** - * Prepare and send the synchronous response. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendSynchResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') - def requestId = execution.getVariable('UPDVfModVol_requestId') - def source = execution.getVariable('UPDVfModVol_source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') - - String synchResponse = """ - <volume-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-info> - <request-id>${requestId}</request-id> - <action>UPDATE_VF_MODULE_VOL</action> - <request-status>IN_PROGRESS</request-status> - <progress>${progress}</progress> - <start-time>${startTime}</start-time> - <source>${source}</source> - </request-info> - ${volumeInputs} - </volume-request> - """ - - synchResponse = utils.formatXml(synchResponse) - sendWorkflowResponse(execution, 200, synchResponse) - utils.logAudit("UpdateVfModuleVolume Synch Response: " + synchResponse) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendSynchResponse(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for querying AAI for Volume Group information using the - * Volume Group Id and Aic Cloud Region. - * - * @param execution The flow's execution instance. - */ - public void queryAAIForVolumeGroup(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.queryAAIForVolumeGroup(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') - def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') - def endPoint = execution.getVariable('URN_aai_endpoint') + - '/aai/v7/cloud-infrastructure/cloud-regions/cloud-region/att-aic/' + UriUtils.encode(aicCloudRegion, "UTF-8") + - '/volume-groups/volume-group/' + UriUtils.encode(volumeGroupId, "UTF-8") - - logDebug('Sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled) - utils.logAudit("UpdateVfModuleVolume sending GET for quering AAI endpoint: " + endPoint) - - AaiUtil aaiUtil = new AaiUtil(this) - APIResponse response = aaiUtil.executeAAIGetCall(execution, endPoint) - def int statusCode = response.getStatusCode() - def responseData = response.getResponseBodyAsString() - logDebug('Response code:' + statusCode, isDebugLogEnabled) - logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) - utils.logAudit("UpdateVfModuleVolume response data: " + responseData) - - def volumeGroup = responseData - def heatStackId = getNodeTextForce(volumeGroup, 'heat-stack-id') - execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId) - if ((statusCode == 200) || (statusCode == 204)) { - def volumeGroupTenantId = getTenantIdFromVolumeGroup(volumeGroup) - if (volumeGroupTenantId == null) { - throw new Exception('Could not find Tenant Id element in Volume Group with Volume Group Id \'' + volumeGroupId + '\'' - + '\', AIC Cloud Region \'' + aicCloudRegion + '\'') - } - execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId) - logDebug('Received Tenant Id \'' + volumeGroupTenantId + '\' from AAI for Volume Group with Volume Group Id \'' + volumeGroupId + '\'' - + '\', AIC Cloud Region \'' + aicCloudRegion + '\'', isDebugLogEnabled) - } else if (statusCode == 404) { - throw new Exception('Volume Group \'' + volumeGroupId + '\' not found at AAI') - } else { - throw new Exception('Bad status code ' + statusCode + ' received from AAI; Response data: ' + responseData) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVolumeGroup(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for invoking the VnfAdapterRest subflow to do - * a Volume Group update. - * - * @param execution The flow's execution instance. - */ - public void prepVnfAdapterRest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') - def tenantId = execution.getVariable('UPDVfModVol_tenantId') - def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') - def volumeGroupHeatStackId = execution.getVariable('UPDVfModVol_volumeGroupHeatStackId') - def vnfType = execution.getVariable('UPDVfModVol_vnfType') - - def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams') - def volumeGroupParams = transformParamsToEntries(volumeParamsXml) - - def requestId = execution.getVariable('UPDVfModVol_requestId') - def serviceId = execution.getVariable('UPDVfModVol_serviceId') - - def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() - def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) - def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") - if ('true'.equals(useQualifiedHostName)) { - notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl) - } - - String vnfAdapterRestRequest = """ - <updateVolumeGroupRequest> - <cloudSiteId>${aicCloudRegion}</cloudSiteId> - <tenantId>${tenantId}</tenantId> - <volumeGroupId>${volumeGroupId}</volumeGroupId> - <volumeGroupStackId>${volumeGroupHeatStackId}</volumeGroupStackId> - <vnfType>${vnfType}</vnfType> - <vnfVersion></vnfVersion> - <vfModuleType></vfModuleType> - <volumeGroupParams> - ${volumeGroupParams} - </volumeGroupParams> - <skipAAI>true</skipAAI> - <msoRequest> - <requestId>${requestId}</requestId> - <serviceInstanceId>${serviceId}</serviceInstanceId> - </msoRequest> - <messageId>${messageId}</messageId> - <notificationUrl>${notificationUrl}</notificationUrl> - </updateVolumeGroupRequest> - """ - vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest) - execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest) - logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled) - - utils.logAudit("UpdateVfModuleVolume Request for VNFAdapter Rest: " + vnfAdapterRestRequest) - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage()) - } - } - - /** - * Prepare a Request for updating the DB for this Infra request. - * - * @param execution The flow's execution instance. - */ - public void prepDbInfraDbRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepDbInfraDbRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestId = execution.getVariable('UPDVfMod_requestId') - - String updateInfraRequest = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" - xmlns:req="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <req:updateInfraRequest> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPEL</lastModifiedBy> - <requestStatus>COMPLETE</requestStatus> - <progress>100</progress> - </req:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope> - """ - - updateInfraRequest = utils.formatXml(updateInfraRequest) - execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest) - logDebug('Request for Update Infra Request:\n' + updateInfraRequest, isDebugLogEnabled) - - utils.logAudit("UpdateVfModuleVolume Request for Updating DB for Infra: " + updateInfraRequest) - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 1002, 'Error in prepDbInfraDbRequest(): ' + e.getMessage()) - } - } - - /** - * Build a "CompletionHandler" request. - * - * @param execution The flow's execution instance. - */ - public void prepCompletionHandlerRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepCompletionHandlerRequest(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') - - String content = """ - <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1"> - ${requestInfo} - <sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name> - </sdncadapterworkflow:MsoCompletionRequest> - """ - - content = utils.formatXml(content) - logDebug('Request for Completion Handler:\n' + content, isDebugLogEnabled) - utils.logAudit("UpdateVfModuleVolume Completion Handler request: " + content) - execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepCompletionHandlerRequest(): ' + e.getMessage()) - } - } - - /** - * Build a "FalloutHandler" request. - * - * @param execution The flow's execution instance. - */ - public void prepFalloutHandler(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepFalloutHandler(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') - - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def errorResponseCode = workflowException.getErrorCode() - def errorResponseMsg = workflowException.getErrorMessage() - def encErrorResponseMsg = "" - if (errorResponseMsg != null) { - encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") - } - - String content = """ - <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1" - xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1" - xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1"> - ${requestInfo} - <sdncadapterworkflow:WorkflowException> - <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage> - <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode> - </sdncadapterworkflow:WorkflowException> - </sdncadapterworkflow:FalloutHandlerRequest> - """ - content = utils.formatXml(content) - logDebug('Request for Fallout Handler:\n' + content, isDebugLogEnabled) - utils.logAudit("UpdateVfModuleVolume Fallout request: " + content) - execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 1002, 'Error in prepFalloutHandler(): ' + e.getMessage()) - } - } - - /** - * Create a WorkflowException for the error case where the Tenant Id from - * AAI did not match the Tenant Id in the incoming request. - * - * @param execution The flow's execution instance. - */ - public void handleTenantIdMismatch(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.handleTenantIdMismatch(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String processKey = getProcessKey(execution); - def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId') - def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion') - def tenantId = execution.getVariable('UPDVfModVol_tenantId') - def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId') - - def String errorMessage = 'TenantId \'' + tenantId + '\' in incoming request does not match Tenant Id \'' + volumeGroupTenantId + - '\' retrieved from AAI for Volume Group Id \'' + volumeGroupId + '\', AIC Cloud Region \'' + aicCloudRegion + '\'' - - logError('Error in UpdateVfModuleVol: ' + errorMessage) - - WorkflowException exception = new WorkflowException(processKey, 5000, errorMessage); - execution.setVariable("WorkflowException", exception); - - logDebug('Exited ' + method, isDebugLogEnabled) - utils.logAudit("UpdateVfModuleVolume workflowException in Tenant Mismatch: " + errorMessage) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy deleted file mode 100644 index 913046b247..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolumeInfraV1.groovy +++ /dev/null @@ -1,563 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-import groovy.json.JsonSlurper
-
-import java.util.concurrent.ExecutionException;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.apache.commons.lang3.*
-import org.springframework.web.util.UriUtils
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
-import org.openecomp.mso.bpmn.common.scripts.VfModuleBase;
-import org.openecomp.mso.bpmn.common.scripts.VidUtils;
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-
-class UpdateVfModuleVolumeInfraV1 extends VfModuleBase {
-
- /**
- * Initialize the flow's variables.
- *
- * @param execution The flow's execution instance.
- */
- private void initProcessVariables(DelegateExecution execution) {
- execution.setVariable('prefix', 'UPDVfModVol_')
- execution.setVariable('UPDVfModVol_Request', null)
- execution.setVariable('UPDVfModVol_requestInfo', null)
- execution.setVariable('UPDVfModVol_requestId', null)
- execution.setVariable('UPDVfModVol_source', null)
- execution.setVariable('UPDVfModVol_volumeInputs', null)
- execution.setVariable('UPDVfModVol_volumeGroupId', null)
- execution.setVariable('UPDVfModVol_vnfType', null)
- execution.setVariable('UPDVfModVol_serviceId', null)
- execution.setVariable('UPDVfModVol_aicCloudRegion', null)
- execution.setVariable('UPDVfModVol_tenantId', null)
- execution.setVariable('UPDVfModVol_volumeParams', null)
- execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', null)
- execution.setVariable('UPDVfModVol_volumeGroupTenantId', null)
- execution.setVariable('UpdateVfModuleVolumeSuccessIndicator', false)
- }
-
-
- /**
- * Perform initial processing, such as request validation, initialization of variables, etc.
- * * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
- preProcessRequest(execution, isDebugEnabled)
- }
-
- public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
-
- initProcessVariables(execution)
- String jsonRequest = validateRequest(execution)
-
- def request = ""
-
- try {
- def jsonSlurper = new JsonSlurper()
- Map reqMap = jsonSlurper.parseText(jsonRequest)
-
- def serviceInstanceId = execution.getVariable('serviceInstanceId')
- def volumeGroupId = execution.getVariable('volumeGroupId')
- //def vnfId = execution.getVariable('vnfId')
-
- def vidUtils = new VidUtils(this)
- request = vidUtils.createXmlVolumeRequest(reqMap, 'UPDATE_VF_MODULE_VOL', serviceInstanceId, volumeGroupId)
-
- execution.setVariable('UPDVfModVol_Request', request)
- execution.setVariable("UPDVfModVol_isVidRequest", true)
-
- //need to get persona-model-id aka model-invariantId to use later to validate vf-module relation in AAI
-
- def modelInvariantId = reqMap.requestDetails.modelInfo.modelInvariantUuid ?: ''
- execution.setVariable('UPDVfModVol_modelInvariantId', modelInvariantId)
-
- utils.log("DEBUG", "modelInvariantId from request: " + modelInvariantId, isDebugLogEnabled)
- utils.log("DEBUG", "XML request:\n" + request, isDebugLogEnabled)
- }
- catch(groovy.json.JsonException je) {
- utils.log("DEBUG", " Request is in XML format.", isDebugLogEnabled)
- // assume request is in XML format - proceed as usual to process XML request
- }
-
- def requestId = execution.getVariable('mso-request-id')
-
- def requestInfo = getRequiredNodeXml(execution, request, 'request-info')
- execution.setVariable('UPDVfModVol_requestInfo', requestInfo)
- execution.setVariable('UPDVfModVol_requestId', requestId)
- //execution.setVariable('UPDVfModVol_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
- execution.setVariable('UPDVfModVol_source', getNodeTextForce(requestInfo, 'source'))
-
- def volumeInputs = getRequiredNodeXml(execution, request, 'volume-inputs')
- execution.setVariable('UPDVfModVol_volumeInputs', volumeInputs)
- execution.setVariable('UPDVfModVol_volumeGroupId', getRequiredNodeText(execution, volumeInputs, 'volume-group-id'))
- execution.setVariable('UPDVfModVol_vnfType', getRequiredNodeText(execution, volumeInputs, 'vnf-type'))
- execution.setVariable('UPDVfModVol_vnfVersion', getRequiredNodeText(execution, volumeInputs, 'asdc-service-model-version'))
- execution.setVariable('UPDVfModVol_serviceId', utils.getNodeText1(volumeInputs, 'service-id'))
- execution.setVariable('UPDVfModVol_aicCloudRegion', getRequiredNodeText(execution, volumeInputs, 'aic-cloud-region'))
- execution.setVariable('UPDVfModVol_tenantId', getRequiredNodeText(execution, volumeInputs, 'tenant-id'))
- //execution.setVariable('UPDVfModVol_modelCustomizationId', getRequiredNodeText(execution, volumeInputs, 'model-customization-id'))
-
- setBasicDBAuthHeader(execution, isDebugLogEnabled)
-
- def volumeParams = utils.getNodeXml(request, 'volume-params')
- execution.setVariable('UPDVfModVol_volumeParams', volumeParams)
- }
-
- /**
- * Prepare and send the synchronous response.
- *
- * @param execution The flow's execution instance.
- */
- public void sendSynchResponse(DelegateExecution execution, isDebugLogEnabled) {
-
- def requestInfo = execution.getVariable('UPDVfModVol_requestInfo')
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- def source = execution.getVariable('UPDVfModVol_source')
- def progress = getNodeTextForce(requestInfo, 'progress')
- if (progress.isEmpty()) {
- progress = '0'
- }
- def startTime = getNodeTextForce(requestInfo, 'start-time')
- if (startTime.isEmpty()) {
- startTime = System.currentTimeMillis()
- }
- def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs')
-
- String xmlSyncResponse = """
- <volume-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-info>
- <request-id>${requestId}</request-id>
- <action>UPDATE_VF_MODULE_VOL</action>
- <request-status>IN_PROGRESS</request-status>
- <progress>${progress}</progress>
- <start-time>${startTime}</start-time>
- <source>${source}</source>
- </request-info>
- ${volumeInputs}
- </volume-request>
- """
-
- def syncResponse = ''
- def isVidRequest = execution.getVariable('UPDVfModVol_isVidRequest')
-
- if(isVidRequest) {
- def volumeGroupId = execution.getVariable('volumeGroupId')
- syncResponse = """{"requestReferences":{"instanceId":"${volumeGroupId}","requestId":"${requestId}"}}""".trim()
- }
- else {
- syncResponse = utils.formatXml(xmlSyncResponse)
- }
-
- logDebug('Sync response: ' + syncResponse, isDebugLogEnabled)
- execution.setVariable('UPDVfModVol_syncResponseSent', true)
- sendWorkflowResponse(execution, 200, syncResponse)
- }
-
- /**
- * Prepare a Request for querying AAI for Volume Group information using the
- * Volume Group Id and Aic Cloud Region.
- * @param execution The flow's execution instance.
- */
- public void queryAAIForVolumeGroup(DelegateExecution execution, isDebugLogEnabled) {
-
- def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
- def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
- String queryAAIVolumeGroupRequest = aaiEndpoint + '/' + URLEncoder.encode(aicCloudRegion, "UTF-8") + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8")
-
- utils.logAudit('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest)
- logDebug('Query AAI volume group by ID: ' + queryAAIVolumeGroupRequest, isDebugLogEnabled)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeGroupRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query volume group by id return code: " + returnCode)
- utils.logAudit("AAI query volume group by id response: " + aaiResponseAsString)
-
- logDebug("AAI Volume Group return code: " + returnCode, isDebugLogEnabled)
- logDebug("AAI Volume Group response: " + aaiResponseAsString, isDebugLogEnabled)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if ((returnCode == '200') || (returnCode == '204')) {
-
- execution.setVariable('UPDVfModVol_aaiVolumeGroupResponse', aaiResponseAsString)
- //def heatStackId = getNodeTextForce(aaiResponseAsString, 'heat-stack-id')
- //execution.setVariable('UPDVfModVol_volumeGroupHeatStackId', heatStackId)
-
- def volumeGroupTenantId = getTenantIdFromVolumeGroup(aaiResponseAsString)
- if (volumeGroupTenantId == null) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Could not find Tenant Id element in Volume Group with Volume Group Id " + volumeGroupId
- + ", AIC Cloud Region " + aicCloudRegion)
- }
- execution.setVariable('UPDVfModVol_volumeGroupTenantId', volumeGroupTenantId)
- logDebug("Received Tenant Id " + volumeGroupTenantId + " from AAI for Volume Group with Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion, isDebugLogEnabled)
-
- def relatedVfModuleLink = getRelatedVfModuleRelatedLink(aaiResponseAsString)
- logDebug("Related VF Module link: " + relatedVfModuleLink, isDebugLogEnabled)
- execution.setVariable('UPDVfModVol_relatedVfModuleLink', relatedVfModuleLink)
-
- }
- else if (returnCode == '404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume Group " + volumeGroupId + " not found at AAI")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
-
- /**
- * Query AAI service instance
- * @param execution
- * @param isDebugEnabled
- */
- public void queryAAIForGenericVnf(DelegateExecution execution, isDebugEnabled) {
-
- def vnfId = execution.getVariable('vnfId')
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution)
- def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8")
-
- utils.logAudit("AAI query generic vnf request: " + queryAAIRequest)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query generic vnf return code: " + returnCode)
- utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if (returnCode=='200') {
- utils.log("DEBUG", 'Generic vnf ' + vnfId + ' found in AAI.', isDebugEnabled)
- execution.setVariable('UPDVfModVol_AAIQueryGenericVfnResponse', aaiResponseAsString)
- } else {
- if (returnCode=='404') {
- def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.'
- utils.log("DEBUG", message, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
- } else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- }
-
- /**
- * Query AAI for VF Module using vf-module-id
- * @param execution
- * @param isDebugLogEnabled
- */
- public void queryAAIForVfModule(DelegateExecution execution, isDebugLogEnabled) {
-
- AaiUtil aaiUtil = new AaiUtil(this)
- String queryAAIVfModuleRequest = execution.getVariable('UPDVfModVol_relatedVfModuleLink')
- execution.setVariable('UPDVfModVol_personaModelId', '')
-
- utils.logAudit('Query AAI VF Module: ' + queryAAIVfModuleRequest)
- logDebug('Query AAI VF Module: ' + queryAAIVfModuleRequest, isDebugLogEnabled)
-
- def aaiUrl = execution.getVariable("URN_aai_endpoint")
- logDebug('A&AI URL: ' + aaiUrl, isDebugLogEnabled)
-
- def requestEndpoint = aaiUrl + queryAAIVfModuleRequest
- logDebug('A&AI request endpoint: ' + requestEndpoint, isDebugLogEnabled)
-
- APIResponse response = aaiUtil.executeAAIGetCall(execution, requestEndpoint)
-
- String returnCode = response.getStatusCode()
- String aaiResponseAsString = response.getResponseBodyAsString()
- aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
-
- utils.logAudit("AAI query vf-module: " + returnCode)
- utils.logAudit("AAI query vf-module response: " + aaiResponseAsString)
-
- logDebug("AAI query vf-module:: " + returnCode, isDebugLogEnabled)
- logDebug("AAI query vf-module response: " + aaiResponseAsString, isDebugLogEnabled)
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
-
- if ((returnCode == '200') || (returnCode == '204')) {
- def personaModelId = utils.getNodeText1(aaiResponseAsString, 'model-invariant-id')
- if(personaModelId == null) {
- //check old attribute name
- personaModelId = utils.getNodeText1(aaiResponseAsString, 'persona-model-id')
- }
- logDebug("vfModule personaModelId: " + personaModelId, isDebugLogEnabled)
- execution.setVariable('UPDVfModVol_personaModelId', personaModelId)
- }
- else if (returnCode == '404') {
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "VF Module not found at AAI")
- }
- else {
- WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- throw new BpmnError("MSOWorkflowException")
- }
- }
- /**
- *
- */
- public String getRelatedVfModuleRelatedLink(xml) {
- def list = new XmlSlurper().parseText(xml)
- def vfModuleRelationship = list.'**'.find { node -> node.'related-to'.text() == 'vf-module' }
- return vfModuleRelationship?.'related-link'?.text() ?: ''
- }
-
- /**
- * Prepare a Request for invoking the VnfAdapterRest subflow to do
- * a Volume Group update.
- *
- * @param execution The flow's execution instance.
- */
- public void prepVnfAdapterRest(DelegateExecution execution, isDebugLogEnabled) {
-
- def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
- def tenantId = execution.getVariable('UPDVfModVol_tenantId')
- def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
-
- def aaiVolumeGroupResponse = execution.getVariable('UPDVfModVol_aaiVolumeGroupResponse')
- def volumeGroupHeatStackId = getNodeTextForce(aaiVolumeGroupResponse, 'heat-stack-id')
- def volumeGroupName = getNodeTextForce(aaiVolumeGroupResponse, 'volume-group-name')
- def modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-model-customization-id')
- if(modelCustomizationId == null) {
- // Check old attribute name
- modelCustomizationId = getNodeTextForce(aaiVolumeGroupResponse, 'vf-module-persona-model-customization-id')
- }
-
- def vnfType = execution.getVariable('UPDVfModVol_vnfType')
- def vnfVersion = execution.getVariable('UPDVfModVol_vnfVersion')
-
- def aaiGenericVnfResponse = execution.getVariable('UPDVfModVol_AAIQueryGenericVfnResponse')
- def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id')
- def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name')
-
-
- def volumeParamsXml = execution.getVariable('UPDVfModVol_volumeParams')
- def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml)
-
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- def serviceId = execution.getVariable('UPDVfModVol_serviceId')
-
- def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
- def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
- def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
- if ('true'.equals(useQualifiedHostName)) {
- notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
- }
-
- String vnfAdapterRestRequest = """
- <updateVolumeGroupRequest>
- <cloudSiteId>${aicCloudRegion}</cloudSiteId>
- <tenantId>${tenantId}</tenantId>
- <vnfId>${vnfId}</vnfId>
- <vnfName>${vnfName}</vnfName>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- <volumeGroupName>${volumeGroupName}</volumeGroupName>
- <volumeGroupStackId>${volumeGroupHeatStackId}</volumeGroupStackId>
- <vnfType>${vnfType}</vnfType>
- <vnfVersion>${vnfVersion}</vnfVersion>
- <vfModuleType></vfModuleType>
- <modelCustomizationUuid>${modelCustomizationId}</modelCustomizationUuid>
- <volumeGroupParams>
- <entry>
- <key>vnf_id</key>
- <value>${vnfId}</value>
- </entry>
- <entry>
- <key>vnf_name</key>
- <value>${vnfName}</value>
- </entry>
- <entry>
- <key>vf_module_id</key>
- <value>${volumeGroupId}</value>
- </entry>
- <entry>
- <key>vf_module_name</key>
- <value>${volumeGroupName}</value>
- </entry>
- ${volumeGroupParams}
- </volumeGroupParams>
- <skipAAI>true</skipAAI>
- <msoRequest>
- <requestId>${requestId}</requestId>
- <serviceInstanceId>${serviceId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </updateVolumeGroupRequest>
- """
- vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
- execution.setVariable('UPDVfModVol_vnfAdapterRestRequest', vnfAdapterRestRequest)
- logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
- }
-
- /**
- * Prepare a Request for updating the DB for this Infra request.
- *
- * @param execution The flow's execution instance.
- */
- public void prepDbInfraDbRequest(DelegateExecution execution, isDebugLogEnabled) {
-
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- ExceptionUtil exceptionUtil = new ExceptionUtil();
-
- String updateInfraRequest = """
- <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:req="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateInfraRequest>
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <requestStatus>COMPLETE</requestStatus>
- <progress>100</progress>
- </req:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
-
- updateInfraRequest = utils.formatXml(updateInfraRequest)
- execution.setVariable('UPDVfModVol_updateInfraRequest', updateInfraRequest)
- logDebug('Request for Update Infra Request:\n' + updateInfraRequest, isDebugLogEnabled)
- }
-
- /**
- * Build a "CompletionHandler" request.
- * @param execution The flow's execution instance.
- */
- public void prepCompletionHandlerRequest(DelegateExecution execution, requestId, action, source, isDebugLogEnabled) {
-
- String content = """
- <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:mso-bpel-name>BPMN VF Module Volume action: UPDATE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>
- """
-
- content = utils.formatXml(content)
- logDebug('Request for Completion Handler:\n' + content, isDebugLogEnabled)
- execution.setVariable('UPDVfModVol_CompletionHandlerRequest', content)
- }
-
-
- /**
- * Build a "FalloutHandler" request.
- * @param execution The flow's execution instance.
- */
- public void prepFalloutHandler(DelegateExecution execution, isDebugLogEnabled) {
- def requestId = execution.getVariable('UPDVfModVol_requestId')
- def source = execution.getVariable('UPDVfModVol_source')
-
- String requestInfo = """
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>"""
-
- def WorkflowException workflowException = execution.getVariable("WorkflowException")
- def errorResponseCode = workflowException.getErrorCode()
- def errorResponseMsg = workflowException.getErrorMessage()
- def encErrorResponseMsg = ""
- if (errorResponseMsg != null) {
- encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">")
- }
-
- String content = """
- <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
- xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
- xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
- ${requestInfo}
- <sdncadapterworkflow:WorkflowException>
- <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage>
- <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode>
- </sdncadapterworkflow:WorkflowException>
- </sdncadapterworkflow:FalloutHandlerRequest>
- """
- content = utils.formatXml(content)
- logDebug('Request for Fallout Handler:\n' + content, isDebugLogEnabled)
- execution.setVariable('UPDVfModVol_FalloutHandlerRequest', content)
- }
-
- /**
- * Create a WorkflowException for the error case where the Tenant Id from
- * AAI did not match the Tenant Id in the incoming request.
- * @param execution The flow's execution instance.
- */
- public void handleTenantIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
- def volumeGroupId = execution.getVariable('UPDVfModVol_volumeGroupId')
- def aicCloudRegion = execution.getVariable('UPDVfModVol_aicCloudRegion')
- def tenantId = execution.getVariable('UPDVfModVol_tenantId')
- def volumeGroupTenantId = execution.getVariable('UPDVfModVol_volumeGroupTenantId')
-
- def String errorMessage = "TenantId " + tenantId + " in incoming request does not match Tenant Id " + volumeGroupTenantId +
- " retrieved from AAI for Volume Group Id " + volumeGroupId + ", AIC Cloud Region " + aicCloudRegion
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- logError('Error in UpdateVfModuleVol: ' + errorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
- /**
- * Create a WorkflowException for the error case where the Personal Model Id from
- * AAI did not match the model invariant ID in the incoming request.
- * @param execution The flow's execution instance.
- */
- public void handlePersonaModelIdMismatch(DelegateExecution execution, isDebugLogEnabled) {
-
- def modelInvariantId = execution.getVariable('UPDVfModVol_modelInvariantId')
- def personaModelId = execution.getVariable('UPDVfModVol_personaModelId')
-
- def String errorMessage = "Model Invariant ID " + modelInvariantId + " in incoming request does not match persona model ID " + personaModelId +
- " retrieved from AAI for Volume Group Id "
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- logError('Error in UpdateVfModuleVol: ' + errorMessage)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
- }
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy deleted file mode 100644 index 0b6ddb8ad2..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVnfInfra.groovy +++ /dev/null @@ -1,501 +0,0 @@ -/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts
-
-import groovy.json.JsonOutput
-import groovy.json.JsonSlurper
-import groovy.util.Node
-import groovy.util.XmlParser;
-import groovy.xml.QName
-
-import java.io.Serializable;
-import java.util.UUID;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.rest.RESTClient
-import org.openecomp.mso.rest.RESTConfig
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
-import org.openecomp.mso.bpmn.common.scripts.VidUtils;
-import org.openecomp.mso.bpmn.core.RollbackData
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.core.domain.ModelInfo
-import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition
-import org.openecomp.mso.bpmn.core.domain.VnfResource
-import org.openecomp.mso.client.aai.*
-
-import org.openecomp.mso.client.appc.ApplicationControllerOrchestrator
-import org.onap.appc.client.lcm.model.Action;
-import org.onap.appc.client.lcm.model.ActionIdentifiers;
-import org.onap.appc.client.lcm.model.LockInput
-import org.onap.appc.client.lcm.model.UnlockInput
-import org.onap.appc.client.lcm.model.HealthCheckInput
-import org.onap.appc.client.lcm.model.StartInput
-import org.onap.appc.client.lcm.model.StopInput
-import org.onap.appc.client.lcm.model.Flags
-import org.onap.appc.client.lcm.model.Status
-
-
-
-public class UpdateVnfInfra extends VnfCmBase {
-
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtils = new JsonUtils()
- def prefix = "UPDVnfI_"
-
- /**
- * Initialize the flow's variables.
- *
- * @param execution The flow's execution instance.
- */
- public void initProcessVariables(DelegateExecution execution) {
- execution.setVariable('prefix', 'UPDVnfI_')
- execution.setVariable('Request', null)
- execution.setVariable('source', null)
- execution.setVariable('vnfInputs', null)
- execution.setVariable('tenantId', null)
- execution.setVariable('vnfParams', null)
- execution.setVariable('controllerType', null)
- execution.setVariable('UpdateVnfSuccessIndicator', false)
- execution.setVariable('serviceType', null)
- execution.setVariable('nfRole', null)
- execution.setVariable('currentActivity', 'UPDVnfI')
- execution.setVariable('workStep', null)
- execution.setVariable('failedActivity', null)
- execution.setVariable('errorCode', "0")
- execution.setVariable('errorText', null)
- execution.setVariable('healthCheckIndex0', 0)
- execution.setVariable('healthCheckIndex1', 1)
- execution.setVariable("rollbackSetClosedLoopDisabledFlag", false)
- execution.setVariable("rollbackVnfStop", false)
- execution.setVariable("rollbackVnfLock", false)
- execution.setVariable("rollbackQuiesceTraffic", false)
- execution.setVariable("rollbackSetVnfInMaintenanceFlag", false)
- }
-
- /**
- * Check for missing elements in the received request.
- *
- * @param execution The flow's execution instance.
- */
- public void preProcessRequest(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessRequest(' +
- 'execution=' + execution.getId() +
- ')'
- initProcessVariables(execution)
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- initProcessVariables(execution)
-
- def incomingRequest = execution.getVariable('bpmnRequest')
-
- utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
- try {
- def jsonSlurper = new JsonSlurper()
- def jsonOutput = new JsonOutput()
- Map reqMap = jsonSlurper.parseText(incomingRequest)
- utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
-
- execution.setVariable("isVidRequest", "true")
- execution.setVariable('serviceType', 'Mobility')
- execution.setVariable('actionLock', Action.Lock)
- execution.setVariable('actionUnlock', Action.Unlock)
- execution.setVariable('actionHealthCheck', Action.HealthCheck)
- execution.setVariable('actionStart', Action.Start)
- execution.setVariable('actionStop', Action.Stop)
-
- def asdcServiceModelVersion = ''
- def serviceModelInfo = null
-
- def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
-
- if (relatedInstanceList != null) {
- relatedInstanceList.each {
- if (it.relatedInstance.modelInfo?.modelType == 'service') {
- utils.log("DEBUG", "PROCESSING SERVICE INFO", isDebugLogEnabled)
- asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
- serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
- utils.log("DEBUG", "ServiceModelInfo: " + serviceModelInfo, isDebugLogEnabled)
- def modelInvariant = jsonUtils.getJsonValue(serviceModelInfo, "modelInvariantUuid")
- utils.log("DEBUG", "modelInvariant: " + modelInvariant, isDebugLogEnabled)
- }
-
- }
- }
-
- execution.setVariable('asdcServiceModelVersion', asdcServiceModelVersion)
- execution.setVariable('serviceModelInfo', serviceModelInfo)
- def vnfModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
- execution.setVariable('vnfModelInfo', vnfModelInfo)
- def vnfModelInvariantUuid = jsonUtils.getJsonValue(vnfModelInfo, "modelInvariantUuid")
- execution.setVariable('vnfModelInvariantUuid', vnfModelInvariantUuid)
- logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled)
-
- def vnfType = execution.getVariable('vnfType')
- execution.setVariable('vnfType', vnfType)
-
- def controllerType = reqMap.requestDetails?.requestParameters?.controllerType
- execution.setVariable('controllerType', controllerType)
-
- utils.log("DEBUG", 'Controller Type: ' + controllerType, isDebugLogEnabled)
-
- def userParams = reqMap.requestDetails?.requestParameters?.userParams
-
- Map<String, String> userParamsMap = [:]
- if (userParams != null) {
- userParams.each { userParam ->
- userParamsMap.put(userParam.name, userParam.value.toString())
- }
- }
-
- utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
-
- execution.setVariable('vfModuleInputParams', userParamsMap)
-
- def requestId = execution.getVariable("mso-request-id")
- execution.setVariable('requestId', requestId)
- execution.setVariable('msoRequestId', requestId)
-
-
- def vnfName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
- execution.setVariable('vnfName', vnfName)
-
- def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null
- execution.setVariable('requestorId', requestorId)
-
- def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
- execution.setVariable('usePreload', usePreload)
-
- def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
- def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId
- execution.setVariable('lcpCloudRegionId', lcpCloudRegionId)
- def tenantId = cloudConfiguration.tenantId
- execution.setVariable('tenantId', tenantId)
-
- def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
- execution.setVariable('globalSubscriberId', globalSubscriberId)
-
- execution.setVariable('sdncVersion', '1702')
-
- execution.setVariable("UpdateVnfInfraSuccessIndicator", false)
-
- execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
-
- def source = reqMap.requestDetails?.requestInfo?.source
- execution.setVariable("source", source)
-
- //For Completion Handler & Fallout Handler
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable("requestInfo", requestInfo)
-
- logDebug('RequestInfo: ' + execution.getVariable("requestInfo"), isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- }
- catch(groovy.json.JsonException je) {
- utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format")
-
- }
- catch(Exception e) {
- String restFaultMessage = e.getMessage()
- utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage)
- }
- }
-
- /**
- * Prepare and send the sychronous response for this flow.
- *
- * @param execution The flow's execution instance.
- */
- public void sendSynchResponse(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.sendSynchResponse(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
-
- try {
- def requestInfo = execution.getVariable('requestInfo')
- def requestId = execution.getVariable('requestId')
- def source = execution.getVariable('source')
- def progress = getNodeTextForce(requestInfo, 'progress')
- if (progress.isEmpty()) {
- progress = '0'
- }
- def startTime = getNodeTextForce(requestInfo, 'start-time')
- if (startTime.isEmpty()) {
- startTime = System.currentTimeMillis()
- }
-
- // RESTResponse (for API Handler (APIH) Reply Task)
- def vnfId = execution.getVariable("vnfId")
- String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim()
-
- sendWorkflowResponse(execution, 200, synchResponse)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
- }
- }
-
-
-
- /**
- * Get VnfResource decomposition object for this VNF.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void getVnfResourceDecomposition(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
- String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid')
- logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled)
- List<VnfResource> vnfResources = serviceDecomposition.getServiceVnfs()
-
- for (i in 0..vnfResources.size()-1) {
- ModelInfo modelInfo = vnfResources[i].getModelInfo()
- String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid()
- logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled)
-
- if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) {
- VnfResource vnfResourceDecomposition = vnfResources[i]
- execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition)
- def nfRole = vnfResourceDecomposition.getNfRole()
- execution.setVariable('nfRole', nfRole)
- logDebug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString(), isDebugLogEnabled)
- break
- }
- else {
- //exception!
- }
-
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage())
- }
- }
-
- /**
- * Check if this VNF is already in maintenance in A&AI.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void checkIfVnfInMaintInAAI(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- execution.setVariable("workStep", "checkIfVnfInMaintInAAI")
- execution.setVariable("failedActivity", "AAI")
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
- AAIRestClientImpl client = new AAIRestClientImpl()
- AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
- aaiValidator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
- boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid)
- logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled)
- execution.setVariable('isVnfInMaintenance', isInMaint)
-
- if (isInMaint) {
- execution.setVariable("errorCode", "1003")
- execution.setVariable("errorText", "VNF is in maintenance in A&AI")
- }
-
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage())
- }
- }
-
-
- /**
- * Check if this VNF's pservers are locked in A&AI.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void checkIfPserversInMaintInAAI(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("workStep", "checkIfPserversInMaintInAAI")
- execution.setVariable("failedActivity", "AAI")
-
- try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
- AAIRestClientImpl client = new AAIRestClientImpl()
- AAIValidatorImpl aaiValidator = new AAIValidatorImpl()
- aaiValidator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
- boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid)
- logDebug("areLocked result: " + areLocked, isDebugLogEnabled)
- execution.setVariable('arePserversLocked', areLocked)
-
- if (areLocked) {
- execution.setVariable("errorCode", "1003")
- execution.setVariable("errorText", "pServers are locked in A&AI")
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage())
- }
- }
-
- /**
- * Set inMaint flag for this VNF to the specified value in A&AI.
- *
- *
- * @param execution The flow's execution instance.
- * @param inMaint The boolean value of the flag to set
- */
- public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) {
- def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- if (inMaint) {
- execution.setVariable("workStep", "setVnfInMaintFlagInAAI")
- }
- else {
- execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI")
- }
- execution.setVariable("failedActivity", "AAI")
-
- try {
- def transactionLoggingUuid = UUID.randomUUID().toString()
- AAIRestClientImpl client = new AAIRestClientImpl()
- AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl()
- aaiUpdator.setClient(client)
- def vnfId = execution.getVariable("vnfId")
- if (inMaint) {
- aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid)
- execution.setVariable("rollbackSetVnfInMaintenanceFlag", true)
- }
- else {
- aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid)
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- execution.setVariable("errorCode", "1002")
- execution.setVariable("errorText", e.getMessage())
- //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage())
- }
- }
-
-
-
- /**
- * Prepare DoUpdateVnfAndModules call.
- *
- *
- * @param execution The flow's execution instance.
- */
- public void prepDoUpdateVnfAndModules(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.prepDoUpdateVnfAndModules(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- execution.setVariable('errorCode', "0")
- logDebug('Entered ' + method, isDebugLogEnabled)
- execution.setVariable("workStep", "doUpdateVnfAndModules")
- execution.setVariable("failedActivity", "MSO Update VNF")
- logDebug('Exited ' + method, isDebugLogEnabled)
-
- }
-
-
- /**
- * Handle Abort disposition from RainyDayHandler
- *
- * @param execution The flow's execution instance.
- */
- public void abortProcessing(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.abortProcessing(' +
- 'execution=' + execution.getId() +
- ')'
- def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
- logDebug('Entered ' + method, isDebugLogEnabled)
-
- def errorText = execution.getVariable("errorText")
- def errorCode = execution.getVariable("errorCode")
-
- exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText)
- }
-
-
-
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfCmBase.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfCmBase.groovy deleted file mode 100644 index d8405aa243..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfCmBase.groovy +++ /dev/null @@ -1,812 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.json.JsonOutput -import groovy.json.JsonSlurper -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import org.json.JSONArray -import org.json.JSONObject - -import java.io.Serializable; -import java.util.List -import java.util.UUID; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.client.aai.* - -import org.openecomp.mso.client.appc.ApplicationControllerClient; -import org.openecomp.mso.client.appc.ApplicationControllerSupport; -import org.openecomp.mso.client.aai.entities.AAIResultWrapper -import org.openecomp.mso.client.aai.entities.Relationships -import org.openecomp.mso.client.aai.entities.uri.AAIResourceUri -import org.openecomp.mso.client.aai.entities.uri.AAIUri -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.LockInput -import org.onap.appc.client.lcm.model.UnlockInput -import org.onap.appc.client.lcm.model.HealthCheckInput -import org.onap.appc.client.lcm.model.StartInput -import org.onap.appc.client.lcm.model.StopInput -import org.onap.appc.client.lcm.model.Flags -import org.onap.appc.client.lcm.model.Status - - - -public abstract class VnfCmBase extends AbstractServiceTaskProcessor { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtils = new JsonUtils() - def prefix = "VnfIPU_" - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - - /** - * Prepare and send the sychronous response for this flow. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendSynchResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - - try { - def requestInfo = execution.getVariable('requestInfo') - def requestId = execution.getVariable('requestId') - def source = execution.getVariable('source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - - // RESTResponse (for API Handler (APIH) Reply Task) - def vnfId = execution.getVariable("vnfId") - String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() - - sendWorkflowResponse(execution, 200, synchResponse) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) - } - } - - - - /** - * Get VnfResource decomposition object for this VNF. - * - * - * @param execution The flow's execution instance. - */ - public void getVnfResourceDecomposition(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.getVnfResourceDecomposition(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - String vnfModelInvariantUuid = execution.getVariable('vnfModelInvariantUuid') - logDebug("vnfModelInvariantUuid: " + vnfModelInvariantUuid, isDebugLogEnabled) - List<VnfResource> vnfResources = serviceDecomposition.getServiceVnfs() - - for (i in 0..vnfResources.size()-1) { - ModelInfo modelInfo = vnfResources[i].getModelInfo() - String modelInvariantUuidFromDecomposition = modelInfo.getModelInvariantUuid() - logDebug("modelInvariantUuidFromDecomposition: " + modelInvariantUuidFromDecomposition, isDebugLogEnabled) - - if (vnfModelInvariantUuid.equals(modelInvariantUuidFromDecomposition)) { - VnfResource vnfResourceDecomposition = vnfResources[i] - execution.setVariable('vnfResourceDecomposition', vnfResourceDecomposition) - def nfRole = vnfResourceDecomposition.getNfRole() - execution.setVariable('nfRole', nfRole) - logDebug("vnfResourceDecomposition: " + vnfResourceDecomposition.toJsonString(), isDebugLogEnabled) - break - } - else { - //exception! - } - - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in getVnfResourceDecomposition(): ' + e.getMessage()) - } - } - - /** - * Check if this VNF is already in maintenance in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfVnfInMaintInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - execution.setVariable("workStep", "checkIfVnfInMaintInAAI") - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIValidatorImpl aaiValidator = new AAIValidatorImpl() - aaiValidator.setClient(client) - def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) - logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled) - execution.setVariable('isVnfInMaintenance', isInMaint) - - if (isInMaint) { - execution.setVariable("errorCode", "1003") - execution.setVariable("errorText", "VNF is in maintenance in A&AI") - } - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) - } - } - - /** - * Get VNF info from A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void queryAAIForVnf(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.queryAAIForVnf(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - logDebug("vnfId is: " + vnfId, isDebugLogEnabled) - def cloudRegionId = execution.getVariable("lcpCloudRegionId") - logDebug("cloudRegionId is: " + cloudRegionId, isDebugLogEnabled) - - AAIResourcesClient client = new AAIResourcesClient() - - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - // Check if this VNF exists - if (!client.exists(genericVnfUri)) { - logDebug("VNF with vnfId " + vnfId + " does not exist in A&AI", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 404, "VNF with vnfId " + vnfId + " does not exist in A&AI") - } - - AAIResultWrapper aaiRW = client.get(genericVnfUri) - - Map<String, Object> result = aaiRW.asMap() - - String vnfName = result.get("vnf-name") - logDebug("vnfName from A&AI is: " + vnfName, isDebugLogEnabled) - execution.setVariable("vnfName", vnfName) - String nfRole = result.get("nf-role") - logDebug("nfRole from A&AI is: " + nfRole, isDebugLogEnabled) - execution.setVariable("nfRole", nfRole) - String vnfHostIpAddress = result.get("ipv4-oam-address") - logDebug("vnfHostIpAddress from A&AI is: " + vnfHostIpAddress, isDebugLogEnabled) - execution.setVariable("vnfHostIpAddress", vnfHostIpAddress) - execution.setVariable("vmIdList", null) - if (aaiRW.getRelationships() != null) { - Relationships relationships = aaiRW.getRelationships().get() - if (relationships != null) { - - List<AAIResourceUri> vserverUris = relationships.getRelatedAAIUris(AAIObjectType.VSERVER) - JSONArray vserverIds = new JSONArray() - - for (AAIResourceUri j in vserverUris) { - - String vserverId = j.getURIKeys().get('vserver-id') - vserverIds.put(vserverId) - } - - JSONObject vmidsArray = new JSONObject() - vmidsArray.put("vmIds", vserverIds.toString()) - - logDebug("vmidsArray is: " + vmidsArray.toString(), isDebugLogEnabled) - - execution.setVariable("vmIdList", vmidsArray.toString()) - } - } - - if (cloudRegionId != null) { - String cloudOwnerId = "att-aic"; - try { - cloudOwnerId = execution.getVariable("URN_mso_default_cloud_owner_id"); - if (cloudOwnerId == null) cloudOwnerId = "att-aic"; - } catch (RuntimeException e) { - cloudOwnerId = "att-aic"; - } - - AAIUri cloudRegionUri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwnerId, cloudRegionId) - // Check if this client region exists - if (!client.exists(cloudRegionUri)) { - logDebug("Cloud Region with cloudOwner ID " + cloudOwnerId + " and cloudRegionId " + cloudRegionId + " does not exist in A&AI", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 404, "Cloud Region with cloudRegionId " + cloudRegionId + " does not exist in A&AI") - } - - AAIResultWrapper aaiRWCloud = client.get(cloudRegionUri) - - Map<String, Object> resultCloud = aaiRWCloud.asMap() - - String aicIdentity = resultCloud.get("identity-url") - logDebug("aicIdentity from A&AI is: " + aicIdentity, isDebugLogEnabled) - execution.setVariable("aicIdentity", aicIdentity) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIForVnf(): ' + e.getMessage()) - } - } - - - - /** - * Check if this VNF's pservers are locked in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfPserversInMaintInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("workStep", "checkIfPserversInMaintInAAI") - execution.setVariable("failedActivity", "AAI") - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIValidatorImpl aaiValidator = new AAIValidatorImpl() - aaiValidator.setClient(client) - def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) - logDebug("areLocked result: " + areLocked, isDebugLogEnabled) - execution.setVariable('arePserversLocked', areLocked) - - if (areLocked) { - execution.setVariable("errorCode", "1003") - execution.setVariable("errorText", "pServers are locked in A&AI") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage()) - } - } - - /** - * Set inMaint flag for this VNF to the specified value in A&AI. - * - * - * @param execution The flow's execution instance. - * @param inMaint The boolean value of the flag to set - */ - public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) { - def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - if (inMaint) { - execution.setVariable("workStep", "setVnfInMaintFlagInAAI") - } - else { - execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI") - } - execution.setVariable("failedActivity", "AAI") - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl() - aaiUpdator.setClient(client) - def vnfId = execution.getVariable("vnfId") - if (inMaint) { - aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid) - execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) - } - else { - aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) - execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) - } - } - - /** - * Check if VF Closed Loop Disabled in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI") - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - logDebug("vnfId is: " + vnfId, isDebugLogEnabled) - AAIResourcesClient client = new AAIResourcesClient() - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - AAIResultWrapper aaiRW = client.get(genericVnfUri) - Map<String, Object> result = aaiRW.asMap() - boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) - - logDebug("isClosedLoopDisabled result: " + isClosedLoopDisabled, isDebugLogEnabled) - execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled) - - if (isClosedLoopDisabled) { - execution.setVariable("errorCode", "1004") - execution.setVariable("errorText", "closedLoop is disabled in A&AI") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - } - } - - /** - * Set VF Closed Loop Disabled Flag in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) { - def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - if (setDisabled) { - execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI") - execution.setVariable("rollbackSetClosedLoopDisabledFlag", true) - } - else { - execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI") - execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) - } - - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - AAIResourcesClient client = new AAIResourcesClient() - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - - Map<String, Boolean> request = new HashMap<>() - request.put("is-closed-loop-disabled", setDisabled) - client.update(genericVnfUri, request) - logDebug("set isClosedLoop to: " + setDisabled, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - } - } - - - - - /** - * Call APP-C client to execute specified APP-C command for this VNF. - * - * - * @param execution The flow's execution instance. - * @param action The action to take in APP-C. - */ - public void runAppcCommand(DelegateExecution execution, Action action) { - def method = getClass().getSimpleName() + '.runAppcCommand(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - - ApplicationControllerClient appcClient = null - - try { - logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled) - String vnfId = execution.getVariable('vnfId') - String msoRequestId = execution.getVariable('requestId') - execution.setVariable('msoRequestId', msoRequestId) - execution.setVariable("failedActivity", "APP-C") - - appcClient = new ApplicationControllerClient() - ApplicationControllerSupport support = new ApplicationControllerSupport() - appcClient.appCSupport=support - org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.onap.appc.client.lcm.model"); - Flags flags = new Flags(); - ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - actionIdentifiers.setVnfId(vnfId); - Status appcStatus - switch(action) { - case Action.Lock: - execution.setVariable('workStep', "LockVNF") - appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,null,msoRequestId) - break - case Action.Unlock: - execution.setVariable('workStep', "UnlockVNF") - appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,null,msoRequestId) - break - case Action.HealthCheck: - def healthCheckIndex = execution.getVariable('healthCheckIndex') - execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex) - execution.setVariable('healthCheckIndex', healthCheckIndex + 1) - appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,null,msoRequestId) - break - case Action.Start: - execution.setVariable('workStep', "StartVNF") - appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,null,msoRequestId) - break - case Action.Stop: - execution.setVariable('workStep', "StopVNF") - appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,null,msoRequestId) - break - default: - break - } - logDebug("Completed AppC request", isDebugLogEnabled) - int appcCode = appcStatus.getCode() - logDebug("AppC status code is: " + appcCode, isDebugLogEnabled) - logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled) - if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { - execution.setVariable("errorCode", Integer.toString(appcCode)) - execution.setVariable("errorText", appcStatus.getMessage()) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - - } catch (java.lang.NoSuchMethodError e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - - } - } - - /** - * Placeholder for a call to APP-C client to execute specified APP-C command for this VNF. - * - * - * @param execution The flow's execution instance. - * @param action The action to take in APP-C. - */ - public void runAppcCommandPlaceholder(DelegateExecution execution, String action) { - def method = getClass().getSimpleName() + '.runAppcCommandPlaceholder(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("failedActivity", "APP-C") - execution.setVariable("workStep", action) - } - - - - - - - - /** - * Builds a "CompletionHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void completionHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.completionHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - - def requestInfo = execution.getVariable('requestInfo') - - String content = """ - <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1"> - ${requestInfo} - <sdncadapterworkflow:status-message>Vnf has been updated successfully.</sdncadapterworkflow:status-message> - <sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name> - </sdncadapterworkflow:MsoCompletionRequest> - """ - - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, 'Internal Error') - } - } - - /** - * Prepare DoUpdateVnfAndModules call. - * - * - * @param execution The flow's execution instance. - */ - public void prepDoUpdateVnfAndModules(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.prepDoUpdateVnfAndModules(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("workStep", "doUpdateVnfAndModules") - execution.setVariable("failedActivity", "MSO Update VNF") - logDebug('Exited ' + method, isDebugLogEnabled) - - } - - /** - * Builds a "FalloutHandler" request and stores it in the specified execution variable. - * - * @param execution the execution - * @param resultVar the execution variable in which the result will be stored - */ - public void falloutHandlerPrep(DelegateExecution execution, String resultVar) { - def method = getClass().getSimpleName() + '.falloutHandlerPrep(' + - 'execution=' + execution.getId() + - ', resultVar=' + resultVar + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def prefix = execution.getVariable('prefix') - def requestInformation = execution.getVariable("requestInfo") - - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def errorResponseCode = workflowException.getErrorCode() - def errorResponseMsg = workflowException.getErrorMessage() - def encErrorResponseMsg = "" - if (errorResponseMsg != null) { - encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">") - } - - String content = """ - <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:reqtype="http://org.openecomp/mso/request/types/v1" - xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1" - xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1"> - ${requestInformation} - <sdncadapterworkflow:WorkflowException> - <sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage> - <sdncadapterworkflow:ErrorCode>${errorResponseCode}</sdncadapterworkflow:ErrorCode> - </sdncadapterworkflow:WorkflowException> - </sdncadapterworkflow:FalloutHandlerRequest> - """ - content = utils.formatXml(content) - logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled) - execution.setVariable(resultVar, content) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error') - } - } - - /** - * Handle Abort disposition from RainyDayHandler - * - * @param execution The flow's execution instance. - */ - public void abortProcessing(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.abortProcessing(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - def errorText = execution.getVariable("errorText") - def errorCode = execution.getVariable("errorCode") - - exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) - } - - /** - * Increment Retry Count for Current Work Step - * - * @param execution The flow's execution instance. - */ - public void incrementRetryCount(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.incrementRetryCount(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String retryCountVariableName = execution.getVariable("workStep") + "RetryCount" - execution.setVariable("retryCountVariableName", retryCountVariableName) - - def retryCountVariable = execution.getVariable(retryCountVariableName) - int retryCount = 0 - - if (retryCountVariable != null) { - retryCount = (int) retryCountVariable - } - - retryCount += 1 - - execution.setVariable(retryCountVariableName, retryCount) - - logDebug("value of " + retryCountVariableName + " is " + retryCount, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) - - - } - - public void preProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) - } - - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy deleted file mode 100644 index aa3320044d..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfConfigUpdate.groovy +++ /dev/null @@ -1,507 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.json.JsonOutput -import groovy.json.JsonSlurper -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import java.io.Serializable; -import java.util.UUID; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.client.aai.* - -import org.openecomp.mso.client.appc.ApplicationControllerClient; -import org.openecomp.mso.client.appc.ApplicationControllerSupport; -import org.openecomp.mso.client.aai.AAIResourcesClient -import org.openecomp.mso.client.aai.entities.AAIResultWrapper -import org.openecomp.mso.client.aai.entities.uri.AAIUri -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.LockInput -import org.onap.appc.client.lcm.model.UnlockInput -import org.onap.appc.client.lcm.model.HealthCheckInput -import org.onap.appc.client.lcm.model.StartInput -import org.onap.appc.client.lcm.model.StopInput -import org.onap.appc.client.lcm.model.Flags -import org.onap.appc.client.lcm.model.Status - - -public class VnfConfigUpdate extends VnfCmBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtils = new JsonUtils() - def prefix = "VnfIPU_" - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'VnfCU_') - execution.setVariable('Request', null) - execution.setVariable('source', null) - execution.setVariable('controllerType', null) - execution.setVariable('UpdateVnfSuccessIndicator', false) - execution.setVariable('serviceType', null) - execution.setVariable('nfRole', null) - execution.setVariable('currentActivity', 'VnfCU') - execution.setVariable('workStep', null) - execution.setVariable('failedActivity', null) - execution.setVariable('errorCode', "0") - execution.setVariable('errorText', null) - execution.setVariable('healthCheckIndex0', 0) - execution.setVariable('healthCheckIndex1', 1) - execution.setVariable('maxRetryCount', 3) - execution.setVariable('retryCount', 0) - execution.setVariable("lcpCloudRegionId", null) - execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) - execution.setVariable("rollbackVnfStop", false) - execution.setVariable("rollbackVnfLock", false) - execution.setVariable("rollbackQuiesceTraffic", false) - execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - initProcessVariables(execution) - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - initProcessVariables(execution) - - def incomingRequest = execution.getVariable('bpmnRequest') - - utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) - try { - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - Map reqMap = jsonSlurper.parseText(incomingRequest) - utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - def vnfId = execution.getVariable('vnfId') - - execution.setVariable('serviceInstanceId', serviceInstanceId) - execution.setVariable('vnfId', vnfId) - execution.setVariable('serviceType', 'Mobility') - execution.setVariable('payload', "") - execution.setVariable('actionHealthCheck', Action.HealthCheck) - execution.setVariable('actionConfigModify', Action.ConfigModify) - - def controllerType = reqMap.requestDetails?.requestParameters?.controllerType - execution.setVariable('controllerType', controllerType) - - utils.log("DEBUG", 'Controller Type: ' + controllerType, isDebugLogEnabled) - - def payload = reqMap.requestDetails?.requestParameters?.payload - execution.setVariable('payload', payload) - - utils.log("DEBUG", 'Processed payload: ' + payload, isDebugLogEnabled) - - def requestId = execution.getVariable("mso-request-id") - execution.setVariable('requestId', requestId) - execution.setVariable('msoRequestId', requestId) - - def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null - execution.setVariable('requestorId', requestorId) - - execution.setVariable('sdncVersion', '1702') - - execution.setVariable("UpdateVnfInfraSuccessIndicator", false) - - execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) - - def source = reqMap.requestDetails?.requestInfo?.source - execution.setVariable("source", source) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable("requestInfo", requestInfo) - - logDebug('RequestInfo: ' + execution.getVariable("requestInfo"), isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - - } - catch(groovy.json.JsonException je) { - utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") - - } - catch(Exception e) { - String restFaultMessage = e.getMessage() - utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) - } - } - - /** - * Prepare and send the sychronous response for this flow. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendSynchResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - - try { - def requestInfo = execution.getVariable('requestInfo') - def requestId = execution.getVariable('requestId') - def source = execution.getVariable('source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - - // RESTResponse (for API Handler (APIH) Reply Task) - def vnfId = execution.getVariable("vnfId") - String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() - - sendWorkflowResponse(execution, 200, synchResponse) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) - } - } - - - /** - * Check if this VNF is already in maintenance in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfVnfInMaintInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - execution.setVariable("workStep", "checkIfVnfInMaintInAAI") - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIValidatorImpl aaiValidator = new AAIValidatorImpl() - aaiValidator.setClient(client) - def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) - logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled) - execution.setVariable('isVnfInMaintenance', isInMaint) - - if (isInMaint) { - execution.setVariable("errorCode", "1003") - execution.setVariable("errorText", "VNF is in maintenance in A&AI") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) - } - } - - - /** - * Check if this VNF's pservers are locked in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfPserversInMaintInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("workStep", "checkIfPserversInMaintInAAI") - execution.setVariable("failedActivity", "AAI") - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIValidatorImpl aaiValidator = new AAIValidatorImpl() - aaiValidator.setClient(client) - def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) - logDebug("areLocked result: " + areLocked, isDebugLogEnabled) - execution.setVariable('arePserversLocked', areLocked) - - if (areLocked) { - execution.setVariable("errorCode", "1003") - execution.setVariable("errorText", "pServers are locked in A&AI") - } - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage()) - } - } - - /** - * Set inMaint flag for this VNF to the specified value in A&AI. - * - * - * @param execution The flow's execution instance. - * @param inMaint The boolean value of the flag to set - */ - public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) { - def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - if (inMaint) { - execution.setVariable("workStep", "setVnfInMaintFlagInAAI") - execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) - } - else { - execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI") - } - execution.setVariable("failedActivity", "AAI") - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl() - aaiUpdator.setClient(client) - def vnfId = execution.getVariable("vnfId") - if (inMaint) { - aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid) - execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) - } - else { - aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) - } - } - - /** - * Check if VF Closed Loop Disabled in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI") - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - logDebug("vnfId is: " + vnfId, isDebugLogEnabled) - AAIResourcesClient client = new AAIResourcesClient() - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - AAIResultWrapper aaiRW = client.get(genericVnfUri) - Map<String, Object> result = aaiRW.asMap() - boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) - - logDebug("isClosedLoopDisabled result: " + isClosedLoopDisabled, isDebugLogEnabled) - execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled) - - if (isClosedLoopDisabled) { - execution.setVariable("errorCode", "1004") - execution.setVariable("errorText", "closedLoop is disabled in A&AI") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) - } - } - - /** - * Set VF Closed Loop Disabled Flag in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) { - def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - if (setDisabled) { - execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI") - execution.setVariable("rollbackSetClosedLoopDisabledFlag", true) - } - else { - execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI") - } - - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - AAIResourcesClient client = new AAIResourcesClient() - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - - Map<String, Boolean> request = new HashMap<>() - request.put("is-closed-loop-disabled", setDisabled) - client.update(genericVnfUri, request) - logDebug("set isClosedLoop to: " + setDisabled, isDebugLogEnabled) - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) - } - } - - - /** - * Handle Abort disposition from RainyDayHandler - * - * @param execution The flow's execution instance. - */ - public void abortProcessing(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.abortProcessing(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - def errorText = execution.getVariable("errorText") - def errorCode = execution.getVariable("errorCode") - - exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) - } - - /** - * Increment Retry Count for Current Work Step - * - * @param execution The flow's execution instance. - */ - public void incrementRetryCount(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.incrementRetryCount(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String retryCountVariableName = execution.getVariable("workStep") + "RetryCount" - execution.setVariable("retryCountVariableName", retryCountVariableName) - - def retryCountVariable = execution.getVariable(retryCountVariableName) - int retryCount = 0 - - if (retryCountVariable != null) { - retryCount = (int) retryCountVariable - } - - retryCount += 1 - - execution.setVariable(retryCountVariableName, retryCount) - - logDebug("value of " + retryCountVariableName + " is " + retryCount, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) - - - } - - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy deleted file mode 100644 index 64894563bf..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/VnfInPlaceUpdate.groovy +++ /dev/null @@ -1,626 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.infrastructure.scripts - -import groovy.json.JsonOutput -import groovy.json.JsonSlurper -import groovy.util.Node -import groovy.util.XmlParser; -import groovy.xml.QName - -import java.io.Serializable; -import java.util.UUID; -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.impl.cmd.AbstractSetVariableCmd -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.openecomp.mso.rest.APIResponse -import org.openecomp.mso.rest.RESTClient -import org.openecomp.mso.rest.RESTConfig -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor; -import org.openecomp.mso.bpmn.common.scripts.VidUtils; -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.core.domain.ModelInfo -import org.openecomp.mso.bpmn.core.domain.ServiceDecomposition -import org.openecomp.mso.bpmn.core.domain.VnfResource -import org.openecomp.mso.client.aai.* - -import org.openecomp.mso.client.appc.ApplicationControllerClient; -import org.openecomp.mso.client.appc.ApplicationControllerSupport; -import org.openecomp.mso.client.aai.AAIResourcesClient -import org.openecomp.mso.client.aai.entities.AAIResultWrapper -import org.openecomp.mso.client.aai.entities.uri.AAIUri -import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory -import org.onap.appc.client.lcm.model.Action; -import org.onap.appc.client.lcm.model.ActionIdentifiers; -import org.onap.appc.client.lcm.model.LockInput -import org.onap.appc.client.lcm.model.UnlockInput -import org.onap.appc.client.lcm.model.HealthCheckInput -import org.onap.appc.client.lcm.model.StartInput -import org.onap.appc.client.lcm.model.StopInput -import org.onap.appc.client.lcm.model.Flags -import org.onap.appc.client.lcm.model.Status - - - -public class VnfInPlaceUpdate extends VnfCmBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtils = new JsonUtils() - def prefix = "VnfIPU_" - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(DelegateExecution execution) { - execution.setVariable('prefix', 'VnfIPU_') - execution.setVariable('Request', null) - execution.setVariable('requestInfo', null) - execution.setVariable('source', null) - execution.setVariable('vnfInputs', null) - execution.setVariable('tenantId', null) - execution.setVariable('vnfParams', null) - execution.setVariable('controllerType', null) - execution.setVariable('UpdateVnfSuccessIndicator', false) - execution.setVariable('serviceType', null) - execution.setVariable('nfRole', null) - execution.setVariable('currentActivity', 'VnfIPU') - execution.setVariable('workStep', null) - execution.setVariable('failedActivity', null) - execution.setVariable('errorCode', "0") - execution.setVariable('errorText', null) - execution.setVariable('healthCheckIndex0', 0) - execution.setVariable('healthCheckIndex1', 1) - execution.setVariable('maxRetryCount', 3) - execution.setVariable("rollbackSetClosedLoopDisabledFlag", false) - execution.setVariable("rollbackVnfStop", false) - execution.setVariable("rollbackVnfLock", false) - execution.setVariable("rollbackQuiesceTraffic", false) - execution.setVariable("rollbackSetVnfInMaintenanceFlag", false) - } - - /** - * Check for missing elements in the received request. - * - * @param execution The flow's execution instance. - */ - public void preProcessRequest(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - initProcessVariables(execution) - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - initProcessVariables(execution) - - def incomingRequest = execution.getVariable('bpmnRequest') - - utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled) - try { - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - Map reqMap = jsonSlurper.parseText(incomingRequest) - utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - def vnfId = execution.getVariable('vnfId') - - execution.setVariable('serviceInstanceId', serviceInstanceId) - execution.setVariable('vnfId', vnfId) - execution.setVariable("isVidRequest", "true") - execution.setVariable('serviceType', 'Mobility') - execution.setVariable('payload', "") - execution.setVariable('actionSnapshot', Action.Snapshot) - execution.setVariable('actionLock', Action.Lock) - execution.setVariable('actionUnlock', Action.Unlock) - execution.setVariable('actionUpgradePreCheck', Action.UpgradePreCheck) - execution.setVariable('actionUpgradePostCheck', Action.UpgradePostCheck) - execution.setVariable('actionQuiesceTraffic', Action.QuiesceTraffic) - execution.setVariable('actionUpgradeBackup', Action.UpgradeBackup) - execution.setVariable('actionUpgradeSoftware', Action.UpgradeSoftware) - execution.setVariable('actionResumeTraffic', Action.ResumeTraffic) - - def controllerType = reqMap.requestDetails?.requestParameters?.controllerType - execution.setVariable('controllerType', controllerType) - - utils.log("DEBUG", 'Controller Type: ' + controllerType, isDebugLogEnabled) - - def payload = reqMap.requestDetails?.requestParameters?.payload - execution.setVariable('payload', payload) - - utils.log("DEBUG", 'Processed payload: ' + payload, isDebugLogEnabled) - - - def requestId = execution.getVariable("mso-request-id") - execution.setVariable('requestId', requestId) - execution.setVariable('msoRequestId', requestId) - - def requestorId = reqMap.requestDetails?.requestInfo?.requestorId ?: null - execution.setVariable('requestorId', requestorId) - - def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration - def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId - execution.setVariable('lcpCloudRegionId', lcpCloudRegionId) - def tenantId = cloudConfiguration.tenantId - execution.setVariable('tenantId', tenantId) - - execution.setVariable("UpdateVnfInfraSuccessIndicator", false) - - execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) - - def source = reqMap.requestDetails?.requestInfo?.source - execution.setVariable("source", source) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>UPDATE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable("requestInfo", requestInfo) - - logDebug('RequestInfo: ' + execution.getVariable("requestInfo"), isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - - } - catch(groovy.json.JsonException je) { - utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Invalid request format") - - } - catch(Exception e) { - String restFaultMessage = e.getMessage() - utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, restFaultMessage) - } - } - - /** - * Prepare and send the sychronous response for this flow. - * - * @param execution The flow's execution instance. - */ - public void sendSynchResponse(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendSynchResponse(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - - try { - def requestInfo = execution.getVariable('requestInfo') - def requestId = execution.getVariable('requestId') - def source = execution.getVariable('source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - - // RESTResponse (for API Handler (APIH) Reply Task) - def vnfId = execution.getVariable("vnfId") - String synchResponse = """{"requestReferences":{"instanceId":"${vnfId}","requestId":"${requestId}"}}""".trim() - - sendWorkflowResponse(execution, 200, synchResponse) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage()) - } - } - - - /** - * Check if this VNF is already in maintenance in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfVnfInMaintInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfVnfInMaintInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - execution.setVariable("workStep", "checkIfVnfInMaintInAAI") - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIValidatorImpl aaiValidator = new AAIValidatorImpl() - aaiValidator.setClient(client) - def vnfId = execution.getVariable("vnfId") - boolean isInMaint = aaiValidator.isVNFLocked(vnfId, transactionLoggingUuid) - logDebug("isInMaint result: " + isInMaint, isDebugLogEnabled) - execution.setVariable('isVnfInMaintenance', isInMaint) - - if (isInMaint) { - execution.setVariable("errorCode", "1003") - execution.setVariable("errorText", "VNF is in maintenance in A&AI") - } - - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfVnfInMaintInAAI(): ' + e.getMessage()) - } - } - - - /** - * Check if this VNF's pservers are locked in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfPserversInMaintInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfPserversInMaintInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("workStep", "checkIfPserversInMaintInAAI") - execution.setVariable("failedActivity", "AAI") - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIValidatorImpl aaiValidator = new AAIValidatorImpl() - aaiValidator.setClient(client) - def vnfId = execution.getVariable("vnfId") - boolean areLocked = aaiValidator.isPhysicalServerLocked(vnfId, transactionLoggingUuid) - logDebug("areLocked result: " + areLocked, isDebugLogEnabled) - execution.setVariable('arePserversLocked', areLocked) - - if (areLocked) { - execution.setVariable("errorCode", "1003") - execution.setVariable("errorText", "pServers are locked in A&AI") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in checkIfPserversInMaintInAAI(): ' + e.getMessage()) - } - } - - /** - * Set inMaint flag for this VNF to the specified value in A&AI. - * - * - * @param execution The flow's execution instance. - * @param inMaint The boolean value of the flag to set - */ - public void setVnfInMaintFlagInAAI(DelegateExecution execution, boolean inMaint) { - def method = getClass().getSimpleName() + '.setVnfInMaintFlagInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - if (inMaint) { - execution.setVariable("workStep", "setVnfInMaintFlagInAAI") - } - else { - execution.setVariable("workStep", "unsetVnfInMaintFlagInAAI") - } - execution.setVariable("failedActivity", "AAI") - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - AAIRestClientImpl client = new AAIRestClientImpl() - AAIUpdatorImpl aaiUpdator = new AAIUpdatorImpl() - aaiUpdator.setClient(client) - def vnfId = execution.getVariable("vnfId") - if (inMaint) { - aaiUpdator.updateVnfToLocked(vnfId, transactionLoggingUuid) - execution.setVariable("rollbackSetVnfInMaintenanceFlag", true) - } - else { - aaiUpdator.updateVnfToUnLocked(vnfId, transactionLoggingUuid) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - //exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in setVnfInMaintFlagInAAI(): ' + e.getMessage()) - } - } - - /** - * Check if VF Closed Loop Disabled in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void checkIfClosedLoopDisabledInAAI(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.checkIfClosedLoopDisabledInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - execution.setVariable("workStep", "checkClosedLoopDisabledFlagInAAI") - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - logDebug("vnfId is: " + vnfId, isDebugLogEnabled) - AAIResourcesClient client = new AAIResourcesClient() - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - AAIResultWrapper aaiRW = client.get(genericVnfUri) - Map<String, Object> result = aaiRW.asMap() - boolean isClosedLoopDisabled = result.getOrDefault("is-closed-loop-disabled", false) - - logDebug("isClosedLoopDisabled result: " + isClosedLoopDisabled, isDebugLogEnabled) - execution.setVariable('isClosedLoopDisabled', isClosedLoopDisabled) - - if (isClosedLoopDisabled) { - execution.setVariable("errorCode", "1004") - execution.setVariable("errorText", "closedLoop is disabled in A&AI") - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - } - } - - /** - * Set VF Closed Loop Disabled Flag in A&AI. - * - * - * @param execution The flow's execution instance. - */ - public void setClosedLoopDisabledInAAI(DelegateExecution execution, boolean setDisabled) { - def method = getClass().getSimpleName() + '.setClosedLoopDisabledInAAI(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - if (setDisabled) { - execution.setVariable("workStep", "setClosedLoopDisabledFlagInAAI") - execution.setVariable("rollbackSetClosedLoopDisabledFlag", true) - } - else { - execution.setVariable("workStep", "unsetClosedLoopDisabledFlagInAAI") - } - - execution.setVariable("failedActivity", "AAI") - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def transactionLoggingUuid = UUID.randomUUID().toString() - def vnfId = execution.getVariable("vnfId") - AAIResourcesClient client = new AAIResourcesClient() - AAIUri genericVnfUri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId) - - Map<String, Boolean> request = new HashMap<>() - request.put("is-closed-loop-disabled", setDisabled) - client.update(genericVnfUri, request) - logDebug("set isClosedLoop to: " + setDisabled, isDebugLogEnabled) - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - } - } - - - - - /** - * Call APP-C client to execute specified APP-C command for this VNF. - * - * - * @param execution The flow's execution instance. - * @param action The action to take in APP-C. - */ - public void runAppcCommand(DelegateExecution execution, Action action) { - def method = getClass().getSimpleName() + '.runAppcCommand(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - - ApplicationControllerClient appcClient = null - - try { - logDebug("Running APP-C action: " + action.toString(), isDebugLogEnabled) - String vnfId = execution.getVariable('vnfId') - String msoRequestId = execution.getVariable('requestId') - execution.setVariable('msoRequestId', msoRequestId) - execution.setVariable("failedActivity", "APP-C") - - appcClient = new ApplicationControllerClient() - ApplicationControllerSupport support = new ApplicationControllerSupport() - appcClient.appCSupport=support - org.springframework.test.util.ReflectionTestUtils.setField(support, "lcmModelPackage", "org.onap.appc.client.lcm.model"); - Flags flags = new Flags(); - ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); - actionIdentifiers.setVnfId(vnfId); - Status appcStatus - switch(action) { - case Action.Lock: - execution.setVariable('workStep', "LockVNF") - appcStatus = appcClient.runCommand(Action.Lock,actionIdentifiers,null,msoRequestId) - break - case Action.Unlock: - execution.setVariable('workStep', "UnlockVNF") - appcStatus = appcClient.runCommand(Action.Unlock,actionIdentifiers,null,msoRequestId) - break - case Action.HealthCheck: - def healthCheckIndex = execution.getVariable('healthCheckIndex') - execution.setVariable('workStep', "HealthCheckVNF" + healthCheckIndex) - execution.setVariable('healthCheckIndex', healthCheckIndex + 1) - appcStatus = appcClient.runCommand(Action.HealthCheck,actionIdentifiers,null,msoRequestId) - break - case Action.Start: - execution.setVariable('workStep', "StartVNF") - appcStatus = appcClient.runCommand(Action.Start,actionIdentifiers,null,msoRequestId) - break - case Action.Stop: - execution.setVariable('workStep', "StopVNF") - appcStatus = appcClient.runCommand(Action.Stop,actionIdentifiers,null,msoRequestId) - break - default: - break - } - logDebug("Completed AppC request", isDebugLogEnabled) - int appcCode = appcStatus.getCode() - logDebug("AppC status code is: " + appcCode, isDebugLogEnabled) - logDebug("AppC status message is: " + appcStatus.getMessage(), isDebugLogEnabled) - if (support.getCategoryOf(appcStatus) == ApplicationControllerSupport.StatusCategory.ERROR) { - execution.setVariable("errorCode", Integer.toString(appcCode)) - execution.setVariable("errorText", appcStatus.getMessage()) - } - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - - } catch (java.lang.NoSuchMethodError e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - - } catch (Exception e) { - logError('Caught exception in ' + method, e) - execution.setVariable("errorCode", "1002") - execution.setVariable("errorText", e.getMessage()) - - } - } - - /** - * Placeholder for a call to APP-C client to execute specified APP-C command for this VNF. - * - * - * @param execution The flow's execution instance. - * @param action The action to take in APP-C. - */ - public void runAppcCommandPlaceholder(DelegateExecution execution, String action) { - def method = getClass().getSimpleName() + '.runAppcCommandPlaceholder(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - execution.setVariable('errorCode', "0") - logDebug('Entered ' + method, isDebugLogEnabled) - execution.setVariable("failedActivity", "APP-C") - execution.setVariable("workStep", action) - } - - - - /** - * Handle Abort disposition from RainyDayHandler - * - * @param execution The flow's execution instance. - */ - public void abortProcessing(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.abortProcessing(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - def errorText = execution.getVariable("errorText") - def errorCode = execution.getVariable("errorCode") - - exceptionUtil.buildAndThrowWorkflowException(execution, errorCode as Integer, errorText) - } - - /** - * Increment Retry Count for Current Work Step - * - * @param execution The flow's execution instance. - */ - public void incrementRetryCount(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.incrementRetryCount(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String retryCountVariableName = execution.getVariable("workStep") + "RetryCount" - execution.setVariable("retryCountVariableName", retryCountVariableName) - - def retryCountVariable = execution.getVariable(retryCountVariableName) - int retryCount = 0 - - if (retryCountVariable != null) { - retryCount = (int) retryCountVariable - } - - retryCount += 1 - - execution.setVariable(retryCountVariableName, retryCount) - - logDebug("value of " + retryCountVariableName + " is " + retryCount, isDebugLogEnabled) - logDebug('Exited ' + method, isDebugLogEnabled) - - - } - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy deleted file mode 100644 index 68f50e033c..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/CreateVcpeResCustService.groovy +++ /dev/null @@ -1,815 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import groovy.xml.XmlUtil -import groovy.json.* - -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.VidUtils -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.domain.* - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.json.JSONObject; -import org.json.JSONArray; -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - -/** - * This groovy class supports the <class>CreateVcpeResCustService.bpmn</class> process. - * - * @author ek1439 - * - */ -public class CreateVcpeResCustService extends AbstractServiceTaskProcessor { - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix = "CVRCS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - CatalogDbUtils catalogDbUtils = new CatalogDbUtils() - - /** - * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process. - * @param execution - */ - public InitializeProcessVariables(DelegateExecution execution) { - /* Initialize all the process variables in this block */ - - execution.setVariable("createVcpeServiceRequest", "") - execution.setVariable("globalSubscriberId", "") - execution.setVariable("serviceInstanceName", "") - execution.setVariable("msoRequestId", "") - execution.setVariable(Prefix + "VnfsCreatedCount", 0) - execution.setVariable("productFamilyId", "") - execution.setVariable("brgWanMacAddress", "") - execution.setVariable("customerLocation", "") - execution.setVariable("homingService", "") - execution.setVariable("cloudOwner", "") - execution.setVariable("cloudRegionId", "") - execution.setVariable("homingModelIds", "") - - //TODO - execution.setVariable("sdncVersion", "1707") - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process. - * @param execution - */ - public void preProcessRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - //Config Inputs - String aaiDistDelay = execution.getVariable('URN_mso_workflow_aai_distribution_delay') - if (isBlank(aaiDistDelay)) { - msg = "URN_mso_workflow_aai_distribution_delay is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("aaiDistDelay", aaiDistDelay) - utils.log("DEBUG", "AAI distribution delay: " + aaiDistDelay, isDebugEnabled) - - // check for incoming json message/input - String createVcpeServiceRequest = execution.getVariable("bpmnRequest") - utils.logAudit(createVcpeServiceRequest) - execution.setVariable("createVcpeServiceRequest", createVcpeServiceRequest); - println 'createVcpeServiceRequest - ' + createVcpeServiceRequest - - // extract requestId - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) { - serviceInstanceId = UUID.randomUUID().toString() - utils.log("DEBUG", " Generated new Service Instance: " + serviceInstanceId, isDebugEnabled) - } else { - utils.log("DEBUG", "Using provided Service Instance ID: " + serviceInstanceId, isDebugEnabled) - } - - serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8") - execution.setVariable("serviceInstanceId", serviceInstanceId) - utils.log("DEBUG", "Incoming serviceInstanceId is: " + serviceInstanceId, isDebugEnabled) - - String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName") - execution.setVariable("serviceInstanceName", serviceInstanceName) - utils.log("DEBUG", "Incoming serviceInstanceName is: " + serviceInstanceName, isDebugEnabled) - - String requestAction = execution.getVariable("requestAction") - execution.setVariable("requestAction", requestAction) - - setBasicDBAuthHeader(execution, isDebugEnabled) - - String source = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - source = "VID" - } - execution.setVariable("source", source) - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") - - // verify element global-customer-id is sent from JSON input, throw exception if missing - if ((globalSubscriberId == null) || (globalSubscriberId.isEmpty())) { - String dataErrorMessage = " Element 'globalSubscriberId' is missing. " - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - execution.setVariable("globalCustomerId", globalSubscriberId) - } - - // extract subscriptionServiceType - String subscriptionServiceType = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - String suppressRollback = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - String subscriberInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.subscriberInfo") - execution.setVariable("subscriberInfo", subscriberInfo) - utils.log("DEBUG", "Incoming subscriberInfo is: " + subscriberInfo, isDebugEnabled) - - // extract cloud configuration, split vid_ID into cloudOwner and cloudRegionId - String vimId = jsonUtil.getJsonValue(createVcpeServiceRequest, - "requestDetails.cloudConfiguration.lcpCloudRegionId") - def cloudRegion = vimId.split("_") - def cloudOwner = cloudRegion[0].toString() - def cloudRegionId = cloudRegion[1].toString() - execution.setVariable("cloudOwner", cloudOwner) - utils.log("DEBUG","cloudOwner: " + cloudOwner, isDebugEnabled) - execution.setVariable("cloudRegionId", cloudRegionId) - utils.log("DEBUG","cloudRegionId: " + cloudRegionId, isDebugEnabled) - - /* - * Extracting User Parameters from incoming Request and converting into a Map - */ - def jsonSlurper = new JsonSlurper() - def jsonOutput = new JsonOutput() - - Map reqMap = jsonSlurper.parseText(createVcpeServiceRequest) - - //InputParams - def userParams = reqMap.requestDetails?.requestParameters?.userParams - - Map<String, String> inputMap = [:] - if (userParams) { - userParams.each { - userParam -> - if ("Customer_Location".equals(userParam?.name)) { - execution.setVariable("customerLocation", userParam.value) - userParam.value.each { - param -> - inputMap.put(param.key, param.value) - } - } - if ("Homing_Model_Ids".equals(userParam?.name)) { - utils.log("DEBUG", "Homing_Model_Ids: " + userParam.value.toString() + " ---- Type is:" + - userParam.value.getClass() , isDebugEnabled) - def modelIdLst = [] - userParam.value.each { - param -> - def valueMap = [:] - param.each { - entry -> - valueMap.put(entry.key, entry.value) - } - modelIdLst.add(valueMap) - utils.log("DEBUG", "Param: " + param.toString() + " ---- Type is:" + - param.getClass() , isDebugEnabled) - } - execution.setVariable("homingModelIds", modelIdLst) - } - if ("BRG_WAN_MAC_Address".equals(userParam?.name)) { - execution.setVariable("brgWanMacAddress", userParam.value) - inputMap.put("BRG_WAN_MAC_Address", userParam.value) - } - if ("Homing_Solution".equals(userParam?.name)) { - execution.setVariable("homingService", userParam.value) - inputMap.put("Homing_Solution", userParam.value) - } - } - } - - if (execution.getVariable("homingService") == "") { - // Set Default Homing to OOF if not set - execution.setVariable("homingService", "oof") - } - - utils.log("DEBUG", "User Input Parameters map: " + userParams.toString(), isDebugEnabled) - execution.setVariable("serviceInputParams", inputMap) - - utils.log("DEBUG", "Incoming brgWanMacAddress is: " + execution.getVariable('brgWanMacAddress'), isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info>""" - - execution.setVariable(Prefix + "requestInfo", requestInfo) - - utils.log("DEBUG", " ***** Completed preProcessRequest CreateVcpeResCustService Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateVcpeResCustService ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // RESTResponse (for API Handler (APIH) Reply Task) - String syncResponse = """{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${ - requestId - }"}}""".trim() - - utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled) - sendWorkflowResponse(execution, 202, syncResponse) - - } catch (Exception ex) { - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // - // ******************************* - public void prepareDecomposeService(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - try { - utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled) - - String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") - - //serviceModelInfo JSON string will be used as-is for DoCreateServiceInstance BB - String serviceModelInfo = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.modelInfo") - execution.setVariable("serviceModelInfo", serviceModelInfo) - - utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // - // ******************************* - public void prepareCreateServiceInstance(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - try { - utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled) - - /* - * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject - * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - * ModelInfo modelInfo = serviceDecomposition.getModelInfo() - * - */ - String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") -// String serviceInputParams = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestParameters") -// execution.setVariable("serviceInputParams", serviceInputParams) - - - String serviceInstanceName = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.instanceName") - execution.setVariable("serviceInstanceName", serviceInstanceName) - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonStringNoRootName()) - - utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void postProcessServiceInstanceCreate(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' + 'execution=' + execution.getId() + ')' - def isDebugLogEnabled = execution.getVariable(DebugFlag) - logDebug('Entered ' + method, isDebugLogEnabled) - - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceInstanceName = execution.getVariable("serviceInstanceName") - - try { - - String payload = """ - <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb"> - <soapenv:Header/> - <soapenv:Body> - <req:updateInfraRequest> - <requestId>${requestId}</requestId> - <lastModifiedBy>BPEL</lastModifiedBy> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - <serviceInstanceName>${serviceInstanceName}</serviceInstanceName> - </req:updateInfraRequest> - </soapenv:Body> - </soapenv:Envelope> - """ - execution.setVariable(Prefix + "setUpdateDbInstancePayload", payload) - utils.logAudit(Prefix + "setUpdateDbInstancePayload: " + payload) - logDebug('Exited ' + method, isDebugLogEnabled) - - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error - Occured in" + method) - } - } - - - public void processDecomposition(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - utils.log("DEBUG", " ***** Inside processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) - - try { - - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - // VNFs - List<VnfResource> vnfList = serviceDecomposition.getServiceVnfs() - filterVnfs(vnfList) - serviceDecomposition.setServiceVnfs(vnfList) - - execution.setVariable("vnfList", vnfList) - execution.setVariable("vnfListString", vnfList.toString()) - - String vnfModelInfoString = "" - if (vnfList != null && vnfList.size() > 0) { - execution.setVariable(Prefix + "VNFsCount", vnfList.size()) - utils.log("DEBUG", "vnfs to create: " + vnfList.size(), isDebugEnabled) - ModelInfo vnfModelInfo = vnfList[0].getModelInfo() - - vnfModelInfoString = vnfModelInfo.toString() - String vnfModelInfoWithRoot = vnfModelInfo.toString() - vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") - } else { - execution.setVariable(Prefix + "VNFsCount", 0) - utils.log("DEBUG", "no vnfs to create based upon serviceDecomposition content", isDebugEnabled) - } - - execution.setVariable("vnfModelInfo", vnfModelInfoString) - execution.setVariable("vnfModelInfoString", vnfModelInfoString) - utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed processDecomposition() of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. processDecomposition() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - private void filterVnfs(List<VnfResource> vnfList) { - if (vnfList == null) { - return - } - - // remove BRG & TXC from VNF list - - Iterator<VnfResource> it = vnfList.iterator() - while (it.hasNext()) { - VnfResource vr = it.next() - - String role = vr.getNfRole() - if (role == "BRG" || role == "TunnelXConn" || role == "Tunnel XConn") { - it.remove() - } - } - } - - - public void prepareCreateAllottedResourceTXC(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - try { - utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled) - - /* - * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject - * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - * ModelInfo modelInfo = serviceDecomposition.getModelInfo() - * - */ - String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - //allottedResourceModelInfo - //allottedResourceRole - //The model Info parameters are a JSON structure as defined in the Service Instantiation API. - //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB. - List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources() - if (allottedResources != null) { - Iterator iter = allottedResources.iterator(); - while (iter.hasNext()) { - AllottedResource allottedResource = (AllottedResource) iter.next(); - - utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled) - utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled) - if ("TunnelXConn".equalsIgnoreCase(allottedResource.getAllottedResourceType()) || "Tunnel XConn".equalsIgnoreCase(allottedResource.getAllottedResourceType())) { - //set create flag to true - execution.setVariable("createTXCAR", true) - ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() - execution.setVariable("allottedResourceModelInfoTXC", allottedResourceModelInfo.toJsonStringNoRootName()) - execution.setVariable("allottedResourceRoleTXC", allottedResource.getAllottedResourceRole()) - execution.setVariable("allottedResourceTypeTXC", allottedResource.getAllottedResourceType()) - //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the TXC, - //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in TXC Allotted Resource structure) (which the Homing BB would have populated). - execution.setVariable("parentServiceInstanceIdTXC", allottedResource.getHomingSolution().getServiceInstanceId()) - } - } - } - - //unit test only - String allottedResourceId = execution.getVariable("allottedResourceId") - execution.setVariable("allottedResourceIdTXC", allottedResourceId) - utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService " + allottedResourceId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceTXC of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceTXC flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareCreateAllottedResourceBRG(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - try { - utils.log("DEBUG", " ***** Inside prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled) - - /* - * Service modelInfo is created in earlier step. This flow can use it as-is ... or, extract from DecompositionObject - * ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - * ModelInfo modelInfo = serviceDecomposition.getModelInfo() - * - */ - String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") - ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") - - //allottedResourceModelInfo - //allottedResourceRole - //The model Info parameters are a JSON structure as defined in the Service Instantiation API. - //It would be sufficient to only include the service model UUID (i.e. the modelVersionId), since this BB will query the full model from the Catalog DB. - List<AllottedResource> allottedResources = serviceDecomposition.getServiceAllottedResources() - if (allottedResources != null) { - Iterator iter = allottedResources.iterator(); - while (iter.hasNext()) { - AllottedResource allottedResource = (AllottedResource) iter.next(); - - utils.log("DEBUG", " getting model info for AllottedResource # :" + allottedResource.toJsonStringNoRootName(), isDebugEnabled) - utils.log("DEBUG", " allottedResource.getAllottedResourceType() :" + allottedResource.getAllottedResourceType(), isDebugEnabled) - if ("BRG".equalsIgnoreCase(allottedResource.getAllottedResourceType())) { - //set create flag to true - execution.setVariable("createBRGAR", true) - ModelInfo allottedResourceModelInfo = allottedResource.getModelInfo() - execution.setVariable("allottedResourceModelInfoBRG", allottedResourceModelInfo.toJsonStringNoRootName()) - execution.setVariable("allottedResourceRoleBRG", allottedResource.getAllottedResourceRole()) - execution.setVariable("allottedResourceTypeBRG", allottedResource.getAllottedResourceType()) - //After decomposition and homing BBs, there should be an allotted resource object in the decomposition that represents the BRG, - //and in its homingSolution section should be found the infraServiceInstanceId (i.e. infraServiceInstanceId in BRG Allotted Resource structure) (which the Homing BB would have populated). - execution.setVariable("parentServiceInstanceIdBRG", allottedResource.getHomingSolution().getServiceInstanceId()) - } - } - } - - //unit test only - String allottedResourceId = execution.getVariable("allottedResourceId") - execution.setVariable("allottedResourceIdBRG", allottedResourceId) - utils.log("DEBUG", "setting allottedResourceId CreateVcpeResCustService " + allottedResourceId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareCreateAllottedResourceBRG of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in prepareCreateAllottedResourceBRG flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareVnfAndModulesCreate(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - - // String disableRollback = execution.getVariable("disableRollback") - // def backoutOnFailure = "" - // if(disableRollback != null){ - // if ( disableRollback == true) { - // backoutOnFailure = "false" - // } else if ( disableRollback == false) { - // backoutOnFailure = "true" - // } - // } - //failIfExists - optional - - String createVcpeServiceRequest = execution.getVariable("createVcpeServiceRequest") - String productFamilyId = jsonUtil.getJsonValue(createVcpeServiceRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "productFamilyId: " + productFamilyId, isDebugEnabled) - - List<VnfResource> vnfList = execution.getVariable("vnfList") - - Integer vnfsCreatedCount = execution.getVariable(Prefix + "VnfsCreatedCount") - String vnfModelInfoString = null; - - if (vnfList != null && vnfList.size() > 0) { - utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled) - ModelInfo vnfModelInfo1 = vnfList[0].getModelInfo() - utils.log("DEBUG", "got 0 ", isDebugEnabled) - ModelInfo vnfModelInfo = vnfList[vnfsCreatedCount.intValue()].getModelInfo() - vnfModelInfoString = vnfModelInfo.toString() - } else { - //TODO: vnfList does not contain data. Need to investigate why ... . Fro VCPE use model stored - vnfModelInfoString = execution.getVariable("vnfModelInfo") - } - - utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - // extract cloud configuration - String vimId = jsonUtil.getJsonValue(createVcpeServiceRequest, - "requestDetails.cloudConfiguration.lcpCloudRegionId") - def cloudRegion = vimId.split("_") - execution.setVariable("cloudOwner", cloudRegion[0]) - utils.log("DEBUG","cloudOwner: "+ cloudRegion[0], isDebugEnabled) - execution.setVariable("cloudRegionId", cloudRegion[1]) - utils.log("DEBUG","cloudRegionId: "+ cloudRegion[1], isDebugEnabled) - execution.setVariable("lcpCloudRegionId", cloudRegion[1]) - utils.log("DEBUG","lcpCloudRegionId: "+ cloudRegion[1], isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createVcpeServiceRequest, - "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG", "tenantId: " + tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG", "sdncVersion: " + sdncVersion, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareVnfAndModulesCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfCreate(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - try { - utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateVcpeResCustService ***** ", isDebugEnabled) - - Integer vnfsCreatedCount = execution.getVariable(Prefix + "VnfsCreatedCount") - vnfsCreatedCount++ - - execution.setVariable(Prefix + "VnfsCreatedCount", vnfsCreatedCount) - - utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateVcpeResCustService ***** " + " vnf # " + vnfsCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - utils.log("DEBUG", " ***** Inside postProcessResponse of CreateVcpeResCustService ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - String msoCompletionRequest = - """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1" - xmlns:ns="http://org.openecomp/mso/request/types/v1"> - <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1"> - <request-id>${requestId}</request-id> - <action>CREATE</action> - <source>${source}</source> - </request-info> - <status-message>Service Instance has been created successfully via macro orchestration</status-message> - <serviceInstanceId>${serviceInstanceId}</serviceInstanceId> - <mso-bpel-name>BPMN macro create</mso-bpel-name> - </aetgt:MsoCompletionRequest>""" - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable(Prefix + "Success", true) - execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateVcpeResCustService flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void preProcessRollback(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", " ***** preProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch (Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG", " *** Exit preProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled) - } - - public void postProcessRollback(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", " ***** postProcessRollback of CreateVcpeResCustService ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch (Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG", " *** Exit postProcessRollback of CreateVcpeResCustService *** ", isDebugEnabled) - } - - public void prepareFalloutRequest(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - - utils.log("DEBUG", " *** STARTED CreateVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable(Prefix + "requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - //TODO. hmmm. there is no way to UPDATE error message. -// String errorMessage = wfex.getErrorMessage() -// boolean successIndicator = execution.getVariable("DCRESI_rolledBack") -// if (successIndicator){ -// errorMessage = errorMessage + ". Rollback successful." -// } else { -// errorMessage = errorMessage + ". Rollback not completed." -// } - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable(Prefix + "falloutRequest", falloutRequest) - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVcpeResCustService prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED CreateVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncError() of CreateVcpeResCustService ***** ", isDebugEnabled) - - try { - String errorMessage = "" - def wfe = execution.getVariable("WorkflowException") - if (wfe instanceof WorkflowException) { - errorMessage = wfe.getErrorMessage() - } else { - errorMessage = "Sending Sync Error." - } - - String buildworkflowException = - """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"> - <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage> - <aetgt:ErrorCode>7000</aetgt:ErrorCode> - </aetgt:WorkflowException>""" - - utils.logAudit(buildworkflowException) - sendWorkflowResponse(execution, 500, buildworkflowException) - } catch (Exception ex) { - utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled) - } - } - - public void processJavaException(DelegateExecution execution) { - def isDebugEnabled = execution.getVariable(DebugFlag) - execution.setVariable("prefix", Prefix) - try { - utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled) - utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled) - utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled) - execution.setVariable(Prefix + "unexpectedError", "Caught a Java Lang Exception") - // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception") - } catch (BpmnError b) { - utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception e) { - utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled) - execution.setVariable(Prefix + "unexpectedError", "Exception in processJavaException method") - // Adding this line temporarily until this flows error handling gets updated - exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method") - } - utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled) - } -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy deleted file mode 100644 index 08edb88c61..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DeleteVcpeResCustService.groovy +++ /dev/null @@ -1,466 +0,0 @@ -/*
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts
-
-import groovy.xml.XmlUtil
-import groovy.json.*
-
-import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils;
-import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
-import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;
-import org.openecomp.mso.bpmn.common.scripts.VidUtils;
-import org.openecomp.mso.bpmn.core.json.JsonUtils
-import org.openecomp.mso.bpmn.core.WorkflowException
-import org.openecomp.mso.rest.APIResponse
-import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor
-import org.openecomp.mso.bpmn.common.scripts.AaiUtil
-
-import java.util.UUID;
-
-import org.camunda.bpm.engine.delegate.BpmnError
-import org.camunda.bpm.engine.delegate.DelegateExecution
-import org.json.JSONObject;
-import org.json.JSONArray;
-import org.apache.commons.lang3.*
-import org.apache.commons.codec.binary.Base64;
-import org.springframework.web.util.UriUtils;
-import static org.apache.commons.lang3.StringUtils.*
-
-/**
- * This groovy class supports the <class>DeleteVcpeResCustService.bpmn</class> process.
- *
- * @author dm4252
- *
- */
-public class DeleteVcpeResCustService extends AbstractServiceTaskProcessor {
-
- private static final String DebugFlag = "isDebugLogEnabled"
-
- String Prefix = "DVRCS_"
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
- VidUtils vidUtils = new VidUtils()
- CatalogDbUtils catalogDbUtils = new CatalogDbUtils()
- NetworkUtils networkUtils = new NetworkUtils()
-
- /**
- * This method is executed during the preProcessRequest task of the <class>DeleteVcpeResCustService.bpmn</class> process.
- * @param execution
- */
- public InitializeProcessVariables(DelegateExecution execution){
- /* Initialize all the process variables in this block */
-
- execution.setVariable("DeleteVcpeResCustServiceRequest", "")
- execution.setVariable("msoRequestId", "")
- execution.setVariable(Prefix+"vnfsDeletedCount", 0)
- execution.setVariable(Prefix+"vnfsCount", 0)
- }
-
- // **************************************************
- // Pre or Prepare Request Section
- // **************************************************
- /**
- * This method is executed during the preProcessRequest task of the <class>CreateServiceInstance.bpmn</class> process.
- * @param execution
- */
- public void preProcessRequest (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- execution.setVariable("prefix",Prefix)
-
- utils.log("DEBUG", " ***** Inside preProcessRequest DeleteVcpeResCustService Request ***** ", isDebugEnabled)
-
- try {
- // initialize flow variables
- InitializeProcessVariables(execution)
-
- // check for incoming json message/input
- String DeleteVcpeResCustServiceRequest = execution.getVariable("bpmnRequest")
- utils.logAudit(DeleteVcpeResCustServiceRequest)
- execution.setVariable("DeleteVcpeResCustServiceRequest", DeleteVcpeResCustServiceRequest);
- println 'DeleteVcpeResCustServiceRequest - ' + DeleteVcpeResCustServiceRequest
-
- // extract requestId
- String requestId = execution.getVariable("mso-request-id")
- execution.setVariable("msoRequestId", requestId)
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- if ((serviceInstanceId == null) || (serviceInstanceId.isEmpty())) {
- String dataErrorMessage = " Element 'serviceInstanceId' is missing. "
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
- }
-
- String requestAction = execution.getVariable("requestAction")
- execution.setVariable("requestAction", requestAction)
-
- String source = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.source")
- if ((source == null) || (source.isEmpty())) {
- source = "VID"
- }
- execution.setVariable("source", source)
-
- // extract globalSubscriberId
- String globalSubscriberId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId")
-
- // global-customer-id is optional on Delete
-
- execution.setVariable("globalSubscriberId", globalSubscriberId)
- execution.setVariable("globalCustomerId", globalSubscriberId)
-
- String suppressRollback = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.suppressRollback")
- execution.setVariable("disableRollback", suppressRollback)
- utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled)
-
- String productFamilyId = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestInfo.productFamilyId")
- execution.setVariable("productFamilyId", productFamilyId)
- utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled)
-
- // extract subscriptionServiceType
- String subscriptionServiceType = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.requestParameters.subscriptionServiceType")
- execution.setVariable("subscriptionServiceType", subscriptionServiceType)
- utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled)
-
- // extract cloud configuration
- String cloudConfiguration = jsonUtil.getJsonValue(DeleteVcpeResCustServiceRequest, "requestDetails.cloudConfiguration")
- execution.setVariable("cloudConfiguration", cloudConfiguration)
- utils.log("DEBUG","cloudConfiguration: "+ cloudConfiguration, isDebugEnabled)
- String lcpCloudRegionId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId")
- execution.setVariable("lcpCloudRegionId", lcpCloudRegionId)
- utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled)
- String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId")
- execution.setVariable("tenantId", tenantId)
- utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled)
-
- String sdncVersion = "1707"
- execution.setVariable("sdncVersion", sdncVersion)
- utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled)
-
- //For Completion Handler & Fallout Handler
- String requestInfo =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable(Prefix+"requestInfo", requestInfo)
-
- //Setting for Generic Sub Flows
- execution.setVariable("GENGS_type", "service-instance")
-
- utils.log("DEBUG", " ***** Completed preProcessRequest DeleteVcpeResCustServiceRequest Request ***** ", isDebugEnabled)
-
- } catch (BpmnError e) {
- throw e;
- } catch (Exception ex){
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void sendSyncResponse(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
-
- utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
- String requestId = execution.getVariable("mso-request-id")
-
- // RESTResponse (for API Handler (APIH) Reply Task)
- String syncResponse ="""{"requestReferences":{"instanceId":"${serviceInstanceId}","requestId":"${requestId}"}}""".trim()
-
- utils.log("DEBUG", " sendSynchResponse: xmlSyncResponse - " + "\n" + syncResponse, isDebugEnabled)
- sendWorkflowResponse(execution, 202, syncResponse)
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected from method preProcessRequest() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void prepareServiceDelete(DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG", " ***** Inside prepareServiceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)
-
- try {
-
- String serviceInstanceId = execution.getVariable("serviceInstanceId")
-
- // confirm if ServiceInstance was found
- if ( !execution.getVariable("GENGS_FoundIndicator") )
- {
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Service Instance was not found in AAI by id: " + serviceInstanceId
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
-
- // get variable within incoming json
- String DeleteVcpeResCustServiceRequest = execution.getVariable("DeleteVcpeResCustServiceRequest");
-
- // get SI extracted by GenericGetService
- String serviceInstanceAaiRecord = execution.getVariable("GENGS_service");
-
- utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled)
- serviceInstanceAaiRecord = utils.removeXmlNamespaces(serviceInstanceAaiRecord)
-
- def (TXC_found, TXC_id) = new Tuple(false, null)
- def (BRG_found, BRG_id) = new Tuple(false, null)
- List relatedVnfIdList = []
-
- for(Node rel: utils.getMultNodeObjects(serviceInstanceAaiRecord, "relationship")) {
- def relto = utils.getChildNodeText(rel, "related-to")
- def relink = utils.getChildNodeText(rel, "related-link")
- utils.log("DEBUG", "check: "+relto+" link: "+relink, isDebugEnabled)
-
- if(isBlank(relto) || isBlank(relink)) {
-
- } else if(relto == "generic-vnf") {
- def id = relink.substring(relink.indexOf("/generic-vnf/")+13)
- if(id.endsWith("/")) {
- id = id.substring(0, id.length()-1)
- }
-
- relatedVnfIdList.add(id)
-
- } else if(relto == "allotted-resource") {
- def (type, id) = getAaiAr(execution, relink)
-
- if(isBlank(type) || isBlank(id)) {
-
- } else if(type == "TunnelXConn" || type == "Tunnel XConn") {
- utils.log("DEBUG","Tunnel XConn AR found", isDebugEnabled)
- TXC_found = true
- TXC_id = id
-
- } else if(type == "BRG") {
- utils.log("DEBUG","BRG AR found", isDebugEnabled)
- BRG_found = true
- BRG_id = id
- }
- }
- }
-
- execution.setVariable(Prefix+"TunnelXConn", TXC_found)
- execution.setVariable("TXC_allottedResourceId", TXC_id)
- utils.log("DEBUG", "TXC_allottedResourceId: " + TXC_id, isDebugEnabled)
-
- execution.setVariable(Prefix+"BRG", BRG_found)
- execution.setVariable("BRG_allottedResourceId", BRG_id)
- utils.log("DEBUG", "BRG_allottedResourceId: " + BRG_id, isDebugEnabled)
-
- int vnfsCount = relatedVnfIdList.size()
- execution.setVariable(Prefix+"vnfsCount", vnfsCount)
- utils.log("DEBUG", " "+Prefix+"vnfsCount : " + vnfsCount, isDebugEnabled)
- if(vnfsCount > 0) {
- execution.setVariable(Prefix+"relatedVnfIdList", relatedVnfIdList)
- }
-
- utils.log("DEBUG", " ***** Completed prepareServiceDelete() of DeleteVcpeResCustService ***** ", isDebugEnabled)
- } catch (BpmnError e){
- throw e;
- } catch (Exception ex) {
- sendSyncError(execution)
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. prepareServiceDelete() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- private getAaiAr(DelegateExecution execution, String relink) {
- def isDebugEnabled = execution.getVariable(DebugFlag)
- AaiUtil aaiUtil = new AaiUtil(this)
- String aaiEndpoint = execution.getVariable("URN_aai_endpoint") + relink
-
- utils.log("DEBUG", "get AR info " + aaiEndpoint, isDebugEnabled)
- APIResponse response = aaiUtil.executeAAIGetCall(execution, aaiEndpoint)
-
- int responseCode = response.getStatusCode()
- utils.log("DEBUG", "get AR info responseCode:" + responseCode, isDebugEnabled)
-
- String aaiResponse = response.getResponseBodyAsString()
- utils.log("DEBUG", "get AR info " + aaiResponse, isDebugEnabled)
-
- if(responseCode < 200 || responseCode >= 300 || isBlank(aaiResponse)) {
- return new Tuple2(null, null)
- }
-
- def type = utils.getNodeText1(aaiResponse, "type")
- def id = utils.getNodeText1(aaiResponse, "id")
-
- return new Tuple2(type, id)
- }
-
-
- // *******************************
- //
- // *******************************
- public void prepareVnfAndModulesDelete (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- List vnfList = execution.getVariable(Prefix+"relatedVnfIdList")
- int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount")
- String vnfModelInfoString = ""
- String vnfId = ""
- if (vnfList.size() > 0 ) {
- vnfId = vnfList.get(vnfsDeletedCount.intValue())
- }
-
- execution.setVariable("vnfId", vnfId)
- utils.log("DEBUG", "need to delete vnfId:" + vnfId, isDebugEnabled)
-
- utils.log("DEBUG", " ***** Completed prepareVnfAndModulesDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- // *******************************
- // Validate Vnf request Section -> increment count
- // *******************************
- public void validateVnfDelete (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- int vnfsDeletedCount = execution.getVariable(Prefix+"vnfsDeletedCount")
- vnfsDeletedCount++
-
- execution.setVariable(Prefix+"vnfsDeletedCount", vnfsDeletedCount)
-
- utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteVcpeResCustService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled)
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DeleteVcpeResCustService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
-
- // *****************************************
- // Prepare Completion request Section
- // *****************************************
- public void postProcessResponse (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- String source = execution.getVariable("source")
- String requestId = execution.getVariable("msoRequestId")
-
- String msoCompletionRequest =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:status-message>vCPE Res Cust Service Instance has been deleted successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>BPMN Service Instance macro action: DELETE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- utils.logAudit(xmlMsoCompletionRequest)
- execution.setVariable(Prefix+"Success", true)
- execution.setVariable(Prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest)
- utils.log("DEBUG", " SUCCESS flow, going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DeleteServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage()
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
- }
- }
-
- public void prepareFalloutRequest(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG", " *** STARTED DeleteVcpeResCustService prepareFalloutRequest Process *** ", isDebugEnabled)
-
- try {
- WorkflowException wfex = execution.getVariable("WorkflowException")
- utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled)
- String requestInfo = execution.getVariable(Prefix+"requestInfo")
- utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled)
-
- String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
-
- execution.setVariable(Prefix+"falloutRequest", falloutRequest)
- } catch (Exception ex) {
- utils.log("DEBUG", "Error Occured in DeleteVcpeResCustService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteVcpeResCustService prepareFalloutRequest Process")
- }
- utils.log("DEBUG", "*** COMPLETED DeleteVcpeResCustService prepareFalloutRequest Process ***", isDebugEnabled)
- }
-
-
- public void sendSyncError (DelegateExecution execution) {
- def isDebugEnabled=execution.getVariable(DebugFlag)
- utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteVcpeResCustService ***** ", isDebugEnabled)
-
- try {
- String errorMessage = ""
- if (execution.getVariable("WorkflowException") instanceof WorkflowException) {
- WorkflowException wfe = execution.getVariable("WorkflowException")
- errorMessage = wfe.getErrorMessage()
- } else {
- errorMessage = "Sending Sync Error."
- }
-
- String buildworkflowException =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
- }
-
- public void processJavaException(DelegateExecution execution){
- def isDebugEnabled=execution.getVariable(DebugFlag)
- execution.setVariable("prefix",Prefix)
- try{
- utils.log("DEBUG", "Caught a Java Exception", isDebugEnabled)
- utils.log("DEBUG", "Started processJavaException Method", isDebugEnabled)
- utils.log("DEBUG", "Variables List: " + execution.getVariables(), isDebugEnabled)
- execution.setVariable(Prefix+"unexpectedError", "Caught a Java Lang Exception") // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Caught a Java Lang Exception")
- }catch(BpmnError b){
- utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugEnabled)
- throw b
- }catch(Exception e){
- utils.log("DEBUG", "Caught Exception during processJavaException Method: " + e, isDebugEnabled)
- execution.setVariable(Prefix+"unexpectedError", "Exception in processJavaException method") // Adding this line temporarily until this flows error handling gets updated
- exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception in processJavaException method")
- }
- utils.log("DEBUG", "Completed processJavaException Method", isDebugEnabled)
- }
-
-
-}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy deleted file mode 100644 index f04b7384a1..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRG.groovy +++ /dev/null @@ -1,678 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import org.openecomp.mso.bpmn.common.scripts.*; -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - - -/** - * This groovy class supports the <class>DoCreateAllottedResourceBRG.bpmn</class> process. - * - * @author - * - * Inputs: - * @param - msoRequestId - * @param - isDEbugLogEnabled - * @param - disableRollback - * @param - failExists - O - * @param - serviceInstanceId - * @param - globalCustomerId - O - * @param - subscriptionServiceType - O - * @param - parentServiceInstanceId - * @param - allottedReourceId - O - * @param - allottedResourceModelInfo - * @param - allottedResourceRole - * @param - allottedResourceType - * @param - brgWanMacAddress - * @param - vni - * @param - vgmuxBearerIP - * - * Outputs: - * @param - rollbackData (localRB->null) - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * @param - WorkflowException - O - * @param - allottedResourceId - * @param - allottedResourceName - * - */ -public class DoCreateAllottedResourceBRG extends AbstractServiceTaskProcessor{ - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix="DCARBRG_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - - try { - execution.setVariable("prefix", Prefix) - - //Config Inputs - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay') - if (isBlank(sdncReplDelay)) { - msg = "URN_mso_workflow_sdnc_replication_delay is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncReplDelay", sdncReplDelay) - utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, isDebugEnabled) - - //Request Inputs - if (isBlank(execution.getVariable("serviceInstanceId"))){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("parentServiceInstanceId"))) { - msg = "Input parentServiceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceModelInfo"))) { - msg = "Input allottedResourceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("vni"))) { - msg = "Input vni is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("vgmuxBearerIP"))) { - msg = "Input vgmuxBearerIP is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("brgWanMacAddress"))) { - msg = "Input brgWanMacAddress is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceRole"))) { - msg = "Input allottedResourceRole is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceType"))) { - msg = "Input allottedResourceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void getAaiAR (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) - - String arType = execution.getVariable("allottedResourceType") - String arRole = execution.getVariable("allottedResourceRole") - - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String orchStatus = arUtils.getAROrchStatus(execution) - - String errorMsg = "" - - if (orchStatus != null) // AR was found - { - if ("true".equals(execution.getVariable("failExists"))) - { - errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists" - } - else - { - if ("Active".equals(orchStatus)) - { - execution.setVariable("foundActiveAR", true) - } - else // blanks included - { - errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus - } - } - } - if (!isBlank(errorMsg)) { - utils.log("DEBUG", errorMsg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) - } - utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled) - } - - public void createAaiAR(DelegateExecution execution) { - - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled) - String msg = "" - - String allottedResourceId = execution.getVariable("allottedResourceId") - if (isBlank(allottedResourceId)) - { - allottedResourceId = UUID.randomUUID().toString() - execution.setVariable("allottedResourceId", allottedResourceId) - } - String arUrl = "" - try { - - //AAI PUT - AaiUtil aaiUriUtil = new AaiUtil(this) - String aaiEndpoint = execution.getVariable("URN_aai_endpoint") - String siResourceLink= execution.getVariable("PSI_resourceLink") - - String siUri = "" - utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled) - - if(!isBlank(siResourceLink)) { - utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled) - String[] split = siResourceLink.split("/aai/") - siUri = "/aai/" + split[1] - } - else - { - msg = "Parent Service Link in AAI is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - execution.setVariable("aaiARPath", arUrl) - utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled) - - String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) - - String arType = execution.getVariable("allottedResourceType") - String arRole = execution.getVariable("allottedResourceRole") - String CSI_resourceLink = execution.getVariable("CSI_resourceLink") - String arModelInfo = execution.getVariable("allottedResourceModelInfo") - String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") - String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") - String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") - - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersionId == null) { - modelVersionId = "" - } - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - - String payload = - """<allotted-resource xmlns="${namespace}"> - <id>${allottedResourceId}</id> - <description></description> - <type>${arType}</type> - <role>${arRole}</role> - <selflink></selflink> - <model-invariant-id>${modelInvariantId}</model-invariant-id> - <model-version-id>${modelVersionId}</model-version-id> - <model-customization-id>${modelCustomizationId}</model-customization-id> - <orchestration-status>PendingCreate</orchestration-status> - <operation-status></operation-status> - <relationship-list> - <relationship> - <related-to>service-instance</related-to> - <related-link>${CSI_resourceLink}</related-link> - </relationship> - </relationship-list> - </allotted-resource>""".trim() - - execution.setVariable("AaiARPayload", payload) - utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload) - int responseCode = response.getStatusCode() - utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled) - - String aaiResponse = response.getResponseBodyAsString() - aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) - utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled) - - //200 OK 201 CREATED 202 ACCEPTED - if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) - { - utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled) - } - else{ - utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex) { - msg = "Exception in createAaiAR " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put(Prefix, "disableRollback", disableRollback.toString()) - rollbackData.put(Prefix, "rollbackAAI", "true") - rollbackData.put(Prefix, "allottedResourceId", allottedResourceId) - rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId")) - rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId")) - rollbackData.put(Prefix, "aaiARPath", arUrl) - execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) - String sdncReq = null - - try { - - String allottedResourceId = execution.getVariable("allottedResourceId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String globalCustomerId = execution.getVariable("globalCustomerId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") - String callbackUrl = execution.getVariable("sdncCallbackUrl") - String requestId = execution.getVariable("msoRequestId") - - String brgWanMacAddress = execution.getVariable("brgWanMacAddress") - String vni = execution.getVariable("vni") - String vgmuxBearerIP = execution.getVariable("vgmuxBearerIP") - - String arModelInfo = execution.getVariable("allottedResourceModelInfo") - String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") - String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion") - String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") - String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") - String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName") - - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersion == null) { - modelVersion = "" - } - if (modelUUId == null) { - modelUUId = "" - } - if (modelName == null) { - modelName = "" - } - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - - sdncReq = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>CreateBRGInstance</request-action> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id></service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information></onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <allotted-resource-information> - <allotted-resource-id>${allottedResourceId}</allotted-resource-id> - <allotted-resource-type>brg</allotted-resource-type> - <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id> - <onap-model-information> - <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid> - <model-uuid>${modelUUId}</model-uuid> - <model-customization-uuid>${modelCustomizationId}</model-customization-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - </allotted-resource-information> - <brg-request-input> - <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address> - <vni>${vni}</vni> - <vgmux-bearer-ip>${vgmuxBearerIP}</vgmux-bearer-ip> - </brg-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled) - sdncReq = utils.formatXml(sdncReq) - - } catch(Exception ex) { - msg = "Exception in buildSDNCRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled) - return sdncReq - } - - public void preProcessSDNCAssign(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId) - execution.setVariable("sdncAssignRequest", sdncAssignReq) - utils.logAudit("sdncAssignRequest: " + sdncAssignReq) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled) - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCAssign. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled) - } - - public void preProcessSDNCCreate(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId) - execution.setVariable("sdncCreateRequest", sdncCreateReq) - utils.logAudit("sdncCreateReq: " + sdncCreateReq) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled) - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCCreate. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled) - } - - public void preProcessSDNCActivate(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId) - execution.setVariable("sdncActivateRequest", sdncActivateReq) - utils.logAudit("sdncActivateReq: " + sdncActivateReq) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateBRGInstance<", ">DeleteBRGInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled) - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCActivate. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled) - } - - public void validateSDNCResp(DelegateExecution execution, String response, String method){ - - def isDebugLogEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled) - - if (!"get".equals(method)) - { - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true") - execution.setVariable("rollbackData", rollbackData) - } - - }else{ - utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) - } - - public void preProcessSDNCGet(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled) - try{ - - def callbackUrl = execution.getVariable("sdncCallbackUrl") - // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI - // or from "object-path" in SDNC response for assign when AR does not exist in AA - - String serviceOperation = "" - - if (execution.getVariable("foundActiveAR")) { - def aaiQueryResponse = execution.getVariable("aaiARGetResponse") - serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink") - utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled) - } - else - { - String response = execution.getVariable("sdncAssignResponse") - String data = utils.getNodeXml(response, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") - utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled) - serviceOperation = utils.getNodeText1(data, "object-path") - utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled) - } - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String sdncRequestId = UUID.randomUUID().toString() - - //neeed the same url as used by vfmodules - String SDNCGetRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>query</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - execution.setVariable("sdncGetRequest", SDNCGetRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled) - } - - public void updateAaiAROrchStatus(DelegateExecution execution, String status){ - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) - String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) - utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled) - } - - public void generateOutputs(DelegateExecution execution) - { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled) - try { - String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped - utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled) - String arData = utils.getNodeXml(sdncGetResponse, "brg-topology") - arData = utils.removeXmlNamespaces(arData) - - String brga = utils.getNodeXml(arData, "brg-assignments") - String ari = utils.getNodeXml(arData, "allotted-resource-identifiers") - execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name")) - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in generateOutputs " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled) - - } - - public void preProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - execution.setVariable("rollbackData", null) - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy deleted file mode 100644 index 4d27b82287..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceBRGRollback.groovy +++ /dev/null @@ -1,276 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import org.openecomp.mso.bpmn.common.scripts.*; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.MsoUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - -/** - * This groovy class supports the <class>CreateAllottedResourceBRGRollback.bpmn</class> process. - * - * @author - * - * Inputs: - * @param - msoRequestId - * @param - isDebugLogEnabled - * @param - disableRollback - O - * @param - rollbackData - * - * Outputs: - * @param - rollbackError - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * - */ -public class DoCreateAllottedResourceBRGRollback extends AbstractServiceTaskProcessor{ - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix="DCARBRGRB_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void preProcessRequest (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - execution.setVariable("prefix", Prefix) - String rbType = "DCARBRG_" - try { - - def rollbackData = execution.getVariable("rollbackData") - utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) - - if (rollbackData != null) { - if (rollbackData.hasType(rbType)) { - - execution.setVariable("serviceInstanceId", rollbackData.get(rbType, "serviceInstanceId")) - execution.setVariable("parentServiceInstanceId", rollbackData.get(rbType, "parentServiceInstanceId")) - execution.setVariable("allottedResourceId", rollbackData.get("SERVICEINSTANCE", "allottedResourceId")) - - - def rollbackAAI = rollbackData.get(rbType, "rollbackAAI") - if ("true".equals(rollbackAAI)) - { - execution.setVariable("rollbackAAI",true) - execution.setVariable("aaiARPath", rollbackData.get(rbType, "aaiARPath")) - - } - def rollbackSDNC = rollbackData.get(rbType, "rollbackSDNCassign") - if ("true".equals(rollbackSDNC)) - { - execution.setVariable("rollbackSDNC", true) - execution.setVariable("deactivateSdnc", rollbackData.get(rbType, "rollbackSDNCactivate")) - execution.setVariable("deleteSdnc", rollbackData.get(rbType, "rollbackSDNCcreate")) - execution.setVariable("unassignSdnc", rollbackData.get(rbType, "rollbackSDNCassign")) - - utils.log("DEBUG","sdncDeactivate:\n" + execution.getVariable("deactivateSdnc") , isDebugEnabled) - utils.log("DEBUG","sdncDelete:\n" + execution.getVariable("deleteSdnc"), isDebugEnabled) - utils.log("DEBUG","sdncUnassign:\n" + execution.getVariable("unassignSdnc"), isDebugEnabled) - - execution.setVariable("sdncDeactivateRequest", rollbackData.get(rbType, "sdncActivateRollbackReq")) - execution.setVariable("sdncDeleteRequest", rollbackData.get(rbType, "sdncCreateRollbackReq")) - execution.setVariable("sdncUnassignRequest", rollbackData.get(rbType, "sdncAssignRollbackReq")) - } - - if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true) - { - execution.setVariable("skipRollback", true) - } - } - else { - execution.setVariable("skipRollback", true) - } - } - else { - execution.setVariable("skipRollback", true) - } - if (execution.getVariable("disableRollback").equals("true" )) - { - execution.setVariable("skipRollback", true) - } - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - // aaiARPath set during query (existing AR) - public void updateAaiAROrchStatus(DelegateExecution execution, String status){ - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = null; - utils.log("DEBUG", " *** updateAaiAROrchStatus ***", isDebugEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String aaiARPath = execution.getVariable("aaiARPath") - utils.log("DEBUG", " aaiARPath:" + aaiARPath, isDebugEnabled) - String ar = null; //need this for getting resourceVersion for delete - if (!isBlank(aaiARPath)) - { - ar = arUtils.getARbyLink(execution, aaiARPath, "") - } - if (isBlank(ar)) - { - msg = "AR not found in AAI at:" + aaiARPath - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) - utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled) - } - - public void validateSDNCResp(DelegateExecution execution, String response, String method){ - - def isDebugLogEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled) - - }else{ - - utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - } catch (BpmnError e) { - if ("404".contentEquals(e.getErrorCode())) - { - msg = "SDNC rollback " + method + " returned a 404. Proceding with rollback" - utils.log("DEBUG", msg, isDebugLogEnabled) - } - else { - throw e; - } - } catch(Exception ex) { - msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) - } - - public void deleteAaiAR(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable(DebugFlag) - try{ - utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String ar = null //need to get resource-version - String arLink = execution.getVariable("aaiARPath") - if (!isBlank(arLink)) - { - ar = arUtils.getARbyLink(execution, arLink, "") - } - arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) - } catch (BpmnError e) { - throw e; - }catch(Exception ex){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + ex, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) - } - utils.log("DEBUG", " *** Exit deleteAaiAR *** ", isDebugLogEnabled) - } - - public void postProcessRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled) - String msg = "" - try { - execution.setVariable("rollbackData", null) - boolean skipRollback = execution.getVariable("skipRollback") - if (!skipRollback) - { - execution.setVariable("rolledBack", true) - utils.log("DEBUG","rolledBack", isDebugEnabled) - } - utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled) - - } catch (BpmnError e) { - msg = "Bpmn Exception in postProcessRequest. " - utils.log("DEBUG", msg, isDebugEnabled) - } catch (Exception ex) { - msg = "Exception in postProcessRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - - } - - public void processRollbackException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled) - try{ - utils.log("DEBUG", "Caught an Exception in DoCreateAllottedResourceRollback", isDebugEnabled) - execution.setVariable("rollbackData", null) - execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") - execution.setVariable("WorkflowException", null) - - }catch(BpmnError b){ - utils.log("DEBUG", "BPMN Error during processRollbackExceptions Method: ", isDebugEnabled) - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processRollbackExceptions Method: " + e.getMessage(), isDebugEnabled) - } - - utils.log("DEBUG", " Exit processRollbackException", isDebugEnabled) - } - - public void processRollbackJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled) - try{ - execution.setVariable("rollbackData", null) - execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") - utils.log("DEBUG", "Caught Exception in processRollbackJavaException", isDebugEnabled) - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception in processRollbackJavaException " + e.getMessage(), isDebugEnabled) - } - utils.log("DEBUG", "***** Exit processRollbackJavaException *****", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy deleted file mode 100644 index dc248845b9..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXC.groovy +++ /dev/null @@ -1,674 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import org.openecomp.mso.bpmn.common.scripts.*; -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.core.RollbackData -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.core.json.JsonUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - - -/** - * This groovy class supports the <class>DoCreateAllottedResourceTXC.bpmn</class> process. - * - * @author - * - * Inputs: - * @param - msoRequestId - * @param - isDEbugLogEnabled - * @param - disableRollback - * @param - failExists - O - * @param - serviceInstanceId - * @param - globalCustomerId - O - * @param - subscriptionServiceType - O - * @param - parentServiceInstanceId - * @param - allottedReourceId - O - * @param - allottedResourceModelInfo - * @param - allottedResourceRole - * @param - allottedResourceType - * @param - brgWanMacAddress - * - * Outputs: - * @param - rollbackData (localRB->null) - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * @param - WorkflowException - O - * @param - allottedResourceId - * @param - allottedResourceName - * @param - vni - * @param - vgmuxBearerIP - * @param - vgmuxLanIP - * - */ -public class DoCreateAllottedResourceTXC extends AbstractServiceTaskProcessor{ - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix="DCARTXC_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - public void preProcessRequest (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - - try { - String msoRequestId = execution.getVariable("msoRequestId") - utils.log("DEBUG", " msoRequestId = " + msoRequestId, isDebugEnabled) - - execution.setVariable("prefix", Prefix) - - //Config Inputs - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - String sdncReplDelay = execution.getVariable('URN_mso_workflow_sdnc_replication_delay') - if (isBlank(sdncReplDelay)) { - msg = "URN_mso_workflow_sdnc_replication_delay is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncReplDelay", sdncReplDelay) - utils.log("DEBUG","SDNC replication delay: " + sdncReplDelay, isDebugEnabled) - - //Request Inputs - if (isBlank(execution.getVariable("serviceInstanceId"))){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("parentServiceInstanceId"))) { - msg = "Input parentServiceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceModelInfo"))) { - msg = "Input allottedResourceModelInfo is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("brgWanMacAddress"))) { - msg = "Input brgWanMacAddress is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceRole"))) { - msg = "Input allottedResourceRole is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceType"))) { - msg = "Input allottedResourceType is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void getAaiAR (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) - - String arType = execution.getVariable("allottedResourceType") - String arRole = execution.getVariable("allottedResourceRole") - - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String orchStatus = arUtils.getAROrchStatus(execution) - - String errorMsg = "" - - if (orchStatus != null) // AR was found - { - if ("true".equals(execution.getVariable("failExists"))) - { - errorMsg = "Allotted resource " + arType + " with Role " + arRole + " already exists" - } - else - { - if ("Active".equals(orchStatus)) - { - execution.setVariable("foundActiveAR", true) - } - else // blanks included - { - errorMsg = "Allotted Resource " + arType + " with Role " + arRole + " already exists in an incomplete state -" + orchStatus - } - } - } - if (!isBlank(errorMsg)) { - utils.log("DEBUG", errorMsg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) - } - utils.log("DEBUG"," *****Exit getAaiAR *****", isDebugEnabled) - } - - public void createAaiAR(DelegateExecution execution) { - - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** createAaiAR ***** ", isDebugEnabled) - String msg = "" - - String allottedResourceId = execution.getVariable("allottedResourceId") - if (isBlank(allottedResourceId)) - { - allottedResourceId = UUID.randomUUID().toString() - execution.setVariable("allottedResourceId", allottedResourceId) - } - String arUrl = "" - try { - - //AAI PUT - AaiUtil aaiUriUtil = new AaiUtil(this) - String aaiEndpoint = execution.getVariable("URN_aai_endpoint") - String siResourceLink= execution.getVariable("PSI_resourceLink") - - String siUri = "" - utils.log("DEBUG", "PSI_resourceLink:" + siResourceLink, isDebugEnabled) - - if(!isBlank(siResourceLink)) { - utils.log("DEBUG", "Incoming PSI Resource Link is: " + siResourceLink, isDebugEnabled) - String[] split = siResourceLink.split("/aai/") - siUri = "/aai/" + split[1] - } - else - { - msg = "Parent Service Link in AAI is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - arUrl = "${aaiEndpoint}${siUri}" + "/allotted-resources/allotted-resource/" + UriUtils.encode(allottedResourceId,"UTF-8") - execution.setVariable("aaiARPath", arUrl) - utils.log("DEBUG", "GET AllottedResource AAI URL is:\n" + arUrl, isDebugEnabled) - - String namespace = aaiUriUtil.getNamespaceFromUri(execution, arUrl) - - String arType = execution.getVariable("allottedResourceType") - String arRole = execution.getVariable("allottedResourceRole") - String CSI_resourceLink = execution.getVariable("CSI_resourceLink") - String arModelInfo = execution.getVariable("allottedResourceModelInfo") - utils.log("DEBUG", "arModelInfo is:\n" + arModelInfo, isDebugEnabled) - String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") - String modelVersionId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") - String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") - - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersionId == null) { - modelVersionId = "" - } - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - - String payload = - """<allotted-resource xmlns="${namespace}"> - <id>${allottedResourceId}</id> - <description></description> - <type>${arType}</type> - <role>${arRole}</role> - <selflink></selflink> - <model-invariant-id>${modelInvariantId}</model-invariant-id> - <model-version-id>${modelVersionId}</model-version-id> - <model-customization-id>${modelCustomizationId}</model-customization-id> - <orchestration-status>PendingCreate</orchestration-status> - <operation-status></operation-status> - <relationship-list> - <relationship> - <related-to>service-instance</related-to> - <related-link>${CSI_resourceLink}</related-link> - </relationship> - </relationship-list> - </allotted-resource>""".trim() - - execution.setVariable("AaiARPayload", payload) - utils.log("DEBUG", " payload to create AllottedResource in AAI:" + "\n" + payload, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, arUrl, payload) - int responseCode = response.getStatusCode() - utils.log("DEBUG", "AllottedResource AAI PUT responseCode:" + responseCode, isDebugEnabled) - - String aaiResponse = response.getResponseBodyAsString() - aaiResponse = StringEscapeUtils.unescapeXml(aaiResponse) - utils.log("DEBUG", "AllottedResource AAI PUT responseStr:" + aaiResponse, isDebugEnabled) - - //200 OK 201 CREATED 202 ACCEPTED - if(responseCode == 200 || responseCode == 201 || responseCode == 202 ) - { - utils.log("DEBUG", "AAI PUT AllottedResource received a Good Response", isDebugEnabled) - } - else{ - utils.log("DEBUG", "AAI Put AllottedResouce received a Bad Response Code: " + responseCode, isDebugEnabled) - exceptionUtil.MapAAIExceptionToWorkflowExceptionGeneric(execution, aaiResponse, responseCode) - throw new BpmnError("MSOWorkflowException") - } - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex) { - msg = "Exception in createAaiAR " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - - //start rollback set up - RollbackData rollbackData = new RollbackData() - def disableRollback = execution.getVariable("disableRollback") - rollbackData.put(Prefix, "disableRollback", disableRollback.toString()) - rollbackData.put(Prefix, "rollbackAAI", "true") - rollbackData.put(Prefix, "allottedResourceId", allottedResourceId) - rollbackData.put(Prefix, "serviceInstanceId", execution.getVariable("serviceInstanceId")) - rollbackData.put(Prefix, "parentServiceInstanceId", execution.getVariable("parentServiceInstanceId")) - rollbackData.put(Prefix, "aaiARPath", arUrl) - execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG"," *** Exit createAaiAR*** ", isDebugEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) - String sdncReq = null - - try { - - String allottedResourceId = execution.getVariable("allottedResourceId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String globalCustomerId = execution.getVariable("globalCustomerId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") - String serviceChainServiceInstanceId = execution.getVariable("serviceChainServiceInstanceId") - String callbackUrl = execution.getVariable("sdncCallbackUrl") - String requestId = execution.getVariable("msoRequestId") - - String brgWanMacAddress = execution.getVariable("brgWanMacAddress") - - String arModelInfo = execution.getVariable("allottedResourceModelInfo") - String modelInvariantId = jsonUtil.getJsonValue(arModelInfo, "modelInvariantUuid") - String modelVersion = jsonUtil.getJsonValue(arModelInfo, "modelVersion") - String modelUUId = jsonUtil.getJsonValue(arModelInfo, "modelUuid") - String modelCustomizationId = jsonUtil.getJsonValue(arModelInfo, "modelCustomizationUuid") - String modelName = jsonUtil.getJsonValue(arModelInfo, "modelName") - - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersion == null) { - modelVersion = "" - } - if (modelUUId == null) { - modelUUId = "" - } - if (modelName == null) { - modelName = "" - } - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - - sdncReq = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>CreateTunnelXConnInstance</request-action> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id></service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information></onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <allotted-resource-information> - <allotted-resource-id>${allottedResourceId}</allotted-resource-id> - <allotted-resource-type>tunnelxconn</allotted-resource-type> - <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id> - <onap-model-information> - <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid> - <model-uuid>${modelUUId}</model-uuid> - <model-customization-uuid>${modelCustomizationId}</model-customization-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - </allotted-resource-information> - <tunnelxconn-request-input> - <brg-wan-mac-address>${brgWanMacAddress}</brg-wan-mac-address> - </tunnelxconn-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled) - sdncReq = utils.formatXml(sdncReq) - - } catch(Exception ex) { - msg = "Exception in buildSDNCRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled) - return sdncReq - } - - public void preProcessSDNCAssign(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCAssign *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncAssignReq = buildSDNCRequest(execution, "assign", sdncRequestId) - execution.setVariable("sdncAssignRequest", sdncAssignReq) - utils.logAudit("sdncAssignRequest: " + sdncAssignReq) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncAssignRollbackReq = sdncAssignReq.replace(">assign<", ">unassign<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "sdncAssignRollbackReq", sdncAssignRollbackReq) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","sdncAssignRollbackReq:\n" + sdncAssignRollbackReq, isDebugEnabled) - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCAssign. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCAssign *****", isDebugEnabled) - } - - public void preProcessSDNCCreate(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCCreate *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncCreateReq = buildSDNCRequest(execution, "create", sdncRequestId) - execution.setVariable("sdncCreateRequest", sdncCreateReq) - utils.logAudit("sdncCreateReq: " + sdncCreateReq) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncCreateRollbackReq = sdncCreateReq.replace(">create<", ">delete<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "sdncCreateRollbackReq", sdncCreateRollbackReq) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","sdncCreateRollbackReq:\n" + sdncCreateRollbackReq, isDebugEnabled) - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCCreate. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCCreate *****", isDebugEnabled) - } - - public void preProcessSDNCActivate(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCActivate *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncActivateReq = buildSDNCRequest(execution, "activate", sdncRequestId) - execution.setVariable("sdncActivateRequest", sdncActivateReq) - utils.logAudit("sdncActivateReq: " + sdncActivateReq) - def sdncRequestId2 = UUID.randomUUID().toString() - String sdncActivateRollbackReq = sdncActivateReq.replace(">activate<", ">deactivate<").replace(">CreateTunnelXConnInstance<", ">DeleteTunnelXConnInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "sdncActivateRollbackReq", sdncActivateRollbackReq) - execution.setVariable("rollbackData", rollbackData) - - utils.log("DEBUG","sdncActivateRollbackReq:\n" + sdncActivateRollbackReq, isDebugEnabled) - utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCActivate. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCActivate *****", isDebugEnabled) - } - - public void validateSDNCResp(DelegateExecution execution, String response, String method){ - - def isDebugLogEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled) - - if (!"get".equals(method)) - { - def rollbackData = execution.getVariable("rollbackData") - rollbackData.put(Prefix, "rollback" + "SDNC" + method, "true") - execution.setVariable("rollbackData", rollbackData) - } - - }else{ - utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) - } - - public void preProcessSDNCGet(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", "*** preProcessSDNCGet *** ", isDebugLogEnabled) - try{ - - def callbackUrl = execution.getVariable("sdncCallbackUrl") - // serviceOperation (URI for topology GET) will be retrieved from "selflink" from AAI if active AR exists in AAI - // or from "object-path" in SDNC response for assign when AR does not exist in AA - - String serviceOperation = "" - - if (execution.getVariable("foundActiveAR")) { - def aaiQueryResponse = execution.getVariable("aaiARGetResponse") - serviceOperation = utils.getNodeText1(aaiQueryResponse, "selflink") - utils.log("DEBUG", "AR service operation/aaiARSelfLink: " + serviceOperation, isDebugLogEnabled) - } - else - { - String response = execution.getVariable("sdncAssignResponse") - String data = utils.getNodeXml(response, "response-data") - data = data.replaceAll("<", "<") - data = data.replaceAll(">", ">") - utils.log("DEBUG", "Assign responseData: " + data, isDebugLogEnabled) - serviceOperation = utils.getNodeText1(data, "object-path") - utils.log("DEBUG", "AR service operation:" + serviceOperation, isDebugLogEnabled) - } - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String sdncRequestId = UUID.randomUUID().toString() - - //neeed the same url as used by vfmodules - String SDNCGetRequest = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>query</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - execution.setVariable("sdncGetRequest", SDNCGetRequest) - - }catch(Exception e){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + e.getMessage()) - } - utils.log("DEBUG", "*** Exit preProcessSDNCGet *** ", isDebugLogEnabled) - } - - public void updateAaiAROrchStatus(DelegateExecution execution, String status){ - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) - String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) or create - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) - utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled) - } - - public void generateOutputs(DelegateExecution execution) - { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** generateOutputs ***** ", isDebugEnabled) - try { - String sdncGetResponse = execution.getVariable("enhancedCallbackRequestData") //unescaped - utils.log("DEBUG", "resp:" + sdncGetResponse, isDebugEnabled) - String arData = utils.getNodeXml(sdncGetResponse, "tunnelxconn-topology") - arData = utils.removeXmlNamespaces(arData) - - String txca = utils.getNodeXml(arData, "tunnelxconn-assignments") - execution.setVariable("vni", utils.getNodeText1(txca, "vni")) - execution.setVariable("vgmuxBearerIP", utils.getNodeText1(txca, "vgmux-bearer-ip")) - execution.setVariable("vgmuxLanIP", utils.getNodeText1(txca, "vgmux-lan-ip")) - - String ari = utils.getNodeXml(arData, "allotted-resource-identifiers") - execution.setVariable("allotedResourceName", utils.getNodeText1(ari, "allotted-resource-name")) - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error in generateOutputs ", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in generateOutputs " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit generateOutputs *** ", isDebugEnabled) - - } - - public void preProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** preProcessRollback ***** ", isDebugEnabled) - try { - - Object workflowException = execution.getVariable("WorkflowException"); - - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Prev workflowException: " + workflowException.getErrorMessage(), isDebugEnabled) - execution.setVariable("prevWorkflowException", workflowException); - //execution.setVariable("WorkflowException", null); - } - } catch (BpmnError e) { - utils.log("DEBUG", "BPMN Error during preProcessRollback", isDebugEnabled) - } catch(Exception ex) { - String msg = "Exception in preProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit preProcessRollback *** ", isDebugEnabled) - } - - public void postProcessRollback (DelegateExecution execution) { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** postProcessRollback ***** ", isDebugEnabled) - String msg = "" - try { - Object workflowException = execution.getVariable("prevWorkflowException"); - if (workflowException instanceof WorkflowException) { - utils.log("DEBUG", "Setting prevException to WorkflowException: ", isDebugEnabled) - execution.setVariable("WorkflowException", workflowException); - } - execution.setVariable("rollbackData", null) - } catch (BpmnError b) { - utils.log("DEBUG", "BPMN Error during postProcessRollback", isDebugEnabled) - throw b; - } catch(Exception ex) { - msg = "Exception in postProcessRollback. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - utils.log("DEBUG"," *** Exit postProcessRollback *** ", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy deleted file mode 100644 index b6efced8fe..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoCreateAllottedResourceTXCRollback.groovy +++ /dev/null @@ -1,276 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import org.openecomp.mso.bpmn.common.scripts.*; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.MsoUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - -/** - * This groovy class supports the <class>CreateAllottedResourceTXCRollback.bpmn</class> process. - * - * @author - * - * Inputs: - * @param - msoRequestId - * @param - isDebugLogEnabled - * @param - disableRollback - O - * @param - rollbackData - * - * Outputs: - * @param - rollbackError - * @param - rolledBack (no localRB->null, localRB F->false, localRB S->true) - * - */ -public class DoCreateAllottedResourceTXCRollback extends AbstractServiceTaskProcessor{ - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix="DCARTXCRB_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void preProcessRequest (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - execution.setVariable("prefix", Prefix) - String rbType = "DCARTXC_" - try { - - def rollbackData = execution.getVariable("rollbackData") - utils.log("DEBUG", "RollbackData:" + rollbackData, isDebugEnabled) - - if (rollbackData != null) { - if (rollbackData.hasType(rbType)) { - - execution.setVariable("serviceInstanceId", rollbackData.get(rbType, "serviceInstanceId")) - execution.setVariable("parentServiceInstanceId", rollbackData.get(rbType, "parentServiceInstanceId")) - execution.setVariable("allottedResourceId", rollbackData.get("SERVICEINSTANCE", "allottedResourceId")) - - - def rollbackAAI = rollbackData.get(rbType, "rollbackAAI") - if ("true".equals(rollbackAAI)) - { - execution.setVariable("rollbackAAI",true) - execution.setVariable("aaiARPath", rollbackData.get(rbType, "aaiARPath")) - - } - def rollbackSDNC = rollbackData.get(rbType, "rollbackSDNCassign") - if ("true".equals(rollbackSDNC)) - { - execution.setVariable("rollbackSDNC", true) - execution.setVariable("deactivateSdnc", rollbackData.get(rbType, "rollbackSDNCactivate")) - execution.setVariable("deleteSdnc", rollbackData.get(rbType, "rollbackSDNCcreate")) - execution.setVariable("unassignSdnc", rollbackData.get(rbType, "rollbackSDNCassign")) - - utils.log("DEBUG","sdncDeactivate:\n" + execution.getVariable("deactivateSdnc") , isDebugEnabled) - utils.log("DEBUG","sdncDelete:\n" + execution.getVariable("deleteSdnc"), isDebugEnabled) - utils.log("DEBUG","sdncUnassign:\n" + execution.getVariable("unassignSdnc"), isDebugEnabled) - - execution.setVariable("sdncDeactivateRequest", rollbackData.get(rbType, "sdncActivateRollbackReq")) - execution.setVariable("sdncDeleteRequest", rollbackData.get(rbType, "sdncCreateRollbackReq")) - execution.setVariable("sdncUnassignRequest", rollbackData.get(rbType, "sdncAssignRollbackReq")) - } - - if (execution.getVariable("rollbackAAI") != true && execution.getVariable("rollbackSDNC") != true) - { - execution.setVariable("skipRollback", true) - } - } - else { - execution.setVariable("skipRollback", true) - } - } - else { - execution.setVariable("skipRollback", true) - } - if (execution.getVariable("disableRollback").equals("true" )) - { - execution.setVariable("skipRollback", true) - } - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - // aaiARPath set during query (existing AR) - public void updateAaiAROrchStatus(DelegateExecution execution, String status){ - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = null; - utils.log("DEBUG", " *** updateAaiAROrchStatus ***", isDebugEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String aaiARPath = execution.getVariable("aaiARPath") - utils.log("DEBUG", " aaiARPath:" + aaiARPath, isDebugEnabled) - String ar = null; //need this for getting resourceVersion for delete - if (!isBlank(aaiARPath)) - { - ar = arUtils.getARbyLink(execution, aaiARPath, "") - } - if (isBlank(ar)) - { - msg = "AR not found in AAI at:" + aaiARPath - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) - utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled) - } - - public void validateSDNCResp(DelegateExecution execution, String response, String method){ - - def isDebugLogEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled) - - }else{ - - utils.log("DEBUG", "Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled) - throw new BpmnError("MSOWorkflowException") - } - } catch (BpmnError e) { - if ("404".contentEquals(e.getErrorCode())) - { - msg = "SDNC rollback " + method + " returned a 404. Proceding with rollback" - utils.log("DEBUG", msg, isDebugLogEnabled) - } - else { - throw e; - } - } catch(Exception ex) { - msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) - } - - public void deleteAaiAR(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable(DebugFlag) - try{ - utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String ar = null //need to get resource-version - String arLink = execution.getVariable("aaiARPath") - if (!isBlank(arLink)) - { - ar = arUtils.getARbyLink(execution, arLink, "") - } - arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) - } catch (BpmnError e) { - throw e; - }catch(Exception ex){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + ex, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) - } - utils.log("DEBUG", " *** Exit deleteAaiAR *** ", isDebugLogEnabled) - } - - public void postProcessRequest(DelegateExecution execution) { - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** postProcessRequest ***** ", isDebugEnabled) - String msg = "" - try { - execution.setVariable("rollbackData", null) - boolean skipRollback = execution.getVariable("skipRollback") - if (!skipRollback) - { - execution.setVariable("rolledBack", true) - utils.log("DEBUG","rolledBack", isDebugEnabled) - } - utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled) - - } catch (BpmnError e) { - msg = "Bpmn Exception in postProcessRequest. " - utils.log("DEBUG", msg, isDebugEnabled) - } catch (Exception ex) { - msg = "Exception in postProcessRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - } - - } - - public void processRollbackException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** processRollbackException ***** ", isDebugEnabled) - try{ - utils.log("DEBUG", "Caught an Exception in DoCreateAllottedResourceRollback", isDebugEnabled) - execution.setVariable("rollbackData", null) - execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", "Caught exception in AllottedResource Create Rollback") - execution.setVariable("WorkflowException", null) - - }catch(BpmnError b){ - utils.log("DEBUG", "BPMN Error during processRollbackExceptions Method: ", isDebugEnabled) - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception during processRollbackExceptions Method: " + e.getMessage(), isDebugEnabled) - } - - utils.log("DEBUG", " Exit processRollbackException", isDebugEnabled) - } - - public void processRollbackJavaException(DelegateExecution execution){ - def isDebugEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** processRollbackJavaException ***** ", isDebugEnabled) - try{ - execution.setVariable("rollbackData", null) - execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", "Caught Java exception in AllottedResource Create Rollback") - utils.log("DEBUG", "Caught Exception in processRollbackJavaException", isDebugEnabled) - - }catch(Exception e){ - utils.log("DEBUG", "Caught Exception in processRollbackJavaException " + e.getMessage(), isDebugEnabled) - } - utils.log("DEBUG", "***** Exit processRollbackJavaException *****", isDebugEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy deleted file mode 100644 index 83ef53d5dd..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceBRG.groovy +++ /dev/null @@ -1,372 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import org.openecomp.mso.bpmn.common.scripts.*; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.MsoUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - -/** - * This groovy class supports the <class>DoDeleteAllottedResourceBRG.bpmn</class> process. - * - * @author - * - * Inputs: - * @param - msoRequestId - * @param - isDebugLogEnabled - * @param - disableRollback - O ignored - * @param - failNotfound - O - * @param - serviceInstanceId - * @param - globalCustomerId - O - * @param - subscriptionServiceType - O - * @param - parentServiceInstanceId - * @param - allottedResourceId - * - * Outputs: - * @param - rollbackData - N/A - * @param - rolledBack - true if no deletions performed - * @param - WorkflowException - O - * @param - wasDeleted - O (ie not silentSuccess) - * - */ -public class DoDeleteAllottedResourceBRG extends AbstractServiceTaskProcessor{ - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix="DDARBRG_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void preProcessRequest (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - - try { - execution.setVariable("prefix", Prefix) - - //Config Inputs - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - //Request Inputs - if (isBlank(execution.getVariable("serviceInstanceId"))){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceId"))){ - msg = "Input allottedResourceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void getAaiAR (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) - - String allottedResourceId = execution.getVariable("allottedResourceId") - - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String ar = arUtils.getARbyId(execution, allottedResourceId) - - String errorMsg = "" - if (isBlank(ar)) // AR was !found - { - errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId - } - else - { - String aaiARPath = execution.getVariable("aaiARPath") - String parentServiceInstanceId = arUtils.getPSIFmARLink(execution, aaiARPath) - execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) - } - if (!isBlank(errorMsg)) { - utils.log("DEBUG", errorMsg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) - } - utils.log("DEBUG"," ***** getAaiAR *****", isDebugEnabled) - - } - - // aaiARPath set during query (existing AR) - public void updateAaiAROrchStatus(DelegateExecution execution, String status){ - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) - String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) - utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) - String sdncReq = null - - try { - - String allottedResourceId = execution.getVariable("allottedResourceId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") - String globalCustomerId = execution.getVariable("globalCustomerId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - - String callbackUrl = execution.getVariable("sdncCallbackUrl") - String requestId = execution.getVariable("msoRequestId") - - String serviceChainServiceInstanceId = "" - String sourceNetworkId = "" - String sourceNetworkRole = "" - String allottedResourceRole = "" - - String arModelInfo = "" - String modelInvariantId = "" - String modelVersion = "" - String modelUUId = "" - String modelCustomizationId = "" - String modelName = "" - - - sdncReq = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>brg-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>DeleteBRGInstance</request-action> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id></service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information></onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <allotted-resource-information> - <allotted-resource-id>${allottedResourceId}</allotted-resource-id> - <allotted-resource-type>brg</allotted-resource-type> - <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id> - <onap-model-information> - <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid> - <model-uuid>${modelUUId}</model-uuid> - <model-customization-uuid>${modelCustomizationId}</model-customization-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - </allotted-resource-information> - <brg-request-input> - </brg-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled) - sdncReq = utils.formatXml(sdncReq) - - } catch(Exception ex) { - msg = "Exception in buildSDNCRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled) - return sdncReq - } - - public void preProcessSDNCUnassign(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCUnassign *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncUnassignReq = buildSDNCRequest(execution, "unassign", sdncRequestId) - execution.setVariable("sdncUnassignRequest", sdncUnassignReq) - utils.logAudit("sdncUnassignRequest: " + sdncUnassignReq) - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCUnassign. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCUnassign *****", isDebugEnabled) - } - - public void preProcessSDNCDelete(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncDeleteReq = buildSDNCRequest(execution, "delete", sdncRequestId) - execution.setVariable("sdncDeleteRequest", sdncDeleteReq) - utils.logAudit("sdncDeleteReq: " + sdncDeleteReq) - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled) - } - - public void preProcessSDNCDeactivate(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCDeactivate *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncDeactivateReq = buildSDNCRequest(execution, "deactivate", sdncRequestId) - execution.setVariable("sdncDeactivateRequest", sdncDeactivateReq) - utils.logAudit("sdncDeactivateReq: " + sdncDeactivateReq) - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDeactivate. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCDeactivate *****", isDebugEnabled) - } - - public void validateSDNCResp(DelegateExecution execution, String response, String method){ - - def isDebugLogEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled) - - }else{ - String sdncRespCode = execution.getVariable(Prefix + 'sdncRequestDataResponseCode') - utils.log("DEBUG", method + " AllottedResource received error response from SDNC. ResponseCode:" + sdncRespCode, isDebugLogEnabled) - if (sdncRespCode.equals("404") && "deactivate".equals(method)) - { - execution.setVariable("ARNotFoundInSDNC", true) - if ("true".equals(execution.getVariable("failNotFound"))) - { - msg = "Allotted Resource Not found in SDNC" - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - else - { - execution.setVariable("wasDeleted", false) - } - } - else - { - throw new BpmnError("MSOWorkflowException") - } - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) - } - - public void deleteAaiAR(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable(DebugFlag) - try{ - utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String ar = null //need to get resource-version again - String arLink = execution.getVariable("aaiARPath") - if (!isBlank(arLink)) - { - ar = arUtils.getARbyLink(execution, arLink, "") - } - arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) - } catch (BpmnError e) { - throw e; - }catch(Exception ex){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + ex, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) - } - utils.log("DEBUG", " *** Exit deleteAaiAR *** ", isDebugLogEnabled) - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy deleted file mode 100644 index 2c531b4224..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/vcpe/scripts/DoDeleteAllottedResourceTXC.groovy +++ /dev/null @@ -1,372 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. 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.vcpe.scripts; - -import org.openecomp.mso.bpmn.common.scripts.*; -import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor -import org.openecomp.mso.bpmn.core.WorkflowException -import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil -import org.openecomp.mso.bpmn.common.scripts.MsoUtils -import org.openecomp.mso.bpmn.common.scripts.AaiUtil -import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils -import org.openecomp.mso.rest.APIResponse - -import java.util.UUID; -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.apache.commons.lang3.* -import org.springframework.web.util.UriUtils; -import static org.apache.commons.lang3.StringUtils.* - -/** - * This groovy class supports the <class>DoDeleteAllottedResourceTXC.bpmn</class> process. - * - * @author - * - * Inputs: - * @param - msoRequestId - * @param - isDebugLogEnabled - * @param - disableRollback - O ignored - * @param - failNotfound - O - * @param - serviceInstanceId - * @param - globalCustomerId - O - * @param - subscriptionServiceType - O - * @param - parentServiceInstanceId - * @param - allottedResourceId - * - * Outputs: - * @param - rollbackData - N/A - * @param - rolledBack - true if no deletions performed - * @param - WorkflowException - O - * @param - wasDeleted - O (ie not silentSuccess) - * - */ -public class DoDeleteAllottedResourceTXC extends AbstractServiceTaskProcessor{ - - private static final String DebugFlag = "isDebugLogEnabled" - - String Prefix="DDARTXC_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void preProcessRequest (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessRequest *****", isDebugEnabled) - - try { - execution.setVariable("prefix", Prefix) - - //Config Inputs - String sdncCallbackUrl = execution.getVariable('URN_mso_workflow_sdncadapter_callback') - if (isBlank(sdncCallbackUrl)) { - msg = "URN_mso_workflow_sdncadapter_callback is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) - utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - - //Request Inputs - if (isBlank(execution.getVariable("serviceInstanceId"))){ - msg = "Input serviceInstanceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - if (isBlank(execution.getVariable("allottedResourceId"))){ - msg = "Input allottedResourceId is null" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } - - }catch(BpmnError b){ - utils.log("DEBUG", "Rethrowing MSOWorkflowException", isDebugEnabled) - throw b - } catch (Exception ex){ - msg = "Exception in preProcessRequest " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) - } - - public void getAaiAR (DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG"," ***** getAaiAR ***** ", isDebugEnabled) - - String allottedResourceId = execution.getVariable("allottedResourceId") - - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String ar = arUtils.getARbyId(execution, allottedResourceId) - - String errorMsg = "" - if (isBlank(ar)) // AR was !found - { - errorMsg = "Allotted resource not found in AAI with AllottedResourceId:" + allottedResourceId - } - else - { - String aaiARPath = execution.getVariable("aaiARPath") - String parentServiceInstanceId = arUtils.getPSIFmARLink(execution, aaiARPath) - execution.setVariable("parentServiceInstanceId", parentServiceInstanceId) - } - if (!isBlank(errorMsg)) { - utils.log("DEBUG", errorMsg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, errorMsg) - } - utils.log("DEBUG"," ***** getAaiAR *****", isDebugEnabled) - - } - - // aaiARPath set during query (existing AR) - public void updateAaiAROrchStatus(DelegateExecution execution, String status){ - def isDebugEnabled = execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** updateAaiAROrchStatus *** ", isDebugEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String aaiARPath = execution.getVariable("aaiARPath") //set during query (existing AR) - String orchStatus = arUtils.updateAROrchStatus(execution, status, aaiARPath) - utils.log("DEBUG", " *** Exit updateAaiAROrchStatus *** ", isDebugEnabled) - } - - public String buildSDNCRequest(DelegateExecution execution, String action, String sdncRequestId) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** buildSDNCRequest *****", isDebugEnabled) - String sdncReq = null - - try { - - String allottedResourceId = execution.getVariable("allottedResourceId") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String parentServiceInstanceId = execution.getVariable("parentServiceInstanceId") - String globalCustomerId = execution.getVariable("globalCustomerId") - String subscriptionServiceType = execution.getVariable("subscriptionServiceType") - - String callbackUrl = execution.getVariable("sdncCallbackUrl") - String requestId = execution.getVariable("msoRequestId") - - String serviceChainServiceInstanceId = "" - String sourceNetworkId = "" - String sourceNetworkRole = "" - String allottedResourceRole = "" - - String arModelInfo = "" - String modelInvariantId = "" - String modelVersion = "" - String modelUUId = "" - String modelCustomizationId = "" - String modelName = "" - - - sdncReq = - """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1" - xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1" - xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1"> - <sdncadapter:RequestHeader> - <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId> - <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId> - <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction> - <sdncadapter:SvcOperation>tunnelxconn-topology-operation</sdncadapter:SvcOperation> - <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl> - </sdncadapter:RequestHeader> - <sdncadapterworkflow:SDNCRequestData> - <request-information> - <request-id>${requestId}</request-id> - <request-action>DeleteTunnelXConnInstance</request-action> - <source>MSO</source> - <notification-url/> - <order-number/> - <order-version/> - </request-information> - <service-information> - <service-id></service-id> - <subscription-service-type>${subscriptionServiceType}</subscription-service-type> - <onap-model-information></onap-model-information> - <service-instance-id>${serviceInstanceId}</service-instance-id> - <subscriber-name/> - <global-customer-id>${globalCustomerId}</global-customer-id> - </service-information> - <allotted-resource-information> - <allotted-resource-id>${allottedResourceId}</allotted-resource-id> - <allotted-resource-type>tunnelxconn</allotted-resource-type> - <parent-service-instance-id>${parentServiceInstanceId}</parent-service-instance-id> - <onap-model-information> - <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid> - <model-uuid>${modelUUId}</model-uuid> - <model-customization-uuid>${modelCustomizationId}</model-customization-uuid> - <model-version>${modelVersion}</model-version> - <model-name>${modelName}</model-name> - </onap-model-information> - </allotted-resource-information> - <tunnelxconn-request-input> - </tunnelxconn-request-input> - </sdncadapterworkflow:SDNCRequestData> - </sdncadapterworkflow:SDNCAdapterWorkflowRequest>""" - - utils.log("DEBUG","sdncRequest:\n" + sdncReq, isDebugEnabled) - sdncReq = utils.formatXml(sdncReq) - - } catch(Exception ex) { - msg = "Exception in buildSDNCRequest. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit buildSDNCRequest *****", isDebugEnabled) - return sdncReq - } - - public void preProcessSDNCUnassign(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCUnassign *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncUnassignReq = buildSDNCRequest(execution, "unassign", sdncRequestId) - execution.setVariable("sdncUnassignRequest", sdncUnassignReq) - utils.logAudit("sdncUnassignRequest: " + sdncUnassignReq) - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCUnassign. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCUnassign *****", isDebugEnabled) - } - - public void preProcessSDNCDelete(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncDeleteReq = buildSDNCRequest(execution, "delete", sdncRequestId) - execution.setVariable("sdncDeleteRequest", sdncDeleteReq) - utils.logAudit("sdncDeleteReq: " + sdncDeleteReq) - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDelete. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled) - } - - public void preProcessSDNCDeactivate(DelegateExecution execution) { - - def isDebugEnabled = execution.getVariable(DebugFlag) - String msg = "" - utils.log("DEBUG"," ***** preProcessSDNCDeactivate *****", isDebugEnabled) - - try { - String sdncRequestId = UUID.randomUUID().toString() - String sdncDeactivateReq = buildSDNCRequest(execution, "deactivate", sdncRequestId) - execution.setVariable("sdncDeactivateRequest", sdncDeactivateReq) - utils.logAudit("sdncDeactivateReq: " + sdncDeactivateReq) - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in preProcessSDNCDeactivate. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," *****Exit preProcessSDNCDeactivate *****", isDebugEnabled) - } - - public void validateSDNCResp(DelegateExecution execution, String response, String method){ - - def isDebugLogEnabled=execution.getVariable(DebugFlag) - utils.log("DEBUG", " *** ValidateSDNCResponse Process*** ", isDebugLogEnabled) - String msg = "" - - try { - WorkflowException workflowException = execution.getVariable("WorkflowException") - utils.logAudit("workflowException: " + workflowException) - - boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator") - utils.logAudit("SDNCResponse: " + response) - - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator) - - if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){ - utils.log("DEBUG", "Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + response, isDebugLogEnabled) - - }else{ - String sdncRespCode = execution.getVariable(Prefix + 'sdncRequestDataResponseCode') - utils.log("DEBUG", method + " AllottedResource received error response from SDNC. ResponseCode:" + sdncRespCode, isDebugLogEnabled) - if (sdncRespCode.equals("404") && "deactivate".equals(method)) - { - execution.setVariable("ARNotFoundInSDNC", true) - if ("true".equals(execution.getVariable("failNotFound"))) - { - msg = "Allotted Resource Not found in SDNC" - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - else - { - execution.setVariable("wasDeleted", false) - } - } - else - { - throw new BpmnError("MSOWorkflowException") - } - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in validateSDNCResp. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logDebug(" *** Exit ValidateSDNCResp Process*** ", isDebugLogEnabled) - } - - public void deleteAaiAR(DelegateExecution execution){ - def isDebugLogEnabled = execution.getVariable(DebugFlag) - try{ - utils.log("DEBUG", " *** deleteAaiAR *** ", isDebugLogEnabled) - AllottedResourceUtils arUtils = new AllottedResourceUtils(this) - String ar = null //need to get resource-version again - String arLink = execution.getVariable("aaiARPath") - if (!isBlank(arLink)) - { - ar = arUtils.getARbyLink(execution, arLink, "") - } - arUtils.deleteAR(execution, arLink + '?resource-version=' + UriUtils.encode(execution.getVariable("aaiARResourceVersion"),"UTF-8")) - } catch (BpmnError e) { - throw e; - }catch(Exception ex){ - utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + ex, isDebugLogEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during SDNC GET Method:\n" + ex.getMessage()) - } - utils.log("DEBUG", " *** Exit deleteAaiAR *** ", isDebugLogEnabled) - } - -} |