2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package com.att.bpm.scripts
23 import static org.camunda.spin.Spin.XML;
24 import groovy.json.JsonSlurper
25 import groovy.lang.GroovyInterceptable;
26 import groovy.xml.XmlUtil
27 import org.springframework.web.util.UriUtils
29 import org.openecomp.mso.rest.APIResponse
30 import org.openecomp.mso.rest.RESTClient
31 import org.openecomp.mso.rest.RESTConfig
32 import org.openecomp.mso.bpmn.core.WorkflowException
34 import java.util.UUID;
36 import org.camunda.bpm.engine.delegate.BpmnError
37 import org.camunda.bpm.engine.runtime.Execution
38 import org.apache.commons.lang3.*
39 import org.apache.commons.codec.binary.Base64;
41 class DoCreateVfModuleVolumeV1 extends VfModuleBase {
43 String prefix='DCVFMODVOLV1_'
47 * Perform initial processing, such as request validation, initialization of variables, etc.
50 public void preProcessRequest (Execution execution) {
51 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
52 preProcessRequest(execution, isDebugEnabled)
56 * Perform initial processing, such as request validation, initialization of variables, etc.
58 * @param isDebugEnabled
60 public void preProcessRequest (Execution execution, isDebugEnabled) {
62 execution.setVariable("prefix",prefix)
63 execution.setVariable(prefix+'SuccessIndicator', false)
66 // INPUT: DoCreateVfModuleVolumeV1Request, att-mso-request-id, volume-group-id, vnf-id, is-vid-request
67 // OUTPUT: DCVFMODVOLV1_SuccessIndicator. WorkflowException
69 def volumeRequest = getVariable(execution, 'DoCreateVfModuleVolumeV1Request')
70 if (volumeRequest != null) {
71 execution.setVariable(prefix+'Request', volumeRequest)
73 volumeRequest = getVariable(execution, prefix+'Request')
74 if (volumeRequest == null) {
75 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'DoCreateVfModuleVolumeV1 received null request.')
79 def vnfId = execution.getVariable('vnf-id')
81 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'DoCreateVfModuleVolumeV1 received null vnf-id.')
84 def volumeGroupId = execution.getVariable('volume-group-id')
85 if (volumeGroupId == null) {
86 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, 'DoCreateVfModuleVolumeV1 received null volume-group-id.')
89 def requestId = execution.getVariable("att-mso-request-id")
90 if (requestId == null || requestId == "") {
91 requestId = utils.getNodeText1(volumeRequest, "request-id")
94 //def serviceId = execution.getVariable("att-mso-service-instance-id")
95 //if (serviceId == null || serviceId == "") {
96 def serviceId = utils.getNodeText1(volumeRequest, "service-id")
99 def source = utils.getNodeText1(volumeRequest, "source")
101 execution.setVariable(prefix+'requestId', requestId)
102 execution.setVariable(prefix+'serviceId', serviceId)
103 execution.setVariable(prefix+'source', source)
105 // @TODO: for better tracking of logs, should we strip all new lines in the log message?
106 utils.logAudit('Incoming request: ' + volumeRequest)
109 NetworkUtils networkUtils = new NetworkUtils()
110 def rollbackEnabled = networkUtils.isRollbackEnabled(execution,volumeRequest)
111 execution.setVariable(prefix+"rollbackEnabled", rollbackEnabled)
112 utils.log("DEBUG", 'rollbackEnabled: ' + rollbackEnabled, isDebugEnabled)
120 * @param isDebugEnabled
122 public void callRESTQueryAAICloudRegion (Execution execution, isDebugEnabled) {
124 def request = execution.getVariable(prefix+'Request')
125 def cloudRegion = utils.getNodeText1(request, "aic-cloud-region")
126 utils.log("DEBUG", 'Request cloud region is: ' + cloudRegion, isDebugEnabled)
128 AaiUtil aaiUtil = new AaiUtil(this)
129 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
130 String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion
132 utils.logAudit(queryCloudRegionRequest)
134 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
136 if ((cloudRegion != "ERROR")) {
137 if(execution.getVariable(prefix+"queryCloudRegionReturnCode") == "404"){
138 cloudRegion = "AAIAIC25"
140 execution.setVariable(prefix+"aicCloudRegion", cloudRegion)
141 utils.log("DEBUG", "AIC Cloud Region: " + cloudRegion, isDebugEnabled)
143 String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
144 utils.log("DEBUG", errorMessage, isDebugEnabled)
145 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
151 * Query AAI volume group by name
153 * @param isDebugEnabled
155 public void callRESTQueryAAIVolGrpName(Execution execution, isDebugEnabled) {
157 def volumeRequest = execution.getVariable(prefix+'Request')
158 def volumeGroupName = utils.getNodeText(volumeRequest, "volume-group-name")
159 def cloudRegion = execution.getVariable(prefix+"aicCloudRegion")
161 // Save volume group name
162 execution.setVariable(prefix+'volumeGroupName', volumeGroupName)
164 // This is for stub testing
165 def testVolumeGroupName = execution.getVariable('test-volume-group-name')
166 if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) {
167 volumeGroupName = testVolumeGroupName
169 execution.setVariable('test-volume-group-name', null)
172 AaiUtil aaiUtil = new AaiUtil(this)
173 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
174 String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8')
176 utils.logAudit('Query AAI volume group by name: ' + queryAAIVolumeNameRequest)
178 APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest)
180 String returnCode = response.getStatusCode()
181 String aaiResponseAsString = response.getResponseBodyAsString()
182 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
184 utils.logAudit("AAI query volume group by name return code: " + returnCode)
185 utils.logAudit("AAI query volume group by name response: " + aaiResponseAsString)
187 ExceptionUtil exceptionUtil = new ExceptionUtil()
189 execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString)
190 execution.setVariable(prefix+'AaiReturnCode', returnCode)
192 if (returnCode=='200') {
193 // @TODO: verify error code
194 // @TODO: create class of literals representing error codes
195 execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString)
196 utils.log("DEBUG", "Volume Group Name $volumeGroupName exists in AAI.", isDebugEnabled)
198 if (returnCode=='404') {
199 utils.log("DEBUG", "Volume Group Name $volumeGroupName does not exist in AAI.", isDebugEnabled)
200 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
202 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
203 throw new BpmnError("MSOWorkflowException")
210 * Create a WorkflowException
212 * @param isDebugEnabled
214 public void buildWorkflowException(Execution execution, int errorCode, errorMessage, isDebugEnabled) {
215 utils.log("DEBUG", errorMessage, isDebugEnabled)
216 (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage)
221 * Create a WorkflowException
223 * @param isDebugEnabled
225 public void handleError(Execution execution, isDebugEnabled) {
226 WorkflowException we = execution.getVariable('WorkflowException')
228 (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!")
230 throw new BpmnError("MSOWorkflowException")
234 * Create volume group in AAI
236 * @param isDebugEnabled
238 public void callRESTCreateAAIVolGrpName(Execution execution, isDebugEnabled) {
240 def volumeRequest = execution.getVariable(prefix+'Request')
241 def vnfId = execution.getVariable('vnf-id')
242 def volumeName = utils.getNodeText(volumeRequest, "volume-group-name")
244 def cloudRegion = execution.getVariable(prefix+"aicCloudRegion")
245 def groupId = execution.getVariable('volume-group-id')
246 utils.log("DEBUG", "volume group id: " + groupId, isDebugEnabled)
248 AaiUtil aaiUtil = new AaiUtil(this)
249 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
250 String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(groupId, "UTF-8")
252 String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution))
253 utils.log("DEBUG", "AAI namespace is: " + namespace, isDebugEnabled)
255 utils.logAudit(createAAIVolumeGrpNameUrlRequest)
257 //Prepare payload (PUT)
258 def vnfType = utils.getNodeText(volumeRequest, "vnf-type")
259 def tenantId = utils.getNodeText(volumeRequest, "tenant-id")
261 NetworkUtils networkUtils = new NetworkUtils()
262 String payload = networkUtils.createCloudRegionVolumeRequest(groupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace)
263 String payloadXml = utils.formatXml(payload)
264 utils.logAudit(payloadXml)
266 APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml)
268 String returnCode = response.getStatusCode()
269 String aaiResponseAsString = response.getResponseBodyAsString()
270 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
272 utils.logAudit("AAI create volume group return code: " + returnCode)
273 utils.logAudit("AAI create volume group response: " + aaiResponseAsString)
275 execution.setVariable(prefix+"createAAIVolumeGrpNameReturnCode", returnCode)
276 execution.setVariable(prefix+"createAAIVolumeGrpNameResponse", aaiResponseAsString)
278 ExceptionUtil exceptionUtil = new ExceptionUtil()
280 if (returnCode =='201') {
281 execution.setVariable(prefix+"isAAIRollbackNeeded", true)
283 execution.setVariable(prefix+"isErrorMessageException", true)
284 if (returnCode=='404') {
285 // @TODO: verify return code and make static LITERAL
286 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
288 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
289 utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled)
290 throw new BpmnError("MSOWorkflowException")
296 * Prepare VNF adapter create request XML
299 public void prepareVnfAdapterCreateRequest(Execution execution, isDebugEnabled) {
302 def volumeRequest = execution.getVariable(prefix+'Request')
303 def requestId = execution.getVariable(prefix+'requestId')
304 def serviceId = execution.getVariable(prefix+'serviceId')
306 def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
307 def vnfId = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-id')
308 def vnfName = utils.getNodeText1(aaiGenericVnfResponse, 'vnf-name')
310 String messageId = UUID.randomUUID()
311 utils.log("DEBUG", "messageId to be used is generated: " + messageId, isDebugEnabled)
313 // prepare vnf request for vnfAdapterCreateV1
314 def cloudSiteId = utils.getNodeText1(volumeRequest, 'aic-cloud-region')
315 def tenantId = utils.getNodeText1(volumeRequest, "tenant-id")
316 def vnfType = utils.getNodeText1(volumeRequest, "vnf-type")
317 def vnfVersion = utils.getNodeText1(volumeRequest, "asdc-service-model-version")
318 def vnfModuleType = utils.getNodeText1(volumeRequest, "vf-module-model-name")
319 def volumeGroupnName = utils.getNodeText1(volumeRequest, "volume-group-name")
321 def volumeParamsXml = utils.getNodeXml(volumeRequest, 'volume-params')
322 def volumeGroupParams = transformVolumeParamsToEntries(volumeParamsXml)
324 utils.log("DEBUG", "volumeGroupParams: "+ volumeGroupParams, isDebugEnabled)
326 String volumeGroupId = execution.getVariable('volume-group-id')
327 def notificationUrl = execution.getVariable("URN_mso_workflow_vnfadapter_rest_callback")
328 def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
329 if ('true'.equals(useQualifiedHostName)) {
330 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
332 utils.log("DEBUG", "CreateVfModuleVolume - notificationUrl: "+ notificationUrl, isDebugEnabled)
334 def backoutOnFailure = execution.getVariable("DCVFMODVOLV1_rollbackEnabled")
335 utils.log("DEBUG", "backoutOnFailure: "+ backoutOnFailure, isDebugEnabled)
338 String vnfSubCreateWorkflowRequest =
340 <createVolumeGroupRequest>
341 <cloudSiteId>${cloudSiteId}</cloudSiteId>
342 <tenantId>${tenantId}</tenantId>
343 <vnfId>${vnfId}</vnfId>
344 <vnfName>${vnfName}</vnfName>
345 <volumeGroupId>${volumeGroupId}</volumeGroupId>
346 <volumeGroupName>${volumeGroupnName}</volumeGroupName>
347 <vnfType>${vnfType}</vnfType>
348 <vnfVersion>${vnfVersion}</vnfVersion>
349 <vfModuleType>${vnfModuleType}</vfModuleType>
353 <value>${vnfId}</value>
357 <value>${vnfName}</value>
360 <key>vf_module_id</key>
361 <value>${volumeGroupId}</value>
364 <key>vf_module_name</key>
365 <value>${volumeGroupnName}</value>
369 <skipAAI>true</skipAAI>
370 <backout>${backoutOnFailure}</backout>
371 <failIfExists>true</failIfExists>
373 <requestId>${requestId}</requestId>
374 <serviceInstanceId>${serviceId}</serviceInstanceId>
376 <messageId>${messageId}</messageId>
377 <notificationUrl>${notificationUrl}</notificationUrl>
378 </createVolumeGroupRequest>
381 String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest)
382 utils.logAudit(vnfSubCreateWorkflowRequestAsString)
383 execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString)
385 // build rollback request for use later if needed
387 String vnfSubRollbackWorkflowRequest =
388 """<rollbackVolumeGroupRequest>
389 <cloudSiteId>${cloudSiteId}</cloudSiteId>
390 <tenantId>${tenantId}</tenantId>
391 <volumeGroupId>${volumeGroupId}</volumeGroupId>
392 <skipAAI>true</skipAAI>
393 <volumeGroupCreated>true</volumeGroupCreated>
395 <requestId>${requestId}</requestId>
396 <serviceInstanceId>${serviceId}</serviceInstanceId>
398 <messageId>${messageId}</messageId>
399 <notificationUrl>${notificationUrl}</notificationUrl>
400 </rollbackVolumeGroupRequest>"""
402 utils.log("DEBUG", "Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest, isDebugEnabled)
404 String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest)
405 execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString)
411 * Update voulume group in AAI
412 * @TODO: Can we re-use the create method??
414 * @param isDebugEnabled
416 public void callRESTUpdateCreatedVolGrpName(Execution execution, isDebugEnabled) {
419 String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse")
420 String volumeGroupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id")
421 String cloudRegion = execution.getVariable(prefix+"aicCloudRegion")
423 AaiUtil aaiUtil = new AaiUtil(this)
424 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
425 String updateAAIVolumeGroupUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, 'UTF-8')
427 String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution))
429 utils.logAudit(updateAAIVolumeGroupUrlRequest)
431 //Prepare payload (PUT)
432 String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
435 // if VID request createVnfresponse will be null, use vnf from JSON request
437 if(createVnfAResponse == null || createVnfAResponse == "") {
438 vnfId = execution.getVariable(prefix+'vnfId')
441 vnfId = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
444 NetworkUtils networkUtils = new NetworkUtils()
445 String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, vnfId, namespace)
446 String payloadXml = utils.formatXml(payload)
448 //execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNamePayloadRequest", payloadXml)
449 utils.logAudit(payload)
450 //utils.log("DEBUG", " 'payload' to Update Created VolumeGroupName - " + "\n" + payloadXml, isDebugEnabled)
452 APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml)
454 String returnCode = response.getStatusCode()
455 String aaiResponseAsString = response.getResponseBodyAsString()
456 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
458 utils.logAudit("AAI create volume group return code: " + returnCode)
459 utils.logAudit("AAI create volume group response: " + aaiResponseAsString)
461 ExceptionUtil exceptionUtil = new ExceptionUtil()
463 if (returnCode =='200') {
464 execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNameResponse", aaiResponseAsString)
465 execution.setVariable(prefix+"isPONR", true)
467 execution.setVariable(prefix+"isErrorMessageException", true)
468 if (returnCode=='404') {
469 // @TODO: verify return code and make static LITERAL
470 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
472 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
473 utils.log("DEBUG", " AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException, isDebugEnabled)
474 throw new BpmnError("MSOWorkflowException")
481 * Query AAI service instance
483 * @param isDebugEnabled
485 public void callRESTQueryAAIGenericVnf(Execution execution, isDebugEnabled) {
487 def request = execution.getVariable(prefix+"Request")
488 def vnfId = execution.getVariable('vnf-id')
490 AaiUtil aaiUtil = new AaiUtil(this)
491 String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution)
492 def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8")
494 utils.logAudit("AAI query generic vnf request: " + queryAAIRequest)
496 APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
498 String returnCode = response.getStatusCode()
499 String aaiResponseAsString = response.getResponseBodyAsString()
500 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
502 utils.logAudit("AAI query generic vnf return code: " + returnCode)
503 utils.logAudit("AAI query generic vnf response: " + aaiResponseAsString)
505 ExceptionUtil exceptionUtil = new ExceptionUtil()
507 if (returnCode=='200') {
508 utils.log("DEBUG", 'Generic vnf ' + vnfId + ' found in AAI.', isDebugEnabled)
509 execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString)
511 if (returnCode=='404') {
512 def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.'
513 utils.log("DEBUG", message, isDebugEnabled)
514 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
516 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
517 throw new BpmnError("MSOWorkflowException")
522 public void callRESTDeleteAAIVolumeGroup(Execution execution, isDebugEnabled) {
524 callRESTQueryAAIVolGrpName(execution, isDebugEnabled)
526 def queryAaiVolumeGroupResponse = execution.getVariable(prefix+'queryAAIVolGrpNameResponse')
528 def volumeGroupId = utils.getNodeText(queryAaiVolumeGroupResponse, "volume-group-id")
529 def resourceVersion = utils.getNodeText(queryAaiVolumeGroupResponse, "resource-version")
531 def cloudRegion = execution.getVariable(prefix+"aicCloudRegion")
533 AaiUtil aaiUtil = new AaiUtil(this)
534 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
535 String deleteAAIVolumeGrpIdRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group" + '/' + volumeGroupId + "?resource-version=" + UriUtils.encode(resourceVersion, "UTF-8")
537 utils.logAudit('Delete AAI volume group : ' + deleteAAIVolumeGrpIdRequest)
539 APIResponse response = aaiUtil.executeAAIDeleteCall(execution, deleteAAIVolumeGrpIdRequest)
541 String returnCode = response.getStatusCode()
542 String aaiResponseAsString = response.getResponseBodyAsString()
543 aaiResponseAsString = StringEscapeUtils.unescapeXml(aaiResponseAsString)
545 utils.logAudit("AAI delete volume group return code: " + returnCode)
546 utils.logAudit("AAI delete volume group response: " + aaiResponseAsString)
548 ExceptionUtil exceptionUtil = new ExceptionUtil()
550 def volumeGroupNameFound = prefix+'volumeGroupNameFound'
551 if (returnCode=='200' || returnCode=='204' ) {
552 utils.log("DEBUG", "Volume group $volumeGroupId deleted.", isDebugEnabled)
554 if (returnCode=='404') {
555 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupId not found for delete in AAI Response code: 404")
557 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
558 throw new BpmnError("MSOWorkflowException")
567 public void prepareSuccessDBRequest(Execution execution, isDebugEnabled) {
568 String requestId = execution.getVariable(prefix+'requestId')
569 String dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs')
570 prepareDBRequest(execution, requestId, "VolumeGroup successfully created.", "COMPLETED", "100", dbVnfOutputs, isDebugEnabled)
573 public void prepareFailDbRequest(Execution execution, isDebugEnabled) {
575 WorkflowException we = execution.getVariable("WorkflowException")
577 String requestId = execution.getVariable(prefix+'requestId')
578 String dbVnfOutputs = execution.getVariable(prefix+'volumeOutputs')
579 prepareDBRequest(execution, requestId, we.getErrorMessage(), "FAILURE", "", dbVnfOutputs, isDebugEnabled)
585 * Prepare Infra DB XML Request
588 public void prepareDBRequest (Execution execution, String requestId, String statusMessage, String requestStatus, String progress, String dbVnfOutputs, isDebugEnabled) {
591 """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
594 <ns:updateInfraRequest xmlns:ns="http://com.att.mso/requestsdb">
595 <requestId>${requestId}</requestId>
596 <lastModifiedBy>BPMN</lastModifiedBy>
597 <statusMessage>${statusMessage}</statusMessage>
598 <responseBody></responseBody>
599 <requestStatus>${requestStatus}</requestStatus>
600 <progress>${progress}</progress>
601 <vnfOutputs>${dbVnfOutputs}</vnfOutputs>
602 </ns:updateInfraRequest>
604 </soapenv:Envelope>"""
606 utils.log("DEBUG", " DB Adapter Request - " + "\n" + dbRequest, isDebugEnabled)
607 String buildDeleteDBRequestAsString = utils.formatXml(dbRequest)
609 execution.setVariable(prefix+"createDBRequest", buildDeleteDBRequestAsString)
611 utils.logAudit(buildDeleteDBRequestAsString)
617 public void postProcessResponse (Execution execution, isDebugEnabled) {
619 String dbReturnCode = execution.getVariable(prefix+"dbReturnCode")
620 utils.log("DEBUG", "DB Update Response Code : " + dbReturnCode, isDebugEnabled)
622 String createDBResponse = execution.getVariable(prefix+"createDBResponse")
623 utils.logAudit(createDBResponse)
625 String source = execution.getVariable(prefix+"source")
626 String requestId = execution.getVariable(prefix+'requestId')
628 String msoCompletionRequest =
629 """<aetgt:MsoCompletionRequest xmlns:aetgt="http://ecomp.att.com/mso/workflow/schema/v1"
630 xmlns:ns="http://ecomp.att.com/mso/request/types/v1">
631 <request-info xmlns="http://ecomp.att.com/mso/infra/vnf-request/v1">
632 <request-id>${requestId}</request-id>
633 <action>CREATE</action>
634 <source>${source}</source>
636 <aetgt:mso-bpel-name>BPEL Volume Group action: CREATE</aetgt:mso-bpel-name>
637 </aetgt:MsoCompletionRequest>"""
640 String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)
641 utils.logAudit(xmlMsoCompletionRequest)
644 if (dbReturnCode == "200") {
645 execution.setVariable(prefix+"Success", true)
646 execution.setVariable(prefix+"CompleteMsoProcessRequest", xmlMsoCompletionRequest)
647 utils.log("DEBUG", " Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest, isDebugEnabled)
649 execution.setVariable(prefix+"isErrorMessageException", true)
650 utils.log("DEBUG", " DB Update failed, code: " + dbReturnCode + ", going to Unexpected Error.", isDebugEnabled)