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 org.onap.so.bpmn.infrastructure.scripts
23 import org.apache.commons.lang3.*
24 import org.camunda.bpm.engine.delegate.BpmnError
25 import org.camunda.bpm.engine.delegate.DelegateExecution
26 import org.onap.so.bpmn.common.scripts.AaiUtil
27 import org.onap.so.bpmn.common.scripts.ExceptionUtil
28 import org.onap.so.bpmn.common.scripts.MsoUtils
29 import org.onap.so.bpmn.common.scripts.NetworkUtils
30 import org.onap.so.bpmn.common.scripts.VfModuleBase;
31 import org.onap.so.bpmn.core.RollbackData
32 import org.onap.so.bpmn.core.UrnPropertiesReader
33 import org.onap.so.bpmn.core.WorkflowException
34 import org.onap.so.bpmn.core.json.JsonUtils;
35 import org.onap.so.logger.MsoLogger
36 import org.onap.so.rest.APIResponse
37 import org.springframework.web.util.UriUtils
39 class DoCreateVfModuleVolumeV2 extends VfModuleBase {
41 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModuleVolumeV2.class);
42 String prefix='DCVFMODVOLV2_'
43 JsonUtils jsonUtil = new JsonUtils()
47 * Perform initial processing, such as request validation, initialization of variables, etc.
50 public void preProcessRequest(DelegateExecution execution) {
51 def isDebugEnabled=execution.getVariable("isDebugLogEnabled")
52 preProcessRequest(execution, isDebugEnabled)
55 public void preProcessRequest(DelegateExecution execution, isDebugLogEnabled) {
57 execution.setVariable("prefix",prefix)
58 execution.setVariable(prefix+'SuccessIndicator', false)
59 execution.setVariable(prefix+'isPONR', false)
61 displayInput(execution, isDebugLogEnabled)
62 setRollbackData(execution, isDebugLogEnabled)
63 setRollbackEnabled(execution, isDebugLogEnabled)
66 def tenantId = execution.getVariable("tenantId")
67 if (tenantId == null) {
68 String cloudConfiguration = execution.getVariable("cloudConfiguration")
69 tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")
70 execution.setVariable("tenantId", tenantId)
73 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
74 if (cloudSiteId == null) {
75 String cloudConfiguration = execution.getVariable("cloudConfiguration")
76 cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")
77 execution.setVariable("lcpCloudRegionId", cloudSiteId)
80 // Extract attributes from modelInfo
81 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
83 //modelCustomizationUuid
84 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
85 execution.setVariable("modelCustomizationId", modelCustomizationUuid)
86 msoLogger.debug("modelCustomizationId: " + modelCustomizationUuid)
89 def modelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
90 execution.setVariable("modelName", modelName)
91 msoLogger.debug("modelName: " + modelName)
93 // The following is used on the get Generic Service Instance call
94 execution.setVariable('GENGS_type', 'service-instance')
99 * Display input variables
101 * @param isDebugLogEnabled
103 public void displayInput(DelegateExecution execution, isDebugLogEnabled) {
104 def input = ['mso-request-id', 'msoRequestId', 'isDebugLogEnabled', 'disableRollback', 'failIfExists', 'serviceInstanceId',
105 'vnfId', 'vnfName', 'tenantId', 'volumeGroupId', 'volumeGroupName', 'lcpCloudRegionId', 'vnfType', 'vfModuleModelInfo', 'asdcServiceModelVersion',
106 'test-volume-group-name', 'test-volume-group-id', 'vfModuleInputParams']
108 msoLogger.debug('Begin input: ')
110 msoLogger.debug(it + ': ' + execution.getVariable(it))
112 msoLogger.debug('End input.')
117 * Define and set rollbackdata object
119 * @param isDebugEnabled
121 public void setRollbackData(DelegateExecution execution, isDebugEnabled) {
122 def rollbackData = execution.getVariable("rollbackData")
123 if (rollbackData == null) {
124 rollbackData = new RollbackData()
126 def volumeGroupName = execution.getVariable('volumeGroupName')
127 rollbackData.put("DCVFMODULEVOL", "volumeGroupName", volumeGroupName)
128 execution.setVariable("rollbackData", rollbackData)
133 * validate getServiceInstance response
135 * @param isDebugEnabled
137 public void validateGetServiceInstanceCall(DelegateExecution execution, isDebugEnabled) {
138 def found = execution.getVariable('GENGS_FoundIndicator')
139 def success = execution.getVariable('GENGS_SuccessIndicator')
140 def serviceInstanceId = execution.getVariable('serviceInstanceId')
141 msoLogger.debug("getServiceInstance success: " + success)
142 msoLogger.debug("getServiceInstance found: " + found)
143 if(!found || !success) {
144 String errorMessage = "Service instance id not found in AAI: ${serviceInstanceId}."
145 msoLogger.debug(errorMessage)
146 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
154 * @param isDebugEnabled
156 public void callRESTQueryAAICloudRegion (DelegateExecution execution, isDebugEnabled) {
158 def cloudRegion = execution.getVariable("lcpCloudRegionId")
159 msoLogger.debug('Request cloud region is: ' + cloudRegion)
161 AaiUtil aaiUtil = new AaiUtil(this)
162 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
163 String queryCloudRegionRequest = aaiEndpoint + '/' + cloudRegion
165 msoLogger.debug(queryCloudRegionRequest)
167 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
169 def aaiCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
170 if ((aaiCloudRegion != "ERROR")) {
171 execution.setVariable("lcpCloudRegionId", aaiCloudRegion)
172 msoLogger.debug("AIC Cloud Region for AAI: " + aaiCloudRegion)
174 String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
175 msoLogger.debug(errorMessage)
176 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
179 def poCloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
180 if ((poCloudRegion != "ERROR")) {
181 execution.setVariable("poLcpCloudRegionId", poCloudRegion)
182 msoLogger.debug("AIC Cloud Region for PO: " + poCloudRegion)
184 String errorMessage = "AAI Query Cloud Region Unsuccessful. Return Code: " + execution.getVariable(prefix+"queryCloudRegionReturnCode")
185 msoLogger.debug(errorMessage)
186 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 2500, errorMessage)
189 def rollbackData = execution.getVariable("rollbackData")
190 rollbackData.put("DCVFMODULEVOL", "aiccloudregion", cloudRegion)
195 * Query AAI volume group by name
197 * @param isDebugEnabled
199 public void callRESTQueryAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
201 def volumeGroupName = execution.getVariable('volumeGroupName')
202 def cloudRegion = execution.getVariable('lcpCloudRegionId')
204 // This is for stub testing
205 def testVolumeGroupName = execution.getVariable('test-volume-group-name')
206 if (testVolumeGroupName != null && testVolumeGroupName.length() > 0) {
207 volumeGroupName = testVolumeGroupName
210 AaiUtil aaiUtil = new AaiUtil(this)
211 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
212 String queryAAIVolumeNameRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups" + "?volume-group-name=" + UriUtils.encode(volumeGroupName, 'UTF-8')
214 msoLogger.debug('Query AAI volume group by name: ' + queryAAIVolumeNameRequest)
216 APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIVolumeNameRequest)
218 String returnCode = response.getStatusCode()
219 String aaiResponseAsString = response.getResponseBodyAsString()
221 msoLogger.debug("AAI query volume group by name return code: " + returnCode)
222 msoLogger.debug("AAI query volume group by name response: " + aaiResponseAsString)
224 ExceptionUtil exceptionUtil = new ExceptionUtil()
226 execution.setVariable(prefix+"queryAAIVolGrpNameResponse", aaiResponseAsString)
227 execution.setVariable(prefix+'AaiReturnCode', returnCode)
229 if (returnCode=='200') {
230 execution.setVariable(prefix+'queryAAIVolGrpNameResponse', aaiResponseAsString)
231 msoLogger.debug("Volume Group Name $volumeGroupName exists in AAI.")
233 if (returnCode=='404') {
234 msoLogger.debug("Volume Group Name $volumeGroupName does not exist in AAI.")
235 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Volume group $volumeGroupName not found in AAI. Response code: 404")
237 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
238 throw new BpmnError("MSOWorkflowException")
245 * Create a WorkflowException
247 * @param isDebugEnabled
249 public void buildWorkflowException(DelegateExecution execution, int errorCode, errorMessage, isDebugEnabled) {
250 msoLogger.debug(errorMessage)
251 (new ExceptionUtil()).buildWorkflowException(execution, 2500, errorMessage)
256 * Create a WorkflowException
258 * @param isDebugEnabled
260 public void handleError(DelegateExecution execution, isDebugEnabled) {
261 WorkflowException we = execution.getVariable('WorkflowException')
263 (new ExceptionUtil()).buildWorkflowException(execution, 2500, "Enexpected error encountered!")
265 throw new BpmnError("MSOWorkflowException")
270 * Create volume group in AAI
272 * @param isDebugEnabled
274 public void callRESTCreateAAIVolGrpName(DelegateExecution execution, isDebugEnabled) {
276 def vnfId = execution.getVariable('vnfId')
277 def volumeGroupId = execution.getVariable('volumeGroupId')
278 def volumeName = execution.getVariable("volumeGroupName")
279 def modelCustomizationId = execution.getVariable("modelCustomizationId")
280 def vnfType = execution.getVariable("vnfType")
281 def tenantId = execution.getVariable("tenantId")
282 def cloudRegion = execution.getVariable('lcpCloudRegionId')
284 msoLogger.debug("volumeGroupId: " + volumeGroupId)
286 def testGroupId = execution.getVariable('test-volume-group-id')
287 if (testGroupId != null && testGroupId.trim() != '') {
288 msoLogger.debug("test volumeGroupId is present: " + testGroupId)
289 volumeGroupId = testGroupId
290 execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
293 msoLogger.debug("volumeGroupId to be used: " + volumeGroupId)
295 AaiUtil aaiUtil = new AaiUtil(this)
296 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
297 String createAAIVolumeGrpNameUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, "UTF-8")
299 String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution))
300 msoLogger.debug("AAI namespace is: " + namespace)
302 msoLogger.debug("Request URL for PUT: " + createAAIVolumeGrpNameUrlRequest)
304 NetworkUtils networkUtils = new NetworkUtils()
305 String payload = networkUtils.createCloudRegionVolumeRequest(volumeGroupId, volumeName, vnfType, vnfId, tenantId, cloudRegion, namespace, modelCustomizationId)
306 String payloadXml = utils.formatXml(payload)
307 msoLogger.debug("Request payload for PUT: " + payloadXml)
309 APIResponse response = aaiUtil.executeAAIPutCall(execution, createAAIVolumeGrpNameUrlRequest, payloadXml)
311 String returnCode = response.getStatusCode()
312 String aaiResponseAsString = response.getResponseBodyAsString()
314 msoLogger.debug("AAI create volume group return code: " + returnCode)
315 msoLogger.debug("AAI create volume group response: " + aaiResponseAsString)
317 execution.setVariable(prefix+"createAAIVolumeGrpNameReturnCode", returnCode)
318 execution.setVariable(prefix+"createAAIVolumeGrpNameResponse", aaiResponseAsString)
320 ExceptionUtil exceptionUtil = new ExceptionUtil()
322 if (returnCode =='201') {
323 RollbackData rollbackData = execution.getVariable("rollbackData")
324 rollbackData.put("DCVFMODULEVOL", "isAAIRollbackNeeded", "true")
326 execution.setVariable(prefix+"isErrorMessageException", true)
327 if (returnCode=='404') {
328 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to create volume group in AAI. Response code: 404")
330 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
331 msoLogger.debug(" AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException)
332 throw new BpmnError("MSOWorkflowException")
339 * Prepare VNF adapter create request XML
342 public void prepareVnfAdapterCreateRequest(DelegateExecution execution, isDebugEnabled) {
344 def aaiGenericVnfResponse = execution.getVariable(prefix+'AAIQueryGenericVfnResponse')
345 def vnfId = utils.getNodeText(aaiGenericVnfResponse, 'vnf-id')
346 def vnfName = utils.getNodeText(aaiGenericVnfResponse, 'vnf-name')
347 def vnfType = utils.getNodeText(aaiGenericVnfResponse, "vnf-type")
349 def requestId = execution.getVariable('msoRequestId')
350 def serviceId = execution.getVariable('serviceInstanceId')
351 def cloudSiteId = execution.getVariable('poLcpCloudRegionId')
352 def tenantId = execution.getVariable('tenantId')
353 def volumeGroupId = execution.getVariable('volumeGroupId')
354 def volumeGroupnName = execution.getVariable('volumeGroupName')
356 def vnfVersion = execution.getVariable("asdcServiceModelVersion")
357 def vnfModuleType = execution.getVariable("modelName")
359 def modelCustomizationId = execution.getVariable("modelCustomizationId")
362 msoLogger.debug("volumeGroupId: " + volumeGroupId)
363 def testGroupId = execution.getVariable('test-volume-group-id')
364 if (testGroupId != null && testGroupId.trim() != '') {
365 msoLogger.debug("test volumeGroupId is present: " + testGroupId)
366 volumeGroupId = testGroupId
367 execution.setVariable("test-volume-group-name", "MSOTESTVOL101a-vSAMP12_base_vol_module-0")
369 msoLogger.debug("volumeGroupId to be used: " + volumeGroupId)
371 // volume group parameters
373 String volumeGroupParams = ''
374 StringBuilder sbParams = new StringBuilder()
375 Map<String, String> paramsMap = execution.getVariable("vfModuleInputParams")
376 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
378 String paramName = entry.getKey();
379 String paramValue = entry.getValue()
382 <key>${MsoUtils.xmlEscape(paramName)}</key>
383 <value>${MsoUtils.xmlEscape(paramValue)}</value>
386 sbParams.append(paramsXml)
389 volumeGroupParams = sbParams.toString()
390 msoLogger.debug("volumeGroupParams: "+ volumeGroupParams)
392 def backoutOnFailure = execution.getVariable(prefix+"backoutOnFailure")
393 msoLogger.debug("backoutOnFailure: "+ backoutOnFailure)
395 def failIfExists = execution.getVariable("failIfExists")
396 if(failIfExists == null) {
397 failIfExists = 'true'
400 String messageId = UUID.randomUUID()
401 msoLogger.debug("messageId to be used is generated: " + messageId)
403 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
404 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
405 if ('true'.equals(useQualifiedHostName)) {
406 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
408 msoLogger.debug("CreateVfModuleVolume - notificationUrl: "+ notificationUrl)
411 String vnfSubCreateWorkflowRequest =
413 <createVolumeGroupRequest>
414 <cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId>
415 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
416 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
417 <vnfName>${MsoUtils.xmlEscape(vnfName)}</vnfName>
418 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
419 <volumeGroupName>${MsoUtils.xmlEscape(volumeGroupnName)}</volumeGroupName>
420 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
421 <vnfVersion>${MsoUtils.xmlEscape(vnfVersion)}</vnfVersion>
422 <vfModuleType>${MsoUtils.xmlEscape(vnfModuleType)}</vfModuleType>
423 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationId)}</modelCustomizationUuid>
427 <value>${MsoUtils.xmlEscape(vnfId)}</value>
431 <value>${MsoUtils.xmlEscape(vnfName)}</value>
434 <key>vf_module_id</key>
435 <value>${MsoUtils.xmlEscape(volumeGroupId)}</value>
438 <key>vf_module_name</key>
439 <value>${MsoUtils.xmlEscape(volumeGroupnName)}</value>
443 <skipAAI>true</skipAAI>
444 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
445 <failIfExists>${MsoUtils.xmlEscape(failIfExists)}</failIfExists>
447 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
448 <serviceInstanceId>${MsoUtils.xmlEscape(serviceId)}</serviceInstanceId>
450 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
451 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
452 </createVolumeGroupRequest>
455 String vnfSubCreateWorkflowRequestAsString = utils.formatXml(vnfSubCreateWorkflowRequest)
456 msoLogger.debug(vnfSubCreateWorkflowRequestAsString)
457 msoLogger.debug(vnfSubCreateWorkflowRequestAsString)
458 execution.setVariable(prefix+"createVnfARequest", vnfSubCreateWorkflowRequestAsString)
460 // build rollback request for use later if needed
461 String vnfSubRollbackWorkflowRequest = buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl)
463 msoLogger.debug("Sub Vnf flow rollback request: vnfSubRollbackWorkflowRequest " + "\n" + vnfSubRollbackWorkflowRequest)
465 String vnfSubRollbackWorkflowRequestAsString = utils.formatXml(vnfSubRollbackWorkflowRequest)
466 execution.setVariable(prefix+"rollbackVnfARequest", vnfSubRollbackWorkflowRequestAsString)
469 public String buildRollbackVolumeGroupRequestXml(volumeGroupId, cloudSiteId, tenantId, requestId, serviceId, messageId, notificationUrl) {
472 <rollbackVolumeGroupRequest>
473 <volumeGroupRollback>
474 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
475 <volumeGroupStackId>{{VOLUMEGROUPSTACKID}}</volumeGroupStackId>
476 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
477 <cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId>
478 <volumeGroupCreated>true</volumeGroupCreated>
480 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
481 <serviceInstanceId>${MsoUtils.xmlEscape(serviceId)}</serviceInstanceId>
483 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
484 </volumeGroupRollback>
485 <skipAAI>true</skipAAI>
486 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
487 </rollbackVolumeGroupRequest>
493 public String updateRollbackVolumeGroupRequestXml(String rollabackRequest, String heatStackId) {
494 String newRequest = rollabackRequest.replace("{{VOLUMEGROUPSTACKID}}", heatStackId)
499 * Validate VNF adapter response
502 public void validateVnfResponse(DelegateExecution execution, isDebugEnabled) {
503 def vnfSuccess = execution.getVariable('VNFREST_SuccessIndicator')
504 msoLogger.debug("vnfAdapterSuccessIndicator: "+ vnfSuccess)
505 if(vnfSuccess==true) {
506 String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
507 String heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
508 String vnfRollbackRequest = execution.getVariable(prefix+"rollbackVnfARequest")
509 String updatedVnfRollbackRequest = updateRollbackVolumeGroupRequestXml(vnfRollbackRequest, heatStackID)
510 msoLogger.debug("vnfAdapter rollback request: "+ updatedVnfRollbackRequest)
511 RollbackData rollbackData = execution.getVariable("rollbackData")
512 rollbackData.put("DCVFMODULEVOL", "rollbackVnfARequest", updatedVnfRollbackRequest)
513 rollbackData.put("DCVFMODULEVOL", "isCreateVnfRollbackNeeded", "true")
519 * Update voulume group in AAI
520 * @TODO: Can we re-use the create method??
522 * @param isDebugEnabled
524 public void callRESTUpdateCreatedVolGrpName(DelegateExecution execution, isDebugEnabled) {
526 String requeryAAIVolGrpNameResponse = execution.getVariable(prefix+"queryAAIVolGrpNameResponse")
527 String volumeGroupId = utils.getNodeText(requeryAAIVolGrpNameResponse, "volume-group-id")
528 String modelCustomizationId = execution.getVariable("modelCustomizationId")
529 String cloudRegion = execution.getVariable("lcpCloudRegionId")
531 AaiUtil aaiUtil = new AaiUtil(this)
532 String aaiEndpoint = aaiUtil.getCloudInfrastructureCloudRegionEndpoint(execution)
533 String updateAAIVolumeGroupUrlRequest = aaiEndpoint + '/' + cloudRegion + "/volume-groups/volume-group/" + UriUtils.encode(volumeGroupId, 'UTF-8')
535 String namespace = aaiUtil.getNamespaceFromUri(aaiUtil.getCloudInfrastructureCloudRegionUri(execution))
537 msoLogger.debug("updateAAIVolumeGroupUrlRequest - " + updateAAIVolumeGroupUrlRequest)
539 String createVnfAResponse = execution.getVariable(prefix+"createVnfAResponse")
540 def heatStackID = utils.getNodeText(createVnfAResponse, "volumeGroupStackId")
542 execution.setVariable(prefix+"heatStackId", heatStackID)
544 NetworkUtils networkUtils = new NetworkUtils()
545 String payload = networkUtils.updateCloudRegionVolumeRequest(requeryAAIVolGrpNameResponse, heatStackID, namespace, modelCustomizationId)
546 String payloadXml = utils.formatXml(payload)
548 msoLogger.debug("Payload to Update Created VolumeGroupName - " + "\n" + payloadXml)
550 APIResponse response = aaiUtil.executeAAIPutCall(execution, updateAAIVolumeGroupUrlRequest, payloadXml)
552 String returnCode = response.getStatusCode()
553 String aaiResponseAsString = response.getResponseBodyAsString()
555 msoLogger.debug("AAI create volume group return code: " + returnCode)
556 msoLogger.debug("AAI create volume group response: " + aaiResponseAsString)
558 ExceptionUtil exceptionUtil = new ExceptionUtil()
560 if (returnCode =='200') {
561 execution.setVariable(prefix+"updateCreatedAAIVolumeGrpNameResponse", aaiResponseAsString)
562 execution.setVariable(prefix+"isPONR", true)
564 execution.setVariable(prefix+"isErrorMessageException", true)
565 if (returnCode=='404') {
566 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Unable to update volume group in AAI. Response code: 404")
568 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
569 msoLogger.debug(" AAI Adapter Query Failed. WorkflowException - " + "\n" + aWorkflowException)
570 throw new BpmnError("MSOWorkflowException")
577 * Query AAI Generic VNF
579 * @param isDebugEnabled
581 public void callRESTQueryAAIGenericVnf(DelegateExecution execution, isDebugEnabled) {
583 def vnfId = execution.getVariable('vnfId')
585 AaiUtil aaiUtil = new AaiUtil(this)
586 String aaiEndpoint = aaiUtil.getNetworkGenericVnfEndpoint(execution)
587 def String queryAAIRequest = aaiEndpoint + "/" + UriUtils.encode(vnfId, "UTF-8")
589 msoLogger.debug("AAI query generic vnf request: " + queryAAIRequest)
591 APIResponse response = aaiUtil.executeAAIGetCall(execution, queryAAIRequest)
593 String returnCode = response.getStatusCode()
594 String aaiResponseAsString = response.getResponseBodyAsString()
596 msoLogger.debug("AAI query generic vnf return code: " + returnCode)
597 msoLogger.debug("AAI query generic vnf response: " + aaiResponseAsString)
599 ExceptionUtil exceptionUtil = new ExceptionUtil()
601 if (returnCode=='200') {
602 msoLogger.debug('Generic vnf ' + vnfId + ' found in AAI.')
603 execution.setVariable(prefix+'AAIQueryGenericVfnResponse', aaiResponseAsString)
605 if (returnCode=='404') {
606 def message = 'Generic vnf ' + vnfId + ' was not found in AAI. Return code: 404.'
607 msoLogger.debug(message)
608 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, message)
610 WorkflowException aWorkflowException = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
611 throw new BpmnError("MSOWorkflowException")