aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/MSOInfrastructureBPMN/src/main/groovy
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/MSOInfrastructureBPMN/src/main/groovy')
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericALaCarteServiceInstance.groovy (renamed from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateServiceInstance.groovy)502
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateGenericMacroServiceNetworkVnf.groovy1540
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleInfra.groovy303
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVfModuleVolumeInfraV1.groovy607
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/CreateVnfInfra.groovy70
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericALaCarteServiceInstance.groovy (renamed from bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DelServiceInstance.groovy)682
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteGenericMacroServiceNetworkVnf.groovy934
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DeleteNetworkInstance.groovy834
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateNetworkInstance.groovy129
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstance.groovy92
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateServiceInstanceRollback.groovy28
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModule.groovy81
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleRollback.groovy68
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVfModuleVolumeV1.groovy5
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnf.groovy976
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy654
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteNetworkInstance.groovy86
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteServiceInstance.groovy840
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoDeleteVnfAndModules.groovy740
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateNetworkInstance.groovy16
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoUpdateVfModule.groovy1840
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateNetworkInstanceInfra.groovy1639
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModule.groovy66
-rw-r--r--bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/UpdateVfModuleVolume.groovy72
24 files changed, 5818 insertions, 6986 deletions
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/CreateGenericALaCarteServiceInstance.groovy
index 2205ffd696..ec414a4ee2 100644
--- 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/CreateGenericALaCarteServiceInstance.groovy
@@ -1,262 +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 <class>CreateServiceInstance.bpmn</class> 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 =
+/*-
+ * ============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 <class>CreateServiceInstance.bpmn</class> process.
+ * AlaCarte flow for 1702 ServiceInstance Create
+ *
+ */
+public class CreateGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor {
+ String Prefix="CRESI_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ 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 =
"""<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
-
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
-
- }
-
- public void prepareCompletionRequest (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 =
+ <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ utils.logAudit(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+
+ } catch (Exception ex) {
+ utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
+ }
+
+ }
+
+ public void prepareCompletionRequest (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 =
"""<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
xmlns:ns="http://org.openecomp/mso/request/types/v1">
<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>
- <status-message>Service Instance was created successfully.</status-message>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- <mso-bpel-name>CreateServiceInstance</mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- execution.setVariable("completionRequest", xmlMsoCompletionRequest)
- utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- String msg = " Exception in prepareCompletion:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled)
- }
-
- public void prepareFalloutRequest(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 =
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>
+ <status-message>Service Instance was created successfully.</status-message>
+ <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+ <mso-bpel-name>CreateGenericALaCarteServiceInstance</mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ // Format Response
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ execution.setVariable("completionRequest", xmlMsoCompletionRequest)
+ utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
+
+ } catch (Exception ex) {
+ String msg = " Exception in prepareCompletion:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled)
+ }
+
+ public void prepareFalloutRequest(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 =
"""<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>"""
-
- String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
- execution.setVariable("falloutRequest", falloutRequest)
- } catch (Exception ex) {
- utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled)
- String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage()
- String requestId = execution.getVariable("msoRequestId")
- String falloutRequest =
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>"""
+
+ String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
+ execution.setVariable("falloutRequest", falloutRequest)
+ } catch (Exception ex) {
+ utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled)
+ String errorException = " Bpmn error encountered in CreateGenericALaCarteServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage()
+ String requestId = execution.getVariable("msoRequestId")
+ String falloutRequest =
"""<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
xmlns:ns="http://org.openecomp/mso/request/types/v1"
xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>VID</source>
- </request-info>
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>VID</source>
+ </request-info>
<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- execution.setVariable("falloutRequest", falloutRequest)
- }
- utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
- }
+ <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>
+ </aetgt:FalloutHandlerRequest>"""
+
+ execution.setVariable("falloutRequest", falloutRequest)
+ }
+ utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
+ }
} \ No newline at end of file
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/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 <class>CreateGenericMacroServiceNetworkVnf.bpmn</class> 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 <class>CreateServiceInstance.bpmn</class> 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 <class>CreateServiceInstance.bpmn</class> 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 <class>CreateGenericMacroServiceNetworkVnf.bpmn</class> 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 <class>CreateServiceInstance.bpmn</class> 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 <class>CreateServiceInstance.bpmn</class> 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 =
"""<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable("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 = """
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>"""
+
+ 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 = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http://org.openecomp.mso/requestsdb">
- <soapenv:Header/>
- <soapenv:Body>
- <req:updateInfraRequest>
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPEL</lastModifiedBy>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>
- </req:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>
- """
- execution.setVariable("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 =
-// """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
-// <soapenv:Header/>
-// <soapenv:Body>
+ <soapenv:Header/>
+ <soapenv:Body>
+ <req:updateInfraRequest>
+ <requestId>${requestId}</requestId>
+ <lastModifiedBy>BPEL</lastModifiedBy>
+ <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+ <serviceInstanceName>${serviceInstanceName}</serviceInstanceName>
+ </req:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>
+ """
+ execution.setVariable("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<NetworkResource> 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<VnfResource> 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<VnfResource> 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<VnfResource> 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 =
+// """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+// <soapenv:Header/>
+// <soapenv:Body>
// <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
-// <requestId>${requestId}</requestId>
-// <lastModifiedBy>BPMN</lastModifiedBy>
-// <statusMessage>${statusMessage}</statusMessage>
-// <responseBody></responseBody>
-// <requestStatus>COMPLETED</requestStatus>
-// <progress>100</progress>
-// <vnfOutputs/>
-// <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
-// </ns:updateInfraRequest>
-// </soapenv:Body>
-// </soapenv:Envelope>"""
-//
-// 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>${requestId}</requestId>
+// <lastModifiedBy>BPMN</lastModifiedBy>
+// <statusMessage>${statusMessage}</statusMessage>
+// <responseBody></responseBody>
+// <requestStatus>COMPLETED</requestStatus>
+// <progress>100</progress>
+// <vnfOutputs/>
+// <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+// </ns:updateInfraRequest>
+// </soapenv:Body>
+// </soapenv:Envelope>"""
+//
+// 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 =
"""<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
xmlns:ns="http://org.openecomp/mso/request/types/v1">
<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>
- <status-message>Service Instance has been created successfully via macro orchestration</status-message>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- <mso-bpel-name>BPMN macro create</mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- utils.logAudit(xmlMsoCompletionRequest)
- execution.setVariable("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 =
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>
+ <status-message>Service Instance has been created successfully via macro orchestration</status-message>
+ <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+ <mso-bpel-name>BPMN macro create</mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ // Format Response
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ utils.logAudit(xmlMsoCompletionRequest)
+ execution.setVariable("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 =
"""<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
- }
-
- public void processJavaException(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)
- }
+ <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ utils.logAudit(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+ } catch (Exception ex) {
+ utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
+ }
+ }
+
+ public void processJavaException(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/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<String, String> 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 =
+ """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>"""
+
+ execution.setVariable("CVFMI_requestInfo", requestInfo)
+
//backoutOnFailure
- 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 =
- """ <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ """ <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
${requestInfo}
</request-info>
<ns8:status-message>Vf Module has been created successfully.</ns8:status-message>
@@ -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 =
"""<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:ns="http://org.openecomp.mso/requestsdb">
+ xmlns:ns="http://org.openecomp.mso/requestsdb">
<soapenv:Header/>
<soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
<requestId>${requestId}</requestId>
<lastModifiedBy>BPMN</lastModifiedBy>
<statusMessage>VF Module successfully created</statusMessage>
<responseBody></responseBody>
<requestStatus>COMPLETE</requestStatus>
<progress>100</progress>
- <vnfOutputs>&lt;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"&gt;&lt;vnf-id&gt;${vnfId}&lt;/vnf-id&gt;&lt;vf-module-id&gt;${vfModuleId}&lt;/vf-module-id&gt;&lt;/vnf-outputs&gt;</vnfOutputs>
+ <vnfOutputs>&lt;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"&gt;&lt;vnf-id&gt;${vnfId}&lt;/vnf-id&gt;&lt;vf-module-id&gt;${vfModuleId}&lt;/vf-module-id&gt;&lt;/vnf-outputs&gt;</vnfOutputs>
<vfModuleId>${vfModuleId}</vfModuleId>
+ <vfModuleName>${vfModuleName}</vfModuleName>
</ns:updateInfraRequest>
</soapenv:Body>
</soapenv:Envelope>"""
@@ -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 = """
- <aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
- xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
- xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
+ <aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
+ xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
+ xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
${requestInformation}
<aetgt:WorkflowException>
<aetgt:ErrorMessage>${encErrorResponseMsg}</aetgt:ErrorMessage>
@@ -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 =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>${requestStatus}</requestStatus>
- <progress>${progress}</progress>
- <vnfOutputs>${dbVnfOutputs}</vnfOutputs>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- String 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 =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:status-message>Volume Group has been created successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>BPMN VF Module Volume action: CREATE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- utils.logAudit(createDBResponse)
- utils.logAudit(xmlMsoCompletionRequest)
- execution.setVariable(prefix+'Success', true)
- execution.setVariable(prefix+'CompleteMsoProcessRequest', xmlMsoCompletionRequest)
- utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
-
- }
-
- public void prepareFalloutHandlerRequest(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 =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:WorkflowException>
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
- </aetgt:WorkflowException>
-
- </aetgt:FalloutHandlerRequest>"""
-
- // Format Response
- String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest)
- utils.logAudit(xmlHandlerRequest)
-
- execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest)
- utils.log("ERROR", "Overall Error Response going to FalloutHandler: " + "\n" + xmlHandlerRequest, isDebugEnabled)
- }
-
-
- /**
- * Query AAI service instance
- * @param execution
- * @param isDebugEnabled
- */
- public void callRESTQueryAAIServiceInstance(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 =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <requestId>${requestId}</requestId>
+ <lastModifiedBy>BPMN</lastModifiedBy>
+ <statusMessage>${statusMessage}</statusMessage>
+ <responseBody></responseBody>
+ <requestStatus>${requestStatus}</requestStatus>
+ <progress>${progress}</progress>
+ <vnfOutputs>${dbVnfOutputs}</vnfOutputs>
+ <volumeGroupId>${volumeGroupId}</volumeGroupId>
+ </ns:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ String 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 =
+ """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>
+ <aetgt:status-message>Volume Group has been created successfully.</aetgt:status-message>
+ <aetgt:mso-bpel-name>BPMN VF Module Volume action: CREATE</aetgt:mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ utils.logAudit(createDBResponse)
+ utils.logAudit(xmlMsoCompletionRequest)
+ execution.setVariable(prefix+'Success', true)
+ execution.setVariable(prefix+'CompleteMsoProcessRequest', xmlMsoCompletionRequest)
+ utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
+
+ }
+
+ public void prepareFalloutHandlerRequest(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 =
+ """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>
+ <aetgt:WorkflowException>
+ <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
+ </aetgt:WorkflowException>
+
+ </aetgt:FalloutHandlerRequest>"""
+
+ // Format Response
+ String xmlHandlerRequest = utils.formatXml(falloutHandlerRequest)
+ utils.logAudit(xmlHandlerRequest)
+
+ execution.setVariable(prefix+'FalloutHandlerRequest', xmlHandlerRequest)
+ utils.log("ERROR", "Overall Error Response going to FalloutHandler: " + "\n" + xmlHandlerRequest, isDebugEnabled)
+ }
+
+
+ /**
+ * Query AAI service instance
+ * @param execution
+ * @param isDebugEnabled
+ */
+ public void callRESTQueryAAIServiceInstance(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 =
- """<generic-vnf xmlns="${namespace}">
- <vnf-id>${vnfId}</vnf-id>
- <vnf-name>${vnfName}</vnf-name>
- <service-id>${serviceId}</service-id>
- <vnf-type>${vnfType}</vnf-type>
- <orchestration-status>${orchStatus}</orchestration-status>
- <persona-model-id>${modelInvariantId}</persona-model-id>
- <persona-model-version>${modelVersion}</persona-model-version>
- <relationship-list>
- <relationship>
- <related-to>service-instance</related-to>
- <related-link>${siRelatedLink}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${globalCustId}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${serviceType}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${serviceInstanceId}</relationship-value>
- </relationship-data>
- </relationship>
- </relationship-list>
- </generic-vnf>"""
-
- execution.setVariable("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/DeleteGenericALaCarteServiceInstance.groovy
index aad0693948..7555885bcb 100644
--- 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/DeleteGenericALaCarteServiceInstance.groovy
@@ -1,353 +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 <class>DelServiceInstance.bpmn</class> 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 =
+/*-
+ * ============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 <class>DelServiceInstance.bpmn</class> process.
+ *
+ */
+public class DeleteGenericALaCarteServiceInstance extends AbstractServiceTaskProcessor {
+
+ String Prefix="DELSI_"
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+ VidUtils vidUtils = new VidUtils()
+
+ public void preProcessRequest (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 =
"""<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
-
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
-
- }
-
- public void prepareCompletionRequest (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 =
+ <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ utils.logAudit(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+
+ } catch (Exception ex) {
+ utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
+ }
+
+ }
+
+ public void prepareCompletionRequest (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 =
"""<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
xmlns:ns="http://org.openecomp/mso/request/types/v1">
<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:status-message>Service Instance was deleted successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>DelServiceInstance</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- execution.setVariable("completionRequest", xmlMsoCompletionRequest)
- utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- String msg = " Exception in prepareCompletion:" + ex.getMessage()
- utils.log("DEBUG", msg, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
- }
- utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled)
- }
-
- public void prepareFalloutRequest(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 =
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>${source}</source>
+ </request-info>
+ <aetgt:status-message>Service Instance was deleted successfully.</aetgt:status-message>
+ <aetgt:mso-bpel-name>DeleteGenericALaCarteServiceInstance</aetgt:mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ // Format Response
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ execution.setVariable("completionRequest", xmlMsoCompletionRequest)
+ utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
+
+ } catch (Exception ex) {
+ String msg = " Exception in prepareCompletion:" + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ utils.log("DEBUG", "*** Exit prepareCompletionRequest ***", isDebugEnabled)
+ }
+
+ public void prepareFalloutRequest(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 =
"""<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>"""
-
- String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
- execution.setVariable("falloutRequest", falloutRequest)
- } catch (Exception ex) {
- utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled)
- String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage()
- String requestId = execution.getVariable("msoRequestId")
- String falloutRequest =
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>${source}</source>
+ </request-info>"""
+
+ String falloutRequest = exceptionUtil.processMainflowsBPMNException(execution, requestInfo)
+ execution.setVariable("falloutRequest", falloutRequest)
+ } catch (Exception ex) {
+ utils.log("DEBUG", "Exception prepareFalloutRequest:" + ex.getMessage(), isDebugEnabled)
+ String errorException = " Bpmn error encountered in CreateServiceInstance flow. FalloutHandlerRequest, buildErrorResponse() - " + ex.getMessage()
+ String requestId = execution.getVariable("msoRequestId")
+ String falloutRequest =
"""<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
xmlns:ns="http://org.openecomp/mso/request/types/v1"
xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>VID</source>
- </request-info>
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>VID</source>
+ </request-info>
<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- execution.setVariable("falloutRequest", falloutRequest)
- }
- utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
- }
-
-
- // *******************************
- // Build DB request Section
- // *******************************
- public void prepareDBRequest (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 =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
+ <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>
+ </aetgt:FalloutHandlerRequest>"""
+
+ execution.setVariable("falloutRequest", falloutRequest)
+ }
+ utils.log("DEBUG", "*** Exit prepareFalloutRequest ***", isDebugEnabled)
+ }
+
+
+ // *******************************
+ // Build DB request Section
+ // *******************************
+ public void prepareDBRequest (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 =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Header/>
+ <soapenv:Body>
<ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>COMPLETED</requestStatus>
- <progress>100</progress>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- String buildDeleteDBRequestAsString = utils.formatXml(dbRequest)
- execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString)
- utils.logAudit(buildDeleteDBRequestAsString)
-
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in 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 =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
+ <requestId>${requestId}</requestId>
+ <lastModifiedBy>BPMN</lastModifiedBy>
+ <statusMessage>${statusMessage}</statusMessage>
+ <responseBody></responseBody>
+ <requestStatus>COMPLETED</requestStatus>
+ <progress>100</progress>
+ </ns:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ String buildDeleteDBRequestAsString = utils.formatXml(dbRequest)
+ execution.setVariable("DELSI_createDBRequest", buildDeleteDBRequestAsString)
+ utils.logAudit(buildDeleteDBRequestAsString)
+
+ } catch (Exception ex) {
+ // try error in method block
+ String exceptionMessage = "Bpmn error encountered in DeleteGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDBRequest() - " + ex.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+
+ }
+
+ // *******************************
+ // Build Error Section
+ // *******************************
+ public void prepareDBRequestError (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 =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Header/>
+ <soapenv:Body>
<ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>FAILED</requestStatus>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- String buildDBRequestAsString = utils.formatXml(dbRequest)
- execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString)
- utils.logAudit(buildDBRequestAsString)
-
- } catch (Exception ex) {
- // try error in method block
- String exceptionMessage = "Bpmn error encountered in DeleteServiceInstanceInfra flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage()
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-}
+ <requestId>${requestId}</requestId>
+ <lastModifiedBy>BPMN</lastModifiedBy>
+ <statusMessage>${statusMessage}</statusMessage>
+ <responseBody></responseBody>
+ <requestStatus>FAILED</requestStatus>
+ </ns:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ String buildDBRequestAsString = utils.formatXml(dbRequest)
+ execution.setVariable("DELSI_createDBInfraErrorRequest", buildDBRequestAsString)
+ utils.logAudit(buildDBRequestAsString)
+
+ } catch (Exception ex) {
+ // try error in method block
+ String exceptionMessage = "Bpmn error encountered in DeleteGenericALaCarteServiceInstance flow. Unexpected Error from method prepareDBRequestError() - " + ex.getMessage()
+ exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+
+ }
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/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 <class>DeleteViprAtmService.bpmn</class> 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 <class>DeleteViprAtmService.bpmn</class> 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 <class>CreateServiceInstance.bpmn</class> 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 =
- """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable("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 =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:status-message>vIPR ATM Service Instance has been deleted successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>BPMN Service Instance macro action: DELETE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- utils.logAudit(xmlMsoCompletionRequest)
- execution.setVariable("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 =
- """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>"""
-
- utils.logAudit(buildworkflowException)
- sendWorkflowResponse(execution, 500, buildworkflowException)
- } catch (Exception ex) {
- utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
- }
- }
-
- public void processJavaException(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 <class>DeleteViprAtmService.bpmn</class> 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 <class>DeleteGenericMacroServiceNetworkVnf.bpmn</class> 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 <class>CreateServiceInstance.bpmn</class> 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 =
+ """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>${source}</source>
+ </request-info>"""
+
+ execution.setVariable("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 =
+ """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>${source}</source>
+ </request-info>
+ <aetgt:status-message>vIPR ATM Service Instance has been deleted successfully.</aetgt:status-message>
+ <aetgt:mso-bpel-name>BPMN Service Instance macro action: DELETE</aetgt:mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ // Format Response
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ utils.logAudit(xmlMsoCompletionRequest)
+ execution.setVariable("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 =
+ """<aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
+ <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>7000</aetgt:ErrorCode>
+ </aetgt:WorkflowException>"""
+
+ utils.logAudit(buildworkflowException)
+ sendWorkflowResponse(execution, 500, buildworkflowException)
+ } catch (Exception ex) {
+ utils.log("DEBUG", " Sending Sync Error Activity Failed. " + "\n" + ex.getMessage(), isDebugEnabled)
+ }
+ }
+
+ public void processJavaException(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 =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>VID</source>
- </request-info>
- <aetgt:status-message>Network has been deleted successfully.</aetgt:status-message>
- <aetgt:mso-bpel-name>BPMN Network action: DELETE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // Format Response
- String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
-
- // normal path
- execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest)
- utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
-
- }
-
- public void prepareDBRequestError (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 =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>FAILED</requestStatus>
- <progress></progress>
- <vnfOutputs>&lt;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"/&gt;</vnfOutputs>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- execution.setVariable(Prefix + "deleteDBRequest", dbRequest)
- utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- // caught exception
- String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, prepareDBRequestError() - " + ex.getMessage()
- logError(exceptionMessage)
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
-
- }
-
- }
-
- // **************************************************
- // Post or Validate Response Section
- // **************************************************
-
- public void postProcessResponse (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 =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELETE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- utils.logAudit(falloutHandlerRequest)
- execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest)
- utils.log("ERROR", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)
-
- } catch (Exception ex) {
- // caught exception
- String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, buildErrorResponse() - " + ex.getMessage()
- utils.log("DEBUG", exceptionMessage, isDebugEnabled)
- falloutHandlerRequest =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>DELEtE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${exceptionMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>9999</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
- execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest)
- utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)
- }
- }
-
-
- public void sendSyncError (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 =
+ """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>VID</source>
+ </request-info>
+ <aetgt:status-message>Network has been deleted successfully.</aetgt:status-message>
+ <aetgt:mso-bpel-name>BPMN Network action: DELETE</aetgt:mso-bpel-name>
+ </aetgt:MsoCompletionRequest>"""
+
+ // Format Response
+ String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
+
+ // normal path
+ execution.setVariable(Prefix + "CompleteMsoProcessRequest", xmlMsoCompletionRequest)
+ utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
+
+ } catch (Exception ex) {
+ String exceptionMessage = " Bpmn error encountered in CreateNetworkInstance flow. prepareCompletion() - " + ex.getMessage()
+ utils.log("DEBUG", exceptionMessage, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+
+
+ }
+
+ public void prepareDBRequestError (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 =
+ """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
+ <requestId>${requestId}</requestId>
+ <lastModifiedBy>BPMN</lastModifiedBy>
+ <statusMessage>${statusMessage}</statusMessage>
+ <responseBody></responseBody>
+ <requestStatus>FAILED</requestStatus>
+ <progress></progress>
+ <vnfOutputs>&lt;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"/&gt;</vnfOutputs>
+ </ns:updateInfraRequest>
+ </soapenv:Body>
+ </soapenv:Envelope>"""
+
+ execution.setVariable(Prefix + "deleteDBRequest", dbRequest)
+ utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled)
+
+ } catch (Exception ex) {
+ // caught exception
+ String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, prepareDBRequestError() - " + ex.getMessage()
+ logError(exceptionMessage)
+ utils.log("DEBUG", exceptionMessage, isDebugEnabled)
+ exceptionUtil.buildWorkflowException(execution, 7000, exceptionMessage)
+
+ }
+
+ }
+
+ // **************************************************
+ // Post or Validate Response Section
+ // **************************************************
+
+ public void postProcessResponse (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 =
+ """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>DELETE</action>
+ <source>${source}</source>
+ </request-info>
+ <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
+ <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
+ </aetgt:WorkflowException>
+ </aetgt:FalloutHandlerRequest>"""
+
+ utils.logAudit(falloutHandlerRequest)
+ execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest)
+ utils.log("ERROR", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)
+
+ } catch (Exception ex) {
+ // caught exception
+ String exceptionMessage = "Bpmn error encountered in DeleteNetworkInstance, buildErrorResponse() - " + ex.getMessage()
+ utils.log("DEBUG", exceptionMessage, isDebugEnabled)
+ falloutHandlerRequest =
+ """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:ns="http://org.openecomp/mso/request/types/v1"
+ xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
+ <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <request-id>${requestId}</request-id>
+ <action>DELEtE</action>
+ <source>${source}</source>
+ </request-info>
+ <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
+ <aetgt:ErrorMessage>${exceptionMessage}</aetgt:ErrorMessage>
+ <aetgt:ErrorCode>9999</aetgt:ErrorCode>
+ </aetgt:WorkflowException>
+ </aetgt:FalloutHandlerRequest>"""
+ execution.setVariable(Prefix + "FalloutHandlerRequest", falloutHandlerRequest)
+ utils.log("DEBUG", " Overall Error Response going to FalloutHandler: " + "\n" + falloutHandlerRequest, isDebugEnabled)
+ }
+ }
+
+
+ public void sendSyncError (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('<?xml version="1.0" encoding="UTF-8"?>', "")
String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
@@ -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 =
""" <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<vpn-binding xmlns="${schemaVersion}">
@@ -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('<?xml version="1.0" encoding="UTF-8"?>', "")
String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
@@ -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 =
""" <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<network-policy xmlns="${schemaVersion}">
@@ -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('<?xml version="1.0" encoding="UTF-8"?>', "")
String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
@@ -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 =
""" <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<route-table-references xmlns="${schemaVersion}">
@@ -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 =
"""<service-instance xmlns=\"${namespace}\">
<service-instance-name>${serviceInstanceName}</service-instance-name>
- <orchestration-status>active</orchestration-status>
- <persona-model-id>${personaModelId}</persona-model-id>
- <persona-model-version>${personaModelVersion}</persona-model-version>
+ <orchestration-status>Active</orchestration-status>
+ <model-invariant-id>${modelInvariantId}</model-invariant-id>
+ <model-version-id>${modelVersionId}</model-version-id>
</service-instance>""".trim()
execution.setVariable("serviceInstanceData", serviceInstanceData)
@@ -362,9 +362,9 @@ public class DoCreateServiceInstance extends AbstractServiceTaskProcessor {
}
String sdncAssignRequest =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
@@ -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 {
<sdncadapter:SvcAction>query</sdncadapter:SvcAction>
<sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
<sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
- <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
+ <sdncadapter:MsoAction>${msoAction}</sdncadapter:MsoAction>
</sdncadapter:RequestHeader>
<sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
</sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
@@ -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 =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
@@ -1057,14 +1065,14 @@ public class DoCreateVfModule extends VfModuleBase {
else {
sdncRequest =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
<sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation>
<sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
<sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
</sdncadapter:RequestHeader>
@@ -1081,10 +1089,7 @@ public class DoCreateVfModule extends VfModuleBase {
${serviceEcompModelInformation}
<service-instance-id>${svcInstId}</service-instance-id>
<global-customer-id>${globalSubscriberId}</global-customer-id>
- </service-information>
- <vnf-request-information>
- <vnf-type>${vfModuleModelName}</vnf-type>
- </vnf-request-information>
+ </service-information>
<vnf-information>
<vnf-id>${vnfId}</vnf-id>
<vnf-type>${vnfType}</vnf-type>
@@ -1095,11 +1100,10 @@ public class DoCreateVfModule extends VfModuleBase {
<vf-module-type>${vfModuleModelName}</vf-module-type>
${vfModuleEcompModelInformation}
</vf-module-information>
- <vf-module-request-input>
- <request-version>${sdncVersion}</request-version>
+ <vf-module-request-input>
<vf-module-name>${vfModuleName}</vf-module-name>
<tenant>${tenantId}</tenant>
- <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
+ <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
${sdncVNFParamsXml}
</vf-module-request-input>
</sdncadapterworkflow:SDNCRequestData>
@@ -1108,9 +1112,9 @@ public class DoCreateVfModule extends VfModuleBase {
/*
sdncRequest =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
@@ -1142,8 +1146,7 @@ public class DoCreateVfModule extends VfModuleBase {
<vf-module-type>${vfModuleModelName}</vf-module-type>
${vfModuleEcompModelInformation}
</vf-module-information>
- <vf-module-request-input>
- <request-version>${sdncVersion}</request-version>
+ <vf-module-request-input>
<vf-module-name>${vfModuleName}</vf-module-name>
<tenant>${tenantId}</tenant>
<aic-cloud-region>${cloudSiteId}</aic-cloud-region>
@@ -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 = """<network-policy xmlns="${aaiNamespace}">
<network-policy-id>${networkPolicyId}</network-policy-id>
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 = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ String request = """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
<sdncadapter:RequestHeader>
<sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
<sdncadapter:SvcInstanceId>${vfModuleId}</sdncadapter:SvcInstanceId>
@@ -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 =
"""<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>CREATE</action>
- <source>${source}</source>
- </request-info>"""
-
- execution.setVariable("DoCVNF_requestInfo", requestInfo)
- //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
- String orchStatus = "Created"
- execution.setVariable("DoCVNF_orchStatus", orchStatus)
-
- //TODO: Equipment Role - Should come from SDN-C Response in 1702
- String equipmentRole = " "
- execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
- String vnfId = execution.getVariable("testVnfId") // for junits
- if(isBlank(vnfId)){
- vnfId = execution.getVariable("vnfId")
- if (isBlank(vnfId)) {
- vnfId = UUID.randomUUID().toString()
- utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled)
- }
- }
- execution.setVariable("DoCVNF_vnfId", vnfId)
-
- // Setting for Sub Flow Calls
- execution.setVariable("DoCVNF_type", "generic-vnf")
- execution.setVariable("GENGS_type", "service-instance")
-
- String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
- if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
- def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
- logError(msg)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
- execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
- 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 =
- """<generic-vnf xmlns="${namespace}">
- <vnf-id>${vnfId}</vnf-id>
- <vnf-name>${vnfName}</vnf-name>
- <service-id>${serviceId}</service-id>
- <vnf-type>${vnfType}</vnf-type>
- <prov-status>PREPROV</prov-status>
- <orchestration-status>${orchStatus}</orchestration-status>
- <persona-model-id>${modelInvariantId}</persona-model-id>
- <persona-model-version>${modelVersion}</persona-model-version>
- <persona-model-customization-id>${modelCustomizationId}</persona-model-customization-id>
- <relationship-list>
- <relationship>
- <related-to>service-instance</related-to>
- <related-link>${siRelatedLink}</related-link>
- <relationship-data>
- <relationship-key>customer.global-customer-id</relationship-key>
- <relationship-value>${globalCustId}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-subscription.service-type</relationship-key>
- <relationship-value>${serviceType}</relationship-value>
- </relationship-data>
- <relationship-data>
- <relationship-key>service-instance.service-instance-id</relationship-key>
- <relationship-value>${serviceInstanceId}</relationship-value>
- </relationship-data>
- </relationship>
- </relationship-list>
- </generic-vnf>"""
-
- execution.setVariable("DoCVNF_genericVnfPayload", payload)
-
- }catch(Exception ex) {
- utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process")
- }
- utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled)
- }
-
- public void postProcessCreateGenericVnf (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){
+ <request-id>${requestId}</request-id>
+ <action>CREATE</action>
+ <source>${source}</source>
+ </request-info>"""
+
+ execution.setVariable("DoCVNF_requestInfo", requestInfo)
+ //TODO: Orch Status - TBD, will come from SDN-C Response in 1702
+ String orchStatus = "Created"
+ execution.setVariable("DoCVNF_orchStatus", orchStatus)
+
+ //TODO: Equipment Role - Should come from SDN-C Response in 1702
+ String equipmentRole = " "
+ execution.setVariable("DoCVNF_equipmentRole", equipmentRole)
+ String vnfId = execution.getVariable("testVnfId") // for junits
+ if(isBlank(vnfId)){
+ vnfId = execution.getVariable("vnfId")
+ if (isBlank(vnfId)) {
+ vnfId = UUID.randomUUID().toString()
+ utils.log("DEBUG", "Generated Vnf Id is: " + vnfId, isDebugEnabled)
+ }
+ }
+ execution.setVariable("DoCVNF_vnfId", vnfId)
+
+ // Setting for Sub Flow Calls
+ execution.setVariable("DoCVNF_type", "generic-vnf")
+ execution.setVariable("GENGS_type", "service-instance")
+
+ String sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
+ if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
+ def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
+ logError(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+ execution.setVariable("DoCVNF_sdncCallbackUrl", sdncCallbackUrl)
+ 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 =
+ """<generic-vnf xmlns="${namespace}">
+ <vnf-id>${vnfId}</vnf-id>
+ <vnf-name>${vnfName}</vnf-name>
+ <service-id>${serviceId}</service-id>
+ <vnf-type>${vnfType}</vnf-type>
+ <prov-status>PREPROV</prov-status>
+ <orchestration-status>${orchStatus}</orchestration-status>
+ <model-invariant-id>${modelInvariantId}</model-invariant-id>
+ <model-version-id>${modelVersionId}</model-version-id>
+ <model-customization-id>${modelCustomizationId}</model-customization-id>
+ <relationship-list>
+ <relationship>
+ <related-to>service-instance</related-to>
+ <related-link>${siRelatedLink}</related-link>
+ <relationship-data>
+ <relationship-key>customer.global-customer-id</relationship-key>
+ <relationship-value>${globalCustId}</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>service-subscription.service-type</relationship-key>
+ <relationship-value>${serviceType}</relationship-value>
+ </relationship-data>
+ <relationship-data>
+ <relationship-key>service-instance.service-instance-id</relationship-key>
+ <relationship-value>${serviceInstanceId}</relationship-value>
+ </relationship-data>
+ </relationship>
+ </relationship-list>
+ </generic-vnf>"""
+
+ execution.setVariable("DoCVNF_genericVnfPayload", payload)
+
+ }catch(Exception ex) {
+ utils.log("DEBUG", "Error Occured in DoCreateVnf PrepareCreateGenericVnf Process " + ex.getMessage(), isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PrepareCreateGenericVnf Process")
+ }
+ utils.log("DEBUG", "*** COMPLETED DoCreateVnf PrepareCreateGenericVnf Process ***", isDebugEnabled)
+ }
+
+ public void postProcessCreateGenericVnf (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 = """<vnf-name>${vnfName}</vnf-name>"""
+ }
+ def tenantId = execution.getVariable("DoCVNF_tenantId")
+ def source = execution.getVariable("DoCVNF_source")
+ def vnfId = execution.getVariable("DoCVNF_vnfId")
+ def cloudSiteId = execution.getVariable("DoCVNF_cloudSiteId")
+ def modelCustomizationId = execution.getVariable("DoCVNF_modelCustomizationId")
+ def serviceModelInfo = execution.getVariable("serviceModelInfo")
+ def vnfModelInfo = execution.getVariable("vnfModelInfo")
+ String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
+ String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
+ def globalSubscriberId = execution.getVariable("DoCVNF_globalSubscriberId")
+ def sdncVersion = execution.getVariable("DoCVNF_sdncVersion")
+
+ String sdncVNFParamsXml = ""
+
+ if(execution.getVariable("DoCVNF_vnfParamsExistFlag") == true){
+ sdncVNFParamsXml = buildSDNCParamsXml(execution)
+ }else{
+ sdncVNFParamsXml = ""
+ }
+
+ String sdncRequest =
"""<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
- <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <request-action>CreateVnfInstance</request-action>
- <source>${source}</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- </request-information>
- <service-information>
- <service-id>${serviceId}</service-id>
- <subscription-service-type>${serviceId}</subscription-service-type>
- ${serviceEcompModelInformation}
- <service-instance-id>${svcInstId}</service-instance-id>
- <global-customer-id>${globalSubscriberId}</global-customer-id>
- </service-information>
- <vnf-information>
- <vnf-id>${vnfId}</vnf-id>
- <vnf-type>${vnfType}</vnf-type>
- ${vnfEcompModelInformation}
- </vnf-information>
- <vnf-request-input>
- <request-version>${sdncVersion}</request-version>
- <vnf-name></vnf-name>
- <tenant>${tenantId}</tenant>
- <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
- ${sdncVNFParamsXml}
- </vnf-request-input>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
- utils.logAudit("sdncRequest: " + sdncRequest)
- return sdncRequest
- }
-
- public void validateSDNCResponse(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)
- }
-
-
-}
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <request-action>CreateVnfInstance</request-action>
+ <source>${source}</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ </request-information>
+ <service-information>
+ <service-id>${serviceId}</service-id>
+ <subscription-service-type>${serviceId}</subscription-service-type>
+ ${serviceEcompModelInformation}
+ <service-instance-id>${svcInstId}</service-instance-id>
+ <global-customer-id>${globalSubscriberId}</global-customer-id>
+ </service-information>
+ <vnf-information>
+ <vnf-id>${vnfId}</vnf-id>
+ <vnf-type>${vnfType}</vnf-type>
+ ${vnfEcompModelInformation}
+ </vnf-information>
+ <vnf-request-input>
+ ${vnfNameString}
+ <tenant>${tenantId}</tenant>
+ <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
+ ${sdncVNFParamsXml}
+ </vnf-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
+
+ utils.logAudit("sdncRequest: " + sdncRequest)
+ return sdncRequest
+ }
+
+ public void validateSDNCResponse(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("&lt;", "<")
+ data = data.replaceAll("&gt;", ">")
+ 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("&lt;", "<")
+ data = data.replaceAll("&gt;", ">")
+ utils.log("DEBUG", "responseData: " + data, isDebugLogEnabled)
+ serviceOperation = utils.getNodeText1(data, "object-path")
+ utils.log("DEBUG", "VNF with sdncVersion of 1707 or later - service operation: " + serviceOperation, isDebugLogEnabled)
+
+
+ //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
+ sleep(5000)
+
+ String SDNCGetRequest =
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>${serviceOperation}</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>vfmodule</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
+
+ utils.logAudit("SDNCGetRequest: \n" + SDNCGetRequest)
+ execution.setVariable("DoCVNF_getSDNCRequest", SDNCGetRequest)
+ utils.log("DEBUG", "Outgoing GetSDNCRequest is: \n" + SDNCGetRequest, isDebugLogEnabled)
+
+ }catch(Exception e){
+ utils.log("ERROR", "Exception Occurred Processing preProcessSDNCGetRequest. Exception is:\n" + e, isDebugLogEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
+ }
+ utils.log("DEBUG", "======== COMPLETED preProcessSDNCGetRequest Process ======== ", isDebugLogEnabled)
+ }
+
+ /**
+ * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepUpdateAAIGenericVnf(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 = """
+ <UpdateAAIGenericVnfRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ <orchestration-status>Active</orchestration-status>
+ </UpdateAAIGenericVnfRequest>
+ """
+ updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
+ execution.setVariable('DoCVNF_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
+ utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
+ logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
+
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
+ }
+ }
+
+
+
+
+}
diff --git a/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy b/bpmn/MSOInfrastructureBPMN/src/main/groovy/org/openecomp/mso/bpmn/infrastructure/scripts/DoCreateVnfAndModules.groovy
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<VnfResource> vnfs = serviceDecomposition.getServiceVnfs()
+ utils.log("DEBUG", "Read vnfs", isDebugEnabled)
+ if (vnfs == null) {
+ utils.log("DEBUG", "Error - vnfs are empty in serviceDecomposition object", isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in 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<ModuleResource> 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 =
- """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
+ """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
${rollbackData}
</NetworkAdapter:rollbackNetwork>"""
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 <class>DoDeleteServiceInstance.bpmn</class> process.
- *
- * Inputs:
- * @param - msoRequestId
- * @param - globalSubscriberId - O
- * @param - subscriptionServiceType - O
- * @param - serviceInstanceId
- * @param - serviceInstanceName - O
- * @param - serviceModelInfo - O
- * @param - productFamilyId
- * @param - 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 =
- """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <source>MSO</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- <request-action>DeleteServiceInstance</request-action>
- </request-information>
- <service-information>
- <service-id>${serviceId}</service-id>
- <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
- <ecomp-model-information>
- <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
- <model-uuid>${modelUUId}</model-uuid>
- <model-version>${modelVersion}</model-version>
- <model-name>${modelName}</model-name>
- </ecomp-model-information>
- <service-instance-id>${serviceInstanceId}</service-instance-id>
- <subscriber-name/>
- <global-customer-id>${globalSubscriberId}</global-customer-id>
- </service-information>
- <service-request-input>
- <service-instance-name>${serviceInstanceName}</service-instance-name>
- </service-request-input>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
-
- 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 <class>DoDeleteServiceInstance.bpmn</class> process.
+ *
+ * Inputs:
+ * @param - msoRequestId
+ * @param - globalSubscriberId - O
+ * @param - subscriptionServiceType - O
+ * @param - serviceInstanceId
+ * @param - serviceInstanceName - O
+ * @param - serviceModelInfo - O
+ * @param - productFamilyId
+ * @param - 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 =
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${sdncRequestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>delete</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>service-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <source>MSO</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ <request-action>DeleteServiceInstance</request-action>
+ </request-information>
+ <service-information>
+ <service-id>${serviceId}</service-id>
+ <subscription-service-type>${subscriptionServiceType}</subscription-service-type>
+ <ecomp-model-information>
+ <model-invariant-uuid>${modelInvariantId}</model-invariant-uuid>
+ <model-uuid>${modelUUId}</model-uuid>
+ <model-version>${modelVersion}</model-version>
+ <model-name>${modelName}</model-name>
+ </ecomp-model-information>
+ <service-instance-id>${serviceInstanceId}</service-instance-id>
+ <subscriber-name/>
+ <global-customer-id>${globalSubscriberId}</global-customer-id>
+ </service-information>
+ <service-request-input>
+ <service-instance-name>${serviceInstanceName}</service-instance-name>
+ </service-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
+
+ sdncDelete = utils.formatXml(sdncDelete)
+ def sdncRequestId2 = UUID.randomUUID().toString()
+ String sdncDeactivate = sdncDelete.replace(">delete<", ">deactivate<").replace(">${sdncRequestId}<", ">${sdncRequestId2}<")
+ execution.setVariable("sdncDelete", sdncDelete)
+ execution.setVariable("sdncDeactivate", sdncDeactivate)
+ utils.log("DEBUG","sdncDeactivate:\n" + sdncDeactivate, isDebugEnabled)
+ utils.log("DEBUG","sdncDelete:\n" + sdncDelete, isDebugEnabled)
+
+ } catch (BpmnError e) {
+ throw e;
+ } catch(Exception ex) {
+ msg = "Exception in preProcessSDNCDelete. " + ex.getMessage()
+ utils.log("DEBUG", msg, isDebugEnabled)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Exception Occured in preProcessSDNCDelete.\n" + ex.getMessage())
+ }
+ utils.log("DEBUG"," *****Exit preProcessSDNCDelete *****", isDebugEnabled)
+ }
+
+ public void postProcessSDNCDelete(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<String, String>[] vfModules = new HashMap<String,String>[]
- List<Map<String,String>> vfModulesList = new ArrayList<Map<String,String>>();
- 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<String, String> vfModuleEntry = new HashMap<String, String>()
- 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<String, String>[] vfModules = new HashMap<String,String>[]
+ def vfModulesList = new ArrayList<Map<String,String>>()
+ def vfModules = null
+ def vfModuleBaseEntry = null
+ if (response.getStatusCode() == 200) {
+ // Parse the VNF record from A&AI to find base module info
+ logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)
+ if (responseData != null) {
+ def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
+ logDebug("vModulesText: " + vfModulesText, isDebugLogEnabled)
+ if (vfModulesText != null && !vfModulesText.trim().isEmpty()) {
+ def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
+ vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
+ execution.setVariable("DDVAM_moduleCount", vfModules.size())
+ int vfModulesSize = 0
+ for (i in 0..vfModules.size()-1) {
+ def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
+
+ Map<String, String> vfModuleEntry = new HashMap<String, String>()
+ def vfModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")
+ vfModuleEntry.put("vfModuleId", vfModuleId)
+ def vfModuleName = utils.getNodeText1(vfModuleXml, "vf-module-name")
+ vfModuleEntry.put("vfModuleName", vfModuleName)
+
+ def 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 =
+ """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.openecomp/mso/request/types/v1"
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>${action}</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackURL}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <request-action>DeleteVnfInstance</request-action>
+ <source>${source}</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ </request-information>
+ <service-information>
+ <service-id/>
+ <subscription-service-type/>
+ <service-instance-id>${serviceInstanceId}</service-instance-id>
+ <global-customer-id/>
+ </service-information>
+ <vnf-information>
+ <vnf-id>${vnfId}</vnf-id>
+ <vnf-type/>
+ </vnf-information>
+ <vnf-request-input>
+ <vnf-name/>
+ <tenant>${tenantId}</tenant>
+ <aic-cloud-region>${cloudSiteId}</aic-cloud-region>
+ </vnf-request-input>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
+
+ utils.logAudit("sdncRequest: " + sdncRequest)
+ return sdncRequest
+ }
+
+ public void validateSDNCResponse(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('<?xml version="1.0" encoding="UTF-8"?>', "")
String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
@@ -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 =
""" <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<vpn-binding xmlns="${schemaVersion}">
@@ -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('<?xml version="1.0" encoding="UTF-8"?>', "")
String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
@@ -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 =
""" <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<network-policy xmlns="${schemaVersion}">
@@ -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('<?xml version="1.0" encoding="UTF-8"?>', "")
String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
@@ -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 =
""" <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
<route-table-references xmlns="${schemaVersion}">
@@ -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 = """
- <PrepareUpdateAAIVfModuleRequest>
- <vnf-id>${vnfId}</vnf-id>
- <vf-module-id>${vfModuleId}</vf-module-id>
- <orchestration-status>${orchestrationStatus}</orchestration-status>
- </PrepareUpdateAAIVfModuleRequest>
- """
- prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
- execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
- utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
- logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
- }
- }
-
- /**
- * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. 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 = """
- <sdncadapterworkflow:SDNCAdapterWorkflowRequest
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <request-action>ChangeVNFActivateRequest</request-action>
- <source>PORTAL</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- </request-information>
- <service-information>
- <service-type>${serviceId}</service-type>
- <service-instance-id>${vnfId}</service-instance-id>
- <subscriber-name>dontcare</subscriber-name>
- </service-information>
- <vnf-request-information>
- <vnf-id>${vfModuleId}</vnf-id>
- <vnf-type>${vfModuleModelName}</vnf-type>
- <vnf-name>${vfModuleName}</vnf-name>
- <generic-vnf-id>${vnfId}</generic-vnf-id>
- <generic-vnf-name>${vnfName}</generic-vnf-name>
- <generic-vnf-type>${vnfType}</generic-vnf-type>
- <tenant>${tenantId}</tenant>
- <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
- ${vnfNetworks}
- </vnf-request-information>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
- """
- sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
- execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
- utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)
- logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
- }
- }
-
- /**
- * Prepare a Request for invoking the SDNC Adapter subflow to perform
- * a VNF topology 'query' operation.
- *
- * @param execution The flow's execution instance.
- */
- public void prepSDNCTopologyQuery(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 = """
- <sdncadapterworkflow:SDNCAdapterWorkflowRequest
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
- <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
- </sdncadapter:RequestHeader>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
- """
- sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
- execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
- utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)
- logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
- }
- }
-
- /**
- * Prepare a Request for invoking the VnfAdapterRest subflow.
- *
- * @param execution The flow's execution instance.
- */
- public void prepVnfAdapterRest(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 = """
- <updateVfModuleRequest>
- <cloudSiteId>${cloudId}</cloudSiteId>
- <tenantId>${tenantId}</tenantId>
- <vnfId>${vnfId}</vnfId>
- <vfModuleId>${vfModuleId}</vfModuleId>
- <vfModuleStackId>${heatStackId}</vfModuleStackId>
- <vnfType>${vnfType}</vnfType>
- <vnfVersion>${asdcServiceModelVersion}</vnfVersion>
- <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
- <vfModuleType>${vfModuleModelName}</vfModuleType>
- <volumeGroupId>${volumeGroupId}</volumeGroupId>
- <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>
- <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>
- <skipAAI>true</skipAAI>
- <backout>${backoutOnFailure}</backout>
- <failIfExists>false</failIfExists>
- <vfModuleParams>
- ${vfModuleParams}
- </vfModuleParams>
- <msoRequest>
- <requestId>${requestId}</requestId>
- <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
- </msoRequest>
- <messageId>${messageId}</messageId>
- <notificationUrl>${notificationUrl}</notificationUrl>
- </updateVfModuleRequest>
- """
- vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
- execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
- utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
- logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
- }
- }
-
- /**
- * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
- *
- * @param execution The flow's execution instance.
- */
- public void prepUpdateAAIGenericVnf(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 = '<persona-model-id>' + personaModelId + '</persona-model-id>'
- def personaModelVersionElement = '<persona-model-version>' + personaModelVersion + '</persona-model-version>'
-
- String updateAAIGenericVnfRequest = """
- <UpdateAAIGenericVnfRequest>
- <vnf-id>${vnfId}</vnf-id>
- ${personaModelIdElement}
- ${personaModelVersionElement}
- </UpdateAAIGenericVnfRequest>
- """
- updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
- execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
- utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
- logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
- }
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
- }
- }
-
- /**
- * Prepare a Request for invoking the UpdateAAIVfModule subflow.
- *
- * @param execution The flow's execution instance.
- */
- public void prepUpdateAAIVfModule(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 = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
- }
- def personaModelIdElement = ''
- def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')
- if (personaModelId != null) {
- personaModelIdElement = '<persona-model-id>' + personaModelId + '</persona-model-id>'
- }
- def personaModelVersionElement = ''
- def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')
- if (personaModelVersion != null) {
- personaModelVersionElement = '<persona-model-version>' + personaModelVersion + '</persona-model-version>'
- }
- def contrailServiceInstanceFqdnElement = ''
- def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')
- if (contrailServiceInstanceFqdn != null) {
- contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
- }
- def personaModelCustomizationIdElement = ''
- def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
- if (modelCustomizationId != null) {
- personaModelCustomizationIdElement = '<persona-model-customization-id>' + modelCustomizationId + '</persona-model-customization-id>'
- }
-
- String updateAAIVfModuleRequest = """
- <UpdateAAIVfModuleRequest>
- <vnf-id>${vnfId}</vnf-id>
- <vf-module-id>${vfModuleId}</vf-module-id>
- <orchestration-status>${orchestrationStatus}</orchestration-status>
- ${volumeGroupIdElement}
- ${personaModelIdElement}
- ${personaModelVersionElement}
- ${contrailServiceInstanceFqdnElement}
- ${personaModelCustomizationIdElement}
- </UpdateAAIVfModuleRequest>
- """
- 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 = """
- <sdncadapterworkflow:SDNCAdapterWorkflowRequest
- xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
- <sdncadapter:RequestHeader>
- <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
- <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
- <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
- <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
- <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
- </sdncadapter:RequestHeader>
- <sdncadapterworkflow:SDNCRequestData>
- <request-information>
- <request-id>${requestId}</request-id>
- <request-action>ChangeVNFActivateRequest</request-action>
- <source>PORTAL</source>
- <notification-url/>
- <order-number/>
- <order-version/>
- </request-information>
- <service-information>
- <service-type>${serviceId}</service-type>
- <service-instance-id>${vnfId}</service-instance-id>
- <subscriber-name>dontcare</subscriber-name>
- </service-information>
- <vnf-request-information>
- <vnf-id>${vfModuleId}</vnf-id>
- <vnf-type>${vfModuleModelName}</vnf-type>
- <vnf-name>${vfModuleName}</vnf-name>
- <generic-vnf-id>${vnfId}</generic-vnf-id>
- <generic-vnf-name>${vnfName}</generic-vnf-name>
- <generic-vnf-type>${vnfType}</generic-vnf-type>
- <tenant>${tenantId}</tenant>
- <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
- </vnf-request-information>
- </sdncadapterworkflow:SDNCRequestData>
- </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
- """
- sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
- execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
- utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)
- logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)
-
-
- logDebug('Exited ' + method, isDebugLogEnabled)
- } catch (BpmnError e) {
- throw e;
- } catch (Exception e) {
- logError('Caught exception in ' + method, e)
- exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
- }
- }
-
- /**
- * Log a WorkflowException that has been created.
- *
- * @param execution The flow's execution instance.
- */
- public void handleWorkflowException(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<String,String> 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 = """
+ <PrepareUpdateAAIVfModuleRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ <vf-module-id>${vfModuleId}</vf-module-id>
+ <orchestration-status>${orchestrationStatus}</orchestration-status>
+ </PrepareUpdateAAIVfModuleRequest>
+ """
+ prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
+ execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
+ utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
+ logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow. 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 = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowRequest
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <request-action>ChangeVNFActivateRequest</request-action>
+ <source>PORTAL</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ </request-information>
+ <service-information>
+ <service-type>${serviceId}</service-type>
+ <service-instance-id>${vnfId}</service-instance-id>
+ <subscriber-name>dontcare</subscriber-name>
+ </service-information>
+ <vnf-request-information>
+ <vnf-id>${vfModuleId}</vnf-id>
+ <vnf-type>${vfModuleModelName}</vnf-type>
+ <vnf-name>${vfModuleName}</vnf-name>
+ <generic-vnf-id>${vnfId}</generic-vnf-id>
+ <generic-vnf-name>${vnfName}</generic-vnf-name>
+ <generic-vnf-type>${vnfType}</generic-vnf-type>
+ <tenant>${tenantId}</tenant>
+ <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
+ ${vnfNetworks}
+ </vnf-request-information>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
+ """
+ sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
+ execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
+ utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)
+ logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the SDNC Adapter subflow to perform
+ * a VNF topology 'query' operation.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepSDNCTopologyQuery(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 = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowRequest
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
+ </sdncadapter:RequestHeader>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
+ """
+ sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
+ execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
+ utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)
+ logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the VnfAdapterRest subflow.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepVnfAdapterRest(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<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
+
+ String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
+
+ String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
+ vfModuleId, vfModuleName, null)
+
+
+ String vnfAdapterRestRequest = """
+ <updateVfModuleRequest>
+ <cloudSiteId>${cloudId}</cloudSiteId>
+ <tenantId>${tenantId}</tenantId>
+ <vnfId>${vnfId}</vnfId>
+ <vfModuleId>${vfModuleId}</vfModuleId>
+ <vfModuleStackId>${heatStackId}</vfModuleStackId>
+ <vnfType>${vnfType}</vnfType>
+ <vnfVersion>${asdcServiceModelVersion}</vnfVersion>
+ <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
+ <vfModuleType>${vfModuleModelName}</vfModuleType>
+ <volumeGroupId>${volumeGroupId}</volumeGroupId>
+ <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>
+ <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>
+ <skipAAI>true</skipAAI>
+ <backout>${backoutOnFailure}</backout>
+ <failIfExists>false</failIfExists>
+ <vfModuleParams>
+ ${vfModuleParams}
+ </vfModuleParams>
+ <msoRequest>
+ <requestId>${requestId}</requestId>
+ <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
+ </msoRequest>
+ <messageId>${messageId}</messageId>
+ <notificationUrl>${notificationUrl}</notificationUrl>
+ </updateVfModuleRequest>
+ """
+ vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
+ execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
+ utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
+ logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepUpdateAAIGenericVnf(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 = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
+ def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
+
+ String updateAAIGenericVnfRequest = """
+ <UpdateAAIGenericVnfRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ ${personaModelIdElement}
+ ${personaModelVersionElement}
+ </UpdateAAIGenericVnfRequest>
+ """
+ updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
+ execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
+ utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
+ logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
+ }
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the UpdateAAIVfModule subflow.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepUpdateAAIVfModule(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 = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
+ }
+ def personaModelIdElement = ''
+ def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')
+ if (personaModelId != null) {
+ personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
+ }
+ def personaModelVersionElement = ''
+ def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')
+ if (personaModelVersion != null) {
+ personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
+ }
+ def contrailServiceInstanceFqdnElement = ''
+ def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')
+ if (contrailServiceInstanceFqdn != null) {
+ contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
+ }
+ def personaModelCustomizationIdElement = ''
+ def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
+ if (modelCustomizationId != null) {
+ personaModelCustomizationIdElement = '<persona-model-customization-id>' + modelCustomizationId + '</persona-model-customization-id>'
+ }
+
+ String updateAAIVfModuleRequest = """
+ <UpdateAAIVfModuleRequest>
+ <vnf-id>${vnfId}</vnf-id>
+ <vf-module-id>${vfModuleId}</vf-module-id>
+ <orchestration-status>${orchestrationStatus}</orchestration-status>
+ ${volumeGroupIdElement}
+ ${personaModelIdElement}
+ ${personaModelVersionElement}
+ ${contrailServiceInstanceFqdnElement}
+ ${personaModelCustomizationIdElement}
+ </UpdateAAIVfModuleRequest>
+ """
+
+ logDebug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest, isDebugLogEnabled)
+ updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
+ execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
+ utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
+ logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled)
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Prepare a Request for invoking the SDNC Adapter subflow to perform
+ * a VNF topology 'activate' operation.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void prepSDNCTopologyAct(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 = """
+ <sdncadapterworkflow:SDNCAdapterWorkflowRequest
+ xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
+ <sdncadapter:RequestHeader>
+ <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
+ <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
+ <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
+ <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
+ <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
+ </sdncadapter:RequestHeader>
+ <sdncadapterworkflow:SDNCRequestData>
+ <request-information>
+ <request-id>${requestId}</request-id>
+ <request-action>ChangeVNFActivateRequest</request-action>
+ <source>PORTAL</source>
+ <notification-url/>
+ <order-number/>
+ <order-version/>
+ </request-information>
+ <service-information>
+ <service-type>${serviceId}</service-type>
+ <service-instance-id>${vnfId}</service-instance-id>
+ <subscriber-name>dontcare</subscriber-name>
+ </service-information>
+ <vnf-request-information>
+ <vnf-id>${vfModuleId}</vnf-id>
+ <vnf-type>${vfModuleModelName}</vnf-type>
+ <vnf-name>${vfModuleName}</vnf-name>
+ <generic-vnf-id>${vnfId}</generic-vnf-id>
+ <generic-vnf-name>${vnfName}</generic-vnf-name>
+ <generic-vnf-type>${vnfType}</generic-vnf-type>
+ <tenant>${tenantId}</tenant>
+ <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
+ </vnf-request-information>
+ </sdncadapterworkflow:SDNCRequestData>
+ </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
+ """
+ sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
+ execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
+ utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)
+ logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)
+
+
+ logDebug('Exited ' + method, isDebugLogEnabled)
+ } catch (BpmnError e) {
+ throw e;
+ } catch (Exception e) {
+ logError('Caught exception in ' + method, e)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
+ }
+ }
+
+ /**
+ * Log a WorkflowException that has been created.
+ *
+ * @param execution The flow's execution instance.
+ */
+ public void handleWorkflowException(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 <class>UpdateNetworkInstanceInfra.bpmn</class> 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 <class>UpdateNetworkInstanceInfra.bpmn</class> 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 <class>UpdateNetworkInstanceInfra.bpmn</class> 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 =
- """<network-outputs>
- <network-id>${netId}</network-id>
- <network-name>${netName}</network-name>
- </network-outputs>"""
- 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 =
- """<network-outputs>
- <network-id>${netId}</network-id>
- <network-name>${netName}</network-name>
- </network-outputs>"""
- 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('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
-
- // Check if Vnf Binding is present, then build a List of vnfBinding
- List vpnBindingUri = networkUtils.getVnfBindingObject(relationship)
- int vpnCount = vpnBindingUri.size()
- execution.setVariable("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 += "<routeTargets>" + routeTarget + "</routeTargets>" + '\n'
- }
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from AAINetworkVpnBinding is 404 (Not Found)."
- utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = " Unexpected Response from AAINetworkVpnBinding - " + returnCode
- utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } // end loop
-
- execution.setVariable("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 =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
- <vpn-binding xmlns="${schemaVersion}">
- <global-route-target/>
- </vpn-binding>
- </rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable("UPDNETI_queryVpnBindingAAIResponse", aaiStubResponseAsXml)
- execution.setVariable("UPDNETI_routeCollection", "<routeTargets/>")
- utils.log("DEBUG", " No vpnBinding, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled)
-
- }
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in 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('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
-
- // Check if Network Policy is present, then build a List of network policy
- List networkPolicyUriList = networkUtils.getNetworkPolicyObject(relationship)
- int networkPolicyCount = networkPolicyUriList.size()
- execution.setVariable("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 += "<policyFqdns>" + networkPolicy + "</policyFqdns>" + '\n'
- }
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkPolicy is 404 (Not Found)."
- utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkPolicy - " + returnCode
- utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } // end loop
-
- execution.setVariable("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 =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
- <network-policy xmlns="${schemaVersion}">
- <network-policy-fqdn/>
- </network-policy>
- </rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable("UPDNETI_queryNetworkPolicyAAIResponse", aaiStubResponseAsXml)
- execution.setVariable("UPDNETI_networkCollection", "<policyFqdns/>")
- utils.log("DEBUG", " No net policies, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled)
-
- }
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in 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('<?xml version="1.0" encoding="UTF-8"?>', "")
- String relationship = networkUtils.getFirstNodeXml(queryIdAAIResponse, "relationship-list").trim().replace("tag0:","").replace(":tag0","")
- utils.log("DEBUG", " relationship - " + relationship, isDebugEnabled)
-
- // Check if Network TableREf is present, then build a List of network policy
- List networkTableRefUriList = networkUtils.getNetworkTableRefObject(relationship)
- int networkTableRefCount = networkTableRefUriList.size()
- execution.setVariable("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 += "<routeTableFqdns>" + networkTableRef + "</routeTableFqdns>" + '\n'
- }
-
- } else {
- if (returnCode=='404') {
- String dataErrorMessage = "Response Error from QueryAAINetworkTableRef is 404 (Not Found)."
- utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- } else {
- if (aaiResponseAsString.contains("RESTFault")) {
- WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
- execution.setVariable("WorkflowException", exceptionObject)
- throw new BpmnError("MSOWorkflowException")
-
- } else {
- // aai all errors
- String dataErrorMessage = "Unexpected Response from QueryAAINetworkTableRef - " + returnCode
- utils.log("DEBUG", dataErrorMessage, isDebugEnabled)
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
- }
- }
-
- } // end loop
-
- execution.setVariable("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 =
- """ <rest:payload contentType="text/xml" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd">
- <route-table-references xmlns="${schemaVersion}">
- <route-table-reference-fqdn/>
- </route-table-references>
- </rest:payload>"""
- String aaiStubResponseAsXml = utils.formatXml(aaiStubResponse)
- execution.setVariable("UPDNETI_queryNetworkTableRefAAIResponse", aaiStubResponseAsXml)
- execution.setVariable("UPDNETI_tableRefCollection", "<routeTableFqdns/>")
- utils.log("DEBUG", " No net table references, using this stub as response - " + '\n' + aaiStubResponseAsXml, isDebugEnabled)
-
- }
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- String exceptionMessage = "Bpmn error encountered in 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 '<network-outputs>' ! ", 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 '<network-outputs>' ! ", isDebugEnabled)
- }
- String requestId = execution.getVariable("UPDNETI_requestId")
-
- String statusMessage = "Network successfully updated."
-
- String dbRequest =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>COMPLETED</requestStatus>
- <progress>100</progress>
- <vnfOutputs>&lt;network-id&gt;${networkId}&lt;/network-id&gt;&lt;network-name&gt;${networkName}&lt;/network-names&gt;</vnfOutputs>
- <networkId>${networkId}</networkId>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- 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 '<network-outputs>' ! ", 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 '<network-outputs>' ! ", isDebugEnabled)
- }
- String dbRequest =
- """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
- <soapenv:Header/>
- <soapenv:Body>
- <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
- <requestId>${requestId}</requestId>
- <lastModifiedBy>BPMN</lastModifiedBy>
- <statusMessage>${statusMessage}</statusMessage>
- <responseBody></responseBody>
- <requestStatus>FAILED</requestStatus>
- <vnfOutputs>&lt;network-id&gt;${networkId}&lt;/network-id&gt;&lt;network-name&gt;${networkName}&lt;/network-names&gt;</vnfOutputs>
- </ns:updateInfraRequest>
- </soapenv:Body>
- </soapenv:Envelope>"""
-
- 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 =
- """<NetworkAdapter:rollbackNetwork xmlns:NetworkAdapter="http://org.openecomp.mso/network">
- ${rollbackData}
- </NetworkAdapter:rollbackNetwork>"""
- 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('<?xml version="1.0" encoding="UTF-8" standalone="yes"?>', '')
- errorMessage = utils.getNodeText1(networkResponse, "message")
- errorMessage = "Received error from Network Adapter: " + errorMessage
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
-
- } else { // CatchAll exception
- if (returnCode == "500") {
- errorMessage = "JBWEB000065: HTTP Status 500."
- } else {
- errorMessage = "Return code is " + returnCode
- }
- errorMessage = "Received error from Network Adapter: " + errorMessage
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
-
- }
-
- } else { // CatchAll exception
- String dataErrorMessage = "Received error from Network Adapter. Return code is: " + returnCode
- exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
-
- }
-
- }
-
- } catch (BpmnError e) {
- throw e;
-
- } catch (Exception ex) {
- String exceptionMessage = " Bpmn error encountered in 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("&", "&amp;").replace('<?xml version="1.0" encoding="UTF-8"?>', "")
- 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 =
- """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:mso-bpel-name>BPMN Network action: UPDATE</aetgt:mso-bpel-name>
- </aetgt:MsoCompletionRequest>"""
-
- // 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("&", "&amp;").replace('$', '').replace('<?xml version="1.0" encoding="UTF-8"?>', "")
-
- if (rollbackSDNCReturnCode == "200") {
- if (utils.nodeExists(rollbackSDNCResponse, "response-code")) {
- rollbackSDNCReturnInnerCode = utils.getNodeText1(rollbackSDNCResponse, "response-code")
- if (rollbackSDNCReturnInnerCode == "200" || rollbackSDNCReturnInnerCode == "" || rollbackSDNCReturnInnerCode == "0") {
- rollbackSdncErrorMessages = " + SNDC 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 =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorMessage}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>${errorCode}</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- utils.logAudit(falloutHandlerRequest)
- execution.setVariable("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 =
- """<aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:ns="http://org.openecomp/mso/request/types/v1"
- xmlns:wfsch="http://org.openecomp/mso/workflow/schema/v1">
- <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
- <request-id>${requestId}</request-id>
- <action>UPDATE</action>
- <source>${source}</source>
- </request-info>
- <aetgt:WorkflowException xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1">
- <aetgt:ErrorMessage>${errorException}</aetgt:ErrorMessage>
- <aetgt:ErrorCode>7000</aetgt:ErrorCode>
- </aetgt:WorkflowException>
- </aetgt:FalloutHandlerRequest>"""
-
- execution.setVariable("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 = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:req="http://org.openecomp.mso/requestsdb">
+ xmlns:req="http://org.openecomp.mso/requestsdb">
<soapenv:Header/>
<soapenv:Body>
<req:updateInfraRequest>
@@ -255,8 +255,8 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor {
def requestInfo = getVariable(execution, 'UPDVfMod_requestInfo')
String content = """
- <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1">
+ <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:reqtype="http://org.openecomp/mso/request/types/v1">
${requestInfo}
<sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name>
</sdncadapterworkflow:MsoCompletionRequest>
@@ -304,10 +304,10 @@ public class UpdateVfModule extends AbstractServiceTaskProcessor {
}
String content = """
- <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
- xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
- xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
+ <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
+ xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
+ xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
${requestInformation}
<sdncadapterworkflow:WorkflowException>
<sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage>
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 = """
- <volume-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
+ <volume-request xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
<request-info>
<request-id>${requestId}</request-id>
<action>UPDATE_VF_MODULE_VOL</action>
@@ -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 = """
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
- xmlns:req="http://org.openecomp.mso/requestsdb">
+ xmlns:req="http://org.openecomp.mso/requestsdb">
<soapenv:Header/>
<soapenv:Body>
<req:updateInfraRequest>
@@ -340,8 +340,8 @@ class UpdateVfModuleVolume extends VfModuleBase {
def requestInfo = execution.getVariable('UPDVfModVol_requestInfo')
String content = """
- <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1">
+ <sdncadapterworkflow:MsoCompletionRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:reqtype="http://org.openecomp/mso/request/types/v1">
${requestInfo}
<sdncadapterworkflow:mso-bpel-name>MSO_ACTIVATE_BPEL</sdncadapterworkflow:mso-bpel-name>
</sdncadapterworkflow:MsoCompletionRequest>
@@ -385,10 +385,10 @@ class UpdateVfModuleVolume extends VfModuleBase {
}
String content = """
- <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
- xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
- xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
- xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
+ <sdncadapterworkflow:FalloutHandlerRequest xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
+ xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
+ xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
+ xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
${requestInfo}
<sdncadapterworkflow:WorkflowException>
<sdncadapterworkflow:ErrorMessage>${encErrorResponseMsg}</sdncadapterworkflow:ErrorMessage>