From b1e5734ef566af5d49ba17d05ca0ab7b56d6666d Mon Sep 17 00:00:00 2001 From: "Determe, Sebastien (sd378r)" Date: Tue, 9 May 2017 03:55:30 -0700 Subject: [MSO-8] Additional fixes for the second rebase DB fixes + BPMN flows and groovy fixes + Fix issue with CloudConfig file not reloaded properly when it's wrong (JSON error or model hierarchy mistake) at MSO startup Change-Id: I2853030b78499e2a761706b643ea210955e72de3 Signed-off-by: Determe, Sebastien (sd378r) [MSO-8] Restore files removed in patch set 2 Those groovy files must be there Change-Id: I9a47ac3d9c8fc06774a1b8f518491b1b0b00af04 Signed-off-by: Determe, Sebastien (sd378r) --- .../CreateGenericALaCarteServiceInstance.groovy | 262 ++ .../CreateGenericMacroServiceNetworkVnf.groovy | 1540 +++++----- .../scripts/CreateServiceInstance.groovy | 262 -- .../scripts/CreateVfModuleInfra.groovy | 303 +- .../scripts/CreateVfModuleVolumeInfraV1.groovy | 607 ++-- .../infrastructure/scripts/CreateVnfInfra.groovy | 70 - .../scripts/DelServiceInstance.groovy | 353 --- .../DeleteGenericALaCarteServiceInstance.groovy | 353 +++ .../DeleteGenericMacroServiceNetworkVnf.groovy | 934 +++--- .../scripts/DeleteNetworkInstance.groovy | 834 +++--- .../scripts/DoCreateNetworkInstance.groovy | 129 +- .../scripts/DoCreateServiceInstance.groovy | 92 +- .../scripts/DoCreateServiceInstanceRollback.groovy | 28 +- .../infrastructure/scripts/DoCreateVfModule.groovy | 81 +- .../scripts/DoCreateVfModuleRollback.groovy | 68 +- .../scripts/DoCreateVfModuleVolumeV1.groovy | 5 +- .../bpmn/infrastructure/scripts/DoCreateVnf.groovy | 976 ++++--- .../scripts/DoCreateVnfAndModules.groovy | 654 +++-- .../scripts/DoDeleteNetworkInstance.groovy | 86 +- .../scripts/DoDeleteServiceInstance.groovy | 840 +++--- .../scripts/DoDeleteVnfAndModules.groovy | 740 +++-- .../scripts/DoUpdateNetworkInstance.groovy | 16 +- .../infrastructure/scripts/DoUpdateVfModule.groovy | 1840 ++++++------ .../scripts/UpdateNetworkInstanceInfra.groovy | 1639 ----------- .../infrastructure/scripts/UpdateVfModule.groovy | 66 +- .../scripts/UpdateVfModuleVolume.groovy | 72 +- .../CreateGenericALaCarteServiceInstance.bpmn | 336 +++ .../CreateGenericMacroServiceNetworkVnf.bpmn | 2416 ++++++++-------- .../resources/process/CreateServiceInstance.bpmn | 336 --- .../resources/process/CreateVfModuleInfra.bpmn | 354 +-- .../src/main/resources/process/CreateVnfInfra.bpmn | 5 +- .../main/resources/process/DelServiceInstance.bpmn | 331 --- .../DeleteGenericALaCarteServiceInstance.bpmn | 331 +++ .../DeleteGenericMacroServiceNetworkVnf.bpmn | 1524 +++++----- .../src/main/resources/process/DeleteVnfInfra.bpmn | 2 +- .../process/UpdateNetworkInstanceInfra.bpmn | 1014 ------- .../subprocess/DoCreateNetworkInstance.bpmn | 208 +- .../subprocess/DoCreateServiceInstance.bpmn | 805 +++--- .../DoCreateServiceInstanceRollback.bpmn | 707 ++--- .../src/main/resources/subprocess/DoCreateVnf.bpmn | 312 +- .../subprocess/DoCreateVnfAndModules.bpmn | 74 +- .../subprocess/DoDeleteServiceInstance.bpmn | 693 ++--- .../resources/subprocess/DoDeleteVfModule.bpmn | 27 +- .../subprocess/DoDeleteVnfAndModules.bpmn | 355 ++- .../scripts/UpdateNetworkInstanceInfraTest.groovy | 3055 -------------------- .../infrastructure/CreateVfModuleInfraTest.java | 122 +- .../UpdateNetworkInstanceInfraTest.java | 840 ------ .../UpdateVfModuleVolumeInfraV1Test.java | 284 +- .../__files/CreateVfModule_VID_request.json | 69 + .../CreateVfModule_VID_request_noPreloads.json | 79 + .../__files/VfModularity/DBUpdateResponse.xml | 4 + .../GenerateVfModuleName_AAIResponse_Success.xml | 51 + .../resources/__files/VfModularity/GenericVnf.xml | 76 +- .../VfModularity/SDNCSITopologyAssignCallback.xml | 11 + .../VfModularity/SDNCTopologyActivateCallback.xml | 13 + .../VfModularity/SDNCTopologyAssignCallback.xml | 16 + .../SDNCTopologyChangeAssignCallback.xml | 13 + .../VfModularity/SDNCTopologyQueryCallback.xml | 315 ++ .../SDNCTopologyQueryCallbackVfModule.xml | 141 + .../VfModularity/VNFAdapterRestCreateCallback.xml | 55 + .../VfModularity/VNFAdapterRestUpdateCallback.xml | 16 + .../VNFAdapterRestVolumeGroupCallback.xml | 15 + .../__files/VfModularity/VfModule-lukewarm.xml | 10 + .../__files/VfModularity/VfModule-new.xml | 16 +- .../__files/VfModularity/VfModule-supercool.xml | 52 +- .../src/test/resources/mso.bpmn.urn.properties | 6 +- 66 files changed, 11673 insertions(+), 16266 deletions(-) create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn create mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy delete mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml (limited to 'bpmn/MSOInfrastructureBPMN') 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 new file mode 100644 index 0000000000..ec414a4ee2 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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.runtime.Execution +import org.apache.commons.lang3.* +import org.apache.commons.codec.binary.Base64; +import org.springframework.web.util.UriUtils + +/** + * This groovy class supports the CreateServiceInstance.bpmn process. + * AlaCarte flow for 1702 ServiceInstance Create + * + */ +public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { + String Prefix="CRESI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + public void preProcessRequest (Execution 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) + } + + //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 (Execution 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 (Execution 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 = + """ + ${errorMessage} + 7000 + """ + + 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 (Execution 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 = + """ + + ${requestId} + CREATE + ${source} + + Service Instance was created successfully. + ${serviceInstanceId} + CreateGenericALaCarteServiceInstance + """ + + // 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(Execution 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 = + """ + ${requestId} + CREATE + ${source} + """ + + 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 = + """ + + ${requestId} + CREATE + VID + + + ${errorException} + 7000 + + """ + + 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/CreateGenericMacroServiceNetworkVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy index 88e2396078..79508cb8cb 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy @@ -1,752 +1,804 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.CatalogDbUtils -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 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.runtime.Execution -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 CreateGenericMacroServiceNetworkVnf.bpmn process. - * - */ -public class CreateGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { - - String Prefix="CREVAS_" - 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 CreateServiceInstance.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("createGenericMacroServiceNetworkVnfRequest", "") - execution.setVariable("globalSubscriberId", "") - execution.setVariable("serviceInstanceName", "") - execution.setVariable("msoRequestId", "") - execution.setVariable("CREVAS_NetworksCreatedCount", 0) - execution.setVariable("CREVAS_VnfsCreatedCount", 0) - execution.setVariable("productFamilyId", "") - - - //TODO - execution.setVariable("sdncVersion", "1702") - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // check for incoming json message/input - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("bpmnRequest") - utils.logAudit(createGenericMacroServiceNetworkVnfRequest) - execution.setVariable("createGenericMacroServiceNetworkVnfRequest", createGenericMacroServiceNetworkVnfRequest); - println 'createGenericMacroServiceNetworkVnfRequest - ' + createGenericMacroServiceNetworkVnfRequest - - // 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) - - String requestAction = execution.getVariable("requestAction") - execution.setVariable("requestAction", requestAction) - - String source = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) - } - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "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(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - String suppressRollback = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.CatalogDbUtils +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.decomposition.ModelInfo +import org.openecomp.mso.bpmn.core.decomposition.NetworkResource +import org.openecomp.mso.bpmn.core.decomposition.ServiceDecomposition +import org.openecomp.mso.bpmn.core.decomposition.VnfResource +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.runtime.Execution +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 CreateGenericMacroServiceNetworkVnf.bpmn process. + * + */ +public class CreateGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { + + String Prefix="CGMSNV_" + 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 CreateServiceInstance.bpmn process. + * @param execution + */ + public InitializeProcessVariables(Execution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable("createViprServiceRequest", "") + execution.setVariable("globalSubscriberId", "") + execution.setVariable("serviceInstanceName", "") + execution.setVariable("msoRequestId", "") + execution.setVariable("CGMSNV_NetworksCreatedCount", 0) + execution.setVariable("CGMSNV_VnfsCreatedCount", 0) + execution.setVariable("productFamilyId", "") + + //TODO + execution.setVariable("sdncVersion", "1707") + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // check for incoming json message/input + String createViprServiceRequest = execution.getVariable("bpmnRequest") + utils.logAudit(createViprServiceRequest) + execution.setVariable("createViprServiceRequest", createViprServiceRequest); + println 'createViprServiceRequest - ' + createViprServiceRequest + + // 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) + + String requestAction = execution.getVariable("requestAction") + execution.setVariable("requestAction", requestAction) + + String source = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + execution.setVariable("source", "VID") + } else { + execution.setVariable("source", source) + } + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(createViprServiceRequest, "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(createViprServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) + + String suppressRollback = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) + + String productFamilyId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) + + //For Completion Handler & Fallout Handler + String requestInfo = """ - ${requestId} - CREATE - ${source} - """ - - execution.setVariable("CREVAS_requestInfo", requestInfo) - - utils.log("DEBUG", " ***** Completed preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateGenericMacroServiceNetworkVnf ***** ", 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 CreateGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // - // ******************************* - public void prepareCreateServiceInstance(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest") - String serviceModelInfo = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.modelInfo") - execution.setVariable("serviceModelInfo", serviceModelInfo) - - String serviceInputParams = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters") - execution.setVariable("serviceInputParams", serviceInputParams) - - String serviceInstanceName = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.instanceName") - execution.setVariable("serviceInstanceName", serviceInstanceName) - - utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareCreateService() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - public void postProcessServiceInstanceCreate (Execution execution){ - def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - String serviceInstanceName = execution.getVariable("serviceInstanceName") - - try { - - String payload = """ + ${requestId} + CREATE + ${source} + """ + + execution.setVariable("CGMSNV_requestInfo", requestInfo) + + utils.log("DEBUG", " ***** Completed preProcessRequest CreateGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + } catch (BpmnError e) { + throw e; + + } catch (Exception ex){ + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside sendSyncResponse of CreateGenericMacroServiceNetworkVnf ***** ", 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 CreateGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareDecomposeService(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareDecomposeService of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + String createViprServiceRequest = execution.getVariable("createViprServiceRequest") + String serviceModelInfo = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.modelInfo") + execution.setVariable("serviceModelInfo", serviceModelInfo) + + utils.log("DEBUG", " ***** Completed prepareDecomposeService of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDecomposeService() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // + // ******************************* + public void prepareCreateServiceInstance(Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", 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 createViprServiceRequest = execution.getVariable("createViprServiceRequest") + String serviceInputParams = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestParameters") + execution.setVariable("serviceInputParams", serviceInputParams) + + String serviceInstanceName = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.instanceName") + execution.setVariable("serviceInstanceName", serviceInstanceName) + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + execution.setVariable("serviceDecompositionString", serviceDecomposition.toJsonString()) + + utils.log("DEBUG", " ***** Completed prepareCreateServiceInstance of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareCreateServiceInstance() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void postProcessServiceInstanceCreate (Execution execution){ + def method = getClass().getSimpleName() + '.postProcessServiceInstanceCreate(' +'execution=' + execution.getId() +')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + String source = execution.getVariable("source") + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + String serviceInstanceName = execution.getVariable("serviceInstanceName") + + try { + + String payload = """ - - - - ${requestId} - BPEL - ${serviceInstanceId} - ${serviceInstanceName} - - - - """ - execution.setVariable("CREVAS_setUpdateDbInstancePayload", payload) - utils.logAudit("CREVAS_setUpdateDbInstancePayload: " + payload) - logDebug('Exited ' + method, isDebugLogEnabled) - //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload")) - - } 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 callDBCatalog (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside callDBCatalog() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - - // get variable within incoming json - String createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest"); - - String catalog_db_endpoint = execution.getVariable("URN_mso_catalog_db_endpoint") - utils.log("DEBUG", "catalog_db_endpoint: "+catalog_db_endpoint, isDebugEnabled) - - String serviceModelInvariantId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.modelInfo.modelInvariantId") - String serviceModelVersion = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.modelInfo.modelVersion") - utils.log("DEBUG", "getting network list ", isDebugEnabled) - - JSONArray networkList = catalogDbUtils.getAllNetworksByServiceModelInvariantUuidAndServiceModelVersion(catalog_db_endpoint, serviceModelInvariantId, serviceModelVersion) - - //utils.log("DEBUG", "got network list: "+ networkList.toString(), isDebugEnabled) - execution.setVariable("networkList", networkList) - execution.setVariable("networkListString", networkList.toString()) - - networkList = execution.getVariable("networkList"); - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - if (networkList != null && networkList.length() > 0) { - - execution.setVariable("CREVAS_NetworksCount", networkList.length()) - utils.log("DEBUG", "networks to create: "+ networkList.length(), isDebugEnabled) - } else { - execution.setVariable("CREVAS_NetworksCount", 0) - utils.log("DEBUG", "no networks to create based upon Catalog DB response", isDebugEnabled) - } - - // VNFs - JSONArray vnfList = catalogDbUtils.getAllVnfsByServiceModelInvariantUuidAndServiceModelVersion(catalog_db_endpoint, serviceModelInvariantId, serviceModelVersion) - execution.setVariable("vnfList", vnfList) - - String vnfModelInfoString = "" - if (vnfList != null && vnfList.length() > 0) { - execution.setVariable("CREVAS_VNFsCount", vnfList.length()) - utils.log("DEBUG", "vnfs to create: "+ vnfList.length(), isDebugEnabled) - JSONObject vnfModelInfo = vnfList.getJSONObject(0).getJSONObject("modelInfo") - vnfModelInfoString = vnfModelInfo.toString() - } else { - execution.setVariable("CREVAS_VNFsCount", 0) - utils.log("DEBUG", "no vnfs to create based upon Catalog DB response", isDebugEnabled) - } - - execution.setVariable("vnfModelInfo", vnfModelInfoString) - //utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed callDBCatalog() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. callDBCatalog() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", 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 createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest") - - JSONArray networkList = execution.getVariable("networkList") - utils.log("DEBUG", "array networkList: "+ networkList, isDebugEnabled) - - if (networkList == null || networkList.length() < 1){ - networkList = new JSONArray(execution.getVariable("networkListString")) - utils.log("DEBUG", "array from string networkList: "+ networkList, isDebugEnabled) - } - - Integer networksCreatedCount = execution.getVariable("CREVAS_NetworksCreatedCount") - String networkModelInfoString = "" - - if (networkList != null) { - utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled) - JSONObject networkModelInfo = networkList.getJSONObject(networksCreatedCount.intValue()).getJSONObject("modelInfo") - networkModelInfoString = networkModelInfo.toString() - } else { - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected number of networks to create - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - execution.setVariable("networkModelInfo", networkModelInfoString) - utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled) - -// String networkModelInfo = execution.getVariable("networkModelInfo") - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = execution.getVariable("sdncVersion") - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> increment count - // ******************************* - public void validateNetworkCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CREVAS_NetworksCreatedCount") - networksCreatedCount++ - - execution.setVariable("CREVAS_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData")) - - utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled) - utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) - - String vnfModelInfo = execution.getVariable("vnfModelInfo") - utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) - - JSONArray networkList = execution.getVariable("networkList") - utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareVnfAndModulesCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", 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 createGenericMacroServiceNetworkVnfRequest = execution.getVariable("createGenericMacroServiceNetworkVnfRequest") - String productFamilyId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled) - - JSONArray vnfList = execution.getVariable("vnfList") - - Integer vnfsCreatedCount = execution.getVariable("CREVAS_VnfsCreatedCount") - String vnfModelInfoString = null; - - if (vnfList != null && vnfList.length() > 0 ) { - utils.log("DEBUG", "getting model info for vnf # " + vnfsCreatedCount, isDebugEnabled) - JSONObject vnfModelInfo1 = vnfList.getJSONObject(0).getJSONObject("modelInfo") - utils.log("DEBUG", "got 0 ", isDebugEnabled) - JSONObject vnfModelInfo = vnfList.getJSONObject(vnfsCreatedCount.intValue()).getJSONObject("modelInfo") - vnfModelInfoString = vnfModelInfo.toString() - } else { - //TODO: vnfList does not contain data. Need to investigate why ... . Fro VIPR use model stored - vnfModelInfoString = execution.getVariable("vnfModelInfo") - } - - utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(createGenericMacroServiceNetworkVnfRequest, "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 CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfCreate (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer vnfsCreatedCount = execution.getVariable("CREVAS_VnfsCreatedCount") - vnfsCreatedCount++ - - execution.setVariable("CREVAS_VnfsCreatedCount", vnfsCreatedCount) - - utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section -> decrement count - // ******************************* - public void validateNetworkRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - Integer networksCreatedCount = execution.getVariable("CREVAS_NetworksCreatedCount") - networksCreatedCount-- - - execution.setVariable("CREVAS_NetworksCreatedCount", networksCreatedCount) - - execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount)) - - utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage() - //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - execution.setVariable("CREVAS_NetworksCreatedCount", 0) - utils.log("ERROR", exceptionMessage, true) - } - } - // ******************************* - // Build DB request Section - // ******************************* -// public void prepareDBRequest (Execution execution) { -// def isDebugEnabled=execution.getVariable("isDebugLogEnabled") -// -// try { -// utils.log("DEBUG", " ***** Inside prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) -// -// String requestId = execution.getVariable("CREVAS_requestId") -// String statusMessage = "vIPR ATM Service Instance successfully created." -// String serviceInstanceId = execution.getVariable("CREVAS_serviceInstanceId") -// -// //TODO - verify the format for Service Instance Create, -// String dbRequest = -// """ -// -// + + + + ${requestId} + BPEL + ${serviceInstanceId} + ${serviceInstanceName} + + + + """ + execution.setVariable("CGMSNV_setUpdateDbInstancePayload", payload) + utils.logAudit("CGMSNV_setUpdateDbInstancePayload: " + payload) + logDebug('Exited ' + method, isDebugLogEnabled) + //println("CMSO_updateDBStatusToSuccessPayload --> " + execution.getVariable("CMSO_updateDBStatusToSuccessPayload")) + + } 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 getDataFromDecomposition (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside getDataFromDecomposition() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + + ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") + + List networkList = serviceDecomposition.getServiceNetworks() + + //utils.log("DEBUG", "got network list: "+ networkList.toString(), isDebugEnabled) + execution.setVariable("networkList", networkList) + execution.setVariable("networkListString", networkList.toString()) + + networkList = execution.getVariable("networkList"); + utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) + + if (networkList != null && networkList.size() > 0) { + + execution.setVariable("CGMSNV_NetworksCount", networkList.size()) + utils.log("DEBUG", "networks to create: "+ networkList.size(), isDebugEnabled) + } else { + execution.setVariable("CGMSNV_NetworksCount", 0) + utils.log("DEBUG", "no networks to create based upon serviceDecomposition content", isDebugEnabled) + } + + // VNFs + List vnfList = serviceDecomposition.getServiceVnfs() + execution.setVariable("vnfList", vnfList) + + String vnfModelInfoString = "" + if (vnfList != null && vnfList.size() > 0) { + execution.setVariable("CGMSNV_VNFsCount", vnfList.size()) + utils.log("DEBUG", "vnfs to create: "+ vnfList.size(), isDebugEnabled) + ModelInfo vnfModelInfo = vnfList[0].getModelInfo() + String vnfModelInfoWithRoot = vnfModelInfo.toString() + vnfModelInfoString = jsonUtil.getJsonValue(vnfModelInfoWithRoot, "modelInfo") + } else { + execution.setVariable("CGMSNV_VNFsCount", 0) + utils.log("DEBUG", "no vnfs to create based upon Catalog DB response", isDebugEnabled) + } + + execution.setVariable("vnfModelInfo", vnfModelInfoString) + //utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed getDataFromDecomposition() of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. getDataFromDecomposition() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareNetworkCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", 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 createViprServiceRequest = execution.getVariable("createViprServiceRequest") + + JSONArray networkList = execution.getVariable("networkList") + utils.log("DEBUG", "array networkList: "+ networkList, isDebugEnabled) + + if (networkList == null || networkList.size() < 1){ + networkList = new JSONArray(execution.getVariable("networkListString")) + utils.log("DEBUG", "array from string networkList: "+ networkList, isDebugEnabled) + } + + Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") + String networkModelInfoString = "" + + if (networkList != null) { + utils.log("DEBUG", " getting model info for network # :" + networksCreatedCount, isDebugEnabled) + ModelInfo networkModelInfo = networkList[networksCreatedCount.intValue()].getModelInfo() + networkModelInfoString = networkModelInfo.toString() + } else { + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected number of networks to create - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + execution.setVariable("networkModelInfo", networkModelInfoString) + utils.log("DEBUG", " networkModelInfoString :" + networkModelInfoString, isDebugEnabled) + +// String networkModelInfo = execution.getVariable("networkModelInfo") + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.tenantId") + execution.setVariable("tenantId", tenantId) + utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) + + String sdncVersion = execution.getVariable("sdncVersion") + utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) + + List vnfList = execution.getVariable("vnfList") + utils.log("DEBUG", "vnfList: "+ vnfList.toString(), isDebugEnabled) + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) + + networkList = execution.getVariable("networkList") + utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed preparenNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Network request Section -> increment count + // ******************************* + public void validateNetworkCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") + networksCreatedCount++ + + execution.setVariable("CGMSNV_NetworksCreatedCount", networksCreatedCount) + + execution.setVariable("DCRENI_rollbackData"+networksCreatedCount, execution.getVariable("DCRENI_rollbackData")) + + utils.log("DEBUG", "networksCreatedCount: "+ networksCreatedCount, isDebugEnabled) + utils.log("DEBUG", "DCRENI_rollbackData N : "+ execution.getVariable("DCRENI_rollbackData"+networksCreatedCount), isDebugEnabled) + + JSONArray vnfList = execution.getVariable("vnfList") + utils.log("DEBUG", "vnfList: "+ vnfList, isDebugEnabled) + + String vnfModelInfo = execution.getVariable("vnfModelInfo") + utils.log("DEBUG", "vnfModelInfo: "+ vnfModelInfo, isDebugEnabled) + + JSONArray networkList = execution.getVariable("networkList") + utils.log("DEBUG", "networkList: "+ networkList, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed validateNetworkCreate of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareVnfAndModulesCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareVnfAndModulesCreate of CreateGenericMacroServiceNetworkVnf ***** ", 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 createViprServiceRequest = execution.getVariable("createViprServiceRequest") + String productFamilyId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG","productFamilyId: "+ productFamilyId, isDebugEnabled) + + List vnfList = execution.getVariable("vnfList") + + Integer vnfsCreatedCount = execution.getVariable("CGMSNV_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 VIPR use model stored + vnfModelInfoString = execution.getVariable("vnfModelInfo") + } + + utils.log("DEBUG", " vnfModelInfoString :" + vnfModelInfoString, isDebugEnabled) + + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(createViprServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(createViprServiceRequest, "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 CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareVnfAndModulesCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfCreate (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer vnfsCreatedCount = execution.getVariable("CGMSNV_VnfsCreatedCount") + vnfsCreatedCount++ + + execution.setVariable("CGMSNV_VnfsCreatedCount", vnfsCreatedCount) + + utils.log("DEBUG", " ***** Completed validateVnfCreate of CreateGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfCreate() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Network request Section -> decrement count + // ******************************* + public void validateNetworkRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer networksCreatedCount = execution.getVariable("CGMSNV_NetworksCreatedCount") + networksCreatedCount-- + + execution.setVariable("CGMSNV_NetworksCreatedCount", networksCreatedCount) + + execution.setVariable("DCRENI_rollbackData", execution.getVariable("DCRENI_rollbackData"+networksCreatedCount)) + + utils.log("DEBUG", " ***** Completed validateNetworkRollback of CreateGenericMacroServiceNetworkVnf ***** "+" network # "+networksCreatedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkRollback() - " + ex.getMessage() + //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + execution.setVariable("CGMSNV_NetworksCreatedCount", 0) + utils.log("ERROR", exceptionMessage, true) + } + } + +// public void extractServiceModelInfo (Execution execution) { +// def isDebugEnabled = execution.getVariable("isDebugLogEnabled") +// String msg = "" +// utils.log("DEBUG"," ***** extractServiceModelInfo of CreateGenericMacroServiceNetworkVnf *****", isDebugEnabled) +// +// try { +// +// // check for input +// String requestId = execution.getVariable("msoRequestId") +// +// ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition") +// ModelInfo modelInfo = serviceDecomposition.getModelInfo() +// +// utils.log("DEBUG", "modelInfo: "+ modelInfo.toJsonString(), isDebugEnabled) +// utils.log("DEBUG", "modelInfo: "+ modelInfo, isDebugEnabled) +// execution.setVariable("serviceDecomposition", modelInfo) +// +// utils.log("DEBUG"," ***** Exit extractServiceModelInfo of CreateGenericMacroServiceNetworkVnf *****", isDebugEnabled) +// +// } catch (BpmnError e) { +// throw e; +// } catch (Exception ex){ +// msg = "Exception in extractServiceModelInfo " + ex.getMessage() +// utils.log("DEBUG", msg, isDebugEnabled) +// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) +// } +// utils.log("DEBUG"," ***** Exit extractServiceModelInfo of DecomposeService *****", isDebugEnabled) +// } + + // ******************************* + // Build DB request Section + // ******************************* +// public void prepareDBRequest (Execution execution) { +// def isDebugEnabled=execution.getVariable("isDebugLogEnabled") +// +// try { +// utils.log("DEBUG", " ***** Inside prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) +// +// String requestId = execution.getVariable("CGMSNV_requestId") +// String statusMessage = "vIPR ATM Service Instance successfully created." +// String serviceInstanceId = execution.getVariable("CGMSNV_serviceInstanceId") +// +// //TODO - verify the format for Service Instance Create, +// String dbRequest = +// """ +// +// // -// ${requestId} -// BPMN -// ${statusMessage} -// -// COMPLETED -// 100 -// -// ${serviceInstanceId} -// -// -// """ -// -// String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) -// execution.setVariable("CREVAS_createDBRequest", buildDeleteDBRequestAsString) -// utils.logAudit(buildDeleteDBRequestAsString) -// -// utils.log("DEBUG", " ***** Completed prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) -// } catch (Exception ex) { -// // try error in method block -// String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() -// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) -// -// } -// -// } - - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside postProcessResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("mso-request-id") - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - String msoCompletionRequest = +// ${requestId} +// BPMN +// ${statusMessage} +// +// COMPLETED +// 100 +// +// ${serviceInstanceId} +// +// +// """ +// +// String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) +// execution.setVariable("CGMSNV_createDBRequest", buildDeleteDBRequestAsString) +// utils.logAudit(buildDeleteDBRequestAsString) +// +// utils.log("DEBUG", " ***** Completed prepareDBRequest of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) +// } catch (Exception ex) { +// // try error in method block +// String exceptionMessage = "Bpmn error encountered in CreateGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() +// exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) +// +// } +// +// } + + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside postProcessResponse of CreateGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("mso-request-id") + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + String msoCompletionRequest = """ - ${requestId} - CREATE - ${source} - - Service Instance has been created successfully via macro orchestration - ${serviceInstanceId} - BPMN macro create - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("CREVAS_Success", true) - execution.setVariable("CREVAS_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 CreateServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void preProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", 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 CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) - } - - public void postProcessRollback (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", 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 CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) - } - - public void prepareFalloutRequest(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " *** STARTED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("CREVAS_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_rollbackSuccessful") -// if (successIndicator){ -// errorMessage = errorMessage + ". Rollback successful." -// } else { -// errorMessage = errorMessage + ". Rollback not completed." -// } - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("CREVAS_falloutRequest", falloutRequest) - - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncError() of CreateServiceInstanceInfra ***** ", 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 = + ${requestId} + CREATE + ${source} + + Service Instance has been created successfully via macro orchestration + ${serviceInstanceId} + BPMN macro create + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + utils.logAudit(xmlMsoCompletionRequest) + execution.setVariable("CGMSNV_Success", true) + execution.setVariable("CGMSNV_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 CreateServiceInstance flow. Unexpected Error from method postProcessResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void preProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** preProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", 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 CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) + } + + public void postProcessRollback (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** postProcessRollback of CreateGenericMacroServiceNetworkVnf ***** ", 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 CreateGenericMacroServiceNetworkVnf *** ", isDebugEnabled) + } + + public void prepareFalloutRequest(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " *** STARTED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestInfo = execution.getVariable("CGMSNV_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_rollbackSuccessful") +// if (successIndicator){ +// errorMessage = errorMessage + ". Rollback successful." +// } else { +// errorMessage = errorMessage + ". Rollback not completed." +// } + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable("CGMSNV_falloutRequest", falloutRequest) + + } catch (Exception ex) { + utils.log("DEBUG", "Error Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process") + } + utils.log("DEBUG", "*** COMPLETED CreateGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) + } + + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside sendSyncError() of CreateServiceInstanceInfra ***** ", 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 = """ - ${errorMessage} - 7000 - """ - - 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(Execution 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("CRESI_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("CRESI_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) - } + ${errorMessage} + 7000 + """ + + 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(Execution 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("CRESI_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("CRESI_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) + } } \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy deleted file mode 100644 index 2205ffd696..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy +++ /dev/null @@ -1,262 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.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.runtime.Execution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the CreateServiceInstance.bpmn process. - * AlaCarte flow for 1702 ServiceInstance Create - * - */ -public class CreateServiceInstance extends AbstractServiceTaskProcessor { - String Prefix="CRESI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (Execution 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) - } - - //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 (Execution 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", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - utils.log("DEBUG"," ***** Exit sendSyncResopnse *****", isDebugEnabled) - } - - - public void sendSyncError (Execution 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 = - """ - ${errorMessage} - 7000 - """ - - 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 (Execution 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 = - """ - - ${requestId} - CREATE - ${source} - - Service Instance was created successfully. - ${serviceInstanceId} - CreateServiceInstance - """ - - // 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(Execution 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 = - """ - ${requestId} - CREATE - ${source} - """ - - 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 = - """ - - ${requestId} - CREATE - VID - - - ${errorException} - 7000 - - """ - - 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/CreateVfModuleInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy index 573deb4155..b468a5116c 100644 --- 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 @@ -1,42 +1,45 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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; +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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 org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution 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 - -public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - +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 + +public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + /** * Validates the request message and sets up the workflow. * @param execution the execution @@ -71,73 +74,160 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { // 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') - - def vidUtils = new VidUtils(this) - - String requestInXmlFormat = vidUtils.createXmlVfModuleRequest(execution, reqMap, 'CREATE_VF_MODULE', serviceInstanceId) - - utils.log("DEBUG", " Request in XML format: " + requestInXmlFormat, isDebugLogEnabled) - - execution.setVariable(prefix + 'Request', requestInXmlFormat) + + execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId) 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, 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") - } - - try { - String request = validateInfraRequest(execution) + + 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 userParamsMap = [:] + if (userParams != null) { + userParams.each { userParam -> + userParamsMap.put(userParam.name, userParam.value) + } + } + + 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(prefix + '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("CreateVfModuleInfraSuccessIndicator", false) execution.setVariable("RollbackCompleted", false) - execution.setVariable("DoCreateVfModuleRequest", request) + execution.setVariable("isDebugLogEnabled", isDebugLogEnabled) - execution.setVariable("CVFMI_requestInfo",utils.getNodeXml(request,"request-info")) - execution.setVariable("CVFMI_requestId",utils.getNodeText1(request,"request-id")) - execution.setVariable("CVFMI_source",utils.getNodeText1(request,"source")) - execution.setVariable("CVFMI_serviceInstanceId", utils.getNodeText1(request, "service-instance-id")) - execution.setVariable("CVFMI_vnfInputs",utils.getNodeXml(request,"vnf-inputs")) + + + def source = reqMap.requestDetails?.requestInfo?.source + execution.setVariable("CVFMI_source", source) + + //For Completion Handler & Fallout Handler + String requestInfo = + """ + ${requestId} + CREATE + ${source} + """ + + execution.setVariable("CVFMI_requestInfo", requestInfo) + //backoutOnFailure - NetworkUtils networkUtils = new NetworkUtils() - execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request)) + //NetworkUtils networkUtils = new NetworkUtils() + //execution.setVariable("CVFMI_rollbackEnabled", networkUtils.isRollbackEnabled(execution,request)) execution.setVariable("CVFMI_originalWorkflowException", null) - def vnfParams = "" - if (utils.nodeExists(request, "vnf-params")) { - vnfParams = utils.getNodeXml(request,"vnf-params") - } - execution.setVariable("CVFMI_vnfParams", vnfParams) + def newVfModuleId = UUID.randomUUID().toString() execution.setVariable("newVfModuleId", newVfModuleId) + execution.setVariable(prefix + 'vfModuleId', newVfModuleId) - logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled) - logDebug('VnfInputs: ' + execution.getVariable("CVFMI_vnfInputs"), isDebugLogEnabled) - logDebug('VnfParams: ' + execution.getVariable("CVFMI_vnfParams"), isDebugLogEnabled) + logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled) + logDebug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled"), isDebugLogEnabled) logDebug('Exited ' + method, isDebugLogEnabled) } catch (BpmnError bpmnError) { throw bpmnError - } catch (Exception exception) { + } + 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") } + } /** @@ -168,16 +258,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { try { def requestInfo = execution.getVariable('CVFMI_requestInfo') def requestId = execution.getVariable('CVFMI_requestId') - def source = execution.getVariable('CVFMI_source') - def progress = getNodeTextForce(requestInfo, 'progress') - if (progress.isEmpty()) { - progress = '0' - } - def startTime = getNodeTextForce(requestInfo, 'start-time') - if (startTime.isEmpty()) { - startTime = System.currentTimeMillis() - } - + 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() @@ -202,9 +284,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { def isDebugEnabled = execution.getVariable("isDebugLogEnabled") utils.log("DEBUG", " ======== STARTED PostProcessResponse Process ======== ", isDebugEnabled) - try{ - def request = execution.getVariable("DoCreateVfModuleRequest") - def requestInfo = utils.getNodeXml(request, 'request-info', false) + try{ + def requestInfo = execution.getVariable("CVFMI_requestInfo") def action = utils.getNodeText1(requestInfo, "action") utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled) @@ -223,10 +304,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } String payload = - """ - + """ + ${requestInfo} Vf Module has been created successfully. @@ -292,7 +373,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { /* - def requestId = execution.getVariable("mso-request-id") + def requestId = execution.getVariable("mso-request-id") if (requestId == null) { exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") @@ -300,7 +381,7 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { setVariable(execution, prefix + 'requestId', requestId) - def serviceInstanceId = execution.getVariable("mso-service-instance-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") @@ -325,14 +406,16 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", " ======== STARTED prepareUpdateInfraRequest Process ======== ", isDebugEnabled) try{ - - String vnfInputs = execution.getVariable("CVFMI_vnfInputs") - String requestInfo = execution.getVariable("CVFMI_requestInfo") - def aicCloudRegion = utils.getNodeText1(vnfInputs, "aic-cloud-region") - def tenantId = utils.getNodeText1(vnfInputs, "tenant-id") + + + 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_db_endpoint") execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint) @@ -352,18 +435,19 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { String payload = """ + xmlns:ns="http://org.openecomp.mso/requestsdb"> - + ${requestId} BPMN VF Module successfully created COMPLETE 100 - <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> + <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> ${vfModuleId} + ${vfModuleName} """ @@ -396,9 +480,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { try { - def WorkflowException workflowException = execution.getVariable("WorkflowException") - def request = execution.getVariable("DoCreateVfModuleRequest") - def requestInformation = utils.getNodeXml(request, 'request-info', false) + def WorkflowException workflowException = execution.getVariable("WorkflowException") + def requestInformation = execution.getVariable("CVFMI_requestInfo") def errorResponseCode = workflowException.getErrorCode() def errorResponseMsg = workflowException.getErrorMessage() def encErrorResponseMsg = "" @@ -407,10 +490,10 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { } String content = """ - + ${requestInformation} ${encErrorResponseMsg} @@ -458,6 +541,8 @@ public class CreateVfModuleInfra extends AbstractServiceTaskProcessor { execution.setVariable("RollbackCompleted", true) } + + } 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 index 289e185522..48ca2905c1 100644 --- 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 @@ -1,304 +1,303 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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 groovy.json.JsonSlurper - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution; -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 (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - preProcessRequest(execution, isDebugEnabled) - } - - - /** - * Perform initial processing, such as request validation, initialization of variables, etc. - * @param execution - * @param isDebugEnabled - */ - public void preProcessRequest (Execution 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) - - def serviceInstanceId = execution.getVariable('serviceInstanceId') - def vnfId = execution.getVariable('vnfId') - - def vidUtils = new VidUtils(this) - createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', serviceInstanceId) - - execution.setVariable(prefix+'Request', createVolumeIncoming) - execution.setVariable(prefix+'vnfId', vnfId) - execution.setVariable(prefix+'isVidRequest', true) - - 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') - } - - execution.setVariable(prefix+'source', utils.getNodeText1(createVolumeIncoming, "source")) - execution.setVariable(prefix+'volumeGroupName', utils.getNodeText1(createVolumeIncoming, 'volume-group-name')) - execution.setVariable(prefix+'volumeOutputs', utils.getNodeXml(createVolumeIncoming, 'volume-outputs', false)) - - execution.setVariable(prefix+'serviceType', 'service-instance') - execution.setVariable(prefix+'serviceInstanceId', utils.getNodeText1(createVolumeIncoming, "service-instance-id")) - - // Generate volume group id - String volumeGroupId = UUID.randomUUID() - utils.log("DEBUG", "Generated volume group id: " + volumeGroupId, isDebugEnabled) - - def testGroupId = execution.getVariable('test-volume-group-id') - if (testGroupId != null && testGroupId.trim() != '') { - volumeGroupId = testGroupId - } - - execution.setVariable(prefix+'volumeGroupId', volumeGroupId) - - } - - - public void sendSyncResponse (Execution execution, isDebugEnabled) { - def volumeGroupId = execution.getVariable(prefix+'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 (Execution 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(Execution execution, int errorCode, errorMessage, isDebugEnabled) { - utils.log("DEBUG", errorMessage, isDebugEnabled) - (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) - } - - - public void prepareDbInfraSuccessRequest(Execution execution, isDebugEnabled) { - ExceptionUtil exceptionUtil = new ExceptionUtil() - def dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs') - def requestId = execution.getVariable('mso-request-id') - def statusMessage = "VolumeGroup successfully created." - def requestStatus = "COMPLETED" - def progress = "100" - - try { - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - /* - 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 = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - ${requestStatus} - ${progress} - ${dbVnfOutputs} - ${volumeGroupId} - - - """ - - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString) - - utils.logAudit(buildDeleteDBRequestAsString) - } - - - - - - public void postProcessResponse (Execution 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 = - """ - - ${requestId} - CREATE - ${source} - - Volume Group has been created successfully. - BPMN VF Module Volume action: CREATE - """ - - 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(Execution 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 = - """ - - ${requestId} - CREATE - ${source} - - - ${errorMessage} - ${errorCode} - - - """ - - // 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(Execution 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") - } - } - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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 groovy.json.JsonSlurper + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution; +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 (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + preProcessRequest(execution, isDebugEnabled) + } + + + /** + * Perform initial processing, such as request validation, initialization of variables, etc. + * @param execution + * @param isDebugEnabled + */ + public void preProcessRequest (Execution 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) + + def serviceInstanceId = execution.getVariable('serviceInstanceId') + def vnfId = execution.getVariable('vnfId') + + def vidUtils = new VidUtils(this) + createVolumeIncoming = vidUtils.createXmlVolumeRequest(reqMap, 'CREATE_VF_MODULE_VOL', serviceInstanceId) + + execution.setVariable(prefix+'Request', createVolumeIncoming) + execution.setVariable(prefix+'vnfId', vnfId) + execution.setVariable(prefix+'isVidRequest', true) + + 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') + } + + execution.setVariable(prefix+'source', utils.getNodeText1(createVolumeIncoming, "source")) + execution.setVariable(prefix+'volumeGroupName', utils.getNodeText1(createVolumeIncoming, 'volume-group-name')) + execution.setVariable(prefix+'volumeOutputs', utils.getNodeXml(createVolumeIncoming, 'volume-outputs', false)) + + execution.setVariable(prefix+'serviceType', 'service-instance') + execution.setVariable(prefix+'serviceInstanceId', utils.getNodeText1(createVolumeIncoming, "service-instance-id")) + + // Generate volume group id + String volumeGroupId = UUID.randomUUID() + utils.log("DEBUG", "Generated volume group id: " + volumeGroupId, isDebugEnabled) + + def testGroupId = execution.getVariable('test-volume-group-id') + if (testGroupId != null && testGroupId.trim() != '') { + volumeGroupId = testGroupId + } + + execution.setVariable(prefix+'volumeGroupId', volumeGroupId) + + } + + + public void sendSyncResponse (Execution execution, isDebugEnabled) { + def volumeGroupId = execution.getVariable(prefix+'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 (Execution 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(Execution execution, int errorCode, errorMessage, isDebugEnabled) { + utils.log("DEBUG", errorMessage, isDebugEnabled) + (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage) + } + + + public void prepareDbInfraSuccessRequest(Execution 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" + + try { + String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") + utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) + + def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) + execution.setVariable("BasicAuthHeaderValueDB",encodedString) + } catch (IOException ex) { + String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() + utils.log("DEBUG", dataErrorMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) + } + + /* + 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 = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + ${requestStatus} + ${progress} + ${dbVnfOutputs} + ${volumeGroupId} + + + """ + + String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) + execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString) + + utils.logAudit(buildDeleteDBRequestAsString) + } + + + + + + public void postProcessResponse (Execution 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 = + """ + + ${requestId} + CREATE + ${source} + + Volume Group has been created successfully. + BPMN VF Module Volume action: CREATE + """ + + 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(Execution 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 = + """ + + ${requestId} + CREATE + ${source} + + + ${errorMessage} + ${errorCode} + + + """ + + // 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(Execution 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") + } + } + } +} 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 index 6168acde44..9b7fd6835c 100644 --- 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 @@ -205,76 +205,6 @@ class CreateVnfInfra extends AbstractServiceTaskProcessor { utils.log("DEBUG", "*** COMPLETED CreateVnfInfra SendSyncResponse Process ***", isDebugEnabled) } - public void prepareCreateGenericVnf (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED CreateVnfInfra PrepareCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = execution.getVariable("CREVI_vnfId") - def vnfName = execution.getVariable("CREVI_vnfName") - def vnfType = execution.getVariable("CREVI_vnfType") - def serviceId = execution.getVariable("CREVI_serviceId") - def orchStatus = execution.getVariable("CREVI_orchStatus") - def modelInvariantId = execution.getVariable("CREVI_modelInvariantId") - def modelVersion = execution.getVariable("CREVI_modelVersion") - // TODO: 1702 Variable - def equipmentRole = execution.getVariable("CREVI_equipmentRole") - - //Get Service Instance Info - def serviceInstanceId = execution.getVariable("CREVI_serviceInstanceId") - String siRelatedLink = execution.getVariable("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) - - //Get Namespace - AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - String namespace = aaiUtil.getNamespaceFromUri(aai_uri) - - String payload = - """ - ${vnfId} - ${vnfName} - ${serviceId} - ${vnfType} - ${orchStatus} - ${modelInvariantId} - ${modelVersion} - - - service-instance - ${siRelatedLink} - - customer.global-customer-id - ${globalCustId} - - - service-subscription.service-type - ${serviceType} - - - service-instance.service-instance-id - ${serviceInstanceId} - - - - """ - - execution.setVariable("CREVI_genericVnfPayload", payload) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in CreateVnfInfra PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVnfInfra PrepareCreateGenericVnf Process") - } - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) - } public void preProcessSDNCAssignRequest(Execution execution){ def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy deleted file mode 100644 index aad0693948..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy +++ /dev/null @@ -1,353 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.runtime.Execution -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 DelServiceInstance.bpmn process. - * - */ -public class DelServiceInstance extends AbstractServiceTaskProcessor { - - String Prefix="DELSI_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (Execution 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) - } - - } 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 (Execution 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 (Execution 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 = - """ - ${errorMessage} - 7000 - """ - - 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 (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) - - try { - String requestId = execution.getVariable("msoRequestId") - String source = execution.getVariable("source") - String msoCompletionRequest = - """ - - ${requestId} - DELETE - ${source} - - Service Instance was deleted successfully. - DelServiceInstance - """ - - // 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(Execution 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 = - """ - ${requestId} - DELETE - ${source} - """ - - 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 = - """ - - ${requestId} - DELETE - VID - - - ${errorException} - 7000 - - """ - - execution.setVariable("falloutRequest", falloutRequest) - } - utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) - } - - - // ******************************* - // Build DB request Section - // ******************************* - public void prepareDBRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequest of DeleteServiceInstance ***** ", isDebugEnabled) - - String requestId = execution.getVariable("DELSI_requestId") - String statusMessage = "Service Instance successfully deleted." - - //TODO - verify the format for Service Instance Delete, - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - COMPLETED - 100 - - - """ - - 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 DeleteServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - // ******************************* - // Build Error Section - // ******************************* - public void prepareDBRequestError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteServiceInstanceInfra ***** ", 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 DeleteServiceInstanceInfra proccessing. " - } - - //TODO - verify the format for Service Instance Create, - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - FAILED - - - """ - - 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 DeleteServiceInstanceInfra 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/DeleteGenericALaCarteServiceInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy new file mode 100644 index 0000000000..7555885bcb --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy @@ -0,0 +1,353 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.runtime.Execution +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 DelServiceInstance.bpmn process. + * + */ +public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor { + + String Prefix="DELSI_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + VidUtils vidUtils = new VidUtils() + + public void preProcessRequest (Execution 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) + } + + } 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 (Execution 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 (Execution 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 = + """ + ${errorMessage} + 7000 + """ + + 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 (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** prepareCompletion *** ", isDebugEnabled) + + try { + String requestId = execution.getVariable("msoRequestId") + String source = execution.getVariable("source") + String msoCompletionRequest = + """ + + ${requestId} + DELETE + ${source} + + Service Instance was deleted successfully. + DeleteGenericALaCarteServiceInstance + """ + + // 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(Execution 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 = + """ + ${requestId} + DELETE + ${source} + """ + + 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 = + """ + + ${requestId} + DELETE + VID + + + ${errorException} + 7000 + + """ + + execution.setVariable("falloutRequest", falloutRequest) + } + utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled) + } + + + // ******************************* + // Build DB request Section + // ******************************* + public void prepareDBRequest (Execution 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 = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + COMPLETED + 100 + + + """ + + 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 (Execution 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 = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + FAILED + + + """ + + 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/DeleteGenericMacroServiceNetworkVnf.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy index e49de0bc09..108f8d3751 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy @@ -1,468 +1,468 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.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.WorkflowException -import org.openecomp.mso.rest.APIResponse; - - -import java.util.UUID; - -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.runtime.Execution -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 DeleteViprAtmService.bpmn process. - * - */ -public class DeleteGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { - - String Prefix="DELVAS_" - 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 DeleteViprAtmService.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("deleteViprAtmServiceRequest", "") - execution.setVariable("msoRequestId", "") - execution.setVariable("DELVAS_vnfsDeletedCount", 0) - execution.setVariable("DELVAS_vnfsCount", 0) - execution.setVariable("DELVAS_networksCount", 0) - execution.setVariable("DELVAS_networksDeletedCount", 0) - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest DeleteViprAtmService Request ***** ", isDebugEnabled) - - try { - // initialize flow variables - InitializeProcessVariables(execution) - - // check for incoming json message/input - String deleteViprAtmServiceRequest = execution.getVariable("bpmnRequest") - utils.logAudit(deleteViprAtmServiceRequest) - execution.setVariable("deleteViprAtmServiceRequest", deleteViprAtmServiceRequest); - println 'deleteViprAtmServiceRequest - ' + deleteViprAtmServiceRequest - - // 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(deleteViprAtmServiceRequest, "requestDetails.requestInfo.source") - if ((source == null) || (source.isEmpty())) { - execution.setVariable("source", "VID") - } else { - execution.setVariable("source", source) - } - - // extract globalSubscriberId - String globalSubscriberId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.subscriberInfo.globalSubscriberId") - - // global-customer-id is optional on Delete - - execution.setVariable("globalSubscriberId", globalSubscriberId) - execution.setVariable("globalCustomerId", globalSubscriberId) - - String suppressRollback = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.requestInfo.suppressRollback") - execution.setVariable("disableRollback", suppressRollback) - utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) - - String productFamilyId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.requestInfo.productFamilyId") - execution.setVariable("productFamilyId", productFamilyId) - utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) - - // extract subscriptionServiceType - String subscriptionServiceType = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.requestParameters.subscriptionServiceType") - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) - - // extract cloud configuration - String lcpCloudRegionId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") - execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) - utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) - String tenantId = jsonUtil.getJsonValue(deleteViprAtmServiceRequest, "requestDetails.cloudConfiguration.tenantId") - execution.setVariable("tenantId", tenantId) - utils.log("DEBUG","tenantId: "+ tenantId, isDebugEnabled) - - String sdncVersion = "1702" - execution.setVariable("sdncVersion", sdncVersion) - utils.log("DEBUG","sdncVersion: "+ sdncVersion, isDebugEnabled) - - //For Completion Handler & Fallout Handler - String requestInfo = - """ - ${requestId} - DELETE - ${source} - """ - - execution.setVariable("DELVAS_requestInfo", requestInfo) - - //Setting for Generic Sub Flows - execution.setVariable("GENGS_type", "service-instance") - - utils.log("DEBUG", " ***** Completed preProcessRequest DeleteViprAtmService Request ***** ", isDebugEnabled) - - } catch (BpmnError e) { - throw e; - } catch (Exception ex){ - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected from method preProcessRequest() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteViprAtmService ***** ", 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 DeleteViprAtmService flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - public void prepareServiceInstanceDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteViprAtmService ***** ", isDebugEnabled) - - try { - - String serviceInstanceId = execution.getVariable("serviceInstanceId") - - // confirm if ServiceInstance was found - if ( !execution.getVariable("GENGS_FoundIndicator") ) - { - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Service Instance was not found in AAI by id: " + serviceInstanceId - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - // get variable within incoming json - String deleteViprAtmServiceRequest = execution.getVariable("deleteViprAtmServiceRequest"); - - // get SI extracted by GenericGetService - String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); - - utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled) - - String relationship = "" - try { - relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list") - } catch (Exception ex) { - //no relationships found - } - utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled) - - int vnfsCount = 0 - int networksCount = 0 - - if (relationship != null && relationship.length() > 0){ - relationship = relationship.trim().replace("tag0:","").replace(":tag0","") - - // Check if Network TableREf is present, then build a List of network policy - List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship) - vnfsCount = relatedVnfIdList.size() - execution.setVariable("DELVAS_vnfsCount", vnfsCount) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList) - - // Check if Network TableREf is present, then build a List of network policy - List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship) - networksCount = relatedNetworkIdList.size() - execution.setVariable("DELVAS_networksCount", networksCount) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList) - } else { - execution.setVariable("DELVAS_vnfsCount", 0) - utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) - execution.setVariable("DELVAS_networksCount", 0) - utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) - } - - utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteViprAtmService ***** ", isDebugEnabled) - } catch (Exception ex) { - sendSyncError(execution) - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. prepareServiceInstanceDelete() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - // ******************************* - // - // ******************************* - public void prepareVnfAndModulesDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) - - List vnfList = execution.getVariable("DELVAS_relatedVnfIdList") - Integer vnfsDeletedCount = execution.getVariable("DELVAS_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 DeleteServiceInstanceMacro ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Vnf request Section -> increment count - // ******************************* - public void validateVnfDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteViprAtmService ***** ", isDebugEnabled) - - String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") - vnfsDeletedCount++ - - execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount) - - utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteViprAtmService ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Generate Network request Section - // ******************************* - public void prepareNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - - List networkList = execution.getVariable("DELVAS_relatedNetworkIdList") - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - - String networkId = "" - if (networkList.size() > 0) { - networkId = networkList.get(networksDeletedCount.intValue()) - } - - execution.setVariable("networkId", networkId) - utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled) - - utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = q"Bpmn error encountered in DeleteViprAtmService flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - // ******************************* - // Validate Network request Section - // ******************************* - public void validateNetworkDelete (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - - try { - utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - - Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") - networksDeletedCount++ - - execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount) - - utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteViprAtmService ***** ", isDebugEnabled) - } catch (Exception ex) { - // try error in method block - String exceptionMessage = "Bpmn error encountered in DeleteViprAtmService flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage() - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - } - - - // ***************************************** - // Prepare Completion request Section - // ***************************************** - public void postProcessResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteViprAtmService ***** ", isDebugEnabled) - - try { - String source = execution.getVariable("source") - String requestId = execution.getVariable("msoRequestId") - - String msoCompletionRequest = - """ - - ${requestId} - DELETE - ${source} - - vIPR ATM Service Instance has been deleted successfully. - BPMN Service Instance macro action: DELETE - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("DELVAS_Success", true) - execution.setVariable("DELVAS_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(Execution execution){ - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " *** STARTED DeleteViprAtmService prepareFalloutRequest Process *** ", isDebugEnabled) - - try { - WorkflowException wfex = execution.getVariable("WorkflowException") - utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) - String requestInfo = execution.getVariable("DELVAS_requestInfo") - utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) - - String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) - - execution.setVariable("DELVAS_falloutRequest", falloutRequest) - } catch (Exception ex) { - utils.log("DEBUG", "Error Occured in DeleteViprAtmService prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteViprAtmService prepareFalloutRequest Process") - } - utils.log("DEBUG", "*** COMPLETED DeleteViprAtmService prepareFalloutRequest Process ***", isDebugEnabled) - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", 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 = - """ - ${errorMessage} - 7000 - """ - - 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(Execution 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("DELVAS_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("DELVAS_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) - } - - +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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.WorkflowException +import org.openecomp.mso.rest.APIResponse; + + +import java.util.UUID; + +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.runtime.Execution +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 DeleteViprAtmService.bpmn process. + * + */ +public class DeleteGenericMacroServiceNetworkVnf extends AbstractServiceTaskProcessor { + + String Prefix="DELVAS_" + 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 DeleteGenericMacroServiceNetworkVnf.bpmn process. + * @param execution + */ + public InitializeProcessVariables(Execution execution){ + /* Initialize all the process variables in this block */ + + execution.setVariable("DeleteGenericMacroServiceNetworkVnfRequest", "") + execution.setVariable("msoRequestId", "") + execution.setVariable("DELVAS_vnfsDeletedCount", 0) + execution.setVariable("DELVAS_vnfsCount", 0) + execution.setVariable("DELVAS_networksCount", 0) + execution.setVariable("DELVAS_networksDeletedCount", 0) + } + + // ************************************************** + // Pre or Prepare Request Section + // ************************************************** + /** + * This method is executed during the preProcessRequest task of the CreateServiceInstance.bpmn process. + * @param execution + */ + public void preProcessRequest (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " ***** Inside preProcessRequest DeleteGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + try { + // initialize flow variables + InitializeProcessVariables(execution) + + // check for incoming json message/input + String DeleteGenericMacroServiceNetworkVnfRequest = execution.getVariable("bpmnRequest") + utils.logAudit(DeleteGenericMacroServiceNetworkVnfRequest) + execution.setVariable("DeleteGenericMacroServiceNetworkVnfRequest", DeleteGenericMacroServiceNetworkVnfRequest); + println 'DeleteGenericMacroServiceNetworkVnfRequest - ' + DeleteGenericMacroServiceNetworkVnfRequest + + // 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(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.source") + if ((source == null) || (source.isEmpty())) { + execution.setVariable("source", "VID") + } else { + execution.setVariable("source", source) + } + + // extract globalSubscriberId + String globalSubscriberId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.subscriberInfo.globalSubscriberId") + + // global-customer-id is optional on Delete + + execution.setVariable("globalSubscriberId", globalSubscriberId) + execution.setVariable("globalCustomerId", globalSubscriberId) + + String suppressRollback = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.suppressRollback") + execution.setVariable("disableRollback", suppressRollback) + utils.log("DEBUG", "Incoming Suppress/Disable Rollback is: " + suppressRollback, isDebugEnabled) + + String productFamilyId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestInfo.productFamilyId") + execution.setVariable("productFamilyId", productFamilyId) + utils.log("DEBUG", "Incoming productFamilyId is: " + productFamilyId, isDebugEnabled) + + // extract subscriptionServiceType + String subscriptionServiceType = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.requestParameters.subscriptionServiceType") + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + utils.log("DEBUG", "Incoming subscriptionServiceType is: " + subscriptionServiceType, isDebugEnabled) + + // extract cloud configuration + String lcpCloudRegionId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.cloudConfiguration.lcpCloudRegionId") + execution.setVariable("lcpCloudRegionId", lcpCloudRegionId) + utils.log("DEBUG","lcpCloudRegionId: "+ lcpCloudRegionId, isDebugEnabled) + String tenantId = jsonUtil.getJsonValue(DeleteGenericMacroServiceNetworkVnfRequest, "requestDetails.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 = + """ + ${requestId} + DELETE + ${source} + """ + + execution.setVariable("DELVAS_requestInfo", requestInfo) + + //Setting for Generic Sub Flows + execution.setVariable("GENGS_type", "service-instance") + + utils.log("DEBUG", " ***** Completed preProcessRequest DeleteGenericMacroServiceNetworkVnf Request ***** ", isDebugEnabled) + + } catch (BpmnError e) { + throw e; + } catch (Exception ex){ + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected from method preProcessRequest() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void sendSyncResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + utils.log("DEBUG", " ***** Inside sendSyncResponse of DeleteGenericMacroServiceNetworkVnf ***** ", 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 DeleteGenericMacroServiceNetworkVnf flow. Unexpected from method sendSyncResponse() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + public void prepareServiceInstanceDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** Inside prepareServiceInstanceDelete() of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + + // confirm if ServiceInstance was found + if ( !execution.getVariable("GENGS_FoundIndicator") ) + { + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Service Instance was not found in AAI by id: " + serviceInstanceId + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + + // get variable within incoming json + String DeleteGenericMacroServiceNetworkVnfRequest = execution.getVariable("DeleteGenericMacroServiceNetworkVnfRequest"); + + // get SI extracted by GenericGetService + String serviceInstanceAaiRecord = execution.getVariable("GENGS_service"); + + utils.log("DEBUG", "serviceInstanceAaiRecord: "+serviceInstanceAaiRecord, isDebugEnabled) + + String relationship = "" + try { + relationship = networkUtils.getFirstNodeXml(serviceInstanceAaiRecord, "relationship-list") + } catch (Exception ex) { + //no relationships found + } + utils.log("DEBUG", " relationship string - " + relationship, isDebugEnabled) + + int vnfsCount = 0 + int networksCount = 0 + + if (relationship != null && relationship.length() > 0){ + relationship = relationship.trim().replace("tag0:","").replace(":tag0","") + + // Check if Network TableREf is present, then build a List of network policy + List relatedVnfIdList = networkUtils.getRelatedVnfIdList(relationship) + vnfsCount = relatedVnfIdList.size() + execution.setVariable("DELVAS_vnfsCount", vnfsCount) + utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) + execution.setVariable("DELVAS_relatedVnfIdList", relatedVnfIdList) + + // Check if Network TableREf is present, then build a List of network policy + List relatedNetworkIdList = networkUtils.getRelatedNetworkIdList(relationship) + networksCount = relatedNetworkIdList.size() + execution.setVariable("DELVAS_networksCount", networksCount) + utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) + execution.setVariable("DELVAS_relatedNetworkIdList", relatedNetworkIdList) + } else { + execution.setVariable("DELVAS_vnfsCount", 0) + utils.log("DEBUG", " DELVAS_vnfsCount : " + vnfsCount, isDebugEnabled) + execution.setVariable("DELVAS_networksCount", 0) + utils.log("DEBUG", " DELVAS_networksCount : " + networksCount, isDebugEnabled) + } + + utils.log("DEBUG", " ***** Completed prepareServiceInstanceDelete() of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + sendSyncError(execution) + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. prepareServiceInstanceDelete() - " + ex.getMessage() + utils.log("DEBUG", exceptionMessage, isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + // ******************************* + // + // ******************************* + public void prepareVnfAndModulesDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareVnfAndModulesDelete of DeleteServiceInstanceMacro ***** ", isDebugEnabled) + + List vnfList = execution.getVariable("DELVAS_relatedVnfIdList") + Integer vnfsDeletedCount = execution.getVariable("DELVAS_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 DeleteServiceInstanceMacro ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceMacro flow. Unexpected Error from method prepareVnfAndModulesDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Vnf request Section -> increment count + // ******************************* + public void validateVnfDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateVnfDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + String vnfsDeletedCount = execution.getVariable("DELVAS_vnfsDeletedCount") + vnfsDeletedCount++ + + execution.setVariable("DELVAS_vnfsDeletedCount", vnfsDeletedCount) + + utils.log("DEBUG", " ***** Completed validateVnfDelete of DeleteGenericMacroServiceNetworkVnf ***** "+" vnf # "+vnfsDeletedCount, isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateVnfDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Generate Network request Section + // ******************************* + public void prepareNetworkDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside prepareNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + List networkList = execution.getVariable("DELVAS_relatedNetworkIdList") + Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") + + String networkId = "" + if (networkList.size() > 0) { + networkId = networkList.get(networksDeletedCount.intValue()) + } + + execution.setVariable("networkId", networkId) + utils.log("DEBUG", "need to delete networkId:" + networkId, isDebugEnabled) + + utils.log("DEBUG", " ***** Completed prepareNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = q"Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method prepareNetworkDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + // ******************************* + // Validate Network request Section + // ******************************* + public void validateNetworkDelete (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + + try { + utils.log("DEBUG", " ***** Inside validateNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + Integer networksDeletedCount = execution.getVariable("DELVAS_networksDeletedCount") + networksDeletedCount++ + + execution.setVariable("DELVAS_networksDeletedCount", networksDeletedCount) + + utils.log("DEBUG", " ***** Completed validateNetworkDelete of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + } catch (Exception ex) { + // try error in method block + String exceptionMessage = "Bpmn error encountered in DeleteGenericMacroServiceNetworkVnf flow. Unexpected Error from method validateNetworkDelete() - " + ex.getMessage() + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) + } + } + + + // ***************************************** + // Prepare Completion request Section + // ***************************************** + public void postProcessResponse (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** Inside postProcessResponse of DeleteGenericMacroServiceNetworkVnf ***** ", isDebugEnabled) + + try { + String source = execution.getVariable("source") + String requestId = execution.getVariable("msoRequestId") + + String msoCompletionRequest = + """ + + ${requestId} + DELETE + ${source} + + vIPR ATM Service Instance has been deleted successfully. + BPMN Service Instance macro action: DELETE + """ + + // Format Response + String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) + + utils.logAudit(xmlMsoCompletionRequest) + execution.setVariable("DELVAS_Success", true) + execution.setVariable("DELVAS_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(Execution execution){ + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " *** STARTED DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process *** ", isDebugEnabled) + + try { + WorkflowException wfex = execution.getVariable("WorkflowException") + utils.log("DEBUG", " Incoming Workflow Exception: " + wfex.toString(), isDebugEnabled) + String requestInfo = execution.getVariable("DELVAS_requestInfo") + utils.log("DEBUG", " Incoming Request Info: " + requestInfo, isDebugEnabled) + + String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo) + + execution.setVariable("DELVAS_falloutRequest", falloutRequest) + } catch (Exception ex) { + utils.log("DEBUG", "Error Occured in DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process " + ex.getMessage(), isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process") + } + utils.log("DEBUG", "*** COMPLETED DeleteGenericMacroServiceNetworkVnf prepareFalloutRequest Process ***", isDebugEnabled) + } + + + public void sendSyncError (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG", " ***** Inside sendSyncError() of DeleteServiceInstanceInfra ***** ", 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 = + """ + ${errorMessage} + 7000 + """ + + 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(Execution 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("DELVAS_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("DELVAS_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) + } + + } \ No newline at end of file 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 index 9e341dafbc..e18af172de 100644 --- 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 @@ -1,417 +1,417 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.runtime.Execution -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(Execution 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 (Execution 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 (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of DeleteNetworkInstance ***** ", isDebugEnabled) - - try { - - // "networkModelInfo" is expected to be sent - String networkModelInfo = execution.getVariable("networkModelInfo") - utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) - - - } 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 (Execution 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 (Execution 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 = - """ - - ${requestId} - DELETE - VID - - Network has been deleted successfully. - BPMN Network action: DELETE - """ - - // 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 (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteNetworkInstance ***** ", isDebugEnabled) - - WorkflowException wfe = execution.getVariable("WorkflowException") - String statusMessage = wfe.getErrorMessage() - String requestId = execution.getVariable(Prefix +"requestId") - - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - FAILED - - <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"/> - - - """ - - 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 (Execution 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 (Execution 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 = - """ - - ${requestId} - DELETE - ${source} - - - ${errorMessage} - ${errorCode} - - """ - - 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 = - """ - - ${requestId} - DELEtE - ${source} - - - ${exceptionMessage} - 9999 - - """ - execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - } - } - - - public void sendSyncError (Execution 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(Execution 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) - } - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.runtime.Execution +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(Execution 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 (Execution 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 (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + utils.log("DEBUG", " ***** Inside getNetworkModelInfo() of DeleteNetworkInstance ***** ", isDebugEnabled) + + try { + + // "networkModelInfo" is expected to be sent + String networkModelInfo = execution.getVariable("networkModelInfo") + utils.log("DEBUG", " networkModelInfo - " + networkModelInfo, isDebugEnabled) + + + } 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 (Execution 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 (Execution 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 = + """ + + ${requestId} + DELETE + VID + + Network has been deleted successfully. + BPMN Network action: DELETE + """ + + // 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 (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + + try { + utils.log("DEBUG", " ***** Inside prepareDBRequestError of DeleteNetworkInstance ***** ", isDebugEnabled) + + WorkflowException wfe = execution.getVariable("WorkflowException") + String statusMessage = wfe.getErrorMessage() + String requestId = execution.getVariable(Prefix +"requestId") + + String dbRequest = + """ + + + + ${requestId} + BPMN + ${statusMessage} + + FAILED + + <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"/> + + + """ + + 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 (Execution 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 (Execution 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 = + """ + + ${requestId} + DELETE + ${source} + + + ${errorMessage} + ${errorCode} + + """ + + 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 = + """ + + ${requestId} + DELEtE + ${source} + + + ${exceptionMessage} + 9999 + + """ + execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest) + utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) + } + } + + + public void sendSyncError (Execution 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(Execution 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/DoCreateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy index 2d5ddf0d0c..d221d0622b 100644 --- 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 @@ -1,37 +1,37 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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========================================================= +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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; +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 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; @@ -322,7 +322,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkInputs = execution.getVariable(Prefix + "networkInputs") String networkName = utils.getNodeText1(networkInputs, "network-name") networkName = UriUtils.encode(networkName,"UTF-8") - String messageId = execution.getVariable("messageId") // Prepare AA&I url with network-name String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -333,14 +332,8 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryNameAAIRequest", queryAAINameRequest) utils.log("DEBUG", Prefix + "queryNameAAIRequest - " + "\n" + queryAAINameRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryAAINameRequest); - try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + 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) @@ -483,7 +476,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "networkName", networkName) networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -494,12 +486,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryIdAAIRequest", queryIdAAIRequest) utils.log("DEBUG", Prefix + "queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryIdAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiIdReturnCode", returnCode) @@ -562,7 +549,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = execution.getVariable(Prefix + "networkId") String netId = networkId networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -573,12 +559,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "requeryIdAAIRequest", requeryIdAAIRequest) utils.log("DEBUG", Prefix + "requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(requeryIdAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiRequeryIdReturnCode", returnCode) utils.log("DEBUG", " ***** AAI ReQuery Response Code : " + returnCode, isDebugEnabled) @@ -642,7 +623,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -693,12 +673,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) utils.log("DEBUG", Prefix + "queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryVpnBindingAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + 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) @@ -747,7 +722,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -781,7 +756,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -835,12 +809,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) utils.log("DEBUG", Prefix + "queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryNetworkPolicyAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + 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) @@ -889,7 +858,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -923,7 +892,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "queryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -977,12 +945,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) utils.log("DEBUG", Prefix + "queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest, isDebugEnabled) - RESTConfig config = new RESTConfig(queryNetworkTableRefAAIRequest); - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + 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) @@ -1031,7 +994,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -1070,7 +1033,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") String createNetworkResponse = execution.getVariable(Prefix + "createNetworkResponse") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -1083,7 +1045,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", Prefix + "updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, createNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) utils.logAudit(payloadXml) @@ -1096,7 +1058,6 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { 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) @@ -1125,7 +1086,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // aai all errors String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, "2500", errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } } } @@ -1153,7 +1114,7 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { // get variables String requestId = execution.getVariable("msoRequestId") if (requestId == null) { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } String messageId = execution.getVariable(Prefix + "messageId") String source = execution.getVariable(Prefix + "source") @@ -1200,12 +1161,12 @@ public class DoCreateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = execution.getVariable(Prefix + "networkId") String serviceInstanceId = execution.getVariable(Prefix + "serviceInstanceId") - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) 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 index e6276a8852..9f28db727d 100644 --- 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 @@ -1,39 +1,39 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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========================================================= +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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; +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.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 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; @@ -134,14 +134,14 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { execution.setVariable("sdncCallbackUrl", sdncCallbackUrl) utils.log("DEBUG","SDNC Callback URL: " + sdncCallbackUrl, isDebugEnabled) - String personaModelId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") - String personaModelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + String modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") + String modelVersionId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") - if (personaModelId == null) { - personaModelId = "" + if (modelInvariantId == null) { + modelInvariantId = "" } - if (personaModelVersion == null) { - personaModelVersion = "" + if (modelVersionId == null) { + modelVersionId = "" } if (serviceInstanceName == null) { execution.setVariable("serviceInstanceName", "") @@ -155,9 +155,9 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { String serviceInstanceData = """ ${serviceInstanceName} - active - ${personaModelId} - ${personaModelVersion} + Active + ${modelInvariantId} + ${modelVersionId} """.trim() execution.setVariable("serviceInstanceData", serviceInstanceData) @@ -362,9 +362,9 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { } String sdncAssignRequest = - """ + """ ${sdncRequestId} ${serviceInstanceId} @@ -406,12 +406,14 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor { utils.logAudit("sdncAssignRequest: " + sdncAssignRequest) def sdncRequestId2 = UUID.randomUUID().toString() - String sdncRollbackRequest = sdncAssignRequest.replace(">assign<", ">delete<").replace(">CreateServiceInstance<", ">DeleteServiceInstance<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<") + 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", "sdncRollbackRequest", sdncRollbackRequest) + rollbackData.put("SERVICEINSTANCE", "sdncDeactivate", sdncDeactivate) + rollbackData.put("SERVICEINSTANCE", "sdncDelete", sdncDelete) execution.setVariable("rollbackData", rollbackData) - utils.log("DEBUG","sdncRollbackRequest:\n" + sdncRollbackRequest, isDebugEnabled) utils.log("DEBUG","rollbackData:\n" + rollbackData.toString(), isDebugEnabled) } catch (BpmnError e) { 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 index 1e6541e226..0e9fd7f4b7 100644 --- 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 @@ -106,8 +106,12 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso execution.setVariable("skipRollback", true) } - def sdncRollbackRequest = rollbackData.get("SERVICEINSTANCE", "sdncRollbackRequest") - execution.setVariable("sdncRollbackRequest", sdncRollbackRequest) + 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) @@ -131,31 +135,33 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso utils.log("DEBUG"," ***** Exit preProcessRequest *****", isDebugEnabled) } - public void validateSDNCResponse(Execution execution) { + public void validateSDNCResponse(Execution 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") - String response = execution.getVariable("sdncAdapterResponse") - + 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", "SDNC Adapter for service-instance delete for rollback successful. response", isDebugEnabled) + msg = "SDNC Adapter service-instance rollback successful for " + method + utils.log("DEBUG", msg, isDebugEnabled) }else{ execution.setVariable("rolledBack", false) - execution.setVariable("rollbackError", "Error Response from SDNC Adapter for service-instance delete for rollback") - utils.log("DEBUG","Error Response from SDNC Adapter for service-instance delete for rollback", isDebugEnabled) + 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 validateSDNCResponse " + ex.getMessage() + msg = "Exception in Create ServiceInstance rollback for " + method + " Exception:" + ex.getMessage() utils.log("DEBUG", msg, isDebugEnabled) exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) } @@ -187,7 +193,7 @@ public class DoCreateServiceInstanceRollback extends AbstractServiceTaskProcesso utils.log("DEBUG","*** Exit postProcessRequest ***", isDebugEnabled) } catch (BpmnError e) { - msg = "Exception in Create ServiceInstance Rollback postProcessRequest. " + ex.getMessage() + 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() 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 index 269cb808c4..1fd5ab0abc 100644 --- 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 @@ -17,12 +17,12 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - + package org.openecomp.mso.bpmn.infrastructure.scripts; - -import javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - + +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.runtime.Execution @@ -37,15 +37,15 @@ 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.w3c.dom.NamedNodeMap -import org.w3c.dom.Node +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 org.xml.sax.InputSource + + public class DoCreateVfModule extends VfModuleBase { @@ -140,7 +140,7 @@ public class DoCreateVfModule extends VfModuleBase { def requestId = execution.getVariable("msoRequestId") execution.setVariable("DCVFM_requestId", requestId) logDebug("requestId: " + requestId, isDebugLogEnabled) - // Set mso-request-id to request-id for VNF Adapter interface + // Set mso-request-id to request-id for VNF Adapter interface execution.setVariable("mso-request-id", requestId) //serviceId def serviceId = execution.getVariable("serviceId") @@ -175,7 +175,7 @@ public class DoCreateVfModule extends VfModuleBase { //personaModelId execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId")) //personaModelVersion - execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion")) + execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersionId")) //vfModuleLabel def vfModuleLabel = execution.getVariable("vfModuleLabel") if (vfModuleLabel != null) { @@ -665,7 +665,7 @@ public class DoCreateVfModule extends VfModuleBase { String uuid = execution.getVariable('testReqId') // for junits if(uuid==null){ - uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() + uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis() } def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl") @@ -680,6 +680,14 @@ public class DoCreateVfModule extends VfModuleBase { 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 @@ -723,7 +731,7 @@ public class DoCreateVfModule extends VfModuleBase { query ${serviceOperation} ${callbackUrl} - mobility + ${msoAction} """ @@ -902,13 +910,13 @@ public class DoCreateVfModule extends VfModuleBase { def requestId = execution.getVariable("mso-request-id") if (requestId == null) { - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id") + 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") + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id") } utils.logContext(requestId, serviceInstanceId) @@ -1014,9 +1022,9 @@ public class DoCreateVfModule extends VfModuleBase { if (!sdncVersion.equals("1707")) { sdncRequest = - """ + """ ${requestId} ${svcInstId} @@ -1057,14 +1065,14 @@ public class DoCreateVfModule extends VfModuleBase { else { sdncRequest = - """ + """ ${requestId} ${svcInstId} ${action} - vnf-topology-operation + vf-module-topology-operation ${callbackURL} generic-resource @@ -1081,10 +1089,7 @@ public class DoCreateVfModule extends VfModuleBase { ${serviceEcompModelInformation} ${svcInstId} ${globalSubscriberId} - - - ${vfModuleModelName} - + ${vnfId} ${vnfType} @@ -1095,11 +1100,10 @@ public class DoCreateVfModule extends VfModuleBase { ${vfModuleModelName} ${vfModuleEcompModelInformation} - - ${sdncVersion} + ${vfModuleName} ${tenantId} - ${cloudSiteId} + ${cloudSiteId} ${sdncVNFParamsXml} @@ -1108,9 +1112,9 @@ public class DoCreateVfModule extends VfModuleBase { /* sdncRequest = - """ + """ ${requestId} ${svcInstId} @@ -1142,8 +1146,7 @@ public class DoCreateVfModule extends VfModuleBase { ${vfModuleModelName} ${vfModuleEcompModelInformation} - - ${sdncVersion} + ${vfModuleName} ${tenantId} ${cloudSiteId} @@ -1662,7 +1665,7 @@ public class DoCreateVfModule extends VfModuleBase { def networkPolicyId = UUID.randomUUID().toString() logDebug("Adding network-policy with network-policy-id " + networkPolicyId, isDebugLogEnabled) - String aaiNamespace = aaiUriUtil.getNamespaceFromUri(aai_uri) + String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) logDebug('AAI namespace is: ' + aaiNamespace, isDebugLogEnabled) String payload = """ ${networkPolicyId} 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 index 8ca749d1ec..af1161b656 100644 --- 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 @@ -1,33 +1,33 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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 +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.runtime.Execution -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 +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 @@ -72,7 +72,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("DCVFMR_cloudSiteId", cloudSiteId) String heatStackId = rollbackData.get("VFMODULE", "heatstackid") execution.setVariable("DCVFMR_heatStackId", heatStackId) - String requestId = rollbackData.get("VFMODULE", "msorequestid") + String requestId = rollbackData.get("VFMODULE", "attmsorequestid") execution.setVariable("DCVFMR_requestId", requestId) List createdNetworkPolicyFqdnList = [] int i = 0 @@ -92,7 +92,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ execution.setVariable("DCVFMR_oamManagementV4Address", oamManagementV4Address) String oamManagementV6Address = rollbackData.get("VFMODULE", "oamManagementV6Address") execution.setVariable("DCVFMR_oamManagementV6Address", oamManagementV6Address) - //String serviceInstanceId = rollbackData.get("VFMODULE", "msoserviceinstanceid") + //String serviceInstanceId = rollbackData.get("VFMODULE", "attmsoserviceinstanceid") //execution.setVariable("DCVFMR_serviceInstanceId", serviceInstanceId) execution.setVariable("DCVFMR_rollbackPrepareUpdateVfModule", rollbackData.get("VFMODULE", "rollbackPrepareUpdateVfModule")) execution.setVariable("DCVFMR_rollbackUpdateAAIVfModule", rollbackData.get("VFMODULE", "rollbackUpdateAAIVfModule")) @@ -159,9 +159,9 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ return - String request = """ + String request = """ ${requestId} ${vfModuleId} @@ -214,7 +214,7 @@ public class DoCreateVfModuleRollback extends AbstractServiceTaskProcessor{ 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') + '-' + + def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId) def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host") diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy index f54fa5c88b..8e54024c6f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy +++ b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy @@ -303,7 +303,7 @@ class DoCreateVfModuleVolumeV1 extends VfModuleBase { def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id') def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name') def modelCustomizationId = getNodeTextForce(volumeRequest, "model-customization-id") - + String messageId = UUID.randomUUID() utils.log("DEBUG", "messageId to be used is generated: " + messageId, isDebugEnabled) @@ -502,6 +502,9 @@ class DoCreateVfModuleVolumeV1 extends VfModuleBase { utils.logAudit("AAI query generic vnf return code: " + returnCode) utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString) + //utils.log("DEBUG", "AAI query generic vnf return code: " + returnCode, isDebugEnabled) + //utils.log("DEBUG", "AAI query generic vnf response: " + aaiResponseAsString, isDebugEnabled) + ExceptionUtil exceptionUtil = new ExceptionUtil() if (returnCode=='200') { 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 index 55d56a6194..8a6cac4a91 100644 --- 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 @@ -16,12 +16,12 @@ * 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.openecomp.mso.bpmn.core.RollbackData +import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution import org.openecomp.mso.bpmn.common.scripts.AaiUtil import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor @@ -30,429 +30,557 @@ 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 - - -/** - * 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(Execution 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 - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vnfModelInfo = execution.getVariable("vnfModelInfo") - String serviceModelInfo = execution.getVariable("serviceModelInfo") - - String requestId = execution.getVariable("requestId") - execution.setVariable("DoCVNF_requestId", requestId) + + +/** + * 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(Execution 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 + + 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) - 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") - 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) - 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, "modelInvariantId") - execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) - utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) - - String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") - 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, "modelCustomizationId") - if (modelCustomizationId == null) { - modelCustomizationId = "" - } - execution.setVariable("DoCVNF_modelCustomizationId", modelCustomizationId) - utils.log("DEBUG", "Incoming Model Customization Id is: " + modelCustomizationId, isDebugEnabled) - - String cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "lcpCloudRegionId") - execution.setVariable("DoCVNF_cloudSiteId", cloudSiteId) - utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) - - String tenantId = jsonUtil.getJsonValue(cloudConfiguration, "tenantId") - execution.setVariable("DoCVNF_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 = + utils.log("DEBUG", "Incoming Request Id is: " + requestId, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + execution.setVariable("DoCVNF_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) + 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, "modelInvariantId") + execution.setVariable("DoCVNF_modelInvariantId", modelInvariantId) + utils.log("DEBUG", "Incoming Invariant Id is: " + modelInvariantId, isDebugEnabled) + + String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId") + 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, "modelCustomizationId") + 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) + utils.log("DEBUG", "Incoming Cloud Site Id is: " + cloudSiteId, isDebugEnabled) + + String tenantId = execution.getVariable("tenantId") + execution.setVariable("DoCVNF_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 = """ - ${requestId} - CREATE - ${source} - """ - - 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) - utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) - logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) - - def rollbackData = execution.getVariable("RollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - 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) - } - - - public void prepareCreateGenericVnf (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfId = execution.getVariable("DoCVNF_vnfId") - def vnfName = execution.getVariable("DoCVNF_vnfName") - def vnfType = execution.getVariable("DoCVNF_vnfType") - def serviceId = execution.getVariable("DoCVNF_serviceId") - def orchStatus = execution.getVariable("DoCVNF_orchStatus") - def modelInvariantId = execution.getVariable("DoCVNF_modelInvariantId") - def modelVersion = execution.getVariable("DoCVNF_modelVersion") - def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") - // TODO: 1702 Variable - def equipmentRole = execution.getVariable("DoCVNF_equipmentRole") - - //Get Service Instance Info - def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") - String siRelatedLink = execution.getVariable("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) - - //Get Namespace - AaiUtil aaiUtil = new AaiUtil(this) - def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) - String namespace = aaiUtil.getNamespaceFromUri(aai_uri) - - String payload = - """ - ${vnfId} - ${vnfName} - ${serviceId} - ${vnfType} - PREPROV - ${orchStatus} - ${modelInvariantId} - ${modelVersion} - ${modelCustomizationId} - - - service-instance - ${siRelatedLink} - - customer.global-customer-id - ${globalCustId} - - - service-subscription.service-type - ${serviceType} - - - service-instance.service-instance-id - ${serviceInstanceId} - - - - """ - - 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 (Execution 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) - 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(Execution 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(Execution 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(Execution execution, String svcInstId, String action){ - - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ + ${requestId} + CREATE + ${source} + """ + + 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) + utils.logAudit("SDNC Callback URL: " + sdncCallbackUrl) + logDebug("SDNC Callback URL is: " + sdncCallbackUrl, isDebugEnabled) + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + 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) + } + + + public void prepareCreateGenericVnf (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " *** STARTED DoCreateVnf PrepareCreateGenericVnf Process *** ", isDebugEnabled) + try { + //Get Vnf Info + String vnfId = execution.getVariable("DoCVNF_vnfId") + def vnfName = execution.getVariable("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) + } + def vnfType = execution.getVariable("DoCVNF_vnfType") + def serviceId = execution.getVariable("DoCVNF_serviceId") + def orchStatus = execution.getVariable("DoCVNF_orchStatus") + def modelInvariantId = execution.getVariable("DoCVNF_modelInvariantId") + def modelVersionId = execution.getVariable("DoCVNF_modelVersionId") + def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId") + // TODO: 1702 Variable + def equipmentRole = execution.getVariable("DoCVNF_equipmentRole") + + //Get Service Instance Info + def serviceInstanceId = execution.getVariable("DoCVNF_serviceInstanceId") + String siRelatedLink = execution.getVariable("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) + + //Get Namespace + AaiUtil aaiUtil = new AaiUtil(this) + def aai_uri = aaiUtil.getNetworkGenericVnfUri(execution) + String namespace = aaiUtil.getNamespaceFromUri(execution, aai_uri) + + String payload = + """ + ${vnfId} + ${vnfName} + ${serviceId} + ${vnfType} + PREPROV + ${orchStatus} + ${modelInvariantId} + ${modelVersionId} + ${modelCustomizationId} + + + service-instance + ${siRelatedLink} + + customer.global-customer-id + ${globalCustId} + + + service-subscription.service-type + ${serviceType} + + + service-instance.service-instance-id + ${serviceInstanceId} + + + + """ + + 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 (Execution 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) + 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(Execution 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(Execution 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(Execution 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("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") - 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 = + } + 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 = """${vnfName}""" + } + 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 = """ - - ${requestId} - ${svcInstId} - ${action} - vnf-topology-operation - ${callbackURL} - generic-resource - - - - ${requestId} - CreateVnfInstance - ${source} - - - - - - ${serviceId} - ${serviceId} - ${serviceEcompModelInformation} - ${svcInstId} - ${globalSubscriberId} - - - ${vnfId} - ${vnfType} - ${vnfEcompModelInformation} - - - ${sdncVersion} - - ${tenantId} - ${cloudSiteId} - ${sdncVNFParamsXml} - - - """ - - utils.logAudit("sdncRequest: " + sdncRequest) - return sdncRequest - } - - public void validateSDNCResponse(Execution 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) - } - - -} + + ${requestId} + ${svcInstId} + ${action} + vnf-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + CreateVnfInstance + ${source} + + + + + + ${serviceId} + ${serviceId} + ${serviceEcompModelInformation} + ${svcInstId} + ${globalSubscriberId} + + + ${vnfId} + ${vnfType} + ${vnfEcompModelInformation} + + + ${vnfNameString} + ${tenantId} + ${cloudSiteId} + ${sdncVNFParamsXml} + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(Execution 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) + } + + }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(Execution 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 = + """ + + ${uuid} + ${svcInstId} + query + ${serviceOperation} + ${callbackUrl} + vfmodule + + + """ + + 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(Execution 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 = """ + + ${vnfId} + Active + + """ + 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 index 861da52397..daae3d7dac 100644 --- 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 @@ -1,285 +1,369 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.runtime.Execution; - -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.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 - - - -/** -* 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(Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) - - try{ - // Get Variables - - - String cloudConfiguration = execution.getVariable("cloudConfiguration") - String vnfModelInfo = execution.getVariable("vnfModelInfo") - - String requestId = execution.getVariable("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 vnfType = execution.getVariable("vnfType") - utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) - - String vnfName = execution.getVariable("vnfName") - execution.setVariable("CREVI_vnfName", vnfName) - utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) - - String productFamilyId = execution.getVariable("productFamilyId") - utils.log("DEBUG", "Incoming Product Family Id is: " + productFamilyId, isDebugEnabled) - - String source = "VID" - execution.setVariable("source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - String disableRollback = execution.getVariable("disableRollback") - utils.log("DEBUG", "Incoming Disable Rollback is: " + disableRollback, isDebugEnabled) - - String asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") - utils.log("DEBUG", "Incoming asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugEnabled) - - 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("vnfId", vnfId) - - def rollbackData = execution.getVariable("RollbackData") - if (rollbackData == null) { - rollbackData = new RollbackData() - } - - execution.setVariable("numOfCreatedAddOnModules", 0) - - rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", 0) - execution.setVariable("RollbackData", rollbackData) - - }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 DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) - } - - - public void queryCatalogDB (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules QueryCatalogDB Process *** ", isDebugEnabled) - try { - //Get Vnf Info - String vnfModelInfo = execution.getVariable("vnfModelInfo") - String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationId") - utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid) - String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint") - - JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(catalogDbEndpoint, - vnfModelCustomizationUuid) - utils.log("DEBUG", "obtained VNF list") - // Only one match here - JSONObject vnf = vnfs[0] - JSONArray vfModules = vnf.getJSONArray("vfModules") - JSONArray addOnModules = new JSONArray() - - // Set up base Vf Module info - for (int i = 0; i < vfModules.length(); i++) { - utils.log("DEBUG", "handling VF Module ") - JSONObject vfModule = vfModules[i] - String isBase = jsonUtil.getJsonValueForKey(vfModule, "isBase") - if (isBase.equals("true")) { - JSONObject baseVfModuleModelInfoObject = vfModule.getJSONObject("modelInfo") - String baseVfModuleModelInfo = baseVfModuleModelInfoObject.toString() - execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) - String baseVfModuleLabel = jsonUtil.getJsonValueForKey(vfModule, "vfModuleLabel") - execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) - String basePersonaModelId = jsonUtil.getJsonValueForKey(baseVfModuleModelInfoObject, "modelInvariantId") - execution.setVariable("basePersonaModelId", basePersonaModelId) - } - else { - addOnModules.add(vfModules[i]) - } - } - - execution.setVariable("addOnModules", addOnModules) - execution.setVariable("addOnModulesToDeploy", addOnModules.length()) - execution.setVariable("addOnModulesDeployed", 0) - - }catch(Exception ex) { - utils.log("DEBUG", "Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) - 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) - utils.log("DEBUG", "*** COMPLETED CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) - } - - public void preProcessAddOnModule(Execution 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, "modelInvariantId") - 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) - } - - public void validateBaseModule(Execution 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) - - }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(Execution 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 preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - public void finishProcessingInitialCountDeployment(Execution execution){ - def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - logDebug(" ======== STARTED finishProcessingInitialCountDeployment ======== ", isDebugLogEnabled) - - try { - int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") - execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) - }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) - } - - - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.runtime.Execution; + +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.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.decomposition.ModelInfo +import org.openecomp.mso.bpmn.core.decomposition.ModuleResource +import org.openecomp.mso.bpmn.core.decomposition.ServiceDecomposition +import org.openecomp.mso.bpmn.core.decomposition.VnfResource + + + +/** +* 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(Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules PreProcessRequest Process*** ", isDebugEnabled) + + 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, isDebugEnabled) + + String serviceInstanceId = execution.getVariable("serviceInstanceId") + utils.log("DEBUG", "Incoming Service Instance Id is: " + serviceInstanceId, isDebugEnabled) + + String vnfType = execution.getVariable("vnfType") + utils.log("DEBUG", "Incoming Vnf Type is: " + vnfType, isDebugEnabled) + + String vnfName = execution.getVariable("vnfName") + execution.setVariable("CREVI_vnfName", vnfName) + utils.log("DEBUG", "Incoming Vnf Name is: " + vnfName, isDebugEnabled) + + String productFamilyId = execution.getVariable("productFamilyId") + utils.log("DEBUG", "Incoming Product Family Id is: " + productFamilyId, isDebugEnabled) + + String source = "VID" + execution.setVariable("source", source) + utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) + + 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, isDebugEnabled) + + String asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion") + utils.log("DEBUG", "Incoming asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugEnabled) + + 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("vnfId", vnfId) + + def rollbackData = execution.getVariable("RollbackData") + if (rollbackData == null) { + rollbackData = new RollbackData() + } + + execution.setVariable("numOfCreatedAddOnModules", 0) + + rollbackData.put("VNFANDMODULES", "numOfCreatedAddOnModules", "0") + execution.setVariable("RollbackData", rollbackData) + + sleep (20000) + + + }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 DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) + } + + + public void queryCatalogDB (Execution execution) { + def isDebugEnabled=execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix",Prefix) + + utils.log("DEBUG", " *** STARTED DoCreateVnfAndModules QueryCatalogDB Process *** ", isDebugEnabled) + try { + 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(), isDebugEnabled) + List 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 DoCreateVnf queryCatalogDB, vnfs are empty") + } + VnfResource vnf = vnfs[0] + utils.log("DEBUG", "Read vnfResource", isDebugEnabled) + if (vnf == null) { + utils.log("DEBUG", "Error - vnf is empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vnf is null") + } + + List vfModules = vnf.getAllVfModuleObjects() + utils.log("DEBUG", "Read vfModules", isDebugEnabled) + if (vfModules == null) { + utils.log("DEBUG", "Error - vfModules are empty in serviceDecomposition object", isDebugEnabled) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf queryCatalogDB, vf modules are empty") + } + JSONArray addOnModules = new JSONArray() + + for (int i = 0; i < vfModules.size; i++) { + utils.log("DEBUG", "handling VF Module ", isDebugEnabled) + 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.getModelInvariantId() + execution.setVariable("basePersonaModelId", basePersonaModelId) + } + else { + addOnModules.put(vfModules[i]) + } + } + + execution.setVariable("addOnModules", addOnModules) + execution.setVariable("addOnModulesToDeploy", addOnModules.length()) + execution.setVariable("addOnModulesDeployed", 0) + + } + else { + //Get Vnf Info + String vnfModelInfo = execution.getVariable("vnfModelInfo") + utils.log("DEBUG", "vnfModelInfo: " + vnfModelInfo, isDebugEnabled) + String vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationId") + if (vnfModelCustomizationUuid == null) { + vnfModelCustomizationUuid = jsonUtil.getJsonValueForKey(vnfModelInfo, "modelCustomizationUuid") + } + utils.log("DEBUG", "querying Catalog DB by vnfModelCustomizationUuid: " + vnfModelCustomizationUuid, isDebugEnabled) + String catalogDbEndpoint = execution.getVariable("URN_mso_catalog_db_endpoint") + + JSONArray vnfs = cutils.getAllVnfsByVnfModelCustomizationUuid(catalogDbEndpoint, + vnfModelCustomizationUuid) + utils.log("DEBUG", "obtained VNF list") + // Only one match here + JSONObject vnf = vnfs[0] + JSONArray vfModules = vnf.getJSONArray("vfModules") + JSONArray addOnModules = new JSONArray() + + // Set up base Vf Module info + for (int i = 0; i < vfModules.length(); i++) { + utils.log("DEBUG", "handling VF Module ") + JSONObject vfModule = vfModules[i] + String isBase = jsonUtil.getJsonValueForKey(vfModule, "isBase") + if (isBase.equals("true")) { + JSONObject baseVfModuleModelInfoObject = vfModule.getJSONObject("modelInfo") + String baseVfModuleModelInfo = baseVfModuleModelInfoObject.toString() + execution.setVariable("baseVfModuleModelInfo", baseVfModuleModelInfo) + String baseVfModuleLabel = jsonUtil.getJsonValueForKey(vfModule, "vfModuleLabel") + execution.setVariable("baseVfModuleLabel", baseVfModuleLabel) + String basePersonaModelId = jsonUtil.getJsonValueForKey(baseVfModuleModelInfoObject, "modelInvariantId") + execution.setVariable("basePersonaModelId", basePersonaModelId) + } + else { + addOnModules.put(vfModules[i]) + } + } + + execution.setVariable("addOnModules", addOnModules) + execution.setVariable("addOnModulesToDeploy", addOnModules.length()) + execution.setVariable("addOnModulesDeployed", 0) + } + + }catch(Exception ex) { + utils.log("DEBUG", "Error Occured in DoCreateVnfAndModules QueryCatalogDB Process " + ex.getMessage(), isDebugEnabled) + 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 CreateVnfInfra PrepareCreateGenericVnf Process ***", isDebugEnabled) + } + + public void preProcessAddOnModule(Execution 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 addOnVfModuleModelInfoWithRoot = addOnVfModuleModelInfoObject.toString() + String addOnVfModuleModelInfo = jsonUtil.getJsonValue(addOnVfModuleModelInfoWithRoot, "modelInfo") + execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo) + String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel") + execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel) + String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantId") + 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) + } + + public void validateBaseModule(Execution 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(Execution 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 preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) + } + + public void finishProcessingInitialCountDeployment(Execution execution){ + def isDebugLogEnabled = execution.getVariable("isDebugLogEnabled") + execution.setVariable("prefix", Prefix) + logDebug(" ======== STARTED finishProcessingInitialCountDeployment ======== ", isDebugLogEnabled) + + try { + int addOnModulesDeployed = execution.getVariable("addOnModulesDeployed") + execution.setVariable("addOnModulesDeployed", addOnModulesDeployed + 1) + }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) + } + + + +} 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 index 76a86ff516..2bf3e55301 100644 --- 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 @@ -1,35 +1,35 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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 +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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; @@ -239,7 +239,6 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String networkInputs = execution.getVariable(Prefix + "networkInputs") String networkId = utils.getNodeText(networkInputs, "network-id") networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -255,11 +254,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { ExceptionUtil exceptionUtil = new ExceptionUtil() Boolean isVfRelationshipExist = false try { - RESTClient client = new RESTClient(config).addHeader("X-TransactionId", messageId) - .addHeader("X-FromAppId", "MSO") - .addHeader("Content-Type", "application/xml") - .addHeader("Accept","application/xml"); - APIResponse response = client.get() + APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryAAIRequest) String returnCode = response.getStatusCode() execution.setVariable(Prefix + "aaiReturnCode", returnCode) @@ -520,15 +515,14 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) - utils.log("DEBUG", Prefix + "requestId " + requestId, isDebugEnabled) String queryAAIResponse = execution.getVariable(Prefix + "queryAAIResponse") @@ -655,7 +649,7 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { execution.setVariable(Prefix + "rollbackNetworkRequest", "") } else { String rollbackNetwork = - """ + """ ${rollbackData} """ String rollbackNetworkXml = utils.formatXml(rollbackNetwork) @@ -996,12 +990,12 @@ public class DoDeleteNetworkInstance extends AbstractServiceTaskProcessor { String serviceInstanceId = utils.getNodeText1(deleteNetworkInput, "service-instance-id") - // get/set 'msoRequestId' and 'mso-request-id' + // get/set 'msoRequestId' and 'mso-request-id' String requestId = execution.getVariable("msoRequestId") if (requestId != null) { - execution.setVariable("mso-request-id", requestId) + execution.setVariable("mso-request-id", requestId) } else { - requestId = execution.getVariable("mso-request-id") + requestId = execution.getVariable("mso-request-id") } execution.setVariable(Prefix + "requestId", requestId) 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 index 6daec69b9d..32197c1bc2 100644 --- 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 @@ -1,420 +1,420 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.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 javax.xml.parsers.DocumentBuilder -import javax.xml.parsers.DocumentBuilderFactory - -import org.camunda.bpm.engine.delegate.BpmnError -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 - -/** - * This groovy class supports the DoDeleteServiceInstance.bpmn process. - * - * Inputs: - * @param - msoRequestId - * @param - globalSubscriberId - O - * @param - subscriptionServiceType - O - * @param - serviceInstanceId - * @param - serviceInstanceName - O - * @param - serviceModelInfo - O - * @param - productFamilyId - * @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() - VidUtils vidUtils = new VidUtils() - - public void preProcessRequest (Execution 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) - - } 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 (Execution execution) { - def isDebugEnabled = execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) - String msg = "" - - try { - /* - String uuid = execution.getVariable('testReqId') // for junits - if(uuid==null){ - uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() - } - */ - 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 modelInvariantId = "" - def modelVersion = "" - def modelUUId = "" - def modelName = "" - if (!isBlank(serviceModelInfo)) - { - modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") - modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") - modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") - modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") - - if (modelInvariantId == null) { - modelInvariantId = "" - } - if (modelVersion == null) { - modelVersion = "" - } - if (modelUUId == null) { - modelUUId = "" - } - if (modelName == null) { - modelName = "" - } - } - if (serviceInstanceName == null) { - serviceInstanceName = "" - } - if (serviceId == null) { - serviceId = "" - } - - def sdncRequestId = UUID.randomUUID().toString() - - String sdncDelete = - """ - - ${sdncRequestId} - ${serviceInstanceId} - delete - service-topology-operation - ${callbackURL} - - - - ${requestId} - MSO - - - - DeleteServiceInstance - - - ${serviceId} - ${subscriptionServiceType} - - ${modelInvariantId} - ${modelUUId} - ${modelVersion} - ${modelName} - - ${serviceInstanceId} - - ${globalSubscriberId} - - - ${serviceInstanceName} - - - """ - - utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled) - sdncDelete = utils.formatXml(sdncDelete) - execution.setVariable("sdncDelete", sdncDelete) - utils.logAudit("sdncDelete: " + sdncDelete) - - - } 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(Execution execution) { - - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - utils.log("DEBUG"," ***** postProcessSDNCDelete ***** ", isDebugEnabled) - String msg = "" - - 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) - - }else{ - msg = "Bad Response from SDNC Adapter for service-instance delete" - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 3500, msg) - } - } catch (BpmnError e) { - throw e; - } catch(Exception ex) { - msg = "Exception in postProcessSDNCDelete. " + ex.getMessage() - utils.log("DEBUG", msg, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage()) - } - utils.log("DEBUG"," *** Exit postProcessSDNCDelete *** ", isDebugEnabled) - } - - public void postProcessAAIGET(Execution 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") - - if(foundInAAI == true){ - 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 serviceType = execution.getVariable("subscriptionServiceType") - if(isBlank(serviceType)){ - int serviceStart = siRelatedLink.indexOf("service-subscription/") - int serviceEnd = siRelatedLink.indexOf("/service-instances/") - String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd) - serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") - execution.setVariable("subscriptionServiceType", serviceType) - } - - if (isBlank(globalSubscriberId) || isBlank(serviceType)) - { - msg = "Could not retrive global-customer-id & 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) - //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")){ - utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs or l3-networks", 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) - } - } - } - } - } - }else{ - boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") - if(succInAAI != true){ - 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(Execution 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 != true){ - 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) - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.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 javax.xml.parsers.DocumentBuilder +import javax.xml.parsers.DocumentBuilderFactory + +import org.camunda.bpm.engine.delegate.BpmnError +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 + +/** + * This groovy class supports the DoDeleteServiceInstance.bpmn process. + * + * Inputs: + * @param - msoRequestId + * @param - globalSubscriberId - O + * @param - subscriptionServiceType - O + * @param - serviceInstanceId + * @param - serviceInstanceName - O + * @param - serviceModelInfo - O + * @param - productFamilyId + * @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() + VidUtils vidUtils = new VidUtils() + + public void preProcessRequest (Execution 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) + + } 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 (Execution execution) { + def isDebugEnabled = execution.getVariable("isDebugLogEnabled") + utils.log("DEBUG"," ***** preProcessSDNCDelete *****", isDebugEnabled) + String msg = "" + + try { + /* + String uuid = execution.getVariable('testReqId') // for junits + if(uuid==null){ + uuid = execution.getVariable("msoRequestId") + "-" + System.currentTimeMillis() + } + */ + 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 modelInvariantId = "" + def modelVersion = "" + def modelUUId = "" + def modelName = "" + if (!isBlank(serviceModelInfo)) + { + modelInvariantId = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantId") + modelVersion = jsonUtil.getJsonValue(serviceModelInfo, "modelVersion") + modelUUId = jsonUtil.getJsonValue(serviceModelInfo, "modelVersionId") + modelName = jsonUtil.getJsonValue(serviceModelInfo, "modelName") + + if (modelInvariantId == null) { + modelInvariantId = "" + } + if (modelVersion == null) { + modelVersion = "" + } + if (modelUUId == null) { + modelUUId = "" + } + if (modelName == null) { + modelName = "" + } + } + if (serviceInstanceName == null) { + serviceInstanceName = "" + } + if (serviceId == null) { + serviceId = "" + } + + def sdncRequestId = UUID.randomUUID().toString() + + String sdncDelete = + """ + + ${sdncRequestId} + ${serviceInstanceId} + delete + service-topology-operation + ${callbackURL} + + + + ${requestId} + MSO + + + + DeleteServiceInstance + + + ${serviceId} + ${subscriptionServiceType} + + ${modelInvariantId} + ${modelUUId} + ${modelVersion} + ${modelName} + + ${serviceInstanceId} + + ${globalSubscriberId} + + + ${serviceInstanceName} + + + """ + + 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(Execution 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(Execution 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") + + if(foundInAAI == true){ + 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 serviceType = execution.getVariable("subscriptionServiceType") + if(isBlank(serviceType)){ + int serviceStart = siRelatedLink.indexOf("service-subscription/") + int serviceEnd = siRelatedLink.indexOf("/service-instances/") + String serviceTypeEncoded = siRelatedLink.substring(serviceStart + 21, serviceEnd) + serviceType = UriUtils.decode(serviceTypeEncoded, "UTF-8") + execution.setVariable("subscriptionServiceType", serviceType) + } + + if (isBlank(globalSubscriberId) || isBlank(serviceType)) + { + msg = "Could not retrive global-customer-id & 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) + //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")){ + utils.log("DEBUG", "ServiceInstance still has relationship(s) to generic-vnfs or l3-networks", 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) + } + } + } + } + } + }else{ + boolean succInAAI = execution.getVariable("GENGS_SuccessIndicator") + if(succInAAI != true){ + 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(Execution 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 != true){ + 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/DoDeleteVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy index 92456b0216..208caa790d 100644 --- 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 @@ -1,256 +1,484 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.runtime.Execution; - -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.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 - -/** - * 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) - - /** - * This method gets and validates the incoming - * request. - * - * @param - execution - * - */ - public void preProcessRequest(Execution 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") - - String requestId = execution.getVariable("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("source", source) - utils.log("DEBUG", "Incoming Source is: " + source, isDebugEnabled) - - 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 DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) - } - - - - public void preProcessAddOnModule(Execution 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, "modelInvariantId") - 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(Execution execution) { - def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled") - def method = getClass().getSimpleName() + '.queryAAIVfModule(' + - 'execution=' + execution.getId() + - ')' - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - def vnfId = execution.getVariable('DvnfId') - - 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) - //Map[] vfModules = new HashMap[] - List> vfModulesList = new ArrayList>(); - 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"} - execution.setVariable("DDVAM_moduleCount", vfModules.size()) - int vfModulesSize = 0 - for (i in 0..vfModules.size()-1) { - def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) - - Map vfModuleEntry = new HashMap() - def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id") - vfModuleEntry.put("vfModuleId", vfModuleName) - def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name") - vfModuleEntry.put("vfModuleName", vfModuleName) - vfModulesList.add(vfModuleEntry) - } - - } - } - execution.setVariable("DDVAM_vfModules", vfModules) - } 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(Execution 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) - - - // HARDCODED FOR NOW - def vfModuleModelInfo = "" - 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 preProcessAddOnModule Method:\n" + e.getMessage()) - } - logDebug("======== COMPLETED preProcessSDNCAssignRequest ======== ", isDebugLogEnabled) - } - - - - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.runtime.Execution; + +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.CatalogDbUtils +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 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(Execution 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") + + 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) + + String sdncVersion = execution.getVariable("sdncVersion") + if (sdncVersion == null) { + sdncVersion = "1702" + } + execution.setVariable("DDVAM_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) + 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_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 DoCreateVnfAndModules PreProcessRequest Process ***", isDebugEnabled) + } + + + + public void preProcessAddOnModule(Execution 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, "modelInvariantId") + 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(Execution 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('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode()) + execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData) + logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled) + logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled) + //Map[] vfModules = new HashMap[] + def vfModulesList = new ArrayList>() + 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 + for (i in 0..vfModules.size()-1) { + def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i]) + + Map vfModuleEntry = new HashMap() + 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 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(Execution 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) + + + // HARDCODED FOR NOW + def vfModuleModelInfo = "" + 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(Execution 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(Execution 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(Execution 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("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 = + """ + + ${requestId} + ${svcInstId} + ${action} + vnf-topology-operation + ${callbackURL} + generic-resource + + + + ${requestId} + DeleteVnfInstance + ${source} + + + + + + + + ${serviceInstanceId} + + + + ${vnfId} + + + + + ${tenantId} + ${cloudSiteId} + + + """ + + utils.logAudit("sdncRequest: " + sdncRequest) + return sdncRequest + } + + public void validateSDNCResponse(Execution 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/DoUpdateNetworkInstance.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy index dd35334ddf..5bd9f96bc6 100644 --- 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 @@ -365,7 +365,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String networkId = utils.getNodeText1(networkRequest, "network-id") networkId = UriUtils.encode(networkId,"UTF-8") execution.setVariable(Prefix + "networkId", networkId) - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -433,7 +432,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { String networkRequest = execution.getVariable(Prefix + "networkRequest") String networkId = utils.getNodeText1(networkRequest, "network-id") networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare AA&I url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -509,7 +507,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -609,7 +606,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryVpnBindingReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -643,7 +640,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -746,7 +742,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkPolicyReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -780,7 +776,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { try { // get variables - String messageId = execution.getVariable(Prefix + "messageId") String queryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse").replace('', "") String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","") utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled) @@ -883,7 +878,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // reset return code to success execution.setVariable(Prefix + "aaiQqueryNetworkTableRefReturnCode", "200") String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String aaiStubResponse = """ @@ -922,7 +917,6 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { networkId = UriUtils.encode(networkId,"UTF-8") String requeryIdAAIResponse = execution.getVariable(Prefix + "requeryIdAAIResponse") String updateNetworkResponse = execution.getVariable(Prefix + "updateNetworkResponse") - String messageId = execution.getVariable(Prefix + "messageId") // Prepare url String aai_endpoint = execution.getVariable("URN_aai_endpoint") @@ -935,7 +929,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { utils.log("DEBUG", " UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) + String schemaVersion = aaiUriUtil.getNamespaceFromUri(execution, aai_uri) String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) String payloadXml = utils.formatXml(payload) utils.logAudit(payloadXml) @@ -973,7 +967,7 @@ public class DoUpdateNetworkInstance extends AbstractServiceTaskProcessor { // aai all errors String errorMessage = "Unexpected Response from UpdateContrailAAINetwork - " + returnCode utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, "2500", errorMessage) + exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) } } } 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 index 5999857608..f07bb0df49 100644 --- 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 @@ -1,919 +1,921 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.runtime.Execution -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.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.springframework.web.util.UriUtils - -public class DoUpdateVfModule extends VfModuleBase { - - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - - /** - * Initialize the flow's variables. - * - * @param execution The flow's execution instance. - */ - public void initProcessVariables(Execution 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_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(Execution 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) - def vnfModelInfo = execution.getVariable("vnfModelInfo") - - - //tenantId - def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId") - execution.setVariable("DOUPVfMod_tenantId", tenantId) - - //volumeGroupId - def volumeGroupId = execution.getVariable("volumeGroupId") - execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) - //volumeGroupName - def volumeGroupName = execution.getVariable("volumeGroupName") - execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName) - //cloudSiteId - def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") - execution.setVariable("DOUPVfMod_cloudSiteId", 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, "modelCustomizationId") - 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("requestId") - 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, "modelInvariantId")) - //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") - } - //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) - - String vnfParamsChildNodes = execution.getVariable("vfModuleInputParams") - execution.setVariable('DOUPVfMod_vnfParams', vnfParamsChildNodes) - } - 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(Execution 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 = """ - - ${vnfId} - ${vfModuleId} - ${orchestrationStatus} - - """ - 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. Currently, - * there is really nothing to do, so we just log that we're passing through. - * - * @param execution The flow's execution instance. - */ - public void prepConfirmVolumeGroupTenant(Execution execution) { - def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + - 'execution=' + execution.getId() + - ')' - def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') - logDebug('Entered ' + method, isDebugLogEnabled) - - try { - // Nothing to do - just log that we're passing through here - - logDebug('Exited ' + method, isDebugLogEnabled) - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logError('Caught exception in ' + method, e) - exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage()) - } - } - - /** - * 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(Execution 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') - 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') - - // 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 = """ - - - ${requestId} - ${serviceInstanceId} - changeassign - vnf-topology-operation - ${callbackUrl} - - - - ${requestId} - ChangeVNFActivateRequest - PORTAL - - - - - - ${serviceId} - ${vnfId} - dontcare - - - ${vfModuleId} - ${vfModuleModelName} - ${vfModuleName} - ${vnfId} - ${vnfName} - ${vnfType} - ${tenantId} - ${aicCloudRegion} - ${vnfNetworks} - - - - """ - 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(Execution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' + - '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 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 = """ - - - ${requestId} - ${svcInstId} - query - /VNF-API:vnfs/vnf-list/${vfModuleId} - ${callbackUrl} - mobility - - - """ - 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(Execution 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 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 vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') - def vfModuleParamsEntries = transformParamsToEntries(vnfParamsXml) - - 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 sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') - - String vfModuleParams = buildVfModuleParams(vfModuleParamsEntries, sdncGetResponse, vnfId, vnfName, - vfModuleId, vfModuleName, null) - - - String vnfAdapterRestRequest = """ - - ${cloudId} - ${tenantId} - ${vnfId} - ${vfModuleId} - ${heatStackId} - ${vnfType} - ${asdcServiceModelVersion} - ${modelCustomizationUuid} - ${vfModuleModelName} - ${volumeGroupId} - ${baseVfModuleId} - ${baseVfModuleStackId} - true - ${backoutOnFailure} - false - - ${vfModuleParams} - - - ${requestId} - ${serviceInstanceId} - - ${messageId} - ${notificationUrl} - - """ - 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(Execution 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 = '' + personaModelId + '' - def personaModelVersionElement = '' + personaModelVersion + '' - - String updateAAIGenericVnfRequest = """ - - ${vnfId} - ${personaModelIdElement} - ${personaModelVersionElement} - - """ - 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(Execution 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 = '' + volumeGroupId + '' - } - def personaModelIdElement = '' - def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id') - if (personaModelId != null) { - personaModelIdElement = '' + personaModelId + '' - } - def personaModelVersionElement = '' - def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version') - if (personaModelVersion != null) { - personaModelVersionElement = '' + personaModelVersion + '' - } - def contrailServiceInstanceFqdnElement = '' - def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn') - if (contrailServiceInstanceFqdn != null) { - contrailServiceInstanceFqdnElement = '' + contrailServiceInstanceFqdn + '' - } - def personaModelCustomizationIdElement = '' - def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid') - if (modelCustomizationId != null) { - personaModelCustomizationIdElement = '' + modelCustomizationId + '' - } - - String updateAAIVfModuleRequest = """ - - ${vnfId} - ${vfModuleId} - ${orchestrationStatus} - ${volumeGroupIdElement} - ${personaModelIdElement} - ${personaModelVersionElement} - ${contrailServiceInstanceFqdnElement} - ${personaModelCustomizationIdElement} - - """ - 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(Execution execution) { - def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' + - '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 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') - - def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') - def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) - - String sdncTopologyRequest = """ - - - ${requestId} - ${serviceInstanceId} - activate - vnf-topology-operation - ${callbackUrl} - - - - ${requestId} - ChangeVNFActivateRequest - PORTAL - - - - - - ${serviceId} - ${vnfId} - dontcare - - - ${vfModuleId} - ${vfModuleModelName} - ${vfModuleName} - ${vnfId} - ${vnfName} - ${vnfType} - ${tenantId} - ${aicCloudRegion} - - - - """ - 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(Execution 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(Execution 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(Execution 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()) - } - } - - -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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.runtime.Execution +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.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.springframework.web.util.UriUtils + +public class DoUpdateVfModule extends VfModuleBase { + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + /** + * Initialize the flow's variables. + * + * @param execution The flow's execution instance. + */ + public void initProcessVariables(Execution 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_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(Execution 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) + def vnfModelInfo = execution.getVariable("vnfModelInfo") + + + //tenantId + def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId") + execution.setVariable("DOUPVfMod_tenantId", tenantId) + + //volumeGroupId + def volumeGroupId = execution.getVariable("volumeGroupId") + execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId) + //volumeGroupName + def volumeGroupName = execution.getVariable("volumeGroupName") + execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName) + //cloudSiteId + def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId") + execution.setVariable("DOUPVfMod_cloudSiteId", 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, "modelCustomizationId") + 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("requestId") + 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, "modelInvariantId")) + //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") + } + //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 vfModuleInputParams = execution.getVariable("vfModuleInputParams") + if (vfModuleInputParams != null) { + execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams) + } + } + 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(Execution 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 = """ + + ${vnfId} + ${vfModuleId} + ${orchestrationStatus} + + """ + 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. Currently, + * there is really nothing to do, so we just log that we're passing through. + * + * @param execution The flow's execution instance. + */ + public void prepConfirmVolumeGroupTenant(Execution execution) { + def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' + + 'execution=' + execution.getId() + + ')' + def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') + logDebug('Entered ' + method, isDebugLogEnabled) + + try { + // Nothing to do - just log that we're passing through here + + logDebug('Exited ' + method, isDebugLogEnabled) + } catch (BpmnError e) { + throw e; + } catch (Exception e) { + logError('Caught exception in ' + method, e) + exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage()) + } + } + + /** + * 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(Execution 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') + 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') + + // 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 = """ + + + ${requestId} + ${serviceInstanceId} + changeassign + vnf-topology-operation + ${callbackUrl} + + + + ${requestId} + ChangeVNFActivateRequest + PORTAL + + + + + + ${serviceId} + ${vnfId} + dontcare + + + ${vfModuleId} + ${vfModuleModelName} + ${vfModuleName} + ${vnfId} + ${vnfName} + ${vnfType} + ${tenantId} + ${aicCloudRegion} + ${vnfNetworks} + + + + """ + 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(Execution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' + + '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 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 = """ + + + ${requestId} + ${svcInstId} + query + /VNF-API:vnfs/vnf-list/${vfModuleId} + ${callbackUrl} + mobility + + + """ + 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(Execution 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 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) + } + + Map vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap") + + String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse') + + String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName, + vfModuleId, vfModuleName, null) + + + String vnfAdapterRestRequest = """ + + ${cloudId} + ${tenantId} + ${vnfId} + ${vfModuleId} + ${heatStackId} + ${vnfType} + ${asdcServiceModelVersion} + ${modelCustomizationUuid} + ${vfModuleModelName} + ${volumeGroupId} + ${baseVfModuleId} + ${baseVfModuleStackId} + true + ${backoutOnFailure} + false + + ${vfModuleParams} + + + ${requestId} + ${serviceInstanceId} + + ${messageId} + ${notificationUrl} + + """ + 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(Execution 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 = '' + personaModelId + '' + def personaModelVersionElement = '' + personaModelVersion + '' + + String updateAAIGenericVnfRequest = """ + + ${vnfId} + ${personaModelIdElement} + ${personaModelVersionElement} + + """ + 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(Execution 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 = '' + volumeGroupId + '' + } + def personaModelIdElement = '' + def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id') + if (personaModelId != null) { + personaModelIdElement = '' + personaModelId + '' + } + def personaModelVersionElement = '' + def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version') + if (personaModelVersion != null) { + personaModelVersionElement = '' + personaModelVersion + '' + } + def contrailServiceInstanceFqdnElement = '' + def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn') + if (contrailServiceInstanceFqdn != null) { + contrailServiceInstanceFqdnElement = '' + contrailServiceInstanceFqdn + '' + } + def personaModelCustomizationIdElement = '' + def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid') + if (modelCustomizationId != null) { + personaModelCustomizationIdElement = '' + modelCustomizationId + '' + } + + String updateAAIVfModuleRequest = """ + + ${vnfId} + ${vfModuleId} + ${orchestrationStatus} + ${volumeGroupIdElement} + ${personaModelIdElement} + ${personaModelVersionElement} + ${contrailServiceInstanceFqdnElement} + ${personaModelCustomizationIdElement} + + """ + + 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(Execution execution) { + def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' + + '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 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') + + def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams') + def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml) + + String sdncTopologyRequest = """ + + + ${requestId} + ${serviceInstanceId} + activate + vnf-topology-operation + ${callbackUrl} + + + + ${requestId} + ChangeVNFActivateRequest + PORTAL + + + + + + ${serviceId} + ${vnfId} + dontcare + + + ${vfModuleId} + ${vfModuleModelName} + ${vfModuleName} + ${vnfId} + ${vnfName} + ${vnfType} + ${tenantId} + ${aicCloudRegion} + + + + """ + 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(Execution 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(Execution 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(Execution 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/UpdateNetworkInstanceInfra.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy deleted file mode 100644 index 5f0f65bd85..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy +++ /dev/null @@ -1,1639 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.runtime.Execution -import org.apache.commons.lang3.* -import org.apache.commons.codec.binary.Base64; -import org.springframework.web.util.UriUtils - -/** - * This groovy class supports the UpdateNetworkInstanceInfra.bpmn process. - */ -public class UpdateNetworkInstanceInfra 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 UpdateNetworkInstanceInfra.bpmn process. - * @param execution - */ - public InitializeProcessVariables(Execution execution){ - /* Initialize all the process variables in this block */ - - execution.setVariable("UPDNETI_messageId", "") - execution.setVariable("BasicAuthHeaderValuePO", "") - execution.setVariable("BasicAuthHeaderValueSDNC", "") - execution.setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", "") - execution.setVariable("UPDNETI_networkRequest", "") - execution.setVariable("UPDNETI_networkInputs", "") - execution.setVariable("UPDNETI_networkOutputs", "") - execution.setVariable("UPDNETI_requestId", "") - execution.setVariable("UPDNETI_source", "") - execution.setVariable("UPDNETI_networkId", "") - - execution.setVariable("UPDNETI_CompleteMsoProcessRequest", "") - execution.setVariable("UPDNETI_FalloutHandlerRequest", "") - execution.setVariable("UPDNETI_isSilentSuccess", false) - execution.setVariable("UPDNETI_isPONR", false) // Point-of-no-return, means, rollback is not needed - - // AAI query Cloud Region - execution.setVariable("UPDNETI_queryCloudRegionRequest","") - execution.setVariable("UPDNETI_queryCloudRegionReturnCode","") - execution.setVariable("UPDNETI_queryCloudRegionResponse","") - execution.setVariable("UPDNETI_cloudRegionPo","") - execution.setVariable("UPDNETI_cloudRegionSdnc","") - execution.setVariable("UPDNETI_isCloudRegionGood", false) - - // AAI query Id - execution.setVariable("UPDNETI_queryIdAAIRequest","") - execution.setVariable("UPDNETI_queryIdAAIResponse", "") - execution.setVariable("UPDNETI_aaiIdReturnCode", "") - - // AAI query vpn binding - execution.setVariable("UPDNETI_queryVpnBindingAAIRequest","") - execution.setVariable("UPDNETI_queryVpnBindingAAIResponse", "") - execution.setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "") - execution.setVariable("UPDNETI_vpnBindings", null) - execution.setVariable("UPDNETI_vpnCount", 0) - execution.setVariable("UPDNETI_routeCollection", "") - - // AAI query network policy - execution.setVariable("UPDNETI_queryNetworkPolicyAAIRequest","") - execution.setVariable("UPDNETI_queryNetworkPolicyAAIResponse", "") - execution.setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "") - execution.setVariable("UPDNETI_networkPolicyUriList", null) - execution.setVariable("UPDNETI_networkPolicyCount", 0) - execution.setVariable("UPDNETI_networkCollection", "") - - // AAI query route table reference - execution.setVariable("UPDNETI_queryNetworkTableRefAAIRequest","") - execution.setVariable("UPDNETI_queryNetworkTableRefAAIResponse", "") - execution.setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "") - execution.setVariable("UPDNETI_networkTableRefUriList", null) - execution.setVariable("UPDNETI_networkTableRefCount", 0) - execution.setVariable("UPDNETI_tableRefCollection", "") - - // AAI requery Id - execution.setVariable("UPDNETI_requeryIdAAIRequest","") - execution.setVariable("UPDNETI_requeryIdAAIResponse", "") - execution.setVariable("UPDNETI_aaiRequeryIdReturnCode", "") - - // AAI update contrail - execution.setVariable("UPDNETI_updateContrailAAIUrlRequest","") - execution.setVariable("UPDNETI_updateContrailAAIPayloadRequest","") - execution.setVariable("UPDNETI_updateContrailAAIResponse", "") - execution.setVariable("UPDNETI_aaiUpdateContrailReturnCode", "") - - execution.setVariable("UPDNETI_updateNetworkRequest", "") - execution.setVariable("UPDNETI_updateNetworkResponse", "") - execution.setVariable("UPDNETI_rollbackNetworkRequest", "") - execution.setVariable("UPDNETI_rollbackNetworkResponse", "") - execution.setVariable("UPDNETI_networkReturnCode", "") - execution.setVariable("UPDNETI_rollbackNetworkReturnCode", "") - execution.setVariable("UPDNETI_isNetworkRollbackNeeded", false) - - execution.setVariable("UPDNETI_changeAssignSDNCRequest", "") - execution.setVariable("UPDNETI_changeAssignSDNCResponse", "") - execution.setVariable("UPDNETI_rollbackSDNCRequest", "") - execution.setVariable("UPDNETI_rollbackSDNCResponse", "") - execution.setVariable("UPDNETI_sdncReturnCode", "") - execution.setVariable("UPDNETI_rollbackSDNCReturnCode", "") - execution.setVariable("UPDNETI_isSdncRollbackNeeded", false) - execution.setVariable("UPDNETI_sdncResponseSuccess", false) - - execution.setVariable("UPDNETI_updateDBRequest", "") - execution.setVariable("UPDNETI_updateDBResponse", "") - execution.setVariable("UPDNETI_dbReturnCode", "") - - execution.setVariable("UPDNETI_isVnfBindingPresent", false) - execution.setVariable("UPDNETI_Success", false) - execution.setVariable("UPDNETI_serviceInstanceId", "") - execution.setVariable("GENGS_type", "service-instance") // Setting for Generic Sub Flow use - - } - - // ************************************************** - // Pre or Prepare Request Section - // ************************************************** - /** - * This method is executed during the preProcessRequest task of the UpdateNetworkInstanceInfra.bpmn process. - * @param execution - */ - public void preProcessRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside preProcessRequest UpdateNetworkInstanceInfra Request ***** ", isDebugEnabled) - - // initialize flow variables - InitializeProcessVariables(execution) - - // get Incoming request & validate json format - String updateNetworkJsonIncoming = execution.getVariable("bpmnRequest") - utils.logAudit(updateNetworkJsonIncoming) - try { - def prettyJson = JsonOutput.prettyPrint(updateNetworkJsonIncoming.toString()) - utils.log("DEBUG", " Incoming message formatted . . . : " + '\n' + prettyJson, isDebugEnabled) - - } catch (Exception ex) { - String dataErrorMessage = " Invalid json format Request - " + ex.getMessage() - utils.log("DEBUG", 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 dataErrorMessage = " Unable to encode PO/SDNC user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, , isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - - execution.setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", updateNetworkJsonIncoming) - - // recreate the xml network-request - String networkRequest = vidUtils.createXmlNetworkRequestInfra(execution, updateNetworkJsonIncoming) - execution.setVariable("UPDNETI_networkRequest", networkRequest) - utils.log("DEBUG", " network-request - " + '\n' + networkRequest, isDebugEnabled) - - String networkInputs = utils.getNodeXml(networkRequest, "network-inputs", false).replace("tag0:","").replace(":tag0","") - execution.setVariable("UPDNETI_networkInputs", networkInputs) - utils.log("DEBUG", " networkInputs - " + '\n' + networkInputs, isDebugEnabled) - - String netId = utils.getNodeText1(networkRequest, "network-id") - String netName = utils.getNodeText1(networkRequest, "network-name") - String networkOutputs = - """ - ${netId} - ${netName} - """ - execution.setVariable("UPDNETI_networkOutputs", networkOutputs) - utils.log("DEBUG", " networkOutputs - " + '\n' + networkOutputs, isDebugEnabled) - - String requestId = execution.getVariable("mso-request-id") - if (requestId == null || requestId == "") { - requestId = execution.getVariable("requestId") - } - execution.setVariable("UPDNETI_requestId", requestId) - execution.setVariable("UPDNETI_source", utils.getNodeText1(networkRequest, "source")) - - // prepare messageId - String messageId = execution.getVariable("UPDNETI_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("UPDNETI_messageId", messageId) - - // validate 'backout-on-failure' to override 'URN_mso_rollback' - boolean rollbackEnabled = networkUtils.isRollbackEnabled(execution, networkRequest) - execution.setVariable("UPDNETI_rollbackEnabled", rollbackEnabled) - - 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) - } - } - - execution.setVariable("UPDNETI_serviceInstanceId", serviceInstanceId) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex){ - sendSyncError(execution) - // caught exception - String exceptionMessage = "Exception Encountered in UpdateNetworkInstanceInfra, PreProcessRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - } - - public void sendSyncResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix",Prefix) - - utils.log("DEBUG", " ***** Inside sendSyncResponse of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - String serviceInstanceId = execution.getVariable("UPDNETI_serviceInstanceId") - String requestId = execution.getVariable("mso-request-id") - - // 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 UpdateNetworkInstanceInfra flow. sendSyncResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - } - - } - - public void callRESTQueryAAICloudRegion (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAICloudRegion of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - String networkInputs = execution.getVariable("UPDNETI_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("UPDNETI_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("UPDNETI_cloudRegionPo", cloudRegionPo) - execution.setVariable("UPDNETI_cloudRegionSdnc", cloudRegionSdnc) - execution.setVariable("UPDNETI_isCloudRegionGood", true) - - } else { - String dataErrorMessage = "QueryAAICloudRegion Unsuccessful. Return Code: " + execution.getVariable("UPDNETI_queryCloudRegionReturnCode") - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - - } - - utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable("UPDNETI_isCloudRegionGood"), isDebugEnabled) - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - // try error - String exceptionMessage = "Bpmn error encountered in UpdateNetworkInstanceInfra flow - callRESTQueryAAICloudRegion() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkId(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkId of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String networkRequest = execution.getVariable("UPDNETI_networkRequest") - String networkId = utils.getNodeText1(networkRequest, "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - execution.setVariable("UPDNETI_networkId", networkId) - String messageId = execution.getVariable("UPDNETI_messageId") - - // 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 - utils.logAudit(queryIdAAIRequest) - execution.setVariable("UPDNETI_queryIdAAIRequest", queryIdAAIRequest) - utils.log("DEBUG", " UPDNETI_queryIdAAIRequest - " + "\n" + queryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiIdReturnCode", returnCode) - - utils.log("DEBUG", " ***** AAI Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_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 UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTReQueryAAINetworkId(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTReQueryAAINetworkId of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String networkId = utils.getNodeText1(execution.getVariable("UPDNETI_changeAssignSDNCResponse"), "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - String messageId = execution.getVariable("UPDNETI_messageId") - - // 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 - utils.logAudit(requeryIdAAIRequest) - execution.setVariable("UPDNETI_requeryIdAAIRequest", requeryIdAAIRequest) - utils.log("DEBUG", " UPDNETI_requeryIdAAIRequest - " + "\n" + requeryIdAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, requeryIdAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiRequeryIdReturnCode", returnCode) - utils.log("DEBUG", " ***** AAI ReQuery Response Code : " + returnCode, isDebugEnabled) - - String aaiResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiResponseAsString) - execution.setVariable("UPDNETI_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 = - """ - ${netId} - ${netName} - """ - execution.setVariable("UPDNETI_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 UpdateNetworkInstanceInfra flow. callRESTReQueryAAINetworkId() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkVpnBinding(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkVpnBinding of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - - // get variables - String messageId = execution.getVariable("UPDNETI_messageId") - String queryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse").replace('', "") - 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("UPDNETI_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("UPDNETI_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) - } else { - queryVpnBindingAAIRequest = "${aai_endpoint}" + vpnBindingUri[i] - } - - } 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 - } - - utils.logAudit(queryVpnBindingAAIRequest) - execution.setVariable("UPDNETI_queryVpnBindingAAIRequest", queryVpnBindingAAIRequest) - utils.log("DEBUG", " UPDNETI_queryVpnBindingAAIRequest, , vpnBinding #" + counting + " : " + "\n" + queryVpnBindingAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryVpnBindingAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_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("UPDNETI_queryVpnBindingAAIResponse", aaiResponseAsString) - utils.log("DEBUG", " AAI Query Vpn Binding Success REST Response, , vpnBinding #" + counting + " : " + "\n" + aaiResponseAsString, isDebugEnabled) - - String routeTarget = "" - if (utils.nodeExists(aaiResponseAsString, "global-route-target")) { - routeTarget = utils.getNodeText1(aaiResponseAsString, "global-route-target") - routeTargets += "" + routeTarget + "" + '\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("UPDNETI_routeCollection", routeTargets) - utils.log("DEBUG", " UPDNETI_routeCollection - " + '\n' + routeTargets, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String aaiStubResponse = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiStubResponseAsXml) - execution.setVariable("UPDNETI_routeCollection", "") - 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 UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkVpnBinding() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkPolicy(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkPolicy of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String messageId = execution.getVariable("UPDNETI_messageId") - String queryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse").replace('', "") - 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("UPDNETI_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("UPDNETI_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) - } else { - queryNetworkPolicyAAIRequest = "${aai_endpoint}" + networkPolicyUriList[i] - } - } 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 - - } - - - utils.logAudit(queryNetworkPolicyAAIRequest) - execution.setVariable("UPDNETI_queryNetworkPolicyAAIRequest", queryNetworkPolicyAAIRequest) - utils.log("DEBUG", " UPDNETI_queryNetworkPolicyAAIRequest, , NetworkPolicy #" + counting + " : " + "\n" + queryNetworkPolicyAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkPolicyAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_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("UPDNETI_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 += "" + networkPolicy + "" + '\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("UPDNETI_networkCollection", networkPolicies) - utils.log("DEBUG", " UPDNETI_networkCollection - " + '\n' + networkPolicies, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String aaiStubResponse = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable("UPDNETI_queryNetworkPolicyAAIResponse", aaiStubResponseAsXml) - execution.setVariable("UPDNETI_networkCollection", "") - 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 UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkPolicy() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTQueryAAINetworkTableRef(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTQueryAAINetworkTableRef of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String messageId = execution.getVariable("UPDNETI_messageId") - String queryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse").replace('', "") - 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("UPDNETI_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("UPDNETI_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) - } else { - queryNetworkTableRefAAIRequest = "${aai_endpoint}" + networkTableRefUriList[i] - } - } 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 - - } - - - utils.logAudit(queryNetworkTableRefAAIRequest) - execution.setVariable("UPDNETI_queryNetworkTableRefAAIRequest", queryNetworkTableRefAAIRequest) - utils.log("DEBUG", " UPDNETI_queryNetworkTableRefAAIRequest, , NetworkTableRef #" + counting + " : " + "\n" + queryNetworkTableRefAAIRequest, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIGetCall(execution, queryNetworkTableRefAAIRequest) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_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("UPDNETI_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 += "" + networkTableRef + "" + '\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("UPDNETI_tableRefCollection", networkTableRefs) - utils.log("DEBUG", " UPDNETI_tableRefCollection - " + '\n' + networkTableRefs, isDebugEnabled) - - } else { - // reset return code to success - execution.setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "200") - String aai_uri = aaiUriUtil.getNetworkL3NetworkUri(execution) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String aaiStubResponse = - """ - - - - """ - String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse) - execution.setVariable("UPDNETI_queryNetworkTableRefAAIResponse", aaiStubResponseAsXml) - execution.setVariable("UPDNETI_tableRefCollection", "") - 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 UpdateNetworkInstanceInfra flow. callRESTQueryAAINetworkTableRef() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void callRESTUpdateContrailAAINetwork(Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside callRESTUpdateContrailAAINetwork of UpdateNetworkInstanceInfra ***** " , isDebugEnabled) - - try { - // get variables - String networkId = utils.getNodeText1(execution.getVariable("UPDNETI_changeAssignSDNCResponse"), "network-id") - networkId = UriUtils.encode(networkId,"UTF-8") - String requeryIdAAIResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse") - String updateNetworkResponse = execution.getVariable("UPDNETI_updateNetworkResponse") - String messageId = execution.getVariable("UPDNETI_messageId") - - // 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 - - utils.logAudit(updateContrailAAIUrlRequest) - execution.setVariable("UPDNETI_updateContrailAAIUrlRequest", updateContrailAAIUrlRequest) - utils.log("DEBUG", " UPDNETI_updateContrailAAIUrlRequest - " + "\n" + updateContrailAAIUrlRequest, isDebugEnabled) - - //Prepare payload (PUT) - String schemaVersion = aaiUriUtil.getNamespaceFromUri(aai_uri) - String payload = networkUtils.ContrailNetworkCreatedUpdate(requeryIdAAIResponse, updateNetworkResponse, schemaVersion) - String payloadXml = utils.formatXml(payload) - utils.logAudit(payloadXml) - execution.setVariable("UPDNETI_updateContrailAAIPayloadRequest", payloadXml) - utils.log("DEBUG", " 'payload' to Update Contrail - " + "\n" + payloadXml, isDebugEnabled) - - APIResponse response = aaiUriUtil.executeAAIPutCall(execution, updateContrailAAIUrlRequest, payload) - String returnCode = response.getStatusCode() - execution.setVariable("UPDNETI_aaiUpdateContrailReturnCode", returnCode) - - utils.log("DEBUG", " ***** AAI Update Contrail Response Code : " + returnCode, isDebugEnabled) - - String aaiUpdateContrailResponseAsString = response.getResponseBodyAsString() - - if (returnCode=='200') { - utils.logAudit(aaiUpdateContrailResponseAsString) - execution.setVariable("UPDNETI_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("UPDNETI_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 UpdateNetworkInstanceInfra flow. callRESTUpdateContrailAAINetwork() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareUpdateNetworkRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareUpdateNetworkRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - - // get variables - String requestId = execution.getVariable("UPDNETI_requestId") - String messageId = execution.getVariable("UPDNETI_messageId") - String source = execution.getVariable("UPDNETI_source") - - String requestInput = execution.getVariable("UPDNETI_networkRequest") - String queryIdResponse = execution.getVariable("UPDNETI_requeryIdAAIResponse") - String cloudRegionId = execution.getVariable("UPDNETI_cloudRegionPo") - String backoutOnFailure = execution.getVariable("UPDNETI_rollbackEnabled") - - // Prepare Network request - String routeCollection = execution.getVariable("UPDNETI_routeCollection") - String policyCollection = execution.getVariable("UPDNETI_networkCollection") - String tableCollection = execution.getVariable("UPDNETI_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("UPDNETI_updateNetworkRequest", buildUpdateNetworkRequestAsString) - utils.log("DEBUG", " UPDNETI_updateNetworkRequest - " + "\n" + buildUpdateNetworkRequestAsString, isDebugEnabled) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareUpdateNetworkRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareSDNCRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String updateNetworkInput = execution.getVariable("UPDNETI_networkRequest") - String cloudRegionId = execution.getVariable("UPDNETI_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("UPDNETI_changeAssignSDNCRequest", sndcTopologyUpdateRequesAsString) - utils.log("DEBUG", " UPDNETI_changeAssignSDNCRequest - " + "\n" + sndcTopologyUpdateRequesAsString, isDebugEnabled) - - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareSDNCRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareDBRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - String networkOutputs = execution.getVariable("UPDNETI_networkOutputs") - String networkName = "" - try { - networkName = utils.getNodeText1(networkOutputs, "network-name") - if (networkName == null) {networkName = ""} - } catch (Exception ex) { - networkName = "" - utils.log("DEBUG", " No 'network-name' found in '' ! ", isDebugEnabled) - } - String networkId = "" - try { - networkId = utils.getNodeText1(networkOutputs, "network-id") - if (networkId == null) {networkId = ""} - } catch (Exception) { - networkId = "" - utils.log("DEBUG", " No 'network-id' found in '' ! ", isDebugEnabled) - } - String requestId = execution.getVariable("UPDNETI_requestId") - - String statusMessage = "Network successfully updated." - - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - COMPLETED - 100 - <network-id>${networkId}</network-id><network-name>${networkName}</network-names> - ${networkId} - - - """ - - String buildDeleteDBRequestAsString = utils.formatXml(dbRequest) - execution.setVariable("UPDNETI_updateDBRequest", buildDeleteDBRequestAsString) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + buildDeleteDBRequestAsString, isDebugEnabled) - utils.logAudit(buildDeleteDBRequestAsString) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareDBRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void prepareDBRequestError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - // Catalog DB headers Authorization - String basicAuthValueDB = execution.getVariable("URN_mso_adapters_db_auth") - utils.log("DEBUG", " Obtained BasicAuth userid password for Catalog DB adapter: " + basicAuthValueDB, isDebugEnabled) - - def encodedString = utils.getBasicAuth(basicAuthValueDB, execution.getVariable("URN_mso_msoKey")) - execution.setVariable("BasicAuthHeaderValueDB",encodedString) - } catch (IOException ex) { - String dataErrorMessage = " Unable to encode Catalog DB user/password string - " + ex.getMessage() - utils.log("DEBUG", dataErrorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage) - } - - try { - utils.log("DEBUG", " ***** Inside prepareDBRequestError of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - String statusMessage = "" - WorkflowException wfe = null - if (execution.getVariable("WorkflowException") instanceof WorkflowException) { - wfe = execution.getVariable("WorkflowException") - statusMessage = wfe.getErrorMessage() - } else { - String workflowException = execution.getVariable("WorkflowException") - try { - statusMessage = utils.getNodeText1(workflowException, "ErrorMessage") - } catch (Exception ex) { - statusMessage = "Encountered Error during DB Update. " + ex.getMessage() - } - } - String networkOutputs = execution.getVariable("UPDNETI_networkOutputs") - String requestId = execution.getVariable("UPDNETI_requestId") - String networkId = "" - try { - networkId = utils.getNodeText1(networkOutputs, "network-id") - if (networkId == null) {networkId = ""} - } catch (Exception) { - networkId = "" - utils.log("DEBUG", " No 'network-id' found in '' ! ", isDebugEnabled) - } - String networkName = "" - try { - networkName = utils.getNodeText1(networkOutputs, "network-name") - if (networkName == null) {networkName = ""} - } catch (Exception ex) { - networkName = "" - utils.log("DEBUG", " No 'network-name' found in '' ! ", isDebugEnabled) - } - String dbRequest = - """ - - - - ${requestId} - BPMN - ${statusMessage} - - FAILED - <network-id>${networkId}</network-id><network-name>${networkName}</network-names> - - - """ - - execution.setVariable("UPDNETI_updateDBRequest", dbRequest) - utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled) - utils.logAudit(dbRequest) - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. prepareDBRequestError() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - - // ************************************************** - // Post or Validate Response Section - // ************************************************** - - public void validateUpdateNetworkResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateUpdateNetworkResponse of UpdateNetworkInstanceInfra *****", isDebugEnabled) - - try { - String returnCode = execution.getVariable("UPDNETI_networkReturnCode") - String networkResponse = execution.getVariable("UPDNETI_updateNetworkResponse") - if (networkResponse==null) { - networkResponse="" // reset - } - - utils.log("DEBUG", " Network Adapter update responseCode: " + returnCode, isDebugEnabled) - - String errorMessage = "" - if (returnCode == "200") { - execution.setVariable("UPDNETI_isNetworkRollbackNeeded", true) - utils.logAudit(networkResponse) - execution.setVariable("UPDNETI_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","") - String rollbackNetwork = - """ - ${rollbackData} - """ - String rollbackNetworkXml = utils.formatXml(rollbackNetwork) - execution.setVariable("UPDNETI_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('', '') - 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 UpdateNetworkInstanceInfra flow. validateUpdateNetworkResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void validateSDNCResponse (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside validateSDNCResponse of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - String response = execution.getVariable("UPDNETI_changeAssignSDNCResponse") - WorkflowException workflowException = null - try { - workflowException = execution.getVariable("UPDNETI_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("UPDNETI_changeAssignSDNCResponse")) - changeAssignSDNCResponseDecodeXml = changeAssignSDNCResponseDecodeXml.replace("&", "&").replace('', "") - execution.setVariable("UPDNETI_changeAssignSDNCResponse", changeAssignSDNCResponseDecodeXml) - - if (execution.getVariable("UPDNETI_sdncResponseSuccess") == true) { // from sdnc util, prefix+'sdncResponseSuccess' - execution.setVariable("UPDNETI_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 (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside postProcessResponse of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - // Display DB response: UPDNETI_updateDBResponse / UPDNETI_dbReturnCode - String dbReturnCode = execution.getVariable("UPDNETI_dbReturnCode") - utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) - String updateDBResponse = execution.getVariable("UPDNETI_updateDBResponse") - utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + updateDBResponse, isDebugEnabled) - utils.logAudit(updateDBResponse) - - String source = execution.getVariable("UPDNETI_source") - String requestId = execution.getVariable("UPDNETI_requestId") - - String msoCompletionRequest = - """ - - ${requestId} - UPDATE - ${source} - - BPMN Network action: UPDATE - """ - - // Format Response - String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest) - - if (dbReturnCode == "200") { - utils.logAudit(updateDBResponse) - utils.logAudit(xmlMsoCompletionRequest) - execution.setVariable("UPDNETI_Success", true) - execution.setVariable("UPDNETI_CompleteMsoProcessRequest", xmlMsoCompletionRequest) - utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled) - - } else { - String errorMessage = " DB Update failed, code: " + dbReturnCode - utils.log("DEBUG", errorMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage) - - } - - - } catch (BpmnError e) { - throw e; - - } catch (Exception ex) { - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. postProcessResponse() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage) - - } - - - } - - public void prepareSDNCRollbackRequest (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - utils.log("DEBUG", " ***** Inside prepareSDNCRollbackRequest of UpdateNetworkInstanceInfra ***** ", isDebugEnabled) - - try { - // for some reason the WorkflowException object is null after the sdnc rollback call task, need to save WorkflowException. - execution.setVariable("UPDNETI_WorkflowException", execution.getVariable("WorkflowException")) - // get variables - String sdncCallback = execution.getVariable("URN_mso_workflow_sdncadapter_callback") - String updateNetworkInput = execution.getVariable("UPDNETI_networkRequest") - String cloudRegionId = execution.getVariable("UPDNETI_cloudRegionSdnc") - String changeAssignSDNCResponse = execution.getVariable("UPDNETI_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("UPDNETI_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 UpdateNetworkInstanceInfra flow. prepareSDNCRollbackRequest() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - } - - public void validateRollbackResponses (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - try { - // Note: Updates do not support rollback. To restore a previous state, another Update would be needed to revert to the original settings. - // This would need to be managed by the client. - String rollbackNetworkErrorMessages = "" - Boolean isNetworkRollbackNeeded = execution.getVariable("UPDNETI_isNetworkRollbackNeeded") - if (isNetworkRollbackNeeded == true) { - rollbackNetworkErrorMessages = " + PO Network rollback is not supported for Update. Submit another Update to restore/rollback." - } - - // validate SDNC rollback response - String rollbackSdncErrorMessages = "" - Boolean isSdncRollbackNeeded = execution.getVariable("UPDNETI_isSdncRollbackNeeded") - if (isSdncRollbackNeeded == true) { - String rollbackSDNCReturnCode = execution.getVariable("UPDNETI_rollbackSDNCReturnCode") - String rollbackSDNCReturnInnerCode = "" - String rollbackSDNCResponse = execution.getVariable("UPDNETI_rollbackSDNCResponse") - SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this) - rollbackSDNCResponse = sdncAdapterUtils.decodeXML(rollbackSDNCResponse) - rollbackSDNCResponse = rollbackSDNCResponse.replace("&", "&").replace('$', '').replace('', "") - - if (rollbackSDNCReturnCode == "200") { - if (utils.nodeExists(rollbackSDNCResponse, "response-code")) { - rollbackSDNCReturnInnerCode = utils.getNodeText1(rollbackSDNCResponse, "response-code") - if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") { - rollbackSdncErrorMessages = " + SNDC rollback completed." - } else { - rollbackSdncErrorMessages = " + SDNC rollback failed. " - } - } else { - rollbackSdncErrorMessages = " + SNDC rollback completed." - } - } else { - rollbackSdncErrorMessages = " + SDNC rollback failed. " - } - - utils.log("DEBUG", " SDNC rollback Code - " + rollbackSDNCReturnCode, isDebugEnabled) - utils.log("DEBUG", " SDNC rollback Response - " + rollbackSDNCResponse, isDebugEnabled) - - } - - //WorkflowException wfe = execution.getVariable("WorkflowException") - //String statusMessage = wfe.getErrorMessage() - //int errorCode = wfe.getErrorCode() - - String statusMessage = "" - int errorCode = 0 - WorkflowException wfe = execution.getVariable("WorkflowException") - if (wfe instanceof WorkflowException) { - statusMessage = wfe.getErrorMessage() - errorCode = wfe.getErrorCode() - } else { - if (execution.getVariable("UPDNETI_WorkflowException") instanceof WorkflowException) { - // get saved WorkflowException - WorkflowException swfe = execution.getVariable("UPDNETI_WorkflowException") - statusMessage = swfe.getErrorMessage() - errorCode = swfe.getErrorCode() - } else { - statusMessage = "Encountered Error, please see previous tasks/activities/steps for error messages." - errorCode = 7000 - } - } - - // recreate WorkflowException to include the rollback Message - statusMessage = statusMessage + rollbackNetworkErrorMessages + rollbackSdncErrorMessages - exceptionUtil.buildWorkflowException(execution, errorCode, statusMessage) - - } catch (Exception ex) { - execution.setVariable("WorkflowException", null) - String exceptionMessage = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. validateRollbackResponses() - " + ex.getMessage() - utils.log("DEBUG", exceptionMessage, isDebugEnabled) - exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage) - - } - - - - } - - // ******************************* - // Build Error Section - // ******************************* - - // Prepare for FalloutHandler - public void buildErrorResponse (Execution 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("UPDNETI_dbReturnCode") - utils.log("DEBUG", " ***** DB Update Response Code : " + dbReturnCode, isDebugEnabled) - String updateDBResponse = execution.getVariable("UPDNETI_updateDBResponse") - utils.log("DEBUG", " ***** DB Update Response String: " + '\n' + updateDBResponse, isDebugEnabled) - utils.logAudit(updateDBResponse) - - String falloutHandlerRequest = "" - String requestId = execution.getVariable("UPDNETI_requestId") - String source = execution.getVariable("UPDNETI_source") - try { - execution.setVariable("UPDNETI_Success", false) - WorkflowException wfe = execution.getVariable("WorkflowException") - String errorCode = String.valueOf(wfe.getErrorCode()) - String errorMessage = wfe.getErrorMessage() - falloutHandlerRequest = - """ - - ${requestId} - UPDATE - ${source} - - - ${errorMessage} - ${errorCode} - - """ - - utils.logAudit(falloutHandlerRequest) - execution.setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } catch (Exception ex) { - String errorException = " Bpmn error encountered in UpdateNetworkInstanceInfra flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage() - utils.log("DEBUG", errorException, isDebugEnabled) - falloutHandlerRequest = - """ - - ${requestId} - UPDATE - ${source} - - - ${errorException} - 7000 - - """ - - execution.setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) - utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled) - - } - - } - - - public void sendSyncError (Execution execution) { - def isDebugEnabled=execution.getVariable("isDebugLogEnabled") - execution.setVariable("prefix", Prefix) - - 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 UpdateNetworkInstanceInfra flow. sendSyncError() - " + ex.getMessage(), isDebugEnabled) - } - - } - - - public void processJavaException(Execution 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", 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 index d428cc33dd..5c313775dd 100644 --- 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 @@ -1,24 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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 +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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; @@ -29,11 +29,11 @@ import java.io.Serializable; import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution 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 +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 { @@ -204,7 +204,7 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { String updateInfraRequest = """ + xmlns:req="http://org.openecomp.mso/requestsdb"> @@ -255,8 +255,8 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { def requestInfo = getVariable(execution, 'UPDVfMod_requestInfo') String content = """ - + ${requestInfo} MSO_ACTIVATE_BPEL @@ -304,10 +304,10 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor { } String content = """ - + ${requestInformation} ${encErrorResponseMsg} 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 index 6d532527d0..9ca247714b 100644 --- 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 @@ -1,24 +1,24 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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 +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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; @@ -26,12 +26,12 @@ import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.runtime.Execution 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 +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 { @@ -130,7 +130,7 @@ class UpdateVfModuleVolume extends VfModuleBase { def volumeInputs = execution.getVariable('UPDVfModVol_volumeInputs') String synchResponse = """ - + ${requestId} UPDATE_VF_MODULE_VOL @@ -238,7 +238,7 @@ class UpdateVfModuleVolume extends VfModuleBase { def requestId = execution.getVariable('UPDVfModVol_requestId') def serviceId = execution.getVariable('UPDVfModVol_serviceId') - def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis() + 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)) { @@ -297,7 +297,7 @@ class UpdateVfModuleVolume extends VfModuleBase { String updateInfraRequest = """ + xmlns:req="http://org.openecomp.mso/requestsdb"> @@ -340,8 +340,8 @@ class UpdateVfModuleVolume extends VfModuleBase { def requestInfo = execution.getVariable('UPDVfModVol_requestInfo') String content = """ - + ${requestInfo} MSO_ACTIVATE_BPEL @@ -385,10 +385,10 @@ class UpdateVfModuleVolume extends VfModuleBase { } String content = """ - + ${requestInfo} ${encErrorResponseMsg} diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn new file mode 100644 index 0000000000..dbd40c072e --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericALaCarteServiceInstance.bpmn @@ -0,0 +1,336 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + SequenceFlow_1lj31zp + + + SequenceFlow_095crcd + + + + SequenceFlow_0lp2z7l + SequenceFlow_0ktadna + + + + + SequenceFlow_1o4wwba + SequenceFlow_0xxvjxq + + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_14eadeb + SequenceFlow_1reso2f + + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + SequenceFlow_0n4umjf + SequenceFlow_14eadeb + + + + + + + + SequenceFlow_0ktadna + SequenceFlow_0eto8sn + + + + + SequenceFlow_1lj31zp + SequenceFlow_1o4wwba + SequenceFlow_1mdnv3l + + + SequenceFlow_1mdnv3l + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn index 7b9b8212e5..a3a36529da 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateGenericMacroServiceNetworkVnf.bpmn @@ -1,1203 +1,1243 @@ - - - - - SequenceFlow_7 - SequenceFlow_3 + + + + + SequenceFlow_7 + SequenceFlow_3 - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_7 +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.sendSyncResponse(execution)]]> + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_7 - - - +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.preProcessRequest(execution) +]]> + + + SequenceFlow_10o22u2 - - - - SequenceFlow_0afe2pg - SequenceFlow_29 + + + + SequenceFlow_0afe2pg + SequenceFlow_29 - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_8 - - - - SequenceFlow_8 - SequenceFlow_6 - - - - - SequenceFlow_6 - - - - - SequenceFlow_2 - - - - SequenceFlow_5 - - - - SequenceFlow_2 - SequenceFlow_5 +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.postProcessResponse(execution)]]> + + + + + + + + + + + + + + SequenceFlow_29 + SequenceFlow_8 + + + + SequenceFlow_8 + SequenceFlow_6 + + + + + SequenceFlow_6 + + + + + SequenceFlow_2 + + + + SequenceFlow_5 + + + + SequenceFlow_2 + SequenceFlow_5 - - - - - SequenceFlow_12ilko1 - - - - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_1bwbn7r - SequenceFlow_12ag2bk - - - SequenceFlow_0cmebdc - SequenceFlow_0dfkfh1 - SequenceFlow_1bwbn7r +def CreateServiceInstanceInfra = new CreateServiceInstanceInfra() +CreateServiceInstanceInfra.processJavaException(execution)]]> + + + + + SequenceFlow_12ilko1 + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1bwbn7r + SequenceFlow_12ag2bk + + + SequenceFlow_0cmebdc + SequenceFlow_0dfkfh1 + SequenceFlow_1bwbn7r - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0j6sjye - SequenceFlow_1ky2sv9 - - - - - - - - - - - - - - - - - - - - SequenceFlow_1h77psn - SequenceFlow_0qi5uxg - - - SequenceFlow_0bvecvm - SequenceFlow_1h77psn +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareNetworkCreate(execution)]]> + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0j6sjye + SequenceFlow_1ky2sv9 + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_1h77psn + SequenceFlow_0qi5uxg + + + SequenceFlow_0bvecvm + SequenceFlow_1h77psn - - - SequenceFlow_0xowenu - - - - SequenceFlow_3 - - - - - SequenceFlow_0zq7i3q - SequenceFlow_0zpbskl - SequenceFlow_0dhf2js - - - SequenceFlow_0zq7i3q - - - - SequenceFlow_0zpbskl - SequenceFlow_1sx5llu - SequenceFlow_02o4yqx - - - SequenceFlow_0sdb3on - SequenceFlow_05lo85t - SequenceFlow_0xtr1g5 - - - SequenceFlow_05lo85t - SequenceFlow_09xerwk - SequenceFlow_19mxskt - SequenceFlow_0tmepzk - - - - - - - - - - - SequenceFlow_0807ukc - SequenceFlow_19yywk8 - - - SequenceFlow_19yywk8 - - - SequenceFlow_19mxskt - SequenceFlow_1brxd2r - SequenceFlow_08s0ew2 - - - SequenceFlow_0jg47xm - SequenceFlow_0807ukc +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareVnfAndModulesCreate(execution)]]> + + + SequenceFlow_0xowenu + + + + SequenceFlow_3 + + + + + SequenceFlow_0zq7i3q + SequenceFlow_0zpbskl + SequenceFlow_0dhf2js + + + SequenceFlow_0zq7i3q + + + + SequenceFlow_0zpbskl + SequenceFlow_1sx5llu + SequenceFlow_02o4yqx + + + SequenceFlow_0sdb3on + SequenceFlow_05lo85t + SequenceFlow_0xtr1g5 + + + SequenceFlow_05lo85t + SequenceFlow_09xerwk + SequenceFlow_19mxskt + SequenceFlow_0tmepzk + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_19mxskt + SequenceFlow_1brxd2r + SequenceFlow_08s0ew2 + + + SequenceFlow_0jg47xm + SequenceFlow_0807ukc - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0xtr1g5 - SequenceFlow_09xerwk - - - - - - - - - - - SequenceFlow_0136s37 - SequenceFlow_1fqmrda - SequenceFlow_1dmsx0d - - - SequenceFlow_1ieiew4 - SequenceFlow_1os9x7w - SequenceFlow_0g7scsg - - - - - - - - - - SequenceFlow_1os9x7w - SequenceFlow_1f1hd3l - - - SequenceFlow_1sx5llu - SequenceFlow_0dhf2js - SequenceFlow_1rabks0 - SequenceFlow_0jg47xm - - - - - - - - - - - SequenceFlow_1dmsx0d - SequenceFlow_1otyild +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareFalloutRequest(execution)]]> + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0xtr1g5 + SequenceFlow_09xerwk + + + + + + + + + + + SequenceFlow_0136s37 + SequenceFlow_1fqmrda + SequenceFlow_1dmsx0d + + + SequenceFlow_1ieiew4 + SequenceFlow_1os9x7w + SequenceFlow_0g7scsg + + + + + + + + + + SequenceFlow_1os9x7w + SequenceFlow_1f1hd3l + + + SequenceFlow_1sx5llu + SequenceFlow_0dhf2js + SequenceFlow_1rabks0 + SequenceFlow_0jg47xm + + + + + + + + + + + SequenceFlow_1dmsx0d + SequenceFlow_1otyild - - - SequenceFlow_1otyild - SequenceFlow_0136s37 - SequenceFlow_12u8ufr - - - - - 0 }]]> - - - - SequenceFlow_0tmepzk - SequenceFlow_1fqmrda - SequenceFlow_1brxd2r - - - - - - - - - - SequenceFlow_12u8ufr - SequenceFlow_08s0ew2 - SequenceFlow_1ieiew4 - SequenceFlow_0sezboq - - - - - - - - - SequenceFlow_1f1hd3l - SequenceFlow_0g7scsg - SequenceFlow_0sezboq - SequenceFlow_0f4u373 - - - SequenceFlow_02o4yqx - SequenceFlow_0sdb3on +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.validateNetworkRollback(execution)]]> + + + SequenceFlow_1otyild + SequenceFlow_0136s37 + SequenceFlow_12u8ufr + + + + + 0 }]]> + + + + SequenceFlow_0tmepzk + SequenceFlow_1fqmrda + SequenceFlow_1brxd2r + + + + + + + + + + SequenceFlow_12u8ufr + SequenceFlow_08s0ew2 + SequenceFlow_1ieiew4 + SequenceFlow_0sezboq + + + + + + + + + SequenceFlow_1f1hd3l + SequenceFlow_0g7scsg + SequenceFlow_0sezboq + SequenceFlow_0f4u373 + + + SequenceFlow_02o4yqx + SequenceFlow_0sdb3on - - - SequenceFlow_0f4u373 - SequenceFlow_1rabks0 +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.preProcessRollback(execution)]]> + + + SequenceFlow_0f4u373 + SequenceFlow_1rabks0 - - - - - - - SequenceFlow_1vwssu7 - SequenceFlow_19etqmx +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.postProcessRollback(execution)]]> + + + + + + + SequenceFlow_1vwssu7 + SequenceFlow_19etqmx - - - SequenceFlow_10o22u2 - SequenceFlow_0j6sjye +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.getDataFromDecomposition(execution)]]> + + + SequenceFlow_0hvcwa1 + SequenceFlow_0j6sjye - - - - SequenceFlow_12ilko1 - SequenceFlow_0afe2pg - - - - - - - - - SequenceFlow_1vwssu7 - - - - SequenceFlow_13uceka - - - - SequenceFlow_19etqmx - SequenceFlow_0cmebdc - SequenceFlow_1f26zbk - - - SequenceFlow_04vlq8r - SequenceFlow_1n7r495 - SequenceFlow_0dfkfh1 - - - - - - 0}]]> - - - SequenceFlow_1n7r495 - SequenceFlow_1f26zbk - SequenceFlow_1j7n6qx - - - - SequenceFlow_1j7n6qx - - - - - - - SequenceFlow_10tbv62 - - - - SequenceFlow_10tbv62 - SequenceFlow_0bvecvm - SequenceFlow_0w7328u - - - SequenceFlow_0qi5uxg - SequenceFlow_0w7328u - SequenceFlow_0xowenu - - - - 0}]]> - - - in 1702 scope only one VNF will be created - - - - - SequenceFlow_12ag2bk - SequenceFlow_04vlq8r +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.prepareCreateServiceInstance(execution)]]> + + + SequenceFlow_12ilko1 + SequenceFlow_0afe2pg + + + + + + + + + SequenceFlow_1vwssu7 + + + + SequenceFlow_13uceka + + + + SequenceFlow_19etqmx + SequenceFlow_0cmebdc + SequenceFlow_1f26zbk + + + SequenceFlow_04vlq8r + SequenceFlow_1n7r495 + SequenceFlow_0dfkfh1 + + + + + + 0}]]> + + + SequenceFlow_1n7r495 + SequenceFlow_1f26zbk + SequenceFlow_1j7n6qx + + + + SequenceFlow_1j7n6qx + + + + + + + SequenceFlow_10tbv62 + + + + SequenceFlow_10tbv62 + SequenceFlow_0bvecvm + SequenceFlow_0w7328u + + + SequenceFlow_0qi5uxg + SequenceFlow_0w7328u + SequenceFlow_0xowenu + + + + 0}]]> + + + in 1702 scope only one VNF will be created + + + + + SequenceFlow_12ag2bk + SequenceFlow_04vlq8r - - - - - - - - - ${URN_mso_adapters_db_endpoint} - - - - application/soap+xml - - - POST - - soap-http-connector - - - SequenceFlow_0vj46ej - SequenceFlow_13uceka - - - - SequenceFlow_1ky2sv9 - SequenceFlow_0vj46ej +def CreateGenericMacroServiceNetworkVnf= new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.validateNetworkCreate(execution)]]> + + + + + + + + + ${URN_mso_adapters_db_endpoint} + + + + application/soap+xml + + + POST + + soap-http-connector + + + SequenceFlow_0vj46ej + SequenceFlow_13uceka + + + + SequenceFlow_1ky2sv9 + SequenceFlow_0vj46ej - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def CreateGenericMacroServiceNetworkVnf = new CreateGenericMacroServiceNetworkVnf() +CreateGenericMacroServiceNetworkVnf.postProcessServiceInstanceCreate(execution)]]> + + + + + + + + + + + + + + SequenceFlow_00h6hmd + SequenceFlow_0hvcwa1 + + + SequenceFlow_1eu60rt + SequenceFlow_00h6hmd + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn deleted file mode 100644 index fa114c5e76..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateServiceInstance.bpmn +++ /dev/null @@ -1,336 +0,0 @@ - - - - - SequenceFlow_0lp2z7l - - - - SequenceFlow_10 - SequenceFlow_14 - - - - - SequenceFlow_10 - - - - - SequenceFlow_14 - - - - - - - - - - - - - - - - - - - - - SequenceFlow_0eto8sn - SequenceFlow_1lj31zp - - - SequenceFlow_095crcd - - - - SequenceFlow_0lp2z7l - SequenceFlow_0ktadna - - - - - SequenceFlow_1o4wwba - SequenceFlow_0xxvjxq - - - - - - - - - - - - SequenceFlow_0xxvjxq - SequenceFlow_095crcd - - - - - SequenceFlow_0n4umjf - - - - SequenceFlow_1ghqolv - - - SequenceFlow_14eadeb - SequenceFlow_1reso2f - - - - - - - - - - - - SequenceFlow_1reso2f - SequenceFlow_1ghqolv - - - - - - SequenceFlow_0n4umjf - SequenceFlow_14eadeb - - - - - - - - SequenceFlow_0ktadna - SequenceFlow_0eto8sn - - - - - SequenceFlow_1lj31zp - SequenceFlow_1o4wwba - SequenceFlow_1mdnv3l - - - SequenceFlow_1mdnv3l - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn index 7a8133ec7f..c58fec9dd9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -1,22 +1,42 @@ - + SequenceFlow_1 - + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_7 SequenceFlow_4 @@ -28,17 +48,17 @@ def createVfModule = new CreateVfModuleInfra() createVfModule.sendResponse(execution)]]> - + SequenceFlow_4 - + - + SequenceFlow_5 - + - + SequenceFlow_5 SequenceFlow_6 @@ -49,7 +69,6 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> - http-connector ${URN_mso_adapters_db_endpoint} @@ -62,13 +81,14 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> ${statusCode} ${response} + http-connector SequenceFlow_6 SequenceFlow_8 - - + + updateInfraRequestResponseGood SequenceFlow_12 @@ -76,15 +96,15 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> def createVfModule = new CreateVfModuleInfra() createVfModule.postProcessResponse(execution)]]> - + - - - - - - + + + + + + SequenceFlow_12 SequenceFlow_14 @@ -94,13 +114,13 @@ createVfModule.postProcessResponse(execution)]]> updateInfraRequestResponseBad updateInfraRequestResponseGood - + updateInfraRequestResponseBad - + @@ -110,37 +130,37 @@ createVfModule.postProcessResponse(execution)]]> def createVfModule = new CreateVfModuleInfra() createVfModule.validateRollbackResponse(execution)]]> - + - - - - + + + + SequenceFlow_19 SequenceFlow_17 - + SequenceFlow_13 - + - + - - - - + + + + SequenceFlow_10 SequenceFlow_11 - + SequenceFlow_11 - + SequenceFlow_22 @@ -149,19 +169,19 @@ createVfModule.validateRollbackResponse(execution)]]> def cvfm = new CreateVfModuleInfra() cvfm.falloutHandlerPrep(execution, 'CVFMI_FalloutHandlerRequest')]]> - + SequenceFlow_21 isRollbackOnNoSequenceFlow SequenceFlow_22 - + SequenceFlow_13 isRollbackOnNoSequenceFlow IsRollbackOnYesSequenceFlow - + IsRollbackOnYesSequenceFlow SequenceFlow_19 @@ -172,7 +192,7 @@ cvfm.logAndSaveOriginalException(execution)]]> - + SequenceFlow_14 @@ -181,18 +201,18 @@ cvfm.logAndSaveOriginalException(execution)]]> SequenceFlow_16 - + - - + + SequenceFlow_15 - + - + SequenceFlow_15 - + SequenceFlow_1 @@ -201,272 +221,272 @@ cvfm.logAndSaveOriginalException(execution)]]> def createVfModule = new CreateVfModuleInfra() createVfModule.preProcessRequest(execution)]]> - + - - + + - + - - + + - + - + - + - - + + - + - + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - - - - + + + + - + - - - - + + + + - + - - - - + + + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + - - + + - + - + - + - + - + - - - - + + + + - + - - - - + + + + - + - - - + + + - + - - - - + + + + - + - + - - + + - + - + - - + + - + - - + + - \ No newline at end of file + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn index e8d27b6014..b10e98b56f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVnfInfra.bpmn @@ -23,7 +23,7 @@ createVnf.sendSyncResponse(execution)]]> - + @@ -31,12 +31,13 @@ createVnf.sendSyncResponse(execution)]]> - + + SequenceFlow_3 SequenceFlow_0lso26t diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn deleted file mode 100644 index 4488e8de1c..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DelServiceInstance.bpmn +++ /dev/null @@ -1,331 +0,0 @@ - - - - - SequenceFlow_0lp2z7l - - - - SequenceFlow_10 - SequenceFlow_14 - - - - - SequenceFlow_10 - - - - - SequenceFlow_14 - - - - - - - - - - - - - - - - - - SequenceFlow_0eto8sn - SequenceFlow_1lj31zp - - - SequenceFlow_095crcd - - - - SequenceFlow_0lp2z7l - SequenceFlow_0ktadna - - - - - SequenceFlow_1qjygj5 - SequenceFlow_0xxvjxq - - - - - - - - - - - - SequenceFlow_0xxvjxq - SequenceFlow_095crcd - - - - - SequenceFlow_0n4umjf - - - - SequenceFlow_1ghqolv - - - SequenceFlow_14eadeb - SequenceFlow_1reso2f - - - - - - - - - - - - SequenceFlow_1reso2f - SequenceFlow_1ghqolv - - - - - - SequenceFlow_0n4umjf - SequenceFlow_14eadeb - - - - - - - - SequenceFlow_0ktadna - SequenceFlow_0eto8sn - - - - - SequenceFlow_1lj31zp - SequenceFlow_1qjygj5 - SequenceFlow_0hgiouk - - - - - - SequenceFlow_0hgiouk - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn new file mode 100644 index 0000000000..ceb0c72218 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericALaCarteServiceInstance.bpmn @@ -0,0 +1,331 @@ + + + + + SequenceFlow_0lp2z7l + + + + SequenceFlow_10 + SequenceFlow_14 + + + + + SequenceFlow_10 + + + + + SequenceFlow_14 + + + + + + + + + + + + + + + + + + SequenceFlow_0eto8sn + SequenceFlow_1lj31zp + + + SequenceFlow_095crcd + + + + SequenceFlow_0lp2z7l + SequenceFlow_0ktadna + + + + + SequenceFlow_1qjygj5 + SequenceFlow_0xxvjxq + + + + + + + + + + + + SequenceFlow_0xxvjxq + SequenceFlow_095crcd + + + + + SequenceFlow_0n4umjf + + + + SequenceFlow_1ghqolv + + + SequenceFlow_14eadeb + SequenceFlow_1reso2f + + + + + + + + + + + + SequenceFlow_1reso2f + SequenceFlow_1ghqolv + + + + + + SequenceFlow_0n4umjf + SequenceFlow_14eadeb + + + + + + + + SequenceFlow_0ktadna + SequenceFlow_0eto8sn + + + + + SequenceFlow_1lj31zp + SequenceFlow_1qjygj5 + SequenceFlow_0hgiouk + + + + + + SequenceFlow_0hgiouk + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn index eeb32599d3..bb2c487e8a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteGenericMacroServiceNetworkVnf.bpmn @@ -1,771 +1,773 @@ - - - - - SequenceFlow_7 - SequenceFlow_3 + + + + + SequenceFlow_7 + SequenceFlow_3 - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_7 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.sendSyncResponse(execution)]]> + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_7 - - - - SequenceFlow_10o22u2 - - - - SequenceFlow_12ilko1 - SequenceFlow_29 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.preProcessRequest(execution) +]]> + + + + SequenceFlow_10o22u2 + + + + SequenceFlow_12ilko1 + SequenceFlow_29 - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_8 - - - - SequenceFlow_8 - SequenceFlow_6 - - - - - SequenceFlow_6 - - - - - SequenceFlow_2 - - - - SequenceFlow_5 - - - - SequenceFlow_2 - SequenceFlow_5 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.postProcessResponse(execution)]]> + + + + + + + + + + + + + + SequenceFlow_29 + SequenceFlow_8 + + + + SequenceFlow_8 + SequenceFlow_6 + + + + + SequenceFlow_6 + + + + + SequenceFlow_2 + + + + SequenceFlow_5 + + + + SequenceFlow_2 + SequenceFlow_5 - - - - - SequenceFlow_12ilko1 - - - - - - - - - - - - - - - - - - - SequenceFlow_1bwbn7r - SequenceFlow_12ag2bk - - - SequenceFlow_0cmebdc - SequenceFlow_0dfkfh1 - SequenceFlow_1bwbn7r +def DeleteServiceInstanceInfra = new DeleteServiceInstanceInfra() +DeleteServiceInstanceInfra.processJavaException(execution)]]> + + + + + SequenceFlow_12ilko1 + + + + + + + + + + + + + + + + + + + SequenceFlow_1bwbn7r + SequenceFlow_12ag2bk + + + SequenceFlow_0cmebdc + SequenceFlow_0dfkfh1 + SequenceFlow_1bwbn7r - - - - - - - - - - - - - - SequenceFlow_10o22u2 - SequenceFlow_04ao07f - - - - - - - - - - - - - - SequenceFlow_1h77psn - SequenceFlow_1dmn40p - - - SequenceFlow_0bvecvm - SequenceFlow_0mr8jgt - SequenceFlow_1h77psn +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareNetworkDelete(execution)]]> + + + + + + + + + + + + + + SequenceFlow_10o22u2 + SequenceFlow_04ao07f + + + + + + + + + + + + + + + + SequenceFlow_1h77psn + SequenceFlow_1dmn40p + + + SequenceFlow_0bvecvm + SequenceFlow_0mr8jgt + SequenceFlow_1h77psn - - - SequenceFlow_0xowenu - - - - SequenceFlow_3 - - - - - SequenceFlow_06llof4 - - - - - - - - - - - - SequenceFlow_0807ukc - SequenceFlow_19yywk8 - - - SequenceFlow_19yywk8 - - - SequenceFlow_06llof4 - SequenceFlow_0807ukc +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareVnfAndModulesDelete(execution)]]> + + + SequenceFlow_0xowenu + + + + SequenceFlow_3 + + + + + SequenceFlow_06llof4 + + + + + + + + + + + + SequenceFlow_0807ukc + SequenceFlow_19yywk8 + + + SequenceFlow_19yywk8 + + + SequenceFlow_06llof4 + SequenceFlow_0807ukc - - - - - - - - - - - - SequenceFlow_1vwssu7 - - - - SequenceFlow_04ao07f - - - - SequenceFlow_1vwssu7 - SequenceFlow_0cmebdc - SequenceFlow_1f26zbk - - - SequenceFlow_04vlq8r - SequenceFlow_1n7r495 - SequenceFlow_0dfkfh1 - - - - - - 0}]]> - - - SequenceFlow_1n7r495 - SequenceFlow_1f26zbk - SequenceFlow_1j7n6qx - - - - SequenceFlow_1j7n6qx - - - - - - SequenceFlow_10tbv62 - - - - SequenceFlow_10tbv62 - SequenceFlow_0bvecvm - SequenceFlow_0w7328u - - - SequenceFlow_0w7328u - SequenceFlow_1wc8h5g - SequenceFlow_0xowenu - - - - 0}]]> - - - - - SequenceFlow_12ag2bk - SequenceFlow_04vlq8r +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareFalloutRequest(execution)]]> + + + + + + + + + + + + SequenceFlow_1vwssu7 + + + + SequenceFlow_04ao07f + + + + SequenceFlow_1vwssu7 + SequenceFlow_0cmebdc + SequenceFlow_1f26zbk + + + SequenceFlow_04vlq8r + SequenceFlow_1n7r495 + SequenceFlow_0dfkfh1 + + + + + + 0}]]> + + + SequenceFlow_1n7r495 + SequenceFlow_1f26zbk + SequenceFlow_1j7n6qx + + + + SequenceFlow_1j7n6qx + + + + + + SequenceFlow_10tbv62 + + + + SequenceFlow_10tbv62 + SequenceFlow_0bvecvm + SequenceFlow_0w7328u + + + SequenceFlow_0w7328u + SequenceFlow_1wc8h5g + SequenceFlow_0xowenu + + + + 0}]]> + + + + + SequenceFlow_12ag2bk + SequenceFlow_04vlq8r - - - - - - - - - - - - - - - SequenceFlow_0jek18q - SequenceFlow_1ttswdr - - - SequenceFlow_1ttswdr - SequenceFlow_18103ca +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.validateNetworkDelete(execution)]]> + + + + + + + + + + + + + + + SequenceFlow_0jek18q + SequenceFlow_1ttswdr + + + SequenceFlow_1ttswdr + SequenceFlow_18103ca - - - SequenceFlow_0jek18q - - - - SequenceFlow_18103ca - - - - - - - - SequenceFlow_1dmn40p - SequenceFlow_0g2cw86 +def DeleteGenericMacroServiceNetworkVnf = new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.prepareServiceInstanceDelete(execution)]]> + + + SequenceFlow_0jek18q + + + + SequenceFlow_18103ca + + + + + + + + SequenceFlow_1dmn40p + SequenceFlow_0g2cw86 - - - SequenceFlow_0g2cw86 - SequenceFlow_0mr8jgt - SequenceFlow_1wc8h5g - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def DeleteGenericMacroServiceNetworkVnf= new DeleteGenericMacroServiceNetworkVnf() +DeleteGenericMacroServiceNetworkVnf.validateVnfDelete(execution)]]> + + + SequenceFlow_0g2cw86 + SequenceFlow_0mr8jgt + SequenceFlow_1wc8h5g + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn index b5b10a0fda..95c0a727ce 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/DeleteVnfInfra.bpmn @@ -129,7 +129,7 @@ deleteVnf.prepareCompletionHandlerRequest(execution)]]> - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn deleted file mode 100644 index f49149b709..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/UpdateNetworkInstanceInfra.bpmn +++ /dev/null @@ -1,1014 +0,0 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_32 - SequenceFlow_11 - - - - - SequenceFlow_12 - SequenceFlow_5 - - - - SequenceFlow_5 - sdncTopoNo_SequenceFlow - sdncTopoYes_SequenceFlow - - - - - - - - SequenceFlow_34 - - - - - sdncTopoNo_SequenceFlow - SequenceFlow_34 - - - - - - - - - - - - - - - - - - - - - - - - - - SequenceFlow_11 - SequenceFlow_12 - - - - SequenceFlow_27 - SequenceFlow_29 - - - - - - SequenceFlow_23 - isRollbackOn_YesNetwork_SequenceFlow - isRollbackOn_NoNetwork_SequenceFlow - - - - - - - SequenceFlow_23 - - - - - isRollbackOn_YesNetwork_SequenceFlow - isPONR_Yes_SequenceFlow - isPONR_No_SequenceFlow - - - - - - - isPONR_No_SequenceFlow - isNetworkOk_No_SequenceFlow - isNetworkOk_Yes_SequenceFlow - - - - - - - isNetworkOk_No_SequenceFlow - isNetworkOk_Yes_SequenceFlow - sdncOk_Yeso_ExclusiveGateway - sdncOk_No_ExclusiveGateway - - - - - - - sdncOk_Yeso_ExclusiveGateway - SequenceFlow_53 - - - - - SequenceFlow_53 - SequenceFlow_55 - - - - - SequenceFlow_47 - SequenceFlow_22 - - - - - - - http-connector - - ${URN_mso_adapters_db_endpoint} - ${UPDNETI_updateDBRequest} - - - application/soap+xml - - - POST - ${response} - ${statusCode} - - - - SequenceFlow_22 - SequenceFlow_19 - - - - - - - - - - - - - - SequenceFlow_25 - SequenceFlow_18 - - - - SequenceFlow_18 - - - SequenceFlow_55 - sdncOk_No_ExclusiveGateway - SequenceFlow_4 - - - - - isRollbackOn_NoNetwork_SequenceFlow - isPONR_Yes_SequenceFlow - SequenceFlow_4 - SequenceFlow_47 - - - - SequenceFlow_19 - SequenceFlow_25 - - - - - - SequenceFlow_13 - SequenceFlow_35 - - - - - SequenceFlow_35 - SequenceFlow_46 - - - - - SequenceFlow_46 - SequenceFlow_37 - - - - - - - http-connector - - ${URN_mso_adapters_db_endpoint} - ${UPDNETI_updateDBRequest} - - - application/soap+xml - - - POST - ${response} - ${statusCode} - - - - SequenceFlow_37 - SequenceFlow_27 - - - - - - - - - - - - - - SequenceFlow_29 - SequenceFlow_17 - - - - SequenceFlow_17 - - - - SequenceFlow_10 - SequenceFlow_14 - - - - - SequenceFlow_10 - - - - - SequenceFlow_14 - - - - SequenceFlow_1 - SequenceFlow_7 - - - - - SequenceFlow_24 - SequenceFlow_32 - - - - - siFoundYes - SequenceFlow_24 - - - - - SequenceFlow_30 - - - - siFoundNo - SequenceFlow_30 - - - - - SequenceFlow_3 - siFoundYes - siFoundNo - - - - - - - - - - - - - - - - SequenceFlow_28 - SequenceFlow_3 - - - - SequenceFlow_7 - SequenceFlow_28 - - - - - SequenceFlow_59 - SequenceFlow_13 - - - - - - - http-connector - - ${UPDNETI_updateNetworkRequest} - ${URN_mso_adapters_network_rest_endpoint}/${UPDNETI_networkId} - - - #{BasicAuthHeaderValuePO} - application/xml - - - PUT - ${statusCode} - ${response} - - - - SequenceFlow_61 - SequenceFlow_59 - - - - SequenceFlow_2 - SequenceFlow_61 - - - - - SequenceFlow_38 - SequenceFlow_2 - - - - - sdncTopoYes_SequenceFlow - SequenceFlow_6 - - - - - SequenceFlow_6 - SequenceFlow_15 - - - - - SequenceFlow_15 - SequenceFlow_38 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn index ecd23f0ca9..5488350afc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateNetworkInstance.bpmn @@ -623,12 +623,12 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - + @@ -675,10 +675,10 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - - + + - + @@ -795,46 +795,46 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - - + + + - + - - + + - + - + - + - - - + + + - + - - - + + + - + @@ -861,7 +861,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + @@ -1074,24 +1074,24 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - + + - + - - - + + + - + @@ -1133,24 +1133,24 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - + + - + - - - + + + - + @@ -1178,7 +1178,7 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + @@ -1187,9 +1187,9 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + @@ -1211,17 +1211,17 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - - + + - + - + @@ -1233,98 +1233,98 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - - + + - + - - + + - + - - - + + + - + - - + + - + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - + - + - - + + - + - + - + - - + + - + @@ -1338,17 +1338,17 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - + - - - + + + - + @@ -1359,20 +1359,20 @@ DoCreateNetworkInstance.postProcessResponse(execution)]]> - + - - + + - + - - + + - + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn index a770c8c11a..19fd490b9f 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstance.bpmn @@ -1,390 +1,431 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_2 - SequenceFlow_3 + + + + + SequenceFlow_1 + + + + SequenceFlow_2 + SequenceFlow_3 - - - - SequenceFlow_1 - SequenceFlow_2 +def dcsi = new DoCreateServiceInstance() +dcsi.getAAICustomerById(execution)]]> + + + + SequenceFlow_1 + SequenceFlow_2 - - - - SequenceFlow_156ih25 - SequenceFlow_14 +def dcsi = new DoCreateServiceInstance() +dcsi.preProcessRequest(execution) +]]> + + + + SequenceFlow_156ih25 + SequenceFlow_14 - - - SequenceFlow_9 - SequenceFlow_10 +def dcsi = new DoCreateServiceInstance() +dcsi.preProcessSDNCAssignRequest(execution)]]> + + + SequenceFlow_9 + SequenceFlow_10 - - - - - - - - - - - SequenceFlow_14 - SequenceFlow_9 - - - SequenceFlow_10 - - - - - - - - - - - - - - - SequenceFlow_11fnnkb - SequenceFlow_4 - - - - - - - - - - - - - SequenceFlow_1uw2p9a - SequenceFlow_1w01tqs - SequenceFlow_129ih1g - - - - SequenceFlow_3 - SequenceFlow_11fnnkb - SequenceFlow_1uw2p9a - - - - - - - - SequenceFlow_0tgrn11 - - - - SequenceFlow_1xzgv5k - - - - - - - - - - SequenceFlow_1lqktwf - SequenceFlow_0eumzpf - - - - - SequenceFlow_0tgrn11 - SequenceFlow_1lqktwf +def dcsi = new DoCreateServiceInstance() +dcsi.postProcessSDNCAssign(execution)]]> + + + + + + + + + + + SequenceFlow_14 + SequenceFlow_9 + + + SequenceFlow_01q6pl4 + + + + + + + + + + + + + + + SequenceFlow_11fnnkb + SequenceFlow_4 + + + + + + + + + + + + + SequenceFlow_1uw2p9a + SequenceFlow_1w01tqs + SequenceFlow_129ih1g + + + + SequenceFlow_3 + SequenceFlow_11fnnkb + SequenceFlow_1uw2p9a + + + + + + + + SequenceFlow_0tgrn11 + + + + SequenceFlow_1xzgv5k + + + + + + + + + + SequenceFlow_1lqktwf + SequenceFlow_0eumzpf + + + + + SequenceFlow_0tgrn11 + SequenceFlow_1lqktwf - - - - SequenceFlow_0eumzpf - SequenceFlow_1xzgv5k +def dcsi = new DoCreateServiceInstance() +dcsi.preProcessRollback(execution) +]]> + + + + SequenceFlow_0eumzpf + SequenceFlow_1xzgv5k - - - - - SequenceFlow_1dd86x8 - SequenceFlow_156ih25 - SequenceFlow_00v4npo - - - - SequenceFlow_00v4npo - - - - - - SequenceFlow_4 - SequenceFlow_1w01tqs +def dcsi = new DoCreateServiceInstance() +dcsi.postProcessRollback(execution) +]]> + + + + + SequenceFlow_1dd86x8 + SequenceFlow_156ih25 + SequenceFlow_00v4npo + + + + SequenceFlow_00v4npo + + + + + + SequenceFlow_4 + SequenceFlow_1w01tqs - - - - SequenceFlow_129ih1g - SequenceFlow_1dd86x8 +def dcsi = new DoCreateServiceInstance() +dcsi.postProcessAAIGET(execution)]]> + + + + SequenceFlow_129ih1g + SequenceFlow_1dd86x8 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def ddsi = new DoCreateServiceInstance() +ddsi.postProcessAAIPUT(execution)]]> + + + + + + + + + + + + + + SequenceFlow_10 + SequenceFlow_0tx5frq + + + + + SequenceFlow_0tx5frq + SequenceFlow_01q6pl4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn index 80ace28ae7..6c24696cbd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateServiceInstanceRollback.bpmn @@ -1,338 +1,379 @@ - - - - - SequenceFlow_1 - - - - SequenceFlow_1 - SequenceFlow_2 + + + + + SequenceFlow_1 + + + + SequenceFlow_1 + SequenceFlow_2 - - - SequenceFlow_01l4ssl - - - - SequenceFlow_8 - - - - SequenceFlow_7 - - - - SequenceFlow_8 - SequenceFlow_7 +def rbk = new DoCreateServiceInstanceRollback() +rbk.preProcessRequest(execution) +]]> + + + SequenceFlow_01l4ssl + + + + SequenceFlow_8 + + + + SequenceFlow_7 + + + + SequenceFlow_8 + SequenceFlow_7 - - - - - - - - - - - - - - - - SequenceFlow_1x9eh33 - SequenceFlow_05wu9i7 - - - SequenceFlow_06aasqh - SequenceFlow_11fnnkb - SequenceFlow_1uw2p9a - - - - - - - rollback AAI - SequenceFlow_1uw2p9a - SequenceFlow_0khjo7l - SequenceFlow_1n7wade - SequenceFlow_1x9eh33 - - - - - - - - - - - - - - - - - SequenceFlow_11fnnkb - SequenceFlow_0k28xib - - - SequenceFlow_0k28xib - SequenceFlow_0khjo7l +def rbk= new DoCreateServiceInstanceRollback() +rbk.processRollbackException(execution)]]> + + + + + + + + + + + + + + + + SequenceFlow_1x9eh33 + SequenceFlow_05wu9i7 + + + SequenceFlow_06aasqh + SequenceFlow_11fnnkb + SequenceFlow_1uw2p9a + + + + + + + rollback AAI + SequenceFlow_1uw2p9a + SequenceFlow_1njogr1 + SequenceFlow_1n7wade + SequenceFlow_1x9eh33 + + + + + + + + + + + + + + + + + SequenceFlow_11fnnkb + SequenceFlow_0k28xib + + + SequenceFlow_0k28xib + SequenceFlow_0khjo7l - - - - SequenceFlow_2 - SequenceFlow_06aasqh - SequenceFlow_1rzlaoy - - - SequenceFlow_05wu9i7 - SequenceFlow_1n7wade - SequenceFlow_1rzlaoy - SequenceFlow_01l4ssl +String response = execution.getVariable("sdncDeactivateResponse") +def rbk= new DoCreateServiceInstanceRollback() +rbk.validateSDNCResponse(execution, response, "deactivate")]]> + + + + SequenceFlow_2 + SequenceFlow_06aasqh + SequenceFlow_1rzlaoy + + + SequenceFlow_05wu9i7 + SequenceFlow_1n7wade + SequenceFlow_1rzlaoy + SequenceFlow_01l4ssl - - - - - - - - - SequenceFlow_1ch4xrf - - - - SequenceFlow_1ch4xrf - SequenceFlow_1pjk2ff +def rbk = new DoCreateServiceInstanceRollback() +rbk.postProcessRequest(execution)]]> + + + + + + + + + SequenceFlow_1ch4xrf + + + + SequenceFlow_1ch4xrf + SequenceFlow_1pjk2ff - - - SequenceFlow_1pjk2ff - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +def rbk= new DoCreateServiceInstanceRollback() +rbk.processRollbackJavaException(execution)]]> + + + SequenceFlow_1pjk2ff + + + + + + + SequenceFlow_006g9e8 + SequenceFlow_1njogr1 + + + + + + + + + + + + SequenceFlow_0khjo7l + SequenceFlow_006g9e8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn index 5e88527676..8411c56bef 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnf.bpmn @@ -9,7 +9,7 @@ SequenceFlow_1 SequenceFlow_2 @@ -42,7 +42,7 @@ exceptionUtil.buildWorkflowException(execution, 404, "Service Instance Not Found found - + @@ -64,7 +64,7 @@ exceptionUtil.buildWorkflowException(execution, 404, "Service Instance Not Found - found + VnfNameSpecified1 SequenceFlow_7 @@ -86,9 +86,10 @@ exceptionUtil.buildWorkflowException(execution, 5000, "Generic Vnf Already Exist vnfExistNo + VnfNameNotSpecified1 SequenceFlow_11 @@ -123,21 +124,20 @@ exceptionUtil.processJavaException(execution)]]> - SequenceFlow_15z3gpq - SequenceFlow_0ay5l4b + SdncInteractionNotEnabled + SequenceFlow_0bj7c4s - - + - SequenceFlow_0ttqcwx + SdncInteractionEnabled SequenceFlow_1q6udwm @@ -155,19 +155,20 @@ createVnf.preProcessSDNCAssignRequest(execution)]]> SequenceFlow_15knw0q - SequenceFlow_0c5h00o SequenceFlow_0lnh79j + +String response = execution.getVariable("DoCVNF_assignSDNCAdapterResponse") + +def createVnfInfra = new DoCreateVnf() createVnfInfra.validateSDNCResponse(execution, response, "assign")]]> - SequenceFlow_0c5h00o + SequenceFlow_1q1poly + VnfNameSpecified2 SequenceFlow_1lalmvp @@ -187,30 +188,102 @@ createVnf.preProcessSDNCActivateRequest(execution)]]> SequenceFlow_0eb41vb SequenceFlow_15z3gpq - + SequenceFlow_1gc18ih - SequenceFlow_0ttqcwx - SequenceFlow_0ay5l4b + SdncInteractionEnabled + SdncInteractionNotEnabled - - + + - + SequenceFlow_0seif8n SequenceFlow_1gc18ih + + found + VnfNameNotSpecified1 + VnfNameSpecified1 + + + + + + + + + + SequenceFlow_0lnh79j + VnfNameNotSpecified2 + VnfNameSpecified2 + + + + + + + + VnfNameNotSpecified2 + SequenceFlow_1h9jdgr + + + + + + + + + + + + + SequenceFlow_1h9jdgr + SequenceFlow_14xac2y + + + SequenceFlow_14xac2y + SequenceFlow_1q1poly + + + + + + + + + + + + SequenceFlow_0nhsdmj + SequenceFlow_0bj7c4s + + + + SequenceFlow_15z3gpq + SequenceFlow_0nhsdmj + + @@ -243,27 +316,27 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + - + - + - - + + - + @@ -280,11 +353,10 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - - - + + - + @@ -339,9 +411,9 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + @@ -400,32 +472,25 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - - - - - - - - - + + - + - - + + - + - - + + - + @@ -438,36 +503,37 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + - + - + - + - - - + + + - + - - - - + + + + + - + @@ -479,14 +545,114 @@ createVnf.postProcessCreateGenericVnf(execution)]]> - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn index 433957572d..be54119bda 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoCreateVnfAndModules.bpmn @@ -13,7 +13,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> - + @@ -36,6 +36,9 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> + + + SequenceFlow_1hf7k7q SequenceFlow_1ixcnb6 @@ -44,7 +47,7 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> - + @@ -67,6 +70,9 @@ doCreateVnfAndModules.preProcessRequest(execution)]]> + + + SequenceFlow_1lh21yl SequenceFlow_1llbx0k @@ -97,7 +103,7 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> - + @@ -105,7 +111,6 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> - @@ -115,6 +120,9 @@ doCreateVnfAndModules.validateAddOnModule(execution)]]> + + + SequenceFlow_1xd3ri5 SequenceFlow_08i3uo6 @@ -141,10 +149,10 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> SequenceFlow_1vrogpr - + - + @@ -159,6 +167,7 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> + SequenceFlow_1ifw9tw SequenceFlow_1hf7k7q @@ -171,6 +180,7 @@ doCreateVnfAndModules.queryCatalogDB(execution)]]> + SequenceFlow_0kld3qt SequenceFlow_1lh21yl @@ -193,7 +203,27 @@ doCreateVnfAndModules.finisthProcessingInitialCountDeployment(execution)]]> + + + SequenceFlow_11bmhi4 + SequenceFlow_1kjlzrn + + + + SequenceFlow_1kjlzrn + + + SequenceFlow_11bmhi4 + + + + + + + @@ -374,6 +404,38 @@ doCreateVnfAndModules.validateBaseModule(execution)]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn index 9d21cc8301..49274bd8a6 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteServiceInstance.bpmn @@ -1,332 +1,373 @@ - - - - - SequenceFlow_0jfgn05 - - - SequenceFlow_0jfgn05 - SequenceFlow_1jqc16k + + + + + SequenceFlow_0jfgn05 + + + SequenceFlow_0jfgn05 + SequenceFlow_1jqc16k - - - SequenceFlow_1wyvxwi - - - - - - - - - - - - - SequenceFlow_1w8ao21 - SequenceFlow_0riudmc - SequenceFlow_05wu9i7 - - - - - - - - - - - - - SequenceFlow_0rtflal - SequenceFlow_0k28xib - - - SequenceFlow_0k28xib - SequenceFlow_1w8ao21 +def ddsi = new DoDeleteServiceInstance() +ddsi.preProcessRequest(execution) +]]> + + + SequenceFlow_1wyvxwi + + + + + + + + + + + + + SequenceFlow_0riudmc + SequenceFlow_0znbzxu + SequenceFlow_05wu9i7 + + + + + + + + + + + + + SequenceFlow_0rtflal + SequenceFlow_0k28xib + + + SequenceFlow_0k28xib + SequenceFlow_1w8ao21 - - - - SequenceFlow_1dwch0k - SequenceFlow_0rtflal + +String response = execution.getVariable("sdncDeactivateResponse") +def ddsi = new DoDeleteServiceInstance() +ddsi.postProcessSDNCDelete(execution, response, "deactivate")]]> + + + + SequenceFlow_1dwch0k + SequenceFlow_0rtflal - - - - SequenceFlow_1up0j5r - SequenceFlow_1hcfvcj - SequenceFlow_05jfuko - - - - - - SequenceFlow_05jfuko - - - - - SequenceFlow_1hcfvcj - SequenceFlow_0riudmc - SequenceFlow_1dwch0k - - - - - - - - - - - - - - - - SequenceFlow_1jqc16k - SequenceFlow_1grea1r - - - - SequenceFlow_1grea1r - SequenceFlow_1up0j5r +def ddsi = new DoDeleteServiceInstance() +ddsi.preProcessSDNCDelete(execution)]]> + + + + SequenceFlow_1up0j5r + SequenceFlow_1hcfvcj + SequenceFlow_05jfuko + + + + + + SequenceFlow_05jfuko + + + + + SequenceFlow_1hcfvcj + SequenceFlow_0riudmc + SequenceFlow_1dwch0k + + + + + + + + + + + + + + + + SequenceFlow_1jqc16k + SequenceFlow_1grea1r + + + + SequenceFlow_1grea1r + SequenceFlow_1up0j5r - - - - - SequenceFlow_05wu9i7 - SequenceFlow_1wyvxwi +def ddsi = new DoDeleteServiceInstance() +ddsi.postProcessAAIGET(execution)]]> + + + + + SequenceFlow_05wu9i7 + SequenceFlow_1wyvxwi - - - - - SequenceFlow_0u33vy6 - - - - SequenceFlow_0hevfee - - - SequenceFlow_0u33vy6 - SequenceFlow_0hevfee +def ddsi = new DoDeleteServiceInstance() +ddsi.postProcessAAIDEL(execution)]]> + + + + + SequenceFlow_0u33vy6 + + + + SequenceFlow_0hevfee + + + SequenceFlow_0u33vy6 + SequenceFlow_0hevfee - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ExceptionUtil ex = new ExceptionUtil() +ex.processJavaException(execution)]]> + + + + + + + + + + + + + + SequenceFlow_1w8ao21 + SequenceFlow_14x55db + + + SequenceFlow_14x55db + SequenceFlow_0znbzxu + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn index ab0812343b..b8c6aa32a4 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/subprocess/DoDeleteVfModule.bpmn @@ -1,8 +1,7 @@ - + SequenceFlow_0fp1wqz SequenceFlow_28 - + @@ -21,8 +19,7 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_31 - + @@ -34,8 +31,7 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_1j9dvfx - + @@ -49,16 +45,14 @@ dvm.prepUpdateAAIVfModule(execution)]]> SequenceFlow_33 - + SequenceFlow_1j9dvfx SequenceFlow_4 - + SequenceFlow_31 SequenceFlow_32 - + @@ -82,8 +75,7 @@ dvm.prepSDNCAdapterRequest(execution, "delete")]]> SequenceFlow_35 - + @@ -94,8 +86,7 @@ dvm.prepSDNCAdapterRequest(execution, "delete")]]> SequenceFlow_35 - + SequenceFlow_2 SequenceFlow_34 SequenceFlow_0t4yszi - SequenceFlow_0lu7b1v + SequenceFlow_1tt31qu + SequenceFlow_1fccvli SequenceFlow_1qrkdn3 SequenceFlow_1936oc0 - + SequenceFlow_05ujwz8 + SequenceFlow_1x25m7t SequenceFlow_1uqlr6b - + @@ -63,20 +65,22 @@ exceptionUtil.processJavaException(execution)]]> - + + - SequenceFlow_1qoor0l + SequenceFlow_1xujrk5 SequenceFlow_1p4ycii - + SequenceFlow_1936oc0 SequenceFlow_05ujwz8 + SDNCInteractionEnabled2 - + SequenceFlow_08nd69s @@ -92,15 +96,115 @@ ddvam.queryAAIVfModule(execution)]]> def ddvam = new DoDeleteVnfAndModules() ddvam.prepareNextModuleToDelete(execution)]]> - - - + + + SequenceFlow_1p4ycii + SequenceFlow_0xl033m SequenceFlow_0t4yszi +int nextModule = execution.getVariable("DDVAM_nextModule") + execution.setVariable("DDVAM_nextModule", nextModule + 1)]]> + + + SequenceFlow_0lu7b1v + SequenceFlow_1tt31qu + SDNCInteractionEnabled1 + + + + + + + + + + SDNCInteractionEnabled1 + SequenceFlow_0fhhsyo + + + SequenceFlow_0qdn8k4 + SequenceFlow_1fccvli + + + + + + + + + + + + + SequenceFlow_0fhhsyo + SequenceFlow_0qdn8k4 + + + + + + + + + SDNCInteractionEnabled2 + SequenceFlow_001uxa1 + + + + + + + + + + + + + SequenceFlow_001uxa1 + SequenceFlow_1x29mht + + + SequenceFlow_1x29mht + SequenceFlow_1x25m7t + + + + SequenceFlow_1qoor0l + SequenceFlow_1xujrk5 + SequenceFlow_1laeenc + + + + + + + + + + + + + + SequenceFlow_1laeenc + SequenceFlow_0xl033m + + + + + + @@ -123,51 +227,51 @@ int nextModule = execution.getVariable("nextModule") - + - + - + - + - + - + - + - + - - + + - + - - + + - + - + - + - + @@ -177,87 +281,208 @@ int nextModule = execution.getVariable("nextModule") - - - + + + - + - + - + - + - - - - + + + - + - - - + + + - + - - - - + + - + - - + + - + - - + + - + - + - + - + - - - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy b/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy deleted file mode 100644 index a90cf12ecb..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfraTest.groovy +++ /dev/null @@ -1,3055 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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.junit.Assert.* -import static org.mockito.Mockito.* -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetwork -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkRouteTable -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding - -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.ProcessEngineServices -import org.camunda.bpm.engine.RepositoryService -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.camunda.bpm.engine.repository.ProcessDefinition -import org.camunda.bpm.engine.runtime.Execution -import org.junit.Before -import org.junit.Ignore; -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.ArgumentCaptor -import org.mockito.MockitoAnnotations -import org.mockito.runners.MockitoJUnitRunner -import org.openecomp.mso.bpmn.common.scripts.MsoUtils -import org.openecomp.mso.bpmn.core.WorkflowException - -import com.github.tomakehurst.wiremock.client.WireMock -import com.github.tomakehurst.wiremock.junit.WireMockRule - - -@RunWith(MockitoJUnitRunner.class) -class UpdateNetworkInstanceInfraTest { - - @Rule - public WireMockRule wireMockRule = new WireMockRule(28090); - - def utils = new MsoUtils() - - String jsonIncomingRequest = - """{ "requestDetails": { - "modelInfo": { - "modelType": "networkTyp", - "modelId": "modelId", - "modelNameVersionId": "modelNameVersionId", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1" - }, - "cloudConfiguration": { - "lcpCloudRegionId": "RDM2WAGPLCP", - "tenantId": "7dd5365547234ee8937416c65507d266" - }, - "requestInfo": { - "instanceName": "MNS-25180-L-01-dmz_direct_net_1", - "source": "VID", - "callbackUrl": "", - "suppressRollback": true, - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" - }, - "relatedInstanceList": [ - { - "relatedInstance": { - "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", - "modelInfo": { - "modelType": "serviceT", - "modelId": "modelI", - "modelNameVersionId": "modelNameVersionI", - "modelName": "modleNam", - "modelVersion": "1" - } - } - } - ], - "requestParameters": { - "userParams": [ - { - "name": "someUserParam1", - "value": "someValue1" - } - ] - } - }}""" - - String jsonIncomingRequest_Missingname = - """{ "requestDetails": { - "modelInfo": { - "modelType": "networkTyp", - "modelId": "modelId", - "modelNameVersionId": "modelNameVersionId", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1" - }, - "cloudConfiguration": { - "lcpCloudRegionId": "RDM2WAGPLCP", - "tenantId": "7dd5365547234ee8937416c65507d266" - }, - "requestInfo": { - "source": "VID", - "callbackUrl": "", - "suppressRollback": true, - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" - }, - "relatedInstanceList": [ - { - "relatedInstance": { - "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", - "modelInfo": { - "modelType": "serviceT", - "modelId": "modelI", - "modelNameVersionId": "modelNameVersionI", - "modelName": "modleNam", - "modelVersion": "1" - } - } - } - ], - "requestParameters": { - "userParams": [] - } - }}""" - - String jsonIncomingRequest_MissingCloudRegion = - """{ "requestDetails": { - "modelInfo": { - "modelType": "networkTyp", - "modelId": "modelId", - "modelNameVersionId": "modelNameVersionId", - "modelName": "CONTRAIL_EXTERNAL", - "modelVersion": "1" - }, - "cloudConfiguration": { - "tenantId": "7dd5365547234ee8937416c65507d266" - }, - "requestInfo": { - "instanceName": "MNS-25180-L-01-dmz_direct_net_1", - "source": "VID", - "callbackUrl": "", - "suppressRollback": true, - "productFamilyId": "a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb" - }, - "relatedInstanceList": [ - { - "relatedInstance": { - "instanceId": "f70e927b-6087-4974-9ef8-c5e4d5847ca4", - "modelInfo": { - "modelType": "serviceT", - "modelId": "modelI", - "modelNameVersionId": "modelNameVersionI", - "modelName": "modleNam", - "modelVersion": "1" - } - } - } - ], - "requestParameters": { - "userParams": [] - } - }}""" - - - - String expectedNetworkRequestMissingNetworkId = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - - - someValue1 - - -""" - - -String expectedNetworkRequestMissingCloudRegion = -""" - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - PORTAL - - - HSL_direct_net_2 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - e81d842d3e8b45c5a59f57cd76af3aaf - - - 1 - -""" - - // vnfRESTRequest - String networkRESTRequest = -""" - - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - - - 1 - 0 - - - - """ - - String networkInputsMissingName = - """ - - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - e81d842d3e8b45c5a59f57cd76af3aaf - """ - -String networkInputsMissingCloudRegion = -""" - HSL_direct_net_2 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - - e81d842d3e8b45c5a59f57cd76af3aaf -""" - - String expectedUpdateNetworkInstanceInfraRequest = - """ - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - dvs-slcp3-01 - 3008 - - - 1 - 0 - - -""" - - String expectedUpdateNetworkInstanceInfraRequest_Output = - """ - - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - - - MNS-25180-L-01-dmz_direct_net_1 - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - - - 1 - 0 - - -""" - - // expectedNetworkRequest - String expectedNetworkRequest = - """ - - UPDATE - VID - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - -""" - -String expectedNetworkInputs = -""" - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true -""" - - - String NetworkRequest_noPhysicalName = - """ - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 3008 - - - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - - -""" - - String vnfRequestFakeRegion = - """ - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MDTWNJ21 - 7dd5365547234ee8937416c65507d266 - - - 1 - 0 - -""" - - // expectedNetworkRequest - String expectedNetworkRequest_Outputs = - """ - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - UPDATE - PORTAL - - - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - - - MNS-25180-L-01-dmz_direct_net_1 - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - - - 1 - 0 - -""" - - - // expectedNetworkRequest - String networkInputs_404 = - """ - myOwn_Network - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - e81d842d3e8b45c5a59f57cd76af3aaf - """ - - String networkInputs = - """ - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - RDM2WAGPLCP - e81d842d3e8b45c5a59f57cd76af3aaf -""" - - String networkOutputs = - """ - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - """ - - String queryAAIResponse = - """ - - - - - - - - - - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - HSL_direct_net_2 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-delete - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - - -""" - - String queryIdAIIResponse = - """ - - - - - - - - - - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - l3-version - pending-delete - ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - - - - - 414 - 4132176 - - - 415 - 4132176 - - - - inner - ctag-version - - - tenant - https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ - - tenant.tenant-id - 897deadc2b954a6bac6d3c197fb3525e - - - tenant.tenant-name - MSOTest1 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ - - vpn-binding.vpn-id - a290b841-f672-44dd-b9cd-6f8c20d7d8c8 - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest2 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ - - vpn-binding.vpn-id - 24a4b507-853a-4a38-99aa-05fcc54be24d - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest1 - - - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - network-policy - https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg - - network-policy.network-policy-id - cee6d136-e378-4678-a024-2cd15f0ee0cg - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - - - -""" - - String queryIdAIIResponseTestScenario01 = - """ - - 4da55fe4-7a9e-478c-a434-8a98d62265ab - GN_EVPN_direct_net_0_ST1 - CONTRAIL30_BASIC - GN_EVPN_direct - contrail - false - 9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - 1465398611 - pending-delete - networkName - false - true - false - - - cb1a7b47-5428-44c9-89c2-8b17541c3228 - 108.239.40.1 - 108.239.40.0 - 28 - 4 - pending-delete - true - 108.239.40.0 - 108.239.40.0 - 1465398611 - subnetName - - - - e2cc7c14-90f0-4205-840d-b4e07f04e621 - 2606:ae00:2e01:604::1 - 2606:ae00:2e01:604:: - 64 - 6 - pending-delete - true - 2606:ae00:2e01:604:: - 2606:ae00:2e01:604:: - 1465398611 - subnetName - - - - - - 416 - 4132176 - - - - cloud-region - https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/ - - - cloud-region.cloud-region-id - AAIAIC25 - - - cloud-region.cloud-owner - att-aic - - - cloud-region.owner-defined-type - - - - - tenant - https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/4ae1d3446a4c48b2bec44b6cfba06d68/ - - tenant.tenant-id - 4ae1d3446a4c48b2bec44b6cfba06d68 - - - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - AAIAIC25 - - - tenant.tenant-name - Ruchira Contrail 3.0 test - - - - vpn-binding - https://mtanjv9aaas03.aic.cip.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 9a7b327d9-287aa00-82c4b0-100001 - - - vpn-binding.vpn-name - GN_EVPN_direct_net_0_ST1 - - - - route-table-reference - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - -""" - - String queryIdAIIResponseVpnNotPresent = - """ - - - - - - - - - - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-delete - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - subnetName - - - - - - -""" - - String queryNameAIIResponse = - """ - - - - - - - - - - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - pending-delete - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - 107.239.52.1 - 107.239.52.0 - 24 - 4 - pending-delete - true - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - - - """ - - String queryNameAIIResponseVpnNotPresent = - """ - - - - - - - - - - - - - - -""" - - String queryVpnBindingAAIResponse = - """ - - - - - - - - - - - - 9a7b327d9-287aa00-82c4b0-105757 - GN_EVPN_Test - 13979:105757 - - - l3-network - https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/689ec39e-c5fc-4462-8db2-4f760763ad28/ - - l3-network.network-id - 689ec39e-c5fc-4462-8db2-4f760763ad28 - - - - l3-network - https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/1a49396b-19b3-40a4-8792-aa2fbd0f0704/ - - l3-network.network-id - 1a49396b-19b3-40a4-8792-aa2fbd0f0704 - - - - l3-network - https://aai-app-e2e.test.com:8443/aai/v3/network/l3-networks/l3-network/774f3329-3c83-4771-86c7-9e6207cd50fd/ - - l3-network.network-id - 774f3329-3c83-4771-86c7-9e6207cd50fd - - - - - -""" - - String updateDBRequest_Active = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network MNS-25180-L-01-dmz_direct_net_1 already exists. Silent success. - - COMPLETED - 100 - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - - -""" - - String updateDBRequest = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network successfully updated. - - COMPLETED - 100 - <network-id></network-id><network-name></network-names> - - - -""" - - String updateDBRequestError = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Received error from SDN-C: No availability zone available - - FAILED - <network-id></network-id><network-name></network-names> - - - """ - - String updateDBRequestError01 = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Received error unexpectedly from SDN-C. - - FAILED - <network-id></network-id><network-name></network-names> - - - """ - - String updateDBRequest_Outputs = - """ - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - BPMN - Network successfully updated. - - COMPLETED - 100 - <network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id><network-name>MNS-25180-L-01-dmz_direct_net_1</network-names> - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - - -""" - - String updateNetworkRequest = - """ - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - - - CONTRAIL - - networkName - 414,415 - - - true - false - 13979:105757 - 13979:105757 - GN_EVPN_Test - refFQDN1 - refFQDN2 - - true - true - false - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - - messageId_generated - -""" - - - String updateNetworkRequest_noPhysicalName = - """ - RDM2WAGPLCP - 7dd5365547234ee8937416c65507d266 - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - - - CONTRAIL - - networkName - 414,415 - - - true - false - 13979:105757 - 13979:105757 - GN_EVPN_Test - - true - true - false - - true - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - true - true - 10.10.125.1 - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - null - - messageId_generated - -""" - - String updateNetworkResponseREST = - """ - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 - - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - - - - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - - CONTRAIL_EXTERNAL - true - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - - messageId_generated -""" - - String updateRollbackNetworkRequest = - """ - - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - - CONTRAIL_EXTERNAL - true - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - -""" - - String updateNetworkResponse = - """ - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - c4f4e878-cde0-4b15-ae9a-bda857759cea - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - - - - RDM2WAGPLCP - - 1ef47428-cade-45bd-a103-0751e8b2deb0 - - - true - MNS-25180-L-01-dmz_direct_net_1/2c88a3a9-69b9-43a7-ada6-1aca577c3641 - CONTRAIL_EXTERNAL - false - c4f4e878-cde0-4b15-ae9a-bda857759cea - 7dd5365547234ee8937416c65507d266 - -""" - - String updateContrailAAIPayloadRequest = - """ - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - MNS-25180-L-01-dmz_direct_net_1 - CONTRAIL_EXTERNAL - dmz_direct - contrail - c4f4e878-cde0-4b15-ae9a-bda857759cea - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - 0 - l3-version - active - ST_2Bindings_6006/55288ef0-595c-47d3-819e-cf93aaac6326 - default-domain:MSOTest:GN_EVPN_direct_net_0_ST1 - networkName - false - true - false - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - 107.239.52.1 - 107.239.52.0 - 24 - 4 - active - true - subnetName - - - 57e9a1ff-d14f-4071-a828-b19ae98eb2fc - bd8e87c6-f4e2-41b8-b0bc-9596aa00cd73 - 107.239.52.1 - 107.239.52.0 - 24 - 4 - active - true - subnetName - - - - 414 - - - 415 - - - - inner - ctag-version - - - tenant - https://aai-ext1.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/897deadc2b954a6bac6d3c197fb3525e/ - - tenant.tenant-id - 897deadc2b954a6bac6d3c197fb3525e - - - tenant.tenant-name - MSOTest1 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/a290b841-f672-44dd-b9cd-6f8c20d7d8c8/ - - vpn-binding.vpn-id - a290b841-f672-44dd-b9cd-6f8c20d7d8c8 - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest2 - - - - vpn-binding - https://aai-ext1.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/24a4b507-853a-4a38-99aa-05fcc54be24d/ - - vpn-binding.vpn-id - 24a4b507-853a-4a38-99aa-05fcc54be24d - - - vpn-binding.vpn-name - oam_protected_net_6_MTN5_msotest1 - - - - - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/ - - vpn-binding.vpn-id - 85f015d0-2e32-4c30-96d2-87a1a27f8017 - - - - vpn-binding - https://aai-app-e2e.test.com:8443/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/ - - vpn-binding.vpn-id - c980a6ef-3b88-49f0-9751-dbad8608d0a6 - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v8/cloud-infrastructure/tenants/tenant/7dd5365547234ee8937416c65507d266/ - - tenant.tenant-id - 7dd5365547234ee8937416c65507d266 - - - - network-policy - https://aai-app-e2e.test.com:8443/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg - - network-policy.network-policy-id - cee6d136-e378-4678-a024-2cd15f0ee0cg - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN1 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - - route-table-reference - https://aai-app-e2e.test.com:8443/aai/v8/network/route-table-references/route-table-reference/refFQDN2 - - route-table-reference.route-table-reference-id - cee6d136-e378-4678-a024-2cd15f0ee0hi - - - -""" - - String updateContrailAAIResponse = - """ - - - - - - - - -""" - - String updateNetworkErrorResponse = - """ - 680bd458-5ec1-4a16-b77c-509022e53450INTERNAL - 400 Bad Request: The server could not comply with the request since it is either malformed or otherwise incorrect., error.type=StackValidationFailed, error.message=Property error: : resources.network.properties: : Unknown Property network_ipam_refs_data - true - """ - - - String networkException500 = - """soap:VersionMismatch"http://org.openecomp.mso/network", the namespace on the "updateNetworkContrail" element, is not a valid SOAP version.""" - - String aaiResponse = - """ - - - - - - - - - - - - bdc5efe8-404a-409b-85f6-0dcc9eebae30 - HSL_direct_net_2 - CONTRAIL_BASIC - HSL_direct - contrail - 8bbd3edf-b835-4610-96a2-a5cafa029042 - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - active - HSL_direct_net_2/57594a56-1c92-4a38-9caa-641c1fa3d4b6 - - - ea5f2a2c-604f-47ff-a9c5-253ee4f0ef0a - 5a77fdc2-7789-4649-a1b9-6eaf1db1813a - 172.16.34.1 - 172.16.34.0 - 28 - 4 - active - true - - - - - - tenant - https://aai-app-e2e.test.com:8443/aai/v3/cloud-infrastructure/tenants/tenant/e81d842d3e8b45c5a59f57cd76af3aaf/ - - tenant.tenant-id - e81d842d3e8b45c5a59f57cd76af3aaf - - - - - - """ - - String changeAssignSDNCRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - changeassign - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - NetworkActivateRequest - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - -String assignResponse = -""" 006927ca-f5a3-47fd-880c-dfcbcd81a093 200 OK 200006927ca-f5a3-47fd-880c-dfcbcd81a093Ynotsurewecarea9a77d5a-123e-4ca2-9eb9-0b015d2ee0fbGN_EVPN_direct_net_0_ST_noGW8abc633a-810b-4ca5-8b3a-09511d13a2ce """ - - String sdncRollbackRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - rollback - network-topology-operation - sdncCallback - - - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - NetworkActivateRequest - VID - - - - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - MSO-dev-service-type - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - MSO_1610_dev - - - 8abc633a-810b-4ca5-8b3a-09511d13a2ce - CONTRAIL_EXTERNAL - MNS-25180-L-01-dmz_direct_net_1 - 7dd5365547234ee8937416c65507d266 - RDM2WAGPLCP - - -""" - - String sdncAdapterWorkflowResponse = - """ - - - 745b1b50-e39e-4685-9cc8-c71f0bde8bf0 - 200 - OK - - <output xmlns="org:openecomp:sdnctl:vnf"><svc-request-id>00703dc8-71ff-442d-a4a8-3adc5beef6a9</svc-request-id><response-code>200</response-code><ack-final-indicator>Y</ack-final-indicator><network-information><network-id>49c86598-f766-46f8-84f8-8d1c1b10f9b4</network-id></network-information><service-information><service-type>a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb</service-type><service-instance-id>MNS-25180-L-01-dmz_direct_net_1</service-instance-id><subscriber-name>notsurewecare</subscriber-name></service-information></output> - -""" - - - String sdncAdapterWorkflowResponse_Error = - """ - - - - 400 - Error writing to l3-netework - Y - c79240d8-34b5-4853-af69-2021928dba00 - - - -""" - - String expected_sdncAdapterWorkflowResponse_Error = - """ - - - - 400 - Error writing to l3-netework - Y - c79240d8-34b5-4853-af69-2021928dba00 - - - -""" - - String sdncAdapterWorkflowFormattedResponse = - """ - - - 00703dc8-71ff-442d-a4a8-3adc5beef6a9 - 200 - Y - - 49c86598-f766-46f8-84f8-8d1c1b10f9b4 - - - a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb - f70e927b-6087-4974-9ef8-c5e4d5847ca4 - notsurewecare - - - -""" - - String falloutHandlerRequest = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - PORTAL - - - Received error from SDN-C: No availability zone available. - 5300 - - """ - - String falloutHandlerRequestObject = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - VID - - - Received error from SDN-C: No availability zone available - 7000 - - """ - - - String falloutHandlerRequest_Scenario01 = - """ - - b69c9054-da09-4a2c-adf5-51042b62bfac - UPDATE - VID - - - Unexpected Response from AAI - 400 - 7020 - - """ - - String completeMsoProcessRequest = - """ - - 88f65519-9a38-4c4b-8445-9eb4a5a5af56 - UPDATE - PORTAL - - BPMN Network action: UPDATE -""" - -// - - - - - - - - - - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - - } - - public void initializeVariables (Execution mockExecution) { - - verify(mockExecution).setVariable("UPDNETI_messageId", "") - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "") - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", "") - verify(mockExecution).setVariable("UPDNETI_networkRequest", "") - verify(mockExecution).setVariable("UPDNETI_networkInputs", "") - verify(mockExecution).setVariable("UPDNETI_networkOutputs", "") - verify(mockExecution).setVariable("UPDNETI_requestId", "") - verify(mockExecution).setVariable("UPDNETI_source", "") - verify(mockExecution).setVariable("UPDNETI_networkId", "") - - verify(mockExecution).setVariable("UPDNETI_CompleteMsoProcessRequest", "") - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", "") - verify(mockExecution).setVariable("UPDNETI_isSilentSuccess", false) - verify(mockExecution).setVariable("UPDNETI_isPONR", false) - - // AAI query Cloud Region - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest","") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionReturnCode","") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionResponse","") - verify(mockExecution).setVariable("UPDNETI_cloudRegionPo","") - verify(mockExecution).setVariable("UPDNETI_cloudRegionSdnc","") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", false) - - // AAI query Id - verify(mockExecution).setVariable("UPDNETI_queryIdAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryIdAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiIdReturnCode", "") - - // AAI query vpn binding - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_vpnBindings", null) - verify(mockExecution).setVariable("UPDNETI_vpnCount", 0) - verify(mockExecution).setVariable("UPDNETI_routeCollection", "") - - // AAI query network policy - verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_networkPolicyUriList", null) - verify(mockExecution).setVariable("UPDNETI_networkPolicyCount", 0) - verify(mockExecution).setVariable("UPDNETI_networkCollection", "") - - // AAI query route table reference - verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_networkTableRefUriList", null) - verify(mockExecution).setVariable("UPDNETI_networkTableRefCount", 0) - verify(mockExecution).setVariable("UPDNETI_tableRefCollection", "") - - - // AAI requery Id - verify(mockExecution).setVariable("UPDNETI_requeryIdAAIRequest","") - verify(mockExecution).setVariable("UPDNETI_requeryIdAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiRequeryIdReturnCode", "") - - // AAI update contrail - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIUrlRequest","") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIPayloadRequest","") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIResponse", "") - verify(mockExecution).setVariable("UPDNETI_aaiUpdateContrailReturnCode", "") - - verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", "") - verify(mockExecution).setVariable("UPDNETI_updateNetworkResponse", "") - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkRequest", "") - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkResponse", "") - verify(mockExecution).setVariable("UPDNETI_networkReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_isNetworkRollbackNeeded", false) - - verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCRequest", "") - verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCResponse", "") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", "") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCResponse", "") - verify(mockExecution).setVariable("UPDNETI_sdncReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCReturnCode", "") - verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", false) - verify(mockExecution).setVariable("UPDNETI_sdncResponseSuccess", false) - - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", "") - verify(mockExecution).setVariable("UPDNETI_updateDBResponse", "") - verify(mockExecution).setVariable("UPDNETI_dbReturnCode", "") - - verify(mockExecution).setVariable("UPDNETI_isVnfBindingPresent", false) - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_serviceInstanceId", "") - verify(mockExecution).setVariable("GENGS_type", "service-instance") // Setting for Generic Sub Flow use - - - } - - @Test - //@Ignore - public void preProcessRequest_NetworkRequest() { - - println "************ preProcessRequest_Payload ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) - when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) - when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("vnfId")).thenReturn("") - when(mockExecution.getVariable("volumeGroupId")).thenReturn("") - when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - when(mockExecution.getVariable("serviceType")).thenReturn("MOG") - when(mockExecution.getVariable("networkType")).thenReturn("modelName") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).getVariable("isDebugLogEnabled") - verify(mockExecution).setVariable("prefix", "UPDNETI_") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest) - //verify(mockExecution).setVariable("UPDNETI_networkRequest", expectedNetworkRequest) - //verify(mockExecution).setVariable("UPDNETI_networkInputs", expectedNetworkInputs) - //verify(mockExecution, atLeast(3)).setVariable("UPDNETI_networkOutputs", "") - - //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("UPDNETI_source", "VID") - //verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution, atLeast(1)).setVariable("GENGS_type", "service-instance") - - } - - - @Test - //@Ignore - public void preProcessRequest_MissingNetworkId() { - - println "************ preProcessRequest_MissingName() ************* " - - WorkflowException missingNameWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "Variable 'network-id' value/element is missing.") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) - when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) - when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("vnfId")).thenReturn("") - when(mockExecution.getVariable("volumeGroupId")).thenReturn("") - //when(mockExecution.getVariable("networkId")).thenReturn("49c86598-f766-46f8-84f8-8d1c1b10f9b4") - when(mockExecution.getVariable("serviceType")).thenReturn("MOG") - when(mockExecution.getVariable("networkType")).thenReturn("modelName") - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest) - - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - - //verify variable initialization - initializeVariables(mockExecution) - - // Authentications - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest) - //verify(mockExecution, atLeast(1)).setVariable("UPDNETI_networkOutputs", networkOutputs) - //verify(mockExecution).setVariable("UPDNETI_networkRequest", expectedNetworkRequestMissingNetworkId) - //verify(mockExecution).setVariable("UPDNETI_networkInputs", expectedNetworkInputs) - - //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("UPDNETI_source", "VID") - //verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - - verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingNameWorkflowException)) - - } - - @Test - //@Ignore - public void preProcessRequest_MissingCloudRegion() { - - println "************ preProcessRequest_MissingCloudRegion() ************* " - - WorkflowException missingCloudRegionWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "requestDetails has missing 'aic-cloud-region' value/element.") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("isBaseVfModule")).thenReturn(true) - when(mockExecution.getVariable("recipeTimeout")).thenReturn(0) - when(mockExecution.getVariable("requestAction")).thenReturn("UPDATE") - when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("vnfId")).thenReturn("") - when(mockExecution.getVariable("volumeGroupId")).thenReturn("") - when(mockExecution.getVariable("networkId")).thenReturn("networkId") - when(mockExecution.getVariable("serviceType")).thenReturn("MOG") - when(mockExecution.getVariable("networkType")).thenReturn("modelName") - - when(mockExecution.getVariable("bpmnRequest")).thenReturn(jsonIncomingRequest_MissingCloudRegion) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_adapters_po_auth")).thenReturn("3141634BF7E070AA289CF2892C986C0B") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_rollback")).thenReturn("true") - - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.preProcessRequest(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).getVariable("isDebugLogEnabled") - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - - //verify variable initialization - initializeVariables(mockExecution) - - verify(mockExecution).setVariable("UPDNETI_messageId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - // Authentications - verify(mockExecution).setVariable("BasicAuthHeaderValuePO", "Basic cGFzc3dvcmQ=") - verify(mockExecution).setVariable("BasicAuthHeaderValueSDNC", "Basic cGFzc3dvcmQ=") - - verify(mockExecution).setVariable("UPDNETI_UpdateNetworkInstanceInfraJsonRequest", jsonIncomingRequest_MissingCloudRegion) - //verify(mockExecution).setVariable("UPDNETI_networkRequest", "") - //verify(mockExecution).setVariable("UPDNETI_networkInputs", "") - //verify(mockExecution, atLeast(1)).setVariable("UPDNETI_networkOutputs", "") - - //verify(mockExecution).setVariable("UPDNETI_requestId", "88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //verify(mockExecution).setVariable("UPDNETI_source", "VID") - - verify(mockExecution).setVariable(eq("WorkflowException"), refEq(missingCloudRegionWorkflowException)) - - } - - @Test - //@Ignore - public void sendSyncResponse() { - - println "************ sendSyncResponse ************* " - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) - when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - //when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.sendSyncResponse(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UpdateNetworkInstanceInfraResponseCode", "202") - - - } - - @Test - //@Ignore - public void sendSyncError() { - - println "************ sendSyncError ************* " - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("isAsyncProcess")).thenReturn(true) - when(mockExecution.getVariable("mso-request-id")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - //when(mockExecution.getVariable("serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.sendSyncError(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UpdateNetworkInstanceInfraResponseCode", "500") - - } - - - @Test - //@Ignore - public void prepareDBRequest() { - - println "************ prepareDBRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareDBRequest(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequest) - - } - - @Test - //@Ignore - public void prepareDBRequestErro_ExceptionObject() { - - println "************ prepareDBRequest ************* " - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 500, "Received error from SDN-C: No availability zone available") - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareDBRequestError(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequestError) - - } - - @Test - //@Ignore - public void prepareDBRequest_Outputs() { - - println "************ prepareDBRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkOutputs")).thenReturn(networkOutputs) - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_orchestrationStatus")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_mso_adapters_db_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareDBRequest(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateDBRequest", updateDBRequest_Outputs) - - } - - @Test - //@Ignore - public void prepareUpdateNetworkRequest() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - //when(mockExecution.getVariable("UPDNETI_queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable("UPDNETI_routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable("UPDNETI_networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable("UPDNETI_tableRefCollection")).thenReturn("refFQDN1refFQDN2") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_rollbackEnabled")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - - verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", updateNetworkRequest) - - } - - - @Test - //@Ignore - public void prepareUpdateNetworkRequest_NoPhysicalname() { - - println "************ prepareNetworkRequest ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(NetworkRequest_noPhysicalName) - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_cloudRegionPo")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("messageId_generated") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - //when(mockExecution.getVariable("UPDNETI_queryVpnBindingAAIResponse")).thenReturn(queryVpnBindingAAIResponse) - when(mockExecution.getVariable("UPDNETI_routeCollection")).thenReturn("13979:10575713979:105757") - when(mockExecution.getVariable("UPDNETI_networkCollection")).thenReturn("GN_EVPN_Test") - when(mockExecution.getVariable("UPDNETI_tableRefCollection")).thenReturn("") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - //when(mockExecution.getVariable("URN_?????")).thenReturn("") // notificationUrl, //TODO - is this coming from URN? What variable/value to use? - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_rollbackEnabled")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareUpdateNetworkRequest(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - - verify(mockExecution).setVariable("UPDNETI_updateNetworkRequest", updateNetworkRequest_noPhysicalName) - - } - - @Test - //@Ignore - public void prepareSDNCRequest() { - - println "************ prepareSDNCRequest ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:28090/SDNCAdapterCallback") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") - - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareSDNCRequest(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_changeAssignSDNCRequest", changeAssignSDNCRequest) - - } - - @Test - //@Ignore - public void prepareSDNCRollbackRequest() { - - println "************ prepareSDNCRollbackRequest ************* " - - - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_cloudRegionSdnc")).thenReturn("RDM2WAGPLCP") - when(mockExecution.getVariable("UPDNETI_serviceInstanceId")).thenReturn("f70e927b-6087-4974-9ef8-c5e4d5847ca4") - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(assignResponse) - when(mockExecution.getVariable("mso-request-id")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("URN_mso_workflow_sdncadapter_callback")).thenReturn("http://localhost:28090/SDNCAdapterCallback") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("GENGSI_siResourceLink")).thenReturn("https://aai-int1.test.com:8443/aai/v8/business/customers/customer/MSO_1610_dev/service-subscriptions/service-subscription/MSO-dev-service-type/service-instances/service-instance/6d4eb22a-82f1-4257-9f80-4176262cfe69/") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.prepareSDNCRollbackRequest(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", sdncRollbackRequest) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkId_200() { - - println "************ callRESTQueryAAINetworkId ************* " - - WireMock.reset(); - - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_networkRequest")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryIdAAIRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") - verify(mockExecution).setVariable("UPDNETI_aaiIdReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion30_200() { - - println "************ callRESTQueryAAICloudRegion30_200 ************* " - - WireMock.reset(); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion25_200() { - - println "************ callRESTQueryAAICloudRegion25_200 ************* " - - WireMock.reset(); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(expectedNetworkRequest) - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/RDM2WAGPLCP") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_queryCloudRegionReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAICloudRegion_NotFound() { - - println "************ callRESTQueryAAICloudRegionFake ************* " - - WireMock.reset(); - MockGetCloudRegion("MDTWNJ21", 404, "") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("UPDNETI_networkInputs")).thenReturn(vnfRequestFakeRegion) - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_cloud_region_uri")).thenReturn("/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAICloudRegion(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_queryCloudRegionRequest", "http://localhost:28090/aai/v8/cloud-infrastructure/cloud-regions/cloud-region/att-aic/MDTWNJ21") - verify(mockExecution, atLeast(1)).setVariable("UPDNETI_queryCloudRegionReturnCode", "404") - verify(mockExecution).setVariable("UPDNETI_cloudRegionPo", "MDTWNJ21") - verify(mockExecution).setVariable("UPDNETI_cloudRegionSdnc", "AAIAIC25") - verify(mockExecution).setVariable("UPDNETI_isCloudRegionGood", true) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) // v6 - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") -// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_vpn-binding_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 2) - verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_TestScenario01_200() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponseTestScenario01) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") -// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_vpn-binding_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 1) - verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_200_URN_Uri() { - - println "************ callRESTQueryAAINetworkVpnBinding_200 ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_vpn_binding_uri")).thenReturn("/aai/v8/network/vpn-bindings/vpn-binding") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 2) - verify(mockExecution).setVariable("UPDNETI_vpnBindings", ['/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017/', '/aai/v8/network/vpn-bindings/vpn-binding/c980a6ef-3b88-49f0-9751-dbad8608d0a6/']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIRequest", "http://localhost:28090/aai/v8/network/vpn-bindings/vpn-binding/85f015d0-2e32-4c30-96d2-87a1a27f8017") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkVpnBinding_NotPresent() { - - println "************ callRESTQueryAAINetworkVpnBinding_NotPresent ************* " - - WireMock.reset(); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponseVpnNotPresent) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkVpnBinding(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryVpnBindingReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_vpnCount", 0) - verify(mockExecution).setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiVpnResponseStub) - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkTableRef_200() { - - println "************ callRESTQueryAAINetworkTableRef_200 ************* " - - WireMock.reset(); - MockGetNetworkRouteTable("refFQDN1", "CreateNetworkV2/createNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200) - MockGetNetworkRouteTable("refFQDN2", "CreateNetworkV2/createNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_route_table_reference_uri")).thenReturn("/aai/v8/network/route-table-references/route-table-reference") -// when(mockExecution.getVariable("URN_mso_workflow_CreateNetworkInstanceInfra_aai_network_table_reference_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkTableRef(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_networkTableRefCount", 2) - verify(mockExecution).setVariable("UPDNETI_networkTableRefUriList", ['/aai/v8/network/route-table-references/route-table-reference/refFQDN1','/aai/v8/network/route-table-references/route-table-reference/refFQDN2']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryNetworkTableRefAAIRequest", "http://localhost:28090/aai/v8/network/route-table-references/route-table-reference/refFQDN1") - verify(mockExecution, atLeast(2)).setVariable("UPDNETI_aaiQqueryNetworkTableRefReturnCode", "200") - - } - - @Test - //@Ignore - public void callRESTQueryAAINetworkPolicy_200() { - - println "************ callRESTQueryAAINetworkPolicy_200 ************* " - - WireMock.reset(); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_network_policy_uri")).thenReturn("/aai/v8/network/network-policies/network-policy") -// when(mockExecution.getVariable("URN_mso_workflow_UpdateNetworkInstanceInfra_aai_network_policy_uri")).thenReturn("") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTQueryAAINetworkPolicy(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_networkPolicyCount", 1) - verify(mockExecution).setVariable("UPDNETI_networkPolicyUriList", ['/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg']) - // the last vpnBinding value is saved. - verify(mockExecution).setVariable("UPDNETI_queryNetworkPolicyAAIRequest", "http://localhost:28090/aai/v8/network/network-policies/network-policy/cee6d136-e378-4678-a024-2cd15f0ee0cg") - verify(mockExecution).setVariable("UPDNETI_aaiQqueryNetworkPolicyReturnCode", "200") - - } - - - @Test - //@Ignore - public void callRESTReQueryAAINetworkId_200() { - - println "************ callRESTReQueryAAINetworkId ************* " - - WireMock.reset(); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200) - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTReQueryAAINetworkId(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_requeryIdAAIRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") - verify(mockExecution).setVariable("UPDNETI_aaiRequeryIdReturnCode", "200") - - } - - - @Test - @Ignore - public void callRESTUpdateContrailAAINetworkREST_200() { - - println "************ callRESTUpdateContrailAAINetwork ************* " - - WireMock.reset(); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml") - - ExecutionEntity mockExecution = setupMock() - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowFormattedResponse) - when(mockExecution.getVariable("UPDNETI_requeryIdAAIResponse")).thenReturn(queryIdAIIResponse) - when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable("UPDNETI_messageId")).thenReturn("e8ebf6a0-f8ea-4dc0-8b99-fe98a87722d6") - when(mockExecution.getVariable("URN_aai_endpoint")).thenReturn("http://localhost:28090") - when(mockExecution.getVariable("URN_mso_workflow_global_default_aai_version")).thenReturn("8") - when(mockExecution.getVariable("URN_mso_workflow_default_aai_v8_l3_network_uri")).thenReturn("/aai/v8/network/l3-networks/l3-network") - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("URN_aai_auth")).thenReturn("757A94191D685FD2092AC1490730A4FC") - when(mockExecution.getVariable("URN_mso_msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - // preProcessRequest(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.callRESTUpdateContrailAAINetwork(mockExecution) - - // Capture the arguments to setVariable - ArgumentCaptor captor1 = ArgumentCaptor.forClass(String.class); - ArgumentCaptor captor2 = ArgumentCaptor.forClass(String.class); - - verify(mockExecution, times(6)).setVariable(captor1.capture(), captor2.capture()) - List arg2List = captor2.getAllValues() - String payloadResponseActual = arg2List.get(4) - - assertEquals(updateContrailAAIResponse.replaceAll("\\s+", ""), payloadResponseActual.replaceAll("\\s+", "")) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIUrlRequest", "http://localhost:28090/aai/v8/network/l3-networks/l3-network/49c86598-f766-46f8-84f8-8d1c1b10f9b4") - verify(mockExecution).setVariable("UPDNETI_updateContrailAAIPayloadRequest", updateContrailAAIPayloadRequest) - verify(mockExecution).setVariable("UPDNETI_aaiUpdateContrailReturnCode", "200") - verify(mockExecution).setVariable("UPDNETI_isPONR", true) - - } - - - - @Test - //@Ignore - public void validateUpdateNetworkResponseREST() { - - println "************ validateNetworkResponse ************* " - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(updateNetworkResponseREST) - when(mockExecution.getVariable("UPDNETI_networkReturnCode")).thenReturn('200') - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateUpdateNetworkResponse(mockExecution) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_updateNetworkResponse", updateNetworkResponseREST) - verify(mockExecution).setVariable("UPDNETI_isNetworkRollbackNeeded", true) - verify(mockExecution).setVariable("UPDNETI_rollbackNetworkRequest", updateRollbackNetworkRequest) - - } - - @Test - //@Ignore - public void validateUpdateNetworkResponseREST_Error() { - - println "************ validateNetworkResponse ************* " - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "Received error from Network Adapter: JBWEB000065: HTTP Status 500.") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_updateNetworkResponse")).thenReturn(networkException500) - when(mockExecution.getVariable("UPDNETI_networkReturnCode")).thenReturn('500') - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.validateUpdateNetworkResponse(mockExecution) - } catch (Exception ex) { - println " Test End - Handle catch-throw BpmnError()! " - } - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(workflowException, any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateSDNCResponse() { - - println "************ validateSDNCResponse ************* " - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse) - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_isResponseGood")).thenReturn(true) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.validateSDNCResponse(mockExecution) - verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", true) - verify(mockExecution).setVariable("UPDNETI_rollbackSDNCRequest", "") - - } catch (Exception ex) { - println " Graceful Exit - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - //verify(mockExecution).setVariable("UPDNETI_isSdncRollbackNeeded", true) - - } - - @Test - //@Ignore - public void validateSDNCResponse_Error() { - - println "************ validateSDNCResponse ************* " - //ExecutionEntity mockExecution = mock(ExecutionEntity.class) - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_changeAssignSDNCResponse")).thenReturn(sdncAdapterWorkflowResponse_Error) - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - when(mockExecution.getVariable("SDNCA_SuccessIndicator")).thenReturn(false) - when(mockExecution.getVariable("UPDNETI_sdncReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_isResponseGood")).thenReturn(true) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - try { - UpdateNetworkInstanceInfra.validateSDNCResponse(mockExecution) - } catch (Exception ex) { - println " Graceful Exit! - " + ex.getMessage() - } - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - // verify set prefix = "UPDNETI_" - //verify(mockExecution).setVariable("UPDNETI_sdncResponseSuccess", false) - - } - - - - @Test - //@Ignore - public void postProcessResponse() { - - println "************ postProcessResponse ************* " - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("PORTAL") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("88f65519-9a38-4c4b-8445-9eb4a5a5af56") - when(mockExecution.getVariable("UPDNETI_dbReturnCode")).thenReturn("200") - - // postProcessResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.postProcessResponse(mockExecution) - - // check the sequence of variable invocation - //MockitoDebuggerImpl preDebugger = new MockitoDebuggerImpl() - //preDebugger.printInvocations(mockExecution) - - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", true) - verify(mockExecution).setVariable("UPDNETI_CompleteMsoProcessRequest", completeMsoProcessRequest) - - } - - @Test - //@Ignore - public void validateRollbackResponses_Good() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SNDC rollback completed.") - - println "************ validateRollbackResponses_Good() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_Failed() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SDNC rollback failed. ") - - println "************ validateRollbackResponses_Failed() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("404") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("BadResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("500") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("BadResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_NetworkFailed() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowExceptionFailed = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SNDC rollback completed.") - - println "************ validateRollbackResponses_NetworkFailed() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("404") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("BadResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowExceptionFailed , any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_SdncFailed() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404.") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "AAI Update Contrail Failed. Error 404. + PO Network rollback is not supported for Update. Submit another Update to restore/rollback. + SDNC rollback failed. ") - - println "************ validateRollbackResponses_SdncFailed() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(true) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("400") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("WorkflowException", refEq(expectedWorkflowException , any(WorkflowException.class))) - - } - - @Test - //@Ignore - public void validateRollbackResponses_NoRollbacks() { - - WorkflowException workflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, " AAI Update Contrail Failed. Error 404") - WorkflowException expectedWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 2500, " AAI Update Contrail Failed. Error 404") - - println "************ validateRollbackResponses_NoRollbacks() ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("prefix")).thenReturn("UPDNETI_") - - when(mockExecution.getVariable("UPDNETI_isNetworkRollbackNeeded")).thenReturn(false) - when(mockExecution.getVariable("UPDNETI_rollbackNetworkReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackNetworkResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("UPDNETI_isSdncRollbackNeeded")).thenReturn(false) - when(mockExecution.getVariable("UPDNETI_rollbackSDNCReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_rollbackSDNCResponse")).thenReturn("GoodResponse") - when(mockExecution.getVariable("WorkflowException")).thenReturn(workflowException) - - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.validateRollbackResponses(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - //verify(mockExecution, atLeast(1)).setVariable("WorkflowException", any(expectedWorkflowException)) - verify(mockExecution, atLeast(1)).setVariable("WorkflowException", refEq(expectedWorkflowException, any(WorkflowException.class))) - - } - - - @Test - //@Ignore - public void buildErrorResponse() { - - println "************ buildErrorResponse ************* " - - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 5300, "Received error from SDN-C: No availability zone available.") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("PORTAL") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - - // buildErrorResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - @Test - //@Ignore - public void buildErrorResponse_WorkflowExceptionObject() { - - println "************ buildErrorResponse ************* " - - WorkflowException sndcWorkflowException = new WorkflowException("UpdateNetworkInstanceInfra", 7000, "Received error from SDN-C: No availability zone available") - - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - when(mockExecution.getVariable("WorkflowException")).thenReturn(sndcWorkflowException) - - // buildErrorResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequestObject) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - @Test - //@Ignore - public void buildErrorResponse_Scenario01() { - - WorkflowException aaiWorkflowException_Secnario01 = new WorkflowException("UpdateNetworkInstanceInfra", 7020, "Unexpected Response from AAI - 400") - - println "************ buildErrorResponse ************* " - ExecutionEntity mockExecution = setupMock() - // Initialize prerequisite variables - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("UPDNETI_requestId")).thenReturn("b69c9054-da09-4a2c-adf5-51042b62bfac") - when(mockExecution.getVariable("UPDNETI_source")).thenReturn("VID") - when(mockExecution.getVariable("WorkflowException")).thenReturn(aaiWorkflowException_Secnario01) - when(mockExecution.getVariable("UPDNETI_dbReturnCode")).thenReturn("200") - when(mockExecution.getVariable("UPDNETI_updateDBResponse")).thenReturn("") - - when(mockExecution.getVariable("UPDNETI_aaiRequeryIdReturnCode")).thenReturn("400") - - // buildErrorResponse(Execution execution) - UpdateNetworkInstanceInfra UpdateNetworkInstanceInfra = new UpdateNetworkInstanceInfra() - UpdateNetworkInstanceInfra.buildErrorResponse(mockExecution) - - // verify set prefix = "UPDNETI_" - verify(mockExecution, atLeast(1)).setVariable("prefix", "UPDNETI_") - verify(mockExecution).setVariable("UPDNETI_Success", false) - verify(mockExecution).setVariable("UPDNETI_FalloutHandlerRequest", falloutHandlerRequest_Scenario01) - - //MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - } - - - private ExecutionEntity setupMock() { - - ProcessDefinition mockProcessDefinition = mock(ProcessDefinition.class) - when(mockProcessDefinition.getKey()).thenReturn("UpdateNetworkInstanceInfra") - RepositoryService mockRepositoryService = mock(RepositoryService.class) - when(mockRepositoryService.getProcessDefinition()).thenReturn(mockProcessDefinition) - when(mockRepositoryService.getProcessDefinition().getKey()).thenReturn("UpdateNetworkInstanceInfra") - when(mockRepositoryService.getProcessDefinition().getId()).thenReturn("100") - ProcessEngineServices mockProcessEngineServices = mock(ProcessEngineServices.class) - when(mockProcessEngineServices.getRepositoryService()).thenReturn(mockRepositoryService) - - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - // Initialize prerequisite variables - - when(mockExecution.getId()).thenReturn("100") - when(mockExecution.getProcessDefinitionId()).thenReturn("UpdateNetworkInstanceInfra") - when(mockExecution.getProcessInstanceId()).thenReturn("UpdateNetworkInstanceInfra") - when(mockExecution.getProcessEngineServices()).thenReturn(mockProcessEngineServices) - when(mockExecution.getProcessEngineServices().getRepositoryService().getProcessDefinition(mockExecution.getProcessDefinitionId())).thenReturn(mockProcessDefinition) - - return mockExecution - } - - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java index 4f987f0d48..dd7497c279 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/CreateVfModuleInfraTest.java @@ -20,26 +20,18 @@ package org.openecomp.mso.bpmn.infrastructure; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithDepth; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfByIdWithPriority; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicyfqdn; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchGenericVnf; import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPatchVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutGenericVnf; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutVfModuleIdNoResponse; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockVNFPost; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockAAIVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockSDNCAdapterVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockVNFAdapterRestVfModule; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockDBUpdateVfModule; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.UUID; - +import org.junit.Ignore; import org.camunda.bpm.engine.test.Deployment; import org.junit.Test; import org.openecomp.mso.bpmn.common.WorkflowTest; @@ -66,7 +58,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { /** - * Sunny day VID scenario. + * Sunny day VID scenario with preloads. * * @throws Exception */ @@ -74,7 +66,9 @@ public class CreateVfModuleInfraTest extends WorkflowTest { @Deployment(resources = { "process/CreateVfModuleInfra.bpmn", "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/SDNCAdapterV1.bpmn", + "subprocess/GenericNotificationService.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", @@ -84,28 +78,80 @@ public class CreateVfModuleInfraTest extends WorkflowTest { "subprocess/CompleteMsoProcess.bpmn", "subprocess/FalloutHandler.bpmn" }) - public void sunnyDayVID() throws Exception { + public void sunnyDayVIDWithPreloads() throws Exception { logStart(); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); - MockGetGenericVnfById("skask", "VfModularity/GenericVnf.xml", 200); - MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); - MockPutNetwork(".*", "VfModularity/AddNetworkPolicy_AAIResponse_Success.xml", 200); - MockPutGenericVnf("skask"); - mockVNFPost("", 202, "skask"); - mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + MockAAIVfModule(); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); String businessKey = UUID.randomUUID().toString(); String createVfModuleRequest = FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json"); - Map variables = setupVariablesSunnyDayVID(); + Map variables = setupVariablesSunnyDayVID(); + + TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleInfra", + "v1", businessKey, createVfModuleRequest, variables); + + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectSDNCCallbacks(callbacks, "assign, query"); + injectVNFRestCallbacks(callbacks, "vnfCreate"); + injectSDNCCallbacks(callbacks, "activate"); + + // TODO add appropriate assertions + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "CreateVfModuleSuccessIndicator", true); + + logEnd(); + } + + /** + * Sunny day VID scenario with no preloads. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "process/CreateVfModuleInfra.bpmn", + "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", + "subprocess/SDNCAdapterV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/ConfirmVolumeGroupTenant.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/ConfirmVolumeGroupName.bpmn", + "subprocess/CreateAAIVfModule.bpmn", + "subprocess/UpdateAAIVfModule.bpmn", + "subprocess/UpdateAAIGenericVnf.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void sunnyDayVIDNoPreloads() throws Exception { + + logStart(); + + MockAAIVfModule(); + MockPatchGenericVnf("skask"); + MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); + + String businessKey = UUID.randomUUID().toString(); + String createVfModuleRequest = + FileUtil.readResourceFile("__files/CreateVfModule_VID_request_noPreloads.json"); + + Map variables = setupVariablesSunnyDayVID(); TestAsyncResponse asyncResponse = invokeAsyncProcess("CreateVfModuleInfra", "v1", businessKey, createVfModuleRequest, variables); @@ -131,7 +177,7 @@ public class CreateVfModuleInfraTest extends WorkflowTest { private Map setupVariablesSunnyDayVID() { Map variables = new HashMap(); //try { - // variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); + //variables.put("bpmnRequest", FileUtil.readResourceFile("__files/CreateVfModule_VID_request.json")); //} //catch (Exception e) { @@ -159,39 +205,35 @@ public class CreateVfModuleInfraTest extends WorkflowTest { * @throws Exception */ @Test + @Ignore @Deployment(resources = { "process/CreateVfModuleInfra.bpmn", "subprocess/DoCreateVfModule.bpmn", + "subprocess/GenericGetVnf.bpmn", "subprocess/SDNCAdapterV1.bpmn", "subprocess/VnfAdapterRestV1.bpmn", "subprocess/ConfirmVolumeGroupTenant.bpmn", "subprocess/ConfirmVolumeGroupName.bpmn", "subprocess/CreateAAIVfModule.bpmn", "subprocess/CreateAAIVfModuleVolumeGroup.bpmn", + "subprocess/GenericNotificationService.bpmn", "subprocess/UpdateAAIVfModule.bpmn", "subprocess/UpdateAAIGenericVnf.bpmn", "subprocess/CompleteMsoProcess.bpmn", "subprocess/FalloutHandler.bpmn" }) + public void sunnyDayVIDWithVolumeGroupAttach() throws Exception { logStart(); - MockGetVolumeGroupById("AAIAIC25", "78987", "VfModularity/VolumeGroup.xml"); - MockGetGenericVnfByIdWithDepth("skask", 1, "VfModularity/GenericVnf.xml"); - MockGetCloudRegion("MDTWNJ21", 200, "CreateNetworkV2/cloudRegion30_AAIResponse_Success.xml"); - MockGetVolumeGroupById("RDM2WAGPLCP", "78987", "DeleteVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockPutVfModuleIdNoResponse("skask", "PCRF", ".*"); - mockVNFPost("", 202, "skask"); - MockGetNetworkPolicyfqdn(".*", "VfModularity/QueryNetworkPolicy_AAIResponse_Success.xml", 200); - MockPutGenericVnf("skask"); - MockGetGenericVnfByIdWithPriority("skask", ".*", 200, "VfModularity/VfModule-new.xml", 5); - mockSDNCAdapter("/SDNCAdapter", "vnf-type>STMTN", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 200, "VfModularity/StandardSDNCSynchResponse.xml"); - mockVNFPost("", 202, "skask"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + MockAAIVfModule(); MockPatchGenericVnf("skask"); MockPatchVfModuleId("skask", ".*"); + MockSDNCAdapterVfModule(); + MockVNFAdapterRestVfModule(); + MockDBUpdateVfModule(); String businessKey = UUID.randomUUID().toString(); String createVfModuleRequest = diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java deleted file mode 100644 index 9ef4c94cce..0000000000 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateNetworkInstanceInfraTest.java +++ /dev/null @@ -1,840 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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; - -import static org.junit.Assert.assertEquals; -import static org.openecomp.mso.bpmn.common.BPMNUtil.executeAsyncWorkflow; -import static org.openecomp.mso.bpmn.common.BPMNUtil.getVariable; -import static org.openecomp.mso.bpmn.common.BPMNUtil.waitForWorkflowToFinish; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetCloudRegion; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkPolicy; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkRouteTable; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetNetworkVpnBinding; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockNodeQueryServiceInstanceById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockPutNetwork; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseNetworkAdapter.MockPutNetworkAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapter; -import static org.openecomp.mso.bpmn.mock.StubResponseSDNCAdapter.mockSDNCAdapterTopology; - -import java.util.HashMap; -import java.util.Map; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Assert; -import org.junit.Rule; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.BPMNUtil; -import org.openecomp.mso.bpmn.common.SDNCAdapterCallbackRule; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.WorkflowTestTransformer; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.mock.SDNCAdapterNetworkTopologyMockTransformer; - -import com.github.tomakehurst.wiremock.extension.ResponseTransformer; - -/** - * Unit test cases for UpdateNetworkInstanceInfra.bpmn - * - */ -public class UpdateNetworkInstanceInfraTest extends WorkflowTest { - @WorkflowTestTransformer - public static final ResponseTransformer sdncAdapterMockTransformer = - new SDNCAdapterNetworkTopologyMockTransformer(); - - @Rule - public final SDNCAdapterCallbackRule sdncAdapterCallbackRule = - new SDNCAdapterCallbackRule(processEngineRule); - - /** - * End-to-End flow - Unit test for UpdateNetworkInstanceInfra.bpmn - * - String input & String response - */ - - @Test - //@Ignore - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Success1() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success1 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - System.out.println("----------------------------------------------------------"); - System.out.println("- got workflow response -"); - System.out.println("----------------------------------------------------------"); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - String workflowResp = BPMNUtil.getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "WorkflowResponse"); - Assert.assertNotNull(workflowResp); - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success1 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - @Test - //@Ignore - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Success2() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success2 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables2(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("true", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - String completeMsoProcessRequest = - "" + '\n' - + " " + '\n' - + " testRequestId" + '\n' - + " UPDATE" + '\n' - + " VID" + '\n' - + " " + '\n' - + " BPMN Network action: UPDATE" + '\n' - + ""; - - Assert.assertEquals(completeMsoProcessRequest, getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" Success2 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_MissingNetworkId() throws Exception { - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" Missing networkId - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("--------------------------------------------------------------------"); - - // setup simulators - - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesMissingNetworkId(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - String falloutHandlerActual = getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest"); - String falloutHandlerExpected = -"" + "\n" + -" " + "\n" + -" 88f65519-9a38-4c4b-8445-9eb4a5a5af56" + "\n" + -" UPDATE" + "\n" + -" VID" + "\n" + -" " + "\n" + -" " + "\n" + -" Variable 'network-id' value/element is missing." + "\n" + -" 2500" + "\n" + -" " + "\n" + -" "; - - assertEquals("Response", falloutHandlerExpected, falloutHandlerActual); - - System.out.println("------------------------------------------------------------------"); - System.out.println(" Missing networkId - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------------"); - - } - - /* NOT NEEDED - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback1() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback1 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockAAIResponse_queryId_UpdateNetwork_404V2(); // failure in queryId in AAI - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesSDNCRollback(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback1 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } */ - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback_Scenario01() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_NoPayload_Success.xml", 200); // no 'payload' response from NetworkAdapter, version 2 - //MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); // let it fail (404) to see SDNC compensation - //MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); // let it fail (404) to see SDNC compensation - //MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariablesSDNCRollback(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SDNCRollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Network_SDNC_Rollback() throws Exception { - - System.out.println("---------------------------------------------------------------"); - System.out.println(" Network and SDNC Rollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("---------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); // designed to fail in AAI Update - //mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("---------------------------------------------------------------------"); - System.out.println(" Network and SCNC Rollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("---------------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_Network_SDNC_Rollback_Failed() throws Exception { - - System.out.println("---------------------------------------------------------------"); - System.out.println(" Network and SDNC Rollback - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("---------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySim500Response.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockAAIResponse_updateContrail_CreateNetwork_SuccessV2(); // designed to fail in AAI Update - //mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("---------------------------------------------------------------------"); - System.out.println(" Network and SCNC Rollback - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("---------------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback2() throws Exception { - - System.out.println("----------------------------------------------------"); - System.out.println(" SDNCRollback2 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 500, "UpdateNetworkV2/updateNetworkResponse_500.xml"); // failure 500 in NetworkAdapter - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("------------------------------------------------------------"); - System.out.println(" SDNCRollback2 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_SDNCRollback3() throws Exception { - - System.out.println("----------------------------------------------------"); - System.out.println(" SDNCRollback3 - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 400, "UpdateNetworkV2/updateNetworkResponse_400.xml"); // failure 400 in NetworkAdapter - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - //MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("------------------------------------------------------------"); - System.out.println(" SDNCRollback3 - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("------------------------------------------------------------"); - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_PONR() throws Exception { - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" PONR (Point-of-no-Return) - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("--------------------------------------------------------------------"); - - // setup simulators - - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>changeassign"); // - mockSDNCAdapterTopology("UpdateNetworkV2mock/sdncUpdateNetworkTopologySimResponse.xml", "SvcAction>rollback"); - MockPutNetworkAdapter("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "updateNetworkRequest", 200, "UpdateNetworkV2/updateNetworkResponse_Success.xml"); - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - MockGetNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", "UpdateNetworkV2/updateNetwork_queryNetworkId_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("85f015d0-2e32-4c30-96d2-87a1a27f8017", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkVpnBinding("c980a6ef-3b88-49f0-9751-dbad8608d0a6", "UpdateNetworkV2/updateNetwork_queryVpnBinding_AAIResponse_Success.xml", 200); - MockGetNetworkPolicy("cee6d136-e378-4678-a024-2cd15f0ee0cg", "UpdateNetworkV2/updateNetwork_queryNetworkPolicy_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN1", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef1_AAIResponse_Success.xml", 200); - MockGetNetworkRouteTable("refFQDN2", "UpdateNetworkV2/updateNetwork_queryNetworkTableRef2_AAIResponse_Success.xml", 200); - MockPutNetwork("49c86598-f766-46f8-84f8-8d1c1b10f9b4", 200, "UpdateNetworkV2/updateNetwork_updateContrail_AAIResponse_Success.xml"); - mockUpdateRequestDB(500, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables1(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_FalloutHandlerRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - String falloutHandlerRequest = - "" + '\n' - + " " + '\n' - + " testRequestId" + '\n' - + " CREATE" + '\n' - + " VID" + '\n' - + " " + '\n' - + " " + '\n' - + " DB Update failed, code: 500" + '\n' - + " 2500" + '\n' - + " " + '\n' - + " "; - - System.out.println("Display UPDNETI_FalloutHandlerRequest - " + getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - //Assert.assertEquals(falloutHandlerRequest, getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_FalloutHandlerRequest")); - - System.out.println("--------------------------------------------------------------------"); - System.out.println(" PONR (Point-of-no-Return) - UpdateNetworkInstanceInfra flow Completed! "); - System.out.println("--------------------------------------------------------------------"); - - - } - - @Test - @Deployment(resources = {"process/UpdateNetworkInstanceInfra.bpmn", - "subprocess/GenericGetService.bpmn", - "subprocess/FalloutHandler.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/SDNCAdapterV1.bpmn"}) - - public void shouldInvokeServiceUpdateNetworkInstanceInfra_sdncFailure() throws Exception { - - System.out.println("----------------------------------------------------------"); - System.out.println(" SNDC Failure - UpdateNetworkInstanceInfra flow Started! "); - System.out.println("----------------------------------------------------------"); - - // setup simulators - - //MockSDNCAdapterBadAsynchronousResponse(); // 404 - mockSDNCAdapter("/SDNCAdapter", "SvcAction>query", 500, ""); // 500 - MockGetCloudRegion("RDM2WAGPLCP", 200, "CreateNetworkV2/cloudRegion25_AAIResponse_Success.xml"); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - MockNodeQueryServiceInstanceById("f70e927b-6087-4974-9ef8-c5e4d5847ca4", "UpdateNetworkV2/updateNetwork_queryInstance_Success.xml"); - - Map variables = setupVariables2(); - WorkflowResponse workflowResponse = executeAsyncWorkflow(processEngineRule, "UpdateNetworkInstanceInfra", variables); - waitForWorkflowToFinish(processEngineRule, workflowResponse.getProcessInstanceID()); - - assertEquals("false", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_Success")); - Assert.assertNotNull("UPDNETI_CompleteMsoProcessRequest - ", getVariable(processEngineRule, "UpdateNetworkInstanceInfra", "UPDNETI_CompleteMsoProcessRequest")); - - System.out.println("----------------------------------------------------------"); - System.out.println(" SNDC Failure - UpdateNetworkInstanceInfra flow Completed "); - System.out.println("----------------------------------------------------------"); - - } - - // ***************** - // Utility Section - // ***************** - - // Success Scenario - private Map setupVariables1() { - Map variables = new HashMap(); - variables.put("bpmnRequest", getCreateNetworkRequest1()); - variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "CREATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequest1() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_1\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"backoutOnFailure\": true, " + '\n' + - " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - } - - // Success Scenario 2 - private Map setupVariables2() { - Map variables = new HashMap(); - variables.put("bpmnRequest", getCreateNetworkRequest2()); - variables.put("mso-request-id", "testRequestId"); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequest2() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"myOwn_Network\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"backoutOnFailure\": true, " + '\n' + - " \"serviceId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\", " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } - - /* Active Scenario - private Map setupVariablesActive() { - Map variables = new HashMap(); - variables.put("mso-request-id", "testRequestId"); - variables.put("bpmnRequest", getCreateNetworkRequestActive()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequestActive() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_2\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } */ - - // Missing Name Scenario - private Map setupVariablesMissingNetworkId() { - Map variables = new HashMap(); - variables.put("mso-request-id", "88f65519-9a38-4c4b-8445-9eb4a5a5af56"); - variables.put("bpmnRequest", getCreateNetworkRequestNetworkId()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - //variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); // missing, ok - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - - return variables; - - } - - public String getCreateNetworkRequestNetworkId() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - return request; - - } - - // SDNC Rollback Scenario - private Map setupVariablesSDNCRollback() { - Map variables = new HashMap(); - variables.put("mso-request-id", "testRequestId"); - variables.put("bpmnRequest", getCreateNetworkRequestSDNCRollback()); - variables.put("requestId", "testRequestId"); - variables.put("isBaseVfModule", "true"); - variables.put("recipeTimeout", "0"); - variables.put("requestAction", "UPDATE"); - variables.put("serviceInstanceId", "f70e927b-6087-4974-9ef8-c5e4d5847ca4"); - variables.put("vnfId", ""); - variables.put("vfModuleId", ""); - variables.put("volumeGroupId", ""); - variables.put("networkId", "49c86598-f766-46f8-84f8-8d1c1b10f9b4"); - variables.put("serviceType", "vMOG"); - variables.put("vfModuleType", ""); - variables.put("networkType", "modelName"); - return variables; - - } - - public String getCreateNetworkRequestSDNCRollback() { - - String request = - "{ \"requestDetails\": { " + '\n' + - " \"modelInfo\": { " + '\n' + - " \"modelType\": \"modelType\", " + '\n' + - " \"modelId\": \"modelId\", " + '\n' + - " \"modelNameVersionId\": \"modelNameVersionId\", " + '\n' + - " \"modelName\": \"CONTRAIL_EXTERNAL\", " + '\n' + - " \"modelVersion\": \"1\" " + '\n' + - " }, " + '\n' + - " \"cloudConfiguration\": { " + '\n' + - " \"lcpCloudRegionId\": \"RDM2WAGPLCP\", " + '\n' + - " \"tenantId\": \"88a6ca3ee0394ade9403f075db23167e\" " + '\n' + - " }, " + '\n' + - " \"requestInfo\": { " + '\n' + - " \"instanceName\": \"MNS-25180-L-01-dmz_direct_net_3\", " + '\n' + - " \"source\": \"VID\", " + '\n' + - " \"callbackUrl\": \"\", " + '\n' + - " \"suppressRollback\": \"true\" ," + '\n' + - " \"productFamilyId\": \"a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb\" " + '\n' + - " }, " + '\n' + - " \"requestParameters\": { " + '\n' + - " \"userParams\": [] " + '\n' + - " } " + '\n' + - " } " + '\n' + - "}"; - - - return request; - } - -} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java index 34c0af43c4..6a5e241dc2 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/UpdateVfModuleVolumeInfraV1Test.java @@ -1,141 +1,143 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * 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; - -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; -import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; -import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; -import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.camunda.bpm.engine.test.Deployment; -import org.junit.Test; -import org.openecomp.mso.bpmn.common.WorkflowTest; -import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; -import org.openecomp.mso.bpmn.mock.FileUtil; - -/** - * Unit test cases for UpdateVfModuleVolume.bpmn - */ -public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { - - private final CallbackSet callbacks = new CallbackSet(); - - public UpdateVfModuleVolumeInfraV1Test() throws IOException { - callbacks.put("volumeGroupUpdate", FileUtil.readResourceFile( - "__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml")); - } - - /** - * Happy path scenario. - * - * @throws Exception - */ - @Test - @Deployment(resources = { - "process/UpdateVfModuleVolumeInfraV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/FalloutHandler.bpmn" - }) - public void happyPath() throws Exception { - - logStart(); - - MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); - MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); - mockPutVNFVolumeGroup("78987", 202); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - String businessKey = UUID.randomUUID().toString(); - String updaetVfModuleVolRequest = - FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json"); - - Map testVariables = new HashMap(); - testVariables.put("requestId", "TEST-REQUEST-ID-0123"); - testVariables.put("serviceInstanceId", "test-service-instance-id"); - testVariables.put("volumeGroupId", "78987"); - testVariables.put("vnfId", "TEST-VNF-ID-0123"); - TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); - - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); - - injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); - - waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); - - logEnd(); - } - - /** - * VF Module Personal model id does not match request model invariant id - * @throws Exception - */ - @Test - //@Ignore - @Deployment(resources = { - "process/UpdateVfModuleVolumeInfraV1.bpmn", - "subprocess/VnfAdapterRestV1.bpmn", - "subprocess/CompleteMsoProcess.bpmn", - "subprocess/FalloutHandler.bpmn" - }) - public void testPersonaModelIdNotMatch() throws Exception { - - logStart(); - - MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); - MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); - MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); - mockPutVNFVolumeGroup("78987", 202); - mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); - - String businessKey = UUID.randomUUID().toString(); - String updaetVfModuleVolRequest = - FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json"); - - Map testVariables = new HashMap(); - testVariables.put("requestId", "TEST-REQUEST-ID-0123"); - testVariables.put("serviceInstanceId", "test-service-instance-id"); - testVariables.put("volumeGroupId", "78987"); - testVariables.put("vnfId", "TEST-VNF-ID-0123"); - TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); - WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); - - String responseBody = response.getResponse(); - System.out.println("Workflow (Synch) Response:\n" + responseBody); - - injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); - - waitForProcessEnd(businessKey, 10000); - checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); - - logEnd(); - } -} +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * 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; + +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetGenericVnfById; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVfModuleId; +import static org.openecomp.mso.bpmn.mock.StubResponseAAI.MockGetVolumeGroupById; +import static org.openecomp.mso.bpmn.mock.StubResponseDatabase.mockUpdateRequestDB; +import static org.openecomp.mso.bpmn.mock.StubResponseVNFAdapter.mockPutVNFVolumeGroup; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; + +import org.camunda.bpm.engine.test.Deployment; +import org.junit.Test; +import org.openecomp.mso.bpmn.common.WorkflowTest; +import org.openecomp.mso.bpmn.common.workflow.service.WorkflowResponse; +import org.openecomp.mso.bpmn.mock.FileUtil; + +/** + * Unit test cases for UpdateVfModuleVolume.bpmn + */ +public class UpdateVfModuleVolumeInfraV1Test extends WorkflowTest { + + private final CallbackSet callbacks = new CallbackSet(); + + public UpdateVfModuleVolumeInfraV1Test() throws IOException { + callbacks.put("volumeGroupUpdate", FileUtil.readResourceFile( + "__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml")); + } + + /** + * Happy path scenario. + * + * @throws Exception + */ + @Test + @Deployment(resources = { + "process/UpdateVfModuleVolumeInfraV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void happyPath() throws Exception { + + logStart(); + + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); + mockPutVNFVolumeGroup("78987", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVfModuleVolRequest = + FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); + + logEnd(); + } + + /** + * VF Module Personal model id does not match request model invariant id + * @throws Exception + */ + @Test + //@Ignore + @Deployment(resources = { + "process/UpdateVfModuleVolumeInfraV1.bpmn", + "subprocess/VnfAdapterRestV1.bpmn", + "subprocess/CompleteMsoProcess.bpmn", + "subprocess/GenericNotificationService.bpmn", + "subprocess/FalloutHandler.bpmn" + }) + public void testPersonaModelIdNotMatch() throws Exception { + + logStart(); + + MockGetVolumeGroupById("mdt1", "78987", "UpdateVfModuleVolumeInfraV1/queryVolumeId_AAIResponse_Success.xml"); + MockGetGenericVnfById("/TEST-VNF-ID-0123", "CreateVfModuleVolumeInfraV1/GenericVnf.xml", 200); + MockGetVfModuleId("9e48f6ea-f786-46de-800a-d480e5ccc846", "6a1dc898-b590-47b9-bbf0-34424a7a2ec3/", "UpdateVfModuleVolumeInfraV1/vf_module_aai_response.xml", 200); + mockPutVNFVolumeGroup("78987", 202); + mockUpdateRequestDB(200, "Database/DBUpdateResponse.xml"); + + String businessKey = UUID.randomUUID().toString(); + String updaetVfModuleVolRequest = + FileUtil.readResourceFile("__files/UpdateVfModuleVolumeInfraV1/updateVfModuleVolume_VID_request_2.json"); + + Map testVariables = new HashMap(); + testVariables.put("requestId", "TEST-REQUEST-ID-0123"); + testVariables.put("serviceInstanceId", "test-service-instance-id"); + testVariables.put("volumeGroupId", "78987"); + testVariables.put("vnfId", "TEST-VNF-ID-0123"); + TestAsyncResponse asyncResponse = invokeAsyncProcess("UpdateVfModuleVolumeInfraV1", "v1", businessKey, updaetVfModuleVolRequest, testVariables); + WorkflowResponse response = receiveResponse(businessKey, asyncResponse, 10000); + + String responseBody = response.getResponse(); + System.out.println("Workflow (Synch) Response:\n" + responseBody); + + injectVNFRestCallbacks(callbacks, "volumeGroupUpdate"); + + waitForProcessEnd(businessKey, 10000); + checkVariable(businessKey, "UpdateVfModuleVolumeSuccessIndicator", true); + + logEnd(); + } +} diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json new file mode 100644 index 0000000000..1b56dbddbc --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request.json @@ -0,0 +1,69 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1", +"modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe" +}, +"subscriberInfo" : { +"globalSubscriberId" : "MSO_1610_dev_id", +"subscriberName" : "MSO_1610_dev_name" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"usePreload": true, +"userParams": {} +} +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json new file mode 100644 index 0000000000..f8cac48f1f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/CreateVfModule_VID_request_noPreloads.json @@ -0,0 +1,79 @@ +{ +"requestDetails": { +"modelInfo": { +"modelType": "vfModule", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "STMTN5MMSC21-MMSC::model-1-0", +"modelVersion": "1", +"modelCustomizationUuid": "ee6478e5-ea33-3346-ac12-ab121484a3fe" +}, +"subscriberInfo" : { +"globalSubscriberId" : "MSO_1610_dev_id", +"subscriberName" : "MSO_1610_dev_name" +}, +"cloudConfiguration": { +"lcpCloudRegionId": "MDTWNJ21", +"tenantId": "fba1bd1e195a404cacb9ce17a9b2b421" +}, +"requestInfo": { +"instanceName": "PCRF::module-0-2", +"source": "VID", +"suppressRollback": true +}, +"relatedInstanceList": [ +{ +"relatedInstance": { +"instanceId": "17ef4658-bd1f-4ef0-9ca0-ea76e2bf122c", +"instanceName": "MSOTESTVOL103a-vSAMP12_base_module-0_vol", +"modelInfo": { +"modelType": "volumeGroup", +"modelInvariantId": "ff5256d2-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6478e5-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12..base..module-0", +"modelVersion": "1" +} +} +}, +{ +"relatedInstance": { +"instanceId": "123456", +"modelInfo": { +"modelType": "service", +"modelInvariantId": "ff3514e3-5a33-55df-13ab-12abad84e7ff", +"modelNameVersionId": "fe6985cd-ea33-3346-ac12-ab121484a3fe", +"modelName": "SERVICE_MODEL_NAME", +"modelVersion": "1.0" +} +} +}, +{ +"relatedInstance": { +"instanceId": "skask", +"instanceName": "skask-test", +"modelInfo": { +"modelType": "vnf", +"modelInvariantId": "skask", +"modelNameVersionId": "fe6478e4-ea33-3346-ac12-ab121484a3fe", +"modelName": "vSAMP12", +"modelVersion": "1.0", +"modelCustomizationName": "vSAMP12 1" +} +} +} +], +"requestParameters": { +"usePreload": false, +"userParams" : [ + { + "name" : "someUserParam", + "value" : "someValue" + }, + { + "name": "sgi_protected_subnet_id", + "value": "thisissomefakevalue" + } +] + +} +} \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml new file mode 100644 index 0000000000..110e4327df --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/DBUpdateResponse.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml new file mode 100644 index 0000000000..181473543f --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenerateVfModuleName_AAIResponse_Success.xml @@ -0,0 +1,51 @@ + + 12345678-f41f-4822-9323-b75962763d74 + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + pending-create + false + false + introvert + 2.0 + 0000020 + + + lukewarm + PCRF::module-0-0 + extrovert + 2.0 + true + fastburn + 2 + pending-create + 0000074 + + + supercool + PCRF::module-1-0 + extrovert + 2.0 + false + slowburn + 0 + pending-create + 0000075 + + + supercool + PCRF::module-1-0 + introvert + 2.0 + false + slowburn + 1 + pending-create + 0000075 + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml index b2560bcb47..85427e2fcc 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/GenericVnf.xml @@ -1,38 +1,38 @@ - - skask - STMTN5MMSC20 - pcrf-capacity - SDN-MOBILITY - vPCRF - pending-create - false - false - introvert - 2.0 - 0000020 - - - lukewarm - PCRF::module-0-0 - introvert - 2.0 - true - fastburn - pending-create - 0000074 - - - supercool - PCRF::module-1-0 - extrovert - 2.0 - false - slowburn - pending-create - 0000075 - - - - - - + + skask + STMTN5MMSC20 + pcrf-capacity + SDN-MOBILITY + vPCRF + pending-create + false + false + introvert + 2.0 + 0000020 + + + lukewarm + PCRF::module-0-0 + introvert + 2.0 + true + fastburn + pending-create + 0000074 + + + supercool + PCRF::module-1-0 + extrovert + 2.0 + false + slowburn + pending-create + 0000075 + + + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml new file mode 100644 index 0000000000..f6314e55b3 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCSITopologyAssignCallback.xml @@ -0,0 +1,11 @@ + + 094d311c-40bc-4ff1-9617-37c4226efcc3 + 200 + + Y + + 8462db9b-3e91-4e90-a2c8-6471313f87bf + restconf/config/GENERIC-RESOURCE-API:services/service/8462db9b-3e91-4e90-a2c8-6471313f87bf/service-data/service-topology/ + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml new file mode 100644 index 0000000000..5fa58e9c03 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyActivateCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml new file mode 100644 index 0000000000..2b732f952d --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyAssignCallback.xml @@ -0,0 +1,16 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + + restconf/SDNCObjectPath + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml new file mode 100644 index 0000000000..3e138775d4 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyChangeAssignCallback.xml @@ -0,0 +1,13 @@ + + + skask + + 200 + {{REQUEST-ID}} + Y + + dontcare + 0 + SDN-MOBILITY + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml new file mode 100644 index 0000000000..27cab6b422 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallback.xml @@ -0,0 +1,315 @@ + + + bd1b3789-6474-4935-94b2-90b656e035d0 + + bd1b3789-6474-4935-94b2-90b656e035d0 + + 9ddf628a-9eca-430e-8974-22d520a31be1 + assign + https://msojra.infra.aic.att.net:8443/adapters/rest/SDNCNotify + + + notsurewecare + bd1b3789-6474-4935-94b2-90b656e035d0 + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + PendingCreate + + + VNN1CA52LCP + skask + afd0f02a-1ddb-43bb-aded-5113e46e82ae + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + 33d209df14ac4c08ad60747185d2f3e0 + bd1b3789-6474-4935-94b2-90b656e035d0 + ZVNN1MOGX01 - VF AUG 1::module-0 + + + + + mog_exn + 03dbd833-785c-40c0-bf32-37594b5334bc + MNS-25180-P-VNNYCA01_exn_protected_net_1 + + + 6f82d234-41a4-48e9-a9e8-415667a72929 + + filter1 + + + filter2 + + + + mog_oam + 3f181cde-9380-4c20-9d3a-e1a4ee74f994 + MNS-25180-P-VNNYCA01_oam_protected_net_1 + + + 713b6770-13fa-4949-8dbb-a1288c5e5932 + + + mog_cor_B + 821a550a-3f50-4725-995b-f212d5caec7c + MNS-25180-P-VNNYCA01_cor_direct_net_1 + + + 18926e56-12b6-4a4d-98b6-37e0c05626ee + + + mog_cor_A + 3dabf5c0-cffb-420c-8960-8499c74eb25f + MNS-25180-P-VNNYCA01_cor_direct_net_2 + + + 35530b29-a4de-48ff-a014-111110ccc652 + + + mog_gn + 3ce97321-6e7f-49af-bd12-f833e377c310 + MNS-25180-P-VNNYCA01_gn_direct_net_1 + + + 32bfdd2c-28e1-4895-87a6-373bf12c3129 + + + mog_dmz + d43ca910-02a5-47dc-8510-100a68a3c9e0 + MNS-25180-P-VNNYCA01_dmz_protected_net_1 + + + cb9500fb-943f-412e-aea6-458711564a75 + + + nova + + + ps + + ZVNN1MOGX01MPS001 + + + ZVNN1MOGX01MPS002 + + + ZVNN1MOGX01MPS003 + + + ZVNN1MOGX01MPS004 + + 4 + + mog_cor_B + + 107.224.36.251 + + + 107.224.36.252 + + + 107.224.36.253 + + + 107.224.36.254 + + N + + + + cm + + ZVNN1MOGX01MCM001 + + + ZVNN1MOGX01OAM002 + + 1 + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + N + + + mog_oam + + 107.239.167.250 + + + 107.239.167.251 + + N + + + + oam + + ZVNN1MOGX01OAM001 + + + ZVNN1MOGX01OAM002 + + 2 + + mog_oam + + 107.239.167.252 + + + 107.239.167.251 + + N + + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + N + + + + pd + + ZVNN1MOGX01MPD001 + + + ZVNN1MOGX01MPD002 + + 2 + + mog_dmz + + 107.225.25.253 + + + 107.225.25.254 + + N + 107.225.254.253 + + + mog_oam + + 107.239.167.254 + + + 107.239.167.253 + + N + 107.239.167.249 + + + mog_exn + + 107.224.46.253 + + + 107.224.46.254 + + N + 107.224.46.252 + + + mog_cor_B + + 107.224.36.247 + + + 107.224.36.248 + + N + 107.224.41.252 + + + mog_gn + + 107.224.41.253 + + + 107.224.41.254 + + N + 107.224.41.252 + + + mog_cor_A + + 107.224.38.253 + + + 107.224.38.254 + + N + + + + sm + + ZVNN1MOGX01MSM001 + + + ZVNN1MOGX01MSM002 + + + ZVNN1MOGX01MSM003 + + + ZVNN1MOGX01MSM004 + + 4 + + mog_cor_B + + 107.224.36.243 + + + 107.224.36.244 + + + 107.224.36.245 + + + 107.224.36.246 + + N + + + + + ZVNNMOGX01_base + SDN-MOBILITY + ZVNN1MOGX01 - VF AUG 1::module-0 + ZVNN1MOGX01-SVC/ZVNN1MOGX01 - VF AUG 1 1 + ZVNN1MOGX01 + + + + 9ddf628a-9eca-430e-8974-22d520a31be1 + + PORTAL + VNFActivateRequest + + + + 200 + Y + synccomplete + 2016-08-05T16:15:19.398Z + vnf-topology-operation + VNFActivateRequest + assign + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml new file mode 100644 index 0000000000..be6f973260 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/SDNCTopologyQueryCallbackVfModule.xml @@ -0,0 +1,141 @@ + + + 28455973-1ee5-4ad1-8d35-c4732679743a + + 200 + Y + synccomplete + 2016-06-08T19:44:59.138Z + vnf-topology-operation + VNFActivateRequest + assign + + + 28455973-1ee5-4ad1-8d35-c4732679743 + + notsurewecare + 28455973-1ee5-4ad1-8d35-c4732679743a + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + a9a77d5a-123e-4ca2-9eb9-0b015d2ee0fb + + + 5e168556-a5c6-4813-bff3-cc03007afbbc + http://mtanjv9moja01-eth1-0.aic.cip.att.com:8080/adapters/rest/SDNCNotify + assign + + + AAIAIC25 + MSOTEST06-vSAMP3::base::module-0 + 91ad7ab0-9ffd-471d-971c-3eb913a2cc75 + Test/vSAMP3 1 + MSOTEST06 + 4ae1d3446a4c48b2bec44b6cfba06d68 + 28455973-1ee5-4ad1-8d35-c4732679743a + vSAMP3::base::module-0 + + + PendingCreate + + + + image + Ubuntu_Perf + + + flavor + m1.small + + + + int_imbl + 680b7453-0ec4-4d96-b355-280d981d418f + Nimbus-25193-T-Willows2_int_imbl_net_1 + default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_int_imbl_net_1 + + 775607fb-e16a-45ef-94a7-82fba0d16eec + 640d07fb-e16a-45ef-94a7-82fba0d169bf + + filter1 + + + filter2 + + + + sgi_protected + f9039ce9-e3cf-4716-b2d1-ec7912178ea4 + Nimbus-25193-T-Willows2_sgi_protected_net_1 + default-domain:Nimbus-25193-T-Willows2:Nimbus-25193-T-Willows2_sgi_protected_net_1 + b9999ce9-e3cf-4716-b2d1-ec791217678c + + bf11bba8-b971-4ab5-8281-215b3fedcd3c + + + cm + + ZVNN1MOGX01MCM001 + + + ZVNN1MOGX01OAM002 + + 1 + + mog_cor_B + + 107.224.36.249 + + + 107.224.36.250 + + + 2606:ae00:2e01:800::67 + + N + 107.224.41.252 + 2001:1890:1001:2B32::29:C + + + mog_oam + + 107.239.167.250 + + + 107.239.167.251 + + + aa::aa::aa::aa::aa::aa + + + bb::bb::bb::bb::bb::bb + + + 1.2.3.4/26 + + + 2002::/64 + + N + 1111:1890:1001:2B32::29:D + + + + nova + + + + MSOTEST06-vSAMP3::base::module-0 + SDN-MOBILITY + vSAMP3::base::module-0 + Test/vSAMP3 1 + MSOTEST06 + + + + 5e168556-a5c6-4813-bff3-cc03007afbbc + + SoapUI-bns-vf-base-vSAMP3-9001 + VNFActivateRequest + + + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml new file mode 100644 index 0000000000..3afcb3f21c --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestCreateCallback.xml @@ -0,0 +1,55 @@ + + skask + supercool + slowburn + true + + + key1 + value1 + + + key2 + value2 + + +server1_private_ip +192.168.28.3 + + +contrail-service-instance-fqdn +default-domain:MSOTest:MsoNW-RA + + +policyKey1_contrail_network_policy_fqdn +MSOTest:DefaultPolicyFQDN1 + + +policyKey2_contrail_network_policy_fqdn +MSOTest:DefaultPolicyFQDN2 + + +oam_management_v6_address +2000:abc:bce:1111 + + +oam_management_v4_address +127.0.0.1 + + + + skask + supercool + slowburn + true + tenantId + cloudSiteId + + requestId + serviceInstanceId + + {{MESSAGE-ID}} + + {{MESSAGE-ID}} + + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml new file mode 100644 index 0000000000..2d3ebebccd --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestUpdateCallback.xml @@ -0,0 +1,16 @@ + + skask + supercool + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml new file mode 100644 index 0000000000..af2bd7abfd --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VNFAdapterRestVolumeGroupCallback.xml @@ -0,0 +1,15 @@ + + 78987 + slowburn + + + key1 + value1 + + + key2 + value2 + + + {{MESSAGE-ID}} + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml new file mode 100644 index 0000000000..8de2f95901 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-lukewarm.xml @@ -0,0 +1,10 @@ + + lukewarm + PCRF::module-1 + slowburn + pending-create + true + 330-90 + introvert + 2.0 + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml index a71441e916..e72d23d9d9 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-new.xml @@ -1,9 +1,9 @@ - - b37d96db-7d2c-47ce-bf61-a6c7b82fe161 - PCRF::module-0-2 - 00000000-0000-0000-0000-000000000000 - 1.0 - false - pending-create - 330-90 + + b37d96db-7d2c-47ce-bf61-a6c7b82fe161 + PCRF::module-0-2 + 00000000-0000-0000-0000-000000000000 + 1.0 + false + pending-create + 330-90 \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml index 1066b17b94..15a84aad05 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/__files/VfModularity/VfModule-supercool.xml @@ -1,27 +1,27 @@ - - supercool - PCRF::module-2 - fastburn - pending-create - false - 330-89 - introvert - 2.0 - - - volume-group - - cloud-region.cloud-owner - att-aic - - - cloud-region.cloud-region-id - pdk1 - - - volume-group.volume-group-id - 78987 - - - + + supercool + PCRF::module-2 + fastburn + pending-create + false + 330-89 + introvert + 2.0 + + + volume-group + + cloud-region.cloud-owner + att-aic + + + cloud-region.cloud-region-id + pdk1 + + + volume-group.volume-group-id + 78987 + + + \ No newline at end of file diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties index ac340c79b6..b14d49511a 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties @@ -10,7 +10,8 @@ mso.csi.usrname=mso mso.msoKey=07a7159d3bf51a0e53be7a8f89699be7 mso.adapters.completemsoprocess.endpoint=http://localhost:28090/CompleteMsoProcess - +mso.workflow.message.endpoint=http://localhost:8080/mso/WorkflowMessage +mso.catalog.db.endpoint=http://localhost:8090 mso.adapters.db.endpoint=http://localhost:28090/dbadapters/RequestsDbAdapter mso.adapters.db.auth=757A94191D685FD2092AC1490730A4FC @@ -30,6 +31,7 @@ mso.sdnc.firewall.yang.model=http://com/openecomp/svc/mis/firewall-lite-gui mso.sdnc.firewall.yang.model.version=2015-05-15 mso.sdnc.password=3141634BF7E070AA289CF2892C986C0B mso.sdnc.timeout.firewall.minutes=20 +mso.callbackRetryAttempts=5 mso.sdnc.timeout=PT10S mso.sdnc.timeout.ucpe.async.hours=120 mso.sdnc.timeout.ucpe.async.minutes=5 @@ -56,7 +58,7 @@ aai.endpoint=http://localhost:28090 # Example to override default version for a resource: #mso.workflow.default.aai.vce.version=6 #mso.workflow.default.aai.v6.vce.uri=/aai/v6/network/vces/vce - +mso.workflow.global.default.aai.namespace=http://org.openecomp.aai.inventory/ mso.workflow.global.default.aai.version=8 mso.workflow.default.aai.cloud-region.version=9 mso.workflow.default.aai.generic-vnf.version=9 -- cgit 1.2.3-korg