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.openecomp.mso.bpmn.infrastructure.scripts
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.runtime.Execution
25 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
26 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
27 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
28 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
29 import org.openecomp.mso.bpmn.common.scripts.VfModule
30 import org.openecomp.mso.bpmn.common.scripts.VfModuleBase
31 import org.openecomp.mso.bpmn.core.WorkflowException
32 import org.openecomp.mso.bpmn.core.json.JsonUtils;
33 import org.openecomp.mso.rest.APIResponse
34 import org.springframework.web.util.UriUtils
36 public class DoUpdateVfModule extends VfModuleBase {
38 ExceptionUtil exceptionUtil = new ExceptionUtil()
39 JsonUtils jsonUtil = new JsonUtils()
42 * Initialize the flow's variables.
44 * @param execution The flow's execution instance.
46 public void initProcessVariables(Execution execution) {
47 execution.setVariable('prefix', 'DOUPVfMod_')
48 execution.setVariable('DOUPVfMod_requestInfo', null)
49 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
50 execution.setVariable('DOUPVfMod_requestId', null)
51 execution.setVariable('DOUPVfMod_vnfInputs', null)
52 execution.setVariable('DOUPVfMod_vnfId', null)
53 execution.setVariable('DOUPVfMod_vnfName', null)
54 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
55 execution.setVariable('DOUPVfMod_vfModuleName', null)
56 execution.setVariable('DOUPVfMod_vfModuleId', null)
57 execution.setVariable('DOUPVfMod_vnfType', null)
58 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
59 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
60 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
61 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
62 execution.setVariable('DOUPVfMod_serviceId', null)
63 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
64 execution.setVariable('DOUPVfMod_tenantId', null)
65 execution.setVariable('DOUPVfMod_volumeGroupId', null)
66 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
67 execution.setVariable('DOUPVfMod_vfModule', null)
68 execution.setVariable('DOUPVfMod_vnfParams', null)
69 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
70 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
71 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
72 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
73 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
74 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
75 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
76 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
77 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
78 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
79 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
80 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
81 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
82 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
86 * Check for missing elements in the received request.
88 * @param execution The flow's execution instance.
90 public void preProcessRequest(Execution execution) {
91 def method = getClass().getSimpleName() + '.preProcessRequest(' +
92 'execution=' + execution.getId() +
94 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
95 logDebug('Entered ' + method, isDebugLogEnabled)
98 initProcessVariables(execution)
99 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
100 utils.logAudit("DoUpdateVfModule request: " + xml)
101 logDebug('Received request xml:\n' + xml, isDebugLogEnabled)
103 if (xml == null || xml.isEmpty()) {
104 // Building Block-type request
106 String cloudConfiguration = execution.getVariable("cloudConfiguration")
107 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
109 def serviceModelInfo = execution.getVariable("serviceModelInfo")
110 logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled)
111 def vnfModelInfo = execution.getVariable("vnfModelInfo")
115 def tenantId = execution.getVariable("tenantId")
116 execution.setVariable("DOUPVfMod_tenantId", tenantId)
119 def volumeGroupId = execution.getVariable("volumeGroupId")
120 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
123 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
124 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
126 logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled)
128 def vnfType = execution.getVariable("vnfType")
129 execution.setVariable("DOUPVfMod_vnfType", vnfType)
131 logDebug("vnfType: " + vnfType, isDebugLogEnabled)
133 def vnfName = execution.getVariable("vnfName")
134 execution.setVariable("DOUPVfMod_vnfName", vnfName)
136 logDebug("vnfName: " + vnfName, isDebugLogEnabled)
138 def vnfId = execution.getVariable("vnfId")
139 execution.setVariable("DOUPVfMod_vnfId", vnfId)
141 logDebug("vnfId: " + vnfId, isDebugLogEnabled)
143 def vfModuleName = execution.getVariable("vfModuleName")
144 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
146 logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled)
148 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
149 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
151 logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled)
152 //modelCustomizationUuid
153 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
154 if (modelCustomizationUuid == null) {
155 modelCustomizationUuid = ""
157 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
159 logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled)
161 def vfModuleId = execution.getVariable("vfModuleId")
162 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
163 logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled)
164 def requestId = execution.getVariable("msoRequestId")
165 execution.setVariable("DOUPVfMod_requestId", requestId)
166 logDebug("requestId: " + requestId, isDebugLogEnabled)
167 // Set mso-request-id to request-id for VNF Adapter interface
168 execution.setVariable("mso-request-id", requestId)
170 def serviceId = execution.getVariable("serviceId")
171 execution.setVariable("DOUPVfMod_serviceId", serviceId)
172 logDebug("serviceId: " + serviceId, isDebugLogEnabled)
174 def serviceInstanceId = execution.getVariable("serviceInstanceId")
175 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
177 logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled)
180 execution.setVariable("DOUPVfMod_source", source)
182 logDebug("source: " + source, isDebugLogEnabled)
184 def disableRollback = execution.getVariable("disableRollback")
185 def backoutOnFailure = true
186 if (disableRollback != null && disableRollback.equals("true")) {
187 backoutOnFailure = false
189 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
190 logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled)
192 def isBaseVfModule = execution.getVariable("isBaseVfModule")
193 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
194 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)
195 //asdcServiceModelVersion
196 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
197 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
198 logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled)
200 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
201 //personaModelVersion
202 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
203 //Get or Generate UUID
204 String uuid = execution.getVariable("DOUPVfMod_uuid")
206 uuid = UUID.randomUUID()
207 logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled)
209 logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled)
212 String isVidRequest = execution.getVariable("isVidRequest")
214 if (isVidRequest == null || isVidRequest.isEmpty()) {
215 execution.setVariable("isVidRequest", "true")
218 def usePreload = execution.getVariable("usePreload")
219 execution.setVariable("DOUPVfMod_usePreload", usePreload)
220 logDebug("usePreload: " + usePreload, isDebugLogEnabled)
222 String globalSubscriberId = execution.getVariable("globalSubscriberId")
223 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
224 logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled)
226 String vnfQueryPath = execution.getVariable("vnfQueryPath")
227 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
228 logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled)
230 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
231 if (vfModuleInputParams != null) {
232 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
237 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
238 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
239 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
240 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
241 if (serviceInstanceId == null) {
242 serviceInstanceId = ''
244 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
246 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
247 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
248 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
249 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
250 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
251 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
252 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
253 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
254 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
255 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
256 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
257 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
258 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
260 def isBaseVfModule = "false"
261 if (utils.nodeExists(xml, "is-base-vf-module")) {
262 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
263 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
265 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)
267 NetworkUtils networkUtils = new NetworkUtils()
268 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
269 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
271 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
272 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
274 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
277 def sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
278 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
279 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
281 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
284 logDebug('Exited ' + method, isDebugLogEnabled)
285 } catch (BpmnError e) {
287 } catch (Exception e) {
288 logError('Caught exception in ' + method, e)
289 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
294 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
295 * set the orchestration-status to 'pending-update'.
297 * @param execution The flow's execution instance.
299 public void prepPrepareUpdateAAIVfModule(Execution execution) {
300 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
301 'execution=' + execution.getId() +
303 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
304 logDebug('Entered ' + method, isDebugLogEnabled)
307 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
308 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
309 def orchestrationStatus = 'pending-update'
311 String prepareUpdateAAIVfModuleRequest = """
312 <PrepareUpdateAAIVfModuleRequest>
313 <vnf-id>${vnfId}</vnf-id>
314 <vf-module-id>${vfModuleId}</vf-module-id>
315 <orchestration-status>${orchestrationStatus}</orchestration-status>
316 </PrepareUpdateAAIVfModuleRequest>
318 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
319 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
320 utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
321 logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)
323 logDebug('Exited ' + method, isDebugLogEnabled)
324 } catch (BpmnError e) {
326 } catch (Exception e) {
327 logError('Caught exception in ' + method, e)
328 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
333 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
334 * Determine cloud region id for the volume group.
336 * @param execution The flow's execution instance.
338 public void prepConfirmVolumeGroupTenant(Execution execution) {
339 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
340 'execution=' + execution.getId() +
343 def prefix = execution.getVariable("prefix")
344 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
345 logDebug('Entered ' + method, isDebugLogEnabled)
348 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
351 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
352 AaiUtil aaiUtil = new AaiUtil(this)
353 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
354 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
355 utils.logAudit("CloudRegion Request: " + queryCloudRegionRequest)
357 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
358 utils.log("DEBUG", prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugLogEnabled)
360 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
362 if ((cloudRegion != "ERROR")) {
363 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
364 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
366 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
368 execution.setVariable(prefix + "isCloudRegionGood", true)
370 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
371 utils.log("DEBUG", errorMessage, isDebugLogEnabled)
372 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
373 execution.setVariable(prefix + "isCloudRegionGood", false)
375 utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"), isDebugLogEnabled)
377 } catch(BpmnError b){
378 utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugLogEnabled)
380 }catch (Exception e) {
382 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
383 utils.log("ERROR", " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, isDebugLogEnabled)
384 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
386 logDebug('Exited ' + method, isDebugLogEnabled)
391 * Prepare a Request for invoking the SDNC Adapter subflow to perform
392 * a VNF topology 'changeassign' operation.
394 * @param execution The flow's execution instance.
396 public void prepSDNCTopologyChg(Execution execution) {
397 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
398 'execution=' + execution.getId() +
400 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
401 logDebug('Entered ' + method, isDebugLogEnabled)
404 def requestId = execution.getVariable('DOUPVfMod_requestId')
405 String uuid = execution.getVariable('testReqId') // for junits
407 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
409 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
410 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
411 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
412 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
413 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
414 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
415 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
416 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
417 def vfModuleName = vfModule.getElementText('vf-module-name')
418 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
419 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
420 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
421 String usePreloadToSDNC = usePreload ? "Y" : "N"
422 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
423 def modelCustomizationUuidString = ""
425 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
428 // Retrieve vnf name from AAI response
429 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
430 execution.setVariable('DOUPVfMod_vnfName', vnfName)
432 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
433 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
435 String sdncTopologyRequest = """
436 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
437 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
438 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
439 <sdncadapter:RequestHeader>
440 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
441 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
442 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
443 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
444 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
445 </sdncadapter:RequestHeader>
446 <sdncadapterworkflow:SDNCRequestData>
447 <request-information>
448 <request-id>${requestId}</request-id>
449 <request-action>ChangeVNFActivateRequest</request-action>
450 <source>PORTAL</source>
454 </request-information>
455 <service-information>
456 <service-type>${serviceId}</service-type>
457 <service-instance-id>${vnfId}</service-instance-id>
458 <subscriber-name>dontcare</subscriber-name>
459 </service-information>
460 <vnf-request-information>
461 <vnf-id>${vfModuleId}</vnf-id>
462 <vnf-type>${vfModuleModelName}</vnf-type>
463 <vnf-name>${vfModuleName}</vnf-name>
464 <generic-vnf-id>${vnfId}</generic-vnf-id>
465 <generic-vnf-name>${vnfName}</generic-vnf-name>
466 <generic-vnf-type>${vnfType}</generic-vnf-type>
467 <tenant>${tenantId}</tenant>
468 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
469 ${modelCustomizationUuidString}
470 <use-preload>${usePreloadToSDNC}</use-preload>
472 </vnf-request-information>
473 </sdncadapterworkflow:SDNCRequestData>
474 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
476 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
477 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
478 utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)
479 logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)
481 logDebug('Exited ' + method, isDebugLogEnabled)
482 } catch (BpmnError e) {
484 } catch (Exception e) {
485 logError('Caught exception in ' + method, e)
486 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
491 * Prepare a Request for invoking the SDNC Adapter subflow to perform
492 * a VNF topology 'query' operation.
494 * @param execution The flow's execution instance.
496 public void prepSDNCTopologyQuery(Execution execution) {
497 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
498 'execution=' + execution.getId() +
500 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
501 logDebug('Entered ' + method, isDebugLogEnabled)
504 String uuid = execution.getVariable('testReqId') // for junits
506 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
508 def requestId = execution.getVariable('DOUPVfMod_requestId')
509 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
510 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
511 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
514 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
515 svcInstId = vfModuleId
518 svcInstId = serviceInstanceId
521 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
524 String sdncTopologyRequest = """
525 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
526 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
527 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
528 <sdncadapter:RequestHeader>
529 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
530 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
531 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
532 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
533 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
534 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
535 </sdncadapter:RequestHeader>
536 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
538 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
539 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
540 utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)
541 logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)
543 logDebug('Exited ' + method, isDebugLogEnabled)
544 } catch (BpmnError e) {
546 } catch (Exception e) {
547 logError('Caught exception in ' + method, e)
548 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
553 * Prepare a Request for invoking the VnfAdapterRest subflow.
555 * @param execution The flow's execution instance.
557 public void prepVnfAdapterRest(Execution execution) {
558 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
559 'execution=' + execution.getId() +
561 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
562 logDebug('Entered ' + method, isDebugLogEnabled)
565 def requestId = execution.getVariable('DOUPVfMod_requestId')
566 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
567 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
568 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
569 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
570 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
571 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
572 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
573 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
574 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
575 def heatStackId = vfModule.getElementText('heat-stack-id')
576 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
577 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
578 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
579 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
580 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
581 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
582 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
583 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
584 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
586 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
587 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
588 def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
589 if ('true'.equals(useQualifiedHostName)) {
590 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
593 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
595 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
597 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
598 vfModuleId, vfModuleName, null)
601 String vnfAdapterRestRequest = """
602 <updateVfModuleRequest>
603 <cloudSiteId>${cloudId}</cloudSiteId>
604 <tenantId>${tenantId}</tenantId>
605 <vnfId>${vnfId}</vnfId>
606 <vfModuleId>${vfModuleId}</vfModuleId>
607 <vfModuleStackId>${heatStackId}</vfModuleStackId>
608 <vnfType>${vnfType}</vnfType>
609 <vnfVersion>${asdcServiceModelVersion}</vnfVersion>
610 <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
611 <vfModuleType>${vfModuleModelName}</vfModuleType>
612 <volumeGroupId>${volumeGroupId}</volumeGroupId>
613 <volumeGroupStackId>${volumeGroupStackId}</volumeGroupStackId>
614 <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>
615 <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>
616 <skipAAI>true</skipAAI>
617 <backout>${backoutOnFailure}</backout>
618 <failIfExists>false</failIfExists>
623 <requestId>${requestId}</requestId>
624 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
626 <messageId>${messageId}</messageId>
627 <notificationUrl>${notificationUrl}</notificationUrl>
628 </updateVfModuleRequest>
630 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
631 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
632 utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
633 logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
635 logDebug('Exited ' + method, isDebugLogEnabled)
636 } catch (BpmnError e) {
638 } catch (Exception e) {
639 logError('Caught exception in ' + method, e)
640 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
645 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
647 * @param execution The flow's execution instance.
649 public void prepUpdateAAIGenericVnf(Execution execution) {
650 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
651 'execution=' + execution.getId() +
653 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
654 logDebug('Entered ' + method, isDebugLogEnabled)
657 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
658 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
660 def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id')
661 def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version')
662 if ((personaModelId == null) || (personaModelVersion == null)) {
663 logDebug('Skipping update for Generic VNF ' + vnfId +
664 ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled)
665 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
667 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
668 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
670 String updateAAIGenericVnfRequest = """
671 <UpdateAAIGenericVnfRequest>
672 <vnf-id>${vnfId}</vnf-id>
673 ${personaModelIdElement}
674 ${personaModelVersionElement}
675 </UpdateAAIGenericVnfRequest>
677 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
678 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
679 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
680 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
683 logDebug('Exited ' + method, isDebugLogEnabled)
684 } catch (BpmnError e) {
686 } catch (Exception e) {
687 logError('Caught exception in ' + method, e)
688 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
693 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
695 * @param execution The flow's execution instance.
697 public void prepUpdateAAIVfModule(Execution execution) {
698 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
699 'execution=' + execution.getId() +
701 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
702 logDebug('Entered ' + method, isDebugLogEnabled)
705 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
706 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
707 def orchestrationStatus = 'updated'
708 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
710 def volumeGroupIdElement = ''
711 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
712 if (volumeGroupId != null) {
713 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
715 def personaModelIdElement = ''
716 def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')
717 if (personaModelId != null) {
718 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
720 def personaModelVersionElement = ''
721 def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')
722 if (personaModelVersion != null) {
723 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
725 def contrailServiceInstanceFqdnElement = ''
726 def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')
727 if (contrailServiceInstanceFqdn != null) {
728 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
730 def personaModelCustomizationIdElement = ''
731 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
732 if (modelCustomizationId != null) {
733 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
736 String updateAAIVfModuleRequest = """
737 <UpdateAAIVfModuleRequest>
738 <vnf-id>${vnfId}</vnf-id>
739 <vf-module-id>${vfModuleId}</vf-module-id>
740 <orchestration-status>${orchestrationStatus}</orchestration-status>
741 ${volumeGroupIdElement}
742 ${personaModelIdElement}
743 ${personaModelVersionElement}
744 ${contrailServiceInstanceFqdnElement}
745 ${personaModelCustomizationIdElement}
746 </UpdateAAIVfModuleRequest>
749 logDebug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest, isDebugLogEnabled)
750 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
751 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
752 utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
753 logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled)
755 logDebug('Exited ' + method, isDebugLogEnabled)
756 } catch (BpmnError e) {
758 } catch (Exception e) {
759 logError('Caught exception in ' + method, e)
760 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
765 * Prepare a Request for invoking the SDNC Adapter subflow to perform
766 * a VNF topology 'activate' operation.
768 * @param execution The flow's execution instance.
770 public void prepSDNCTopologyAct(Execution execution) {
771 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
772 'execution=' + execution.getId() +
774 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
775 logDebug('Entered ' + method, isDebugLogEnabled)
778 String uuid = execution.getVariable('testReqId') // for junits
780 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
782 def requestId = execution.getVariable('DOUPVfMod_requestId')
783 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
784 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
785 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
786 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
787 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
788 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
789 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
790 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
791 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
792 def vfModuleName = vfModule.getElementText('vf-module-name')
793 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
794 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
796 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
797 String usePreloadToSDNC = usePreload ? "Y" : "N"
798 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
799 def modelCustomizationUuidString = ""
801 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
804 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
805 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
807 String sdncTopologyRequest = """
808 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
809 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
810 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
811 <sdncadapter:RequestHeader>
812 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
813 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
814 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
815 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
816 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
817 </sdncadapter:RequestHeader>
818 <sdncadapterworkflow:SDNCRequestData>
819 <request-information>
820 <request-id>${requestId}</request-id>
821 <request-action>ChangeVNFActivateRequest</request-action>
822 <source>PORTAL</source>
826 </request-information>
827 <service-information>
828 <service-type>${serviceId}</service-type>
829 <service-instance-id>${vnfId}</service-instance-id>
830 <subscriber-name>dontcare</subscriber-name>
831 </service-information>
832 <vnf-request-information>
833 <vnf-id>${vfModuleId}</vnf-id>
834 <vnf-type>${vfModuleModelName}</vnf-type>
835 <vnf-name>${vfModuleName}</vnf-name>
836 <generic-vnf-id>${vnfId}</generic-vnf-id>
837 <generic-vnf-name>${vnfName}</generic-vnf-name>
838 <generic-vnf-type>${vnfType}</generic-vnf-type>
839 <tenant>${tenantId}</tenant>
840 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
841 ${modelCustomizationUuidString}
842 <use-preload>${usePreloadToSDNC}</use-preload>
843 </vnf-request-information>
844 </sdncadapterworkflow:SDNCRequestData>
845 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
847 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
848 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
849 utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)
850 logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)
853 logDebug('Exited ' + method, isDebugLogEnabled)
854 } catch (BpmnError e) {
856 } catch (Exception e) {
857 logError('Caught exception in ' + method, e)
858 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
863 * Log a WorkflowException that has been created.
865 * @param execution The flow's execution instance.
867 public void handleWorkflowException(Execution execution) {
868 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
869 'execution=' + execution.getId() +
871 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
872 logDebug('Entered ' + method, isDebugLogEnabled)
875 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
876 logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage())
878 logDebug('Exited ' + method, isDebugLogEnabled)
879 } catch (BpmnError e) {
881 } catch (Exception e) {
882 logError('Caught exception in ' + method, e)
883 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
887 public void validateSDNCResponse(Execution execution, String response, String method){
888 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
889 def prefix = execution.getVariable("prefix")
891 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
893 WorkflowException workflowException = execution.getVariable("WorkflowException")
894 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
896 utils.logAudit("workflowException: " + workflowException)
898 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
899 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
901 utils.logAudit("SDNCResponse: " + response)
903 String sdncResponse = response
904 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
905 logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)
907 logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
908 throw new BpmnError("MSOWorkflowException")
910 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
914 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
915 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
917 * @param execution The flow's execution instance.
919 public void queryAAIVfModule(Execution execution) {
920 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
921 def method = getClass().getSimpleName() + '.getVfModule(' +
922 'execution=' + execution.getId() +
924 logDebug('Entered ' + method, isDebugLogEnabled)
927 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
928 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
930 AaiUtil aaiUriUtil = new AaiUtil(this)
931 String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
932 logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)
934 String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
935 utils.logAudit("AAI endPoint: " + endPoint)
938 def aaiRequestId = UUID.randomUUID().toString()
939 logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled)
940 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
941 utils.logAudit("createVfModule - invoking httpGet() to AAI")
943 def responseData = response.getResponseBodyAsString()
944 if (responseData != null) {
945 logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled)
949 utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData)
950 utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
952 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
953 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
954 logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)
955 logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)
956 if (response.getStatusCode() == 200) {
957 // Parse the VNF record from A&AI to find base module info
958 logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)
959 if (responseData != null) {
960 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
961 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
962 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
963 int vfModulesSize = 0
964 for (i in 0..vfModules.size()-1) {
965 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
966 def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
968 if (isBaseVfModule == "true") {
969 String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")
970 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
971 logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled)
972 String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id")
973 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
974 logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled)
979 } catch (Exception ex) {
981 logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled)
982 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
984 logDebug('Exited ' + method, isDebugLogEnabled)
985 } catch (BpmnError e) {
987 } catch (Exception e) {
988 logError('Caught exception in ' + method, e)
989 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())