2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.infrastructure.scripts;
\r
23 import groovy.json.JsonSlurper
\r
24 import groovy.json.JsonOutput
\r
26 import javax.xml.parsers.DocumentBuilder
\r
27 import javax.xml.parsers.DocumentBuilderFactory
\r
29 import org.w3c.dom.Document
\r
30 import org.w3c.dom.Element
\r
31 import org.w3c.dom.Node
\r
32 import org.w3c.dom.NodeList
\r
33 import org.xml.sax.InputSource
\r
35 import org.camunda.bpm.engine.delegate.BpmnError
\r
36 import org.camunda.bpm.engine.delegate.DelegateExecution
\r
37 import org.onap.appc.client.lcm.model.Action
\r
38 import org.apache.commons.lang3.*
\r
39 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
\r
40 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil;
\r
41 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils;
\r
42 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils;
\r
43 import org.openecomp.mso.bpmn.common.scripts.VidUtils;
\r
44 import org.openecomp.mso.bpmn.core.RollbackData
\r
45 import org.openecomp.mso.bpmn.core.WorkflowException
\r
46 import org.openecomp.mso.bpmn.core.json.JsonUtils
\r
47 import org.openecomp.mso.bpmn.infrastructure.aai.AAICreateResources;
\r
48 import org.onap.aai.domain.yang.v12.GenericVnf;
\r
50 public class CreateVfModuleInfra extends AbstractServiceTaskProcessor {
\r
52 ExceptionUtil exceptionUtil = new ExceptionUtil()
\r
53 JsonUtils jsonUtil = new JsonUtils()
\r
55 private AbstractServiceTaskProcessor taskProcessor
\r
57 public SDNCAdapterUtils(AbstractServiceTaskProcessor taskProcessor) {
\r
58 this.taskProcessor = taskProcessor
\r
62 * Validates the request message and sets up the workflow.
\r
63 * @param execution the execution
\r
65 public void preProcessRequest(DelegateExecution execution) {
\r
66 def method = getClass().getSimpleName() + '.preProcessRequest(' +
\r
67 'execution=' + execution.getId() +
\r
69 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
70 logDebug('Entered ' + method, isDebugLogEnabled)
\r
72 execution.setVariable("CVFMI_sentSyncResponse", false)
\r
74 def prefix = 'CVFMI_'
\r
75 logDebug('Entered 1' + method, isDebugLogEnabled)
\r
76 execution.setVariable('prefix', prefix)
\r
77 logDebug('Entered 2' + method, isDebugLogEnabled)
\r
78 execution.setVariable("isVidRequest", "false")
\r
80 logDebug("Set variables", isDebugLogEnabled)
\r
82 def rollbackData = execution.getVariable("RollbackData")
\r
83 if (rollbackData == null) {
\r
84 rollbackData = new RollbackData()
\r
86 execution.setVariable("RollbackData", rollbackData)
\r
88 logDebug("Set rollback data", isDebugLogEnabled)
\r
89 def incomingRequest = execution.getVariable('bpmnRequest')
\r
91 utils.log("DEBUG", "Incoming Infra Request: " + incomingRequest, isDebugLogEnabled)
\r
92 utils.logAudit("CreateVfModule Infra incoming Request: " + incomingRequest)
\r
94 setBasicDBAuthHeader(execution, isDebugLogEnabled)
\r
96 // check if request is xml or json
\r
98 def jsonSlurper = new JsonSlurper()
\r
99 def jsonOutput = new JsonOutput()
\r
100 Map reqMap = jsonSlurper.parseText(incomingRequest)
\r
101 utils.log("DEBUG", " Request is in JSON format.", isDebugLogEnabled)
\r
103 def serviceInstanceId = execution.getVariable('serviceInstanceId')
\r
104 def vnfId = execution.getVariable('vnfId')
\r
106 execution.setVariable(prefix + 'serviceInstanceId', serviceInstanceId)
\r
107 execution.setVariable(prefix+'vnfId', vnfId)
\r
108 execution.setVariable("isVidRequest", "true")
\r
111 def asdcServiceModelVersion = ''
\r
112 def serviceModelInfo = null
\r
113 def vnfModelInfo = null
\r
115 def relatedInstanceList = reqMap.requestDetails?.relatedInstanceList
\r
117 if (relatedInstanceList != null) {
\r
118 relatedInstanceList.each {
\r
119 if (it.relatedInstance.modelInfo?.modelType == 'service') {
\r
120 asdcServiceModelVersion = it.relatedInstance.modelInfo?.modelVersion
\r
121 serviceModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
\r
124 if (it.relatedInstance.modelInfo.modelType == 'vnf') {
\r
125 vnfName = it.relatedInstance.instanceName ?: ''
\r
126 vnfModelInfo = jsonOutput.toJson(it.relatedInstance.modelInfo)
\r
131 execution.setVariable(prefix + 'vnfName', vnfName)
\r
132 execution.setVariable(prefix + 'asdcServiceModelVersion', asdcServiceModelVersion)
\r
133 execution.setVariable(prefix + 'serviceModelInfo', serviceModelInfo)
\r
134 execution.setVariable(prefix + 'vnfModelInfo', vnfModelInfo)
\r
137 def vnfType = execution.getVariable('vnfType')
\r
138 execution.setVariable(prefix + 'vnfType', vnfType)
\r
139 def vfModuleId = execution.getVariable('vfModuleId')
\r
140 execution.setVariable(prefix + 'vfModuleId', vfModuleId)
\r
141 def volumeGroupId = execution.getVariable('volumeGroupId')
\r
142 execution.setVariable(prefix + 'volumeGroupId', volumeGroupId)
\r
143 def userParams = reqMap.requestDetails?.requestParameters?.userParams
\r
145 Map<String, String> userParamsMap = [:]
\r
146 if (userParams != null) {
\r
147 userParams.each { userParam ->
\r
148 userParamsMap.put(userParam.name, jsonOutput.toJson(userParam.value).toString())
\r
152 utils.log("DEBUG", 'Processed user params: ' + userParamsMap, isDebugLogEnabled)
\r
154 execution.setVariable(prefix + 'vfModuleInputParams', userParamsMap)
\r
156 def isBaseVfModule = "false"
\r
157 if (execution.getVariable('isBaseVfModule') == true) {
\r
158 isBaseVfModule = "true"
\r
161 execution.setVariable(prefix + 'isBaseVfModule', isBaseVfModule)
\r
163 def requestId = execution.getVariable("mso-request-id")
\r
164 execution.setVariable(prefix + 'requestId', requestId)
\r
166 def vfModuleModelInfo = jsonOutput.toJson(reqMap.requestDetails?.modelInfo)
\r
167 execution.setVariable(prefix + 'vfModuleModelInfo', vfModuleModelInfo)
\r
169 def suppressRollback = reqMap.requestDetails?.requestInfo?.suppressRollback
\r
172 def backoutOnFailure = ""
\r
173 if(suppressRollback != null){
\r
174 if ( suppressRollback == true) {
\r
175 backoutOnFailure = "false"
\r
176 } else if ( suppressRollback == false) {
\r
177 backoutOnFailure = "true"
\r
181 execution.setVariable('disableRollback', suppressRollback)
\r
183 def vfModuleName = reqMap.requestDetails?.requestInfo?.instanceName ?: null
\r
184 execution.setVariable(prefix + 'vfModuleName', vfModuleName)
\r
186 def serviceId = reqMap.requestDetails?.requestParameters?.serviceId ?: ''
\r
187 execution.setVariable(prefix + 'serviceId', serviceId)
\r
189 def usePreload = reqMap.requestDetails?.requestParameters?.usePreload
\r
190 execution.setVariable(prefix + 'usePreload', usePreload)
\r
192 // This is aLaCarte flow, so aLaCarte flag is always on
\r
193 execution.setVariable(prefix + 'aLaCarte', true)
\r
195 def cloudConfiguration = reqMap.requestDetails?.cloudConfiguration
\r
196 def lcpCloudRegionId = cloudConfiguration.lcpCloudRegionId
\r
197 execution.setVariable(prefix + 'lcpCloudRegionId', lcpCloudRegionId)
\r
198 def tenantId = cloudConfiguration.tenantId
\r
199 execution.setVariable(prefix + 'tenantId', tenantId)
\r
201 def globalSubscriberId = reqMap.requestDetails?.subscriberInfo?.globalSubscriberId ?: ''
\r
202 execution.setVariable(prefix + 'globalSubscriberId', globalSubscriberId)
\r
204 execution.setVariable(prefix + 'sdncVersion', '1702')
\r
206 execution.setVariable("CreateVfModuleInfraSuccessIndicator", false)
\r
207 execution.setVariable("RollbackCompleted", false)
\r
209 execution.setVariable("isDebugLogEnabled", isDebugLogEnabled)
\r
212 def source = reqMap.requestDetails?.requestInfo?.source
\r
213 execution.setVariable("CVFMI_source", source)
\r
215 //For Completion Handler & Fallout Handler
\r
216 String requestInfo =
\r
217 """<request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
218 <request-id>${requestId}</request-id>
\r
219 <action>CREATE</action>
\r
220 <source>${source}</source>
\r
223 execution.setVariable("CVFMI_requestInfo", requestInfo)
\r
227 execution.setVariable("CVFMI_originalWorkflowException", null)
\r
230 def newVfModuleId = UUID.randomUUID().toString()
\r
231 execution.setVariable("newVfModuleId", newVfModuleId)
\r
232 execution.setVariable(prefix + 'vfModuleId', newVfModuleId)
\r
233 execution.setVariable('actionHealthCheck', Action.HealthCheck)
\r
234 execution.setVariable('actionConfigScaleOut', Action.ConfigScaleOut)
\r
235 execution.setVariable('controllerType', "APPC")
\r
236 def controllerType = execution.getVariable('controllerType')
\r
237 execution.setVariable(prefix + 'controllerType', controllerType)
\r
238 execution.setVariable('healthCheckIndex0', 0)
\r
240 logDebug('RequestInfo: ' + execution.getVariable("CVFMI_requestInfo"), isDebugLogEnabled)
\r
242 logDebug('rollbackEnabled: ' + execution.getVariable("CVFMI_rollbackEnabled"), isDebugLogEnabled)
\r
244 logDebug('Exited ' + method, isDebugLogEnabled)
\r
245 } catch (BpmnError bpmnError) {
\r
248 catch(groovy.json.JsonException je) {
\r
249 utils.log("DEBUG", " Request is not in JSON format.", isDebugLogEnabled)
\r
250 exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
\r
252 catch(Exception e) {
\r
253 String restFaultMessage = e.getMessage()
\r
254 //execution.setVariable("CVFMODVOL2_RESTFault", restFaultMessage)
\r
255 //execution.setVariable("CVFMODVOL2_isDataOk", false)
\r
256 utils.log("ERROR", " Exception Encountered - " + "\n" + restFaultMessage, isDebugLogEnabled)
\r
257 exceptionUtil.buildAndThrowWorkflowException(execution, 400, "Internal Error - During PreProcessRequest")
\r
263 * Validates a workflow response.
\r
264 * @param execution the execution
\r
265 * @param responseVar the execution variable in which the response is stored
\r
266 * @param responseCodeVar the execution variable in which the response code is stored
\r
267 * @param errorResponseVar the execution variable in which the error response is stored
\r
269 public void validateWorkflowResponse(DelegateExecution execution, String responseVar,
\r
270 String responseCodeVar, String errorResponseVar) {
\r
271 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
\r
272 sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
\r
277 * Sends the empty, synchronous response back to the API Handler.
\r
278 * @param execution the execution
\r
280 public void sendResponse(DelegateExecution execution) {
\r
281 def method = getClass().getSimpleName() + '.sendResponse(' +
\r
282 'execution=' + execution.getId() +
\r
284 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
285 logDebug('Entered ' + method, isDebugLogEnabled)
\r
288 def requestInfo = execution.getVariable('CVFMI_requestInfo')
\r
289 def requestId = execution.getVariable('CVFMI_requestId')
\r
290 def source = execution.getVariable('CVFMI_source')
\r
292 // RESTResponse (for API Handler (APIH) Reply Task)
\r
293 def newVfModuleId = execution.getVariable("newVfModuleId")
\r
294 String synchResponse = """{"requestReferences":{"instanceId":"${newVfModuleId}","requestId":"${requestId}"}}""".trim()
\r
296 sendWorkflowResponse(execution, 200, synchResponse)
\r
298 execution.setVariable("CVFMI_sentSyncResponse", true)
\r
299 utils.logAudit("CreateVfModule Infra Response: " + synchResponse)
\r
300 logDebug('Exited ' + method, isDebugLogEnabled)
\r
301 } catch (BpmnError e) {
\r
303 } catch (Exception e) {
\r
304 logError('Caught exception in ' + method, e)
\r
305 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in sendResponse(): ' + e.getMessage())
\r
310 * Query AAI for vnf orchestration status to determine if health check and config scaling should be run
\r
312 public void queryAAIForVnfOrchestrationStatus(DelegateExecution execution) {
\r
313 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
314 def vnfId = execution.getVariable("CVFMI_vnfId")
\r
315 execution.setVariable("runHealthCheck", false);
\r
316 execution.setVariable("runConfigScaleOut", false);
\r
317 AAICreateResources aaiCreateResources = new AAICreateResources();
\r
318 Optional<GenericVnf> vnf = aaiCreateResources.getVnfInstance(vnfId);
\r
319 if(vnf.isPresent()){
\r
320 def vnfOrchestrationStatus = vnf.get().getOrchestrationStatus();
\r
321 if("active".equalsIgnoreCase(vnfOrchestrationStatus)){
\r
322 execution.setVariable("runHealthCheck", false);
\r
323 execution.setVariable("runConfigScaleOut", true);
\r
329 * Retrieve data for ConfigScaleOut from SDNC topology
\r
332 public void retreiveConfigScaleOutData(DelegateExecution execution){
\r
333 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
334 def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
\r
335 String ipAddress = "";
\r
336 String oamIpAddress = "";
\r
337 String vnfHostIpAddress = "";
\r
339 String vnfGetSDNC = execution.getVariable("DCVFM_getSDNCAdapterResponse");
\r
341 String data = utils.getNodeXml(vnfGetSDNC, "response-data")
\r
342 data = data.replaceAll("<", "<")
\r
343 data = data.replaceAll(">", ">")
\r
345 InputSource source = new InputSource(new StringReader(data));
\r
346 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
\r
347 docFactory.setNamespaceAware(true)
\r
348 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
\r
349 Document responseXml = docBuilder.parse(source)
\r
351 NodeList paramsList = responseXml.getElementsByTagNameNS("*", "vnf-parameters")
\r
352 for (int z = 0; z < paramsList.getLength(); z++) {
\r
353 Node node = paramsList.item(z)
\r
354 Element eElement = (Element) node
\r
355 String vnfParameterName = utils.getElementText(eElement, "vnf-parameter-name")
\r
356 String vnfParameterValue = utils.getElementText(eElement, "vnf-parameter-value")
\r
357 if (vnfParameterName.equals("vlb_private_ip_1")) {
\r
358 vnfHostIpAddress = vnfParameterValue
\r
360 else if (vnfParameterName.equals("vdns_private_ip_0")) {
\r
361 ipAddress = vnfParameterValue
\r
363 else if (vnfParameterName.equals("vdns_private_ip_1")) {
\r
364 oamIpAddress = vnfParameterValue
\r
368 String payload = "{\"request-parameters\":{\"vnf-host-ip-address\":\"" + vnfHostIpAddress + "\",\"vf-module-id\":\"" + vfModuleId + "\"},\"configuration-parameters\":{\"ip-addr\":\"" + ipAddress +"\", \"oam-ip-addr\":\""+ oamIpAddress +"\",\"enabled\":\"true\"}}"
\r
369 execution.setVariable("payload", payload);
\r
374 * @param execution the execution
\r
376 public void postProcessResponse(DelegateExecution execution){
\r
377 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
379 utils.log("DEBUG", " ======== STARTED PostProcessResponse Process ======== ", isDebugEnabled)
\r
381 def requestInfo = execution.getVariable("CVFMI_requestInfo")
\r
382 def action = utils.getNodeText1(requestInfo, "action")
\r
384 utils.log("DEBUG", "requestInfo is: " + requestInfo, isDebugEnabled)
\r
385 utils.log("DEBUG", "action is: " + action, isDebugEnabled)
\r
388 """ <aetgt:MsoCompletionRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
389 xmlns:ns="http://org.openecomp/mso/request/types/v1"
\r
390 xmlns:ns8="http://org.openecomp/mso/workflow/schema/v1">
\r
391 <request-info xmlns="http://org.openecomp/mso/infra/vnf-request/v1">
\r
394 <ns8:status-message>Vf Module has been created successfully.</ns8:status-message>
\r
395 <ns8:mso-bpel-name>BPMN</ns8:mso-bpel-name>
\r
396 </aetgt:MsoCompletionRequest>"""
\r
398 payload = utils.formatXml(payload)
\r
399 execution.setVariable("CVFMI_SuccessFlag", true)
\r
400 execution.setVariable("CVFMI_msoCompletionRequest", payload)
\r
401 utils.logAudit("CreateVfModuleInfra completion request: " + payload)
\r
402 utils.log("DEBUG", "Outgoing MsoCompletionRequest: \n" + payload, isDebugEnabled)
\r
404 }catch(Exception e){
\r
405 utils.log("ERROR", "Exception Occured Processing PostProcessResponse. Exception is:\n" + e, isDebugEnabled)
\r
406 execution.setVariable("CVFMI_ErrorResponse", "Error Occured during PostProcessResponse Method:\n" + e.getMessage())
\r
408 utils.log("DEBUG", "======== COMPLETED PostProcessResponse Process ======== ", isDebugEnabled)
\r
416 * Validates the request, request id and service instance id. If a problem is found,
\r
417 * a WorkflowException is generated and an MSOWorkflowException event is thrown. This
\r
418 * method also sets up the log context for the workflow.
\r
419 * @param execution the execution
\r
420 * @return the validated request
\r
422 public String validateInfraRequest(DelegateExecution execution) {
\r
423 def method = getClass().getSimpleName() + '.validateInfraRequest(' +
\r
424 'execution=' + execution.getId() +
\r
426 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
427 logDebug('Entered ' + method, isDebugLogEnabled)
\r
429 String processKey = getProcessKey(execution);
\r
430 def prefix = execution.getVariable("prefix")
\r
432 if (prefix == null) {
\r
433 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null")
\r
437 def request = execution.getVariable(prefix + 'Request')
\r
439 if (request == null) {
\r
440 request = execution.getVariable(processKey + 'Request')
\r
442 if (request == null) {
\r
443 request = execution.getVariable('bpmnRequest')
\r
446 setVariable(execution, processKey + 'Request', null);
\r
447 setVariable(execution, 'bpmnRequest', null);
\r
448 setVariable(execution, prefix + 'Request', request);
\r
451 if (request == null) {
\r
452 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null")
\r
457 def requestId = execution.getVariable("mso-request-id")
\r
459 if (requestId == null) {
\r
460 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id")
\r
463 setVariable(execution, prefix + 'requestId', requestId)
\r
465 def serviceInstanceId = execution.getVariable("mso-service-instance-id")
\r
467 if (serviceInstanceId == null) {
\r
468 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id")
\r
471 utils.logContext(requestId, serviceInstanceId)
\r
473 utils.logAudit("CreateVfModule incoming request: " + request)
\r
474 logDebug('Incoming message: ' + System.lineSeparator() + request, isDebugLogEnabled)
\r
475 logDebug('Exited ' + method, isDebugLogEnabled)
\r
477 } catch (BpmnError e) {
\r
479 } catch (Exception e) {
\r
480 logError('Caught exception in ' + method, e)
\r
481 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
\r
485 public void prepareUpdateInfraRequest(DelegateExecution execution){
\r
486 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
488 utils.log("DEBUG", " ======== STARTED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
\r
492 String requestInfo = execution.getVariable("CVFMI_requestInfo")
\r
493 def aicCloudRegion = execution.getVariable("CVFMI_lcpCloudRegionId")
\r
494 def tenantId = execution.getVariable("CVFMI_tenantId")
\r
495 def requestId = utils.getNodeText1(requestInfo, "request-id")
\r
496 def vnfId = execution.getVariable("CVFMI_vnfId")
\r
497 def vfModuleId = execution.getVariable("CVFMI_vfModuleId")
\r
498 // vfModuleName may be generated by DoCreateVfModule subprocess if it is not specified on the input
\r
499 def vfModuleName = execution.getVariable("CVFMI_vfModuleName")
\r
501 def dbAdapterEndpoint = execution.getVariable("URN_mso_adapters_openecomp_db_endpoint")
\r
502 execution.setVariable("CVFMI_dbAdapterEndpoint", dbAdapterEndpoint)
\r
503 utils.log("DEBUG", "DB Adapter Endpoint is: " + dbAdapterEndpoint, isDebugEnabled)
\r
506 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
\r
507 xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
510 <ns:updateInfraRequest xmlns:ns="http://org.openecomp.mso/requestsdb">
\r
511 <requestId>${requestId}</requestId>
\r
512 <lastModifiedBy>BPMN</lastModifiedBy>
\r
513 <statusMessage>VF Module successfully created</statusMessage>
\r
514 <responseBody></responseBody>
\r
515 <requestStatus>COMPLETE</requestStatus>
\r
516 <progress>100</progress>
\r
517 <vnfOutputs><vnf-outputs xmlns="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:aetgt="http://org.openecomp/mso/infra/vnf-request/v1" xmlns:rest="http://schemas.activebpel.org/REST/2007/12/01/aeREST.xsd"><vnf-id>${vnfId}</vnf-id><vf-module-id>${vfModuleId}</vf-module-id></vnf-outputs></vnfOutputs>
\r
518 <vfModuleId>${vfModuleId}</vfModuleId>
\r
519 <vfModuleName>${vfModuleName}</vfModuleName>
\r
520 </ns:updateInfraRequest>
\r
522 </soapenv:Envelope>"""
\r
524 payload = utils.formatXml(payload)
\r
525 execution.setVariable("CVFMI_updateInfraRequest", payload)
\r
526 utils.log("DEBUG", "Outgoing UpdateInfraRequest: \n" + payload, isDebugEnabled)
\r
527 utils.logAudit("CreateVfModuleInfra Outgoing UpdateInfra Request: " + payload)
\r
529 }catch(Exception e){
\r
530 utils.log("ERROR", "Exception Occured Processing prepareUpdateInfraRequest. Exception is:\n" + e, isDebugEnabled)
\r
531 execution.setVariable("CVFMI_ErrorResponse", "Error Occurred during prepareUpdateInfraRequest Method:\n" + e.getMessage())
\r
533 utils.log("DEBUG", "======== COMPLETED prepareUpdateInfraRequest Process ======== ", isDebugEnabled)
\r
537 * Builds a "FalloutHandler" request and stores it in the specified execution variable.
\r
539 * @param execution the execution
\r
540 * @param resultVar the execution variable in which the result will be stored
\r
542 public void falloutHandlerPrep(DelegateExecution execution, String resultVar) {
\r
543 def method = getClass().getSimpleName() + '.falloutHandlerPrep(' +
\r
544 'execution=' + execution.getId() +
\r
545 ', resultVar=' + resultVar +
\r
547 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
548 logDebug('Entered ' + method, isDebugLogEnabled)
\r
552 def WorkflowException workflowException = execution.getVariable("WorkflowException")
\r
553 def requestInformation = execution.getVariable("CVFMI_requestInfo")
\r
554 def errorResponseCode = workflowException.getErrorCode()
\r
555 def errorResponseMsg = workflowException.getErrorMessage()
\r
556 def encErrorResponseMsg = ""
\r
557 if (errorResponseMsg != null) {
\r
558 encErrorResponseMsg = errorResponseMsg.replace("&", "&").replace("<", "<").replace(">", ">")
\r
561 String content = """
\r
562 <aetgt:FalloutHandlerRequest xmlns:aetgt="http://org.openecomp/mso/workflow/schema/v1"
\r
563 xmlns:reqtype="http://org.openecomp/mso/request/types/v1"
\r
564 xmlns:msoservtypes="http://org.openecomp/mso/request/types/v1"
\r
565 xmlns:structuredtypes="http://org.openecomp/mso/structured/types/v1">
\r
566 ${requestInformation}
\r
567 <aetgt:WorkflowException>
\r
568 <aetgt:ErrorMessage>${encErrorResponseMsg}</aetgt:ErrorMessage>
\r
569 <aetgt:ErrorCode>${errorResponseCode}</aetgt:ErrorCode>
\r
570 </aetgt:WorkflowException>
\r
571 </aetgt:FalloutHandlerRequest>
\r
574 logDebug("CONTENT before translation: " + content, isDebugLogEnabled)
\r
575 content = utils.formatXml(content)
\r
576 logDebug(resultVar + ' = ' + System.lineSeparator() + content, isDebugLogEnabled)
\r
577 utils.logAudit("CreateVfModuleInfra FallOutHander Request: " + content)
\r
578 execution.setVariable(resultVar, content)
\r
580 logDebug('Exited ' + method, isDebugLogEnabled)
\r
581 } catch (BpmnError e) {
\r
583 } catch (Exception e) {
\r
584 logError('Caught exception in ' + method, e)
\r
585 exceptionUtil.buildWorkflowException(execution, 2000, 'Internal Error')
\r
589 public void logAndSaveOriginalException(DelegateExecution execution) {
\r
590 def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
\r
591 'execution=' + execution.getId() +
\r
593 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
594 logDebug('Entered ' + method, isDebugLogEnabled)
\r
596 logWorkflowException(execution, 'CreateVfModuleInfra caught an event')
\r
597 saveWorkflowException(execution, 'CVFMI_originalWorkflowException')
\r
600 public void validateRollbackResponse(DelegateExecution execution) {
\r
601 def method = getClass().getSimpleName() + '.validateRollbackResponse(' +
\r
602 'execution=' + execution.getId() +
\r
604 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
605 logDebug('Entered ' + method, isDebugLogEnabled)
\r
607 def originalException = execution.getVariable("CVFMI_originalWorkflowException")
\r
608 execution.setVariable("WorkflowException", originalException)
\r
610 execution.setVariable("RollbackCompleted", true)
\r
614 public void sendErrorResponse(DelegateExecution execution){
\r
615 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
\r
617 utils.log("DEBUG", " *** STARTED CreateVfModulenfra sendErrorResponse Process *** ", isDebugEnabled)
\r
619 def sentSyncResponse = execution.getVariable("CVFMI_sentSyncResponse")
\r
620 if(sentSyncResponse == false){
\r
621 WorkflowException wfex = execution.getVariable("WorkflowException")
\r
622 String response = exceptionUtil.buildErrorResponseXml(wfex)
\r
624 utils.logAudit(response)
\r
625 sendWorkflowResponse(execution, 500, response)
\r
627 utils.log("DEBUG", "Not Sending Error Response. Sync Response Already Sent", isDebugEnabled)
\r
630 } catch (Exception ex) {
\r
631 utils.log("DEBUG", "Error Occured in CreateVfModuleInfra sendErrorResponse Process " + ex.getMessage(), isDebugEnabled)
\r
632 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in CreateVfModuleInfra sendErrorResponse Process")
\r
635 utils.log("DEBUG", "*** COMPLETED CreateVfModuleInfra sendErrorResponse Process ***", isDebugEnabled)
\r