f07bb0df4914ac91218a64e2ba5fe82f068d0edd
[so.git] / bpmn / MSOInfrastructureBPMN / src / main / groovy / org / openecomp / mso / bpmn / infrastructure / scripts / DoUpdateVfModule.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.mso.bpmn.infrastructure.scripts
22
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
35
36 public class DoUpdateVfModule extends VfModuleBase {
37
38         ExceptionUtil exceptionUtil = new ExceptionUtil()
39
40         /**
41          * Initialize the flow's variables.
42          *
43          * @param execution The flow's execution instance.
44          */
45         public void initProcessVariables(Execution execution) {
46                 execution.setVariable('prefix', 'DOUPVfMod_')
47                 execution.setVariable('DOUPVfMod_requestInfo', null)
48                 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
49                 execution.setVariable('DOUPVfMod_requestId', null)
50                 execution.setVariable('DOUPVfMod_vnfInputs', null)
51                 execution.setVariable('DOUPVfMod_vnfId', null)
52                 execution.setVariable('DOUPVfMod_vnfName', null)
53                 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
54                 execution.setVariable('DOUPVfMod_vfModuleName', null)
55                 execution.setVariable('DOUPVfMod_vfModuleId', null)
56                 execution.setVariable('DOUPVfMod_vnfType', null)
57                 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
58                 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
59                 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
60                 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
61                 execution.setVariable('DOUPVfMod_serviceId', null)
62                 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
63                 execution.setVariable('DOUPVfMod_tenantId', null)
64                 execution.setVariable('DOUPVfMod_volumeGroupId', null)
65                 execution.setVariable('DOUPVfMod_vfModule', null)
66                 execution.setVariable('DOUPVfMod_vnfParams', null)
67                 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
68                 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
69                 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
70                 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
71                 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
72                 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
73                 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
74                 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
75                 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
76                 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
77                 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
78                 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
79                 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
80                 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
81         }
82
83         /**
84          * Check for missing elements in the received request.
85          *
86          * @param execution The flow's execution instance.
87          */
88         public void preProcessRequest(Execution execution) {
89                 def method = getClass().getSimpleName() + '.preProcessRequest(' +
90                         'execution=' + execution.getId() +
91                         ')'
92                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
93                 logDebug('Entered ' + method, isDebugLogEnabled)
94
95                 try {
96                         initProcessVariables(execution)
97                         def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
98                         utils.logAudit("DoUpdateVfModule request: " + xml)
99                         logDebug('Received request xml:\n' + xml, isDebugLogEnabled)
100                         
101                         if (xml == null || xml.isEmpty()) {
102                                 // Building Block-type request
103
104                                 String cloudConfiguration = execution.getVariable("cloudConfiguration")
105                                 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
106                                 
107                                 def serviceModelInfo = execution.getVariable("serviceModelInfo")
108                                 logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled)
109                                 def vnfModelInfo = execution.getVariable("vnfModelInfo")
110                                 
111
112                                 //tenantId
113                                 def tenantId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.tenantId")
114                                 execution.setVariable("DOUPVfMod_tenantId", tenantId)
115                                 
116                                 //volumeGroupId
117                                 def volumeGroupId = execution.getVariable("volumeGroupId")
118                                 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
119                                 //volumeGroupName
120                                 def volumeGroupName = execution.getVariable("volumeGroupName")
121                                 execution.setVariable("DOUPVfMod_volumeGroupName", volumeGroupName)
122                                 //cloudSiteId
123                                 def cloudSiteId = jsonUtil.getJsonValue(cloudConfiguration, "cloudConfiguration.lcpCloudRegionId")
124                                 execution.setVariable("DOUPVfMod_cloudSiteId", cloudSiteId)
125                                 
126                                 logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled)
127                                 //vnfType
128                                 def vnfType = execution.getVariable("vnfType")
129                                 execution.setVariable("DOUPVfMod_vnfType", vnfType)
130                                 
131                                 logDebug("vnfType: " + vnfType, isDebugLogEnabled)
132                                 //vnfName
133                                 def vnfName = execution.getVariable("vnfName")
134                                 execution.setVariable("DOUPVfMod_vnfName", vnfName)
135                                 
136                                 logDebug("vnfName: " + vnfName, isDebugLogEnabled)
137                                 //vnfId
138                                 def vnfId = execution.getVariable("vnfId")
139                                 execution.setVariable("DOUPVfMod_vnfId", vnfId)
140                                 
141                                 logDebug("vnfId: " + vnfId, isDebugLogEnabled)
142                                 //vfModuleName
143                                 def vfModuleName = execution.getVariable("vfModuleName")
144                                 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
145                                 
146                                 logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled)
147                                 //vfModuleModelName
148                                 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
149                                 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
150                                 
151                                 logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled)
152                                 //modelCustomizationUuid
153                                 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationId")
154                                 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
155                                 
156                                 logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled)
157                                 //vfModuleId
158                                 def vfModuleId = execution.getVariable("vfModuleId")
159                                 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
160                                 logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled)
161                                 def requestId = execution.getVariable("requestId")
162                                 execution.setVariable("DOUPVfMod_requestId", requestId)
163                                 logDebug("requestId: " + requestId, isDebugLogEnabled)
164                                 // Set mso-request-id to request-id for VNF Adapter interface
165                                 execution.setVariable("mso-request-id", requestId)
166                                 //serviceId
167                                 def serviceId = execution.getVariable("serviceId")
168                                 execution.setVariable("DOUPVfMod_serviceId", serviceId)
169                                 logDebug("serviceId: " + serviceId, isDebugLogEnabled)
170                                 //serviceInstanceId
171                                 def serviceInstanceId = execution.getVariable("serviceInstanceId")
172                                 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
173                                 
174                                 logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled)
175                                 //source - HARDCODED
176                                 def source = "VID"
177                                 execution.setVariable("DOUPVfMod_source", source)
178                                 
179                                 logDebug("source: " + source, isDebugLogEnabled)
180                                 //backoutOnFailure
181                                 def disableRollback = execution.getVariable("disableRollback")
182                                 def backoutOnFailure = true
183                                 if (disableRollback != null && disableRollback.equals("true")) {
184                                         backoutOnFailure = false
185                                 }
186                                 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
187                                 logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled)
188                                 //isBaseVfModule
189                                 def isBaseVfModule = execution.getVariable("isBaseVfModule")
190                                 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
191                                 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)
192                                 //asdcServiceModelVersion
193                                 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
194                                 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
195                                 logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled)
196                                 //personaModelId
197                                 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantId"))
198                                 //personaModelVersion
199                                 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
200                                 //Get or Generate UUID
201                                 String uuid = execution.getVariable("DOUPVfMod_uuid")
202                                 if(uuid == null){
203                                         uuid = UUID.randomUUID()
204                                         logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled)
205                                 }else{
206                                         logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled)
207                                 }
208                                 //isVidRequest
209                                 String isVidRequest = execution.getVariable("isVidRequest")
210                                 // default to true
211                                 if (isVidRequest == null || isVidRequest.isEmpty()) {
212                                         execution.setVariable("isVidRequest", "true")
213                                 }
214                                 //globalSubscriberId
215                                 String globalSubscriberId = execution.getVariable("globalSubscriberId")
216                                 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
217                                 logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled)
218                                 //vnfQueryPath
219                                 String vnfQueryPath = execution.getVariable("vnfQueryPath")
220                                 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
221                                 logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled)
222                                 
223                                 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
224                                 if (vfModuleInputParams != null) {
225                                         execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)                                    
226                                 }                               
227                         }
228                         else {
229
230                                 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
231                                 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
232                                 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
233                                 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
234                                 if (serviceInstanceId == null) {
235                                         serviceInstanceId = ''
236                                 }
237                                 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
238         
239                                 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
240                                 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
241                                 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
242                                 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
243                                 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
244                                 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
245                                 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
246                                 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
247                                 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
248                                 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
249                                 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
250                                 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
251                                 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
252                                 //isBaseVfModule
253                                 def isBaseVfModule = "false"
254                                 if (utils.nodeExists(xml, "is-base-vf-module")) {
255                                         isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
256                                         execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
257                                 }
258                                 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)
259         
260                                 NetworkUtils networkUtils = new NetworkUtils()
261                                 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
262                                 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
263         
264                                 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
265                                 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
266         
267                                 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
268                         }
269
270                         def sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
271                         if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
272                                 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
273                                 logError(msg)
274                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
275                         }
276
277                         logDebug('Exited ' + method, isDebugLogEnabled)
278                 } catch (BpmnError e) {
279                         throw e;
280                 } catch (Exception e) {
281                         logError('Caught exception in ' + method, e)
282                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
283                 }
284         }
285
286         /**
287          * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow.  This will
288          * set the orchestration-status to 'pending-update'.
289          *
290          * @param execution The flow's execution instance.
291          */
292         public void prepPrepareUpdateAAIVfModule(Execution execution) {
293                 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
294                         'execution=' + execution.getId() +
295                         ')'
296                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
297                 logDebug('Entered ' + method, isDebugLogEnabled)
298
299                 try {
300                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
301                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
302                         def orchestrationStatus = 'pending-update'
303
304                         String prepareUpdateAAIVfModuleRequest = """
305                                 <PrepareUpdateAAIVfModuleRequest>
306                                         <vnf-id>${vnfId}</vnf-id>
307                                         <vf-module-id>${vfModuleId}</vf-module-id>
308                                         <orchestration-status>${orchestrationStatus}</orchestration-status>
309                                 </PrepareUpdateAAIVfModuleRequest>
310                         """
311                         prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
312                         execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
313                         utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
314                         logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)
315
316                         logDebug('Exited ' + method, isDebugLogEnabled)
317                 } catch (BpmnError e) {
318                         throw e;
319                 } catch (Exception e) {
320                         logError('Caught exception in ' + method, e)
321                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
322                 }
323         }
324
325         /**
326          * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.  Currently,
327          * there is really nothing to do, so we just log that we're passing through.
328          *
329          * @param execution The flow's execution instance.
330          */
331         public void prepConfirmVolumeGroupTenant(Execution execution) {
332                 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
333                         'execution=' + execution.getId() +
334                         ')'
335                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
336                 logDebug('Entered ' + method, isDebugLogEnabled)
337
338                 try {
339                         // Nothing to do - just log that we're passing through here
340
341                         logDebug('Exited ' + method, isDebugLogEnabled)
342                 } catch (BpmnError e) {
343                         throw e;
344                 } catch (Exception e) {
345                         logError('Caught exception in ' + method, e)
346                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepConfirmVolumeGroupTenant(): ' + e.getMessage())
347                 }
348         }
349
350         /**
351          * Prepare a Request for invoking the SDNC Adapter subflow to perform
352          * a VNF topology 'changeassign' operation.
353          *
354          * @param execution The flow's execution instance.
355          */
356         public void prepSDNCTopologyChg(Execution execution) {
357                 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
358                         'execution=' + execution.getId() +
359                         ')'
360                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
361                 logDebug('Entered ' + method, isDebugLogEnabled)
362
363                 try {
364                         def requestId = execution.getVariable('DOUPVfMod_requestId')
365                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
366                         def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
367                         def serviceId = execution.getVariable('DOUPVfMod_serviceId')
368                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
369                         def vnfType = execution.getVariable('DOUPVfMod_vnfType')
370                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
371                         def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
372                         def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
373                         def vfModuleName = vfModule.getElementText('vf-module-name')
374                         def tenantId = execution.getVariable('DOUPVfMod_tenantId')
375                         def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
376
377                         // Retrieve vnf name from AAI response
378                         def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
379                         execution.setVariable('DOUPVfMod_vnfName', vnfName)
380
381                         def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
382                         def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
383
384                         String sdncTopologyRequest = """
385                                 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
386                                                 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
387                                                 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
388                                         <sdncadapter:RequestHeader>
389                                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
390                                                 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
391                                                 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
392                                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
393                                                 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
394                                         </sdncadapter:RequestHeader>
395                                         <sdncadapterworkflow:SDNCRequestData>
396                                               <request-information>
397                                                  <request-id>${requestId}</request-id>
398                                                  <request-action>ChangeVNFActivateRequest</request-action>
399                                                  <source>PORTAL</source>
400                                                  <notification-url/>
401                                                  <order-number/>
402                                                  <order-version/>
403                                               </request-information>
404                                               <service-information>
405                                                  <service-type>${serviceId}</service-type>
406                                                  <service-instance-id>${vnfId}</service-instance-id>
407                                                  <subscriber-name>dontcare</subscriber-name>
408                                               </service-information>
409                                               <vnf-request-information>
410                                                  <vnf-id>${vfModuleId}</vnf-id>
411                                                  <vnf-type>${vfModuleModelName}</vnf-type>
412                                                  <vnf-name>${vfModuleName}</vnf-name>
413                                                  <generic-vnf-id>${vnfId}</generic-vnf-id>
414                                                  <generic-vnf-name>${vnfName}</generic-vnf-name>
415                                                          <generic-vnf-type>${vnfType}</generic-vnf-type>
416                                                  <tenant>${tenantId}</tenant>
417                                                  <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
418                                                  ${vnfNetworks}
419                                               </vnf-request-information>
420                                         </sdncadapterworkflow:SDNCRequestData>
421                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
422                         """
423                         sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
424                         execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
425                         utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)
426                         logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)
427
428                         logDebug('Exited ' + method, isDebugLogEnabled)
429                 } catch (BpmnError e) {
430                         throw e;
431                 } catch (Exception e) {
432                         logError('Caught exception in ' + method, e)
433                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
434                 }
435         }
436
437         /**
438          * Prepare a Request for invoking the SDNC Adapter subflow to perform
439          * a VNF topology 'query' operation.
440          *
441          * @param execution The flow's execution instance.
442          */
443         public void prepSDNCTopologyQuery(Execution execution) {
444                 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
445                         'execution=' + execution.getId() +
446                         ')'
447                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
448                 logDebug('Entered ' + method, isDebugLogEnabled)
449
450                 try {
451                         def requestId = execution.getVariable('DOUPVfMod_requestId')
452                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
453                         def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
454                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
455
456                         def svcInstId = ""
457                         if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
458                                 svcInstId = vfModuleId
459                         }
460                         else {
461                                 svcInstId = serviceInstanceId
462                         }
463
464                         //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
465                         sleep(5000)
466
467                         String sdncTopologyRequest = """
468                                 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
469                                                 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
470                                                 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
471                                         <sdncadapter:RequestHeader>
472                                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
473                                                 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
474                                                 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
475                                                 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
476                                                 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
477                                                 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
478                                         </sdncadapter:RequestHeader>
479                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
480                         """
481                         sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
482                         execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
483                         utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)
484                         logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)
485
486                         logDebug('Exited ' + method, isDebugLogEnabled)
487                 } catch (BpmnError e) {
488                         throw e;
489                 } catch (Exception e) {
490                         logError('Caught exception in ' + method, e)
491                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
492                 }
493         }
494
495         /**
496          * Prepare a Request for invoking the VnfAdapterRest subflow.
497          *
498          * @param execution The flow's execution instance.
499          */
500         public void prepVnfAdapterRest(Execution execution) {
501                 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
502                         'execution=' + execution.getId() +
503                         ')'
504                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
505                 logDebug('Entered ' + method, isDebugLogEnabled)
506
507                 try {
508                         def requestId = execution.getVariable('DOUPVfMod_requestId')
509                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
510                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
511                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
512                         def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
513                         def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
514                         def tenantId = execution.getVariable('DOUPVfMod_tenantId')
515                         def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
516                         def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
517                         def heatStackId = vfModule.getElementText('heat-stack-id')
518                         def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
519                         def vnfType = execution.getVariable('DOUPVfMod_vnfType')
520                         def vnfName = execution.getVariable('DOUPVfMod_vnfName')
521                         def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
522                         def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
523                         def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
524                         def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
525                         def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
526                         def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
527                         
528                         def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
529                         def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
530                         def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
531                         if ('true'.equals(useQualifiedHostName)) {
532                                         notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
533                         }
534                         
535                         Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
536
537                         String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
538
539                         String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
540                                         vfModuleId, vfModuleName, null)
541
542
543                         String vnfAdapterRestRequest = """
544                                 <updateVfModuleRequest>
545                                         <cloudSiteId>${cloudId}</cloudSiteId>
546                                         <tenantId>${tenantId}</tenantId>
547                                         <vnfId>${vnfId}</vnfId>
548                                         <vfModuleId>${vfModuleId}</vfModuleId>
549                                         <vfModuleStackId>${heatStackId}</vfModuleStackId>
550                                         <vnfType>${vnfType}</vnfType>
551                                         <vnfVersion>${asdcServiceModelVersion}</vnfVersion>
552                                         <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
553                                         <vfModuleType>${vfModuleModelName}</vfModuleType>
554                                         <volumeGroupId>${volumeGroupId}</volumeGroupId>
555                                         <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>
556                                 <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>
557                                         <skipAAI>true</skipAAI>
558                                         <backout>${backoutOnFailure}</backout>
559                                     <failIfExists>false</failIfExists>
560                                         <vfModuleParams>
561                                                 ${vfModuleParams}
562                                     </vfModuleParams>
563                                     <msoRequest>
564                                         <requestId>${requestId}</requestId>
565                                         <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
566                                     </msoRequest>
567                                     <messageId>${messageId}</messageId>
568                                     <notificationUrl>${notificationUrl}</notificationUrl>
569                                 </updateVfModuleRequest>
570                         """
571                         vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
572                         execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
573                         utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
574                         logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
575
576                         logDebug('Exited ' + method, isDebugLogEnabled)
577                 } catch (BpmnError e) {
578                         throw e;
579                 } catch (Exception e) {
580                         logError('Caught exception in ' + method, e)
581                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
582                 }
583         }
584
585         /**
586          * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
587          *
588          * @param execution The flow's execution instance.
589          */
590         public void prepUpdateAAIGenericVnf(Execution execution) {
591                 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
592                         'execution=' + execution.getId() +
593                         ')'
594                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
595                 logDebug('Entered ' + method, isDebugLogEnabled)
596
597                 try {
598                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
599                         def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
600
601                         def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id')
602                         def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version')
603                         if ((personaModelId == null) || (personaModelVersion == null)) {
604                                 logDebug('Skipping update for Generic VNF ' + vnfId +
605                                         ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled)
606                                 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
607                         } else {
608                                 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
609                                 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
610
611                                 String updateAAIGenericVnfRequest = """
612                                         <UpdateAAIGenericVnfRequest>
613                                                 <vnf-id>${vnfId}</vnf-id>
614                                                 ${personaModelIdElement}
615                                                 ${personaModelVersionElement}
616                                         </UpdateAAIGenericVnfRequest>
617                                 """
618                                 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
619                                 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
620                                 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
621                                 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
622                         }
623
624                         logDebug('Exited ' + method, isDebugLogEnabled)
625                 } catch (BpmnError e) {
626                         throw e;
627                 } catch (Exception e) {
628                         logError('Caught exception in ' + method, e)
629                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
630                 }
631         }
632
633         /**
634          * Prepare a Request for invoking the UpdateAAIVfModule subflow.
635          *
636          * @param execution The flow's execution instance.
637          */
638         public void prepUpdateAAIVfModule(Execution execution) {
639                 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
640                         'execution=' + execution.getId() +
641                         ')'
642                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
643                 logDebug('Entered ' + method, isDebugLogEnabled)
644
645                 try {
646                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
647                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
648                         def orchestrationStatus = 'updated'
649                         def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
650
651                         def volumeGroupIdElement = ''
652                         def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
653                         if (volumeGroupId != null) {
654                                 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
655                         }
656                         def personaModelIdElement = ''
657                         def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')
658                         if (personaModelId != null) {
659                                 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
660                         }
661                         def personaModelVersionElement = ''
662                         def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')
663                         if (personaModelVersion != null) {
664                                 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
665                         }
666                         def contrailServiceInstanceFqdnElement = ''
667                         def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')
668                         if (contrailServiceInstanceFqdn != null) {
669                                 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
670                         }
671                         def personaModelCustomizationIdElement = ''
672                         def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
673                         if (modelCustomizationId != null) {
674                                 personaModelCustomizationIdElement = '<persona-model-customization-id>' + modelCustomizationId + '</persona-model-customization-id>'
675                         }
676
677                         String updateAAIVfModuleRequest = """
678                                 <UpdateAAIVfModuleRequest>
679                                         <vnf-id>${vnfId}</vnf-id>
680                                         <vf-module-id>${vfModuleId}</vf-module-id>
681                                         <orchestration-status>${orchestrationStatus}</orchestration-status>
682                                         ${volumeGroupIdElement}
683                                         ${personaModelIdElement}
684                                         ${personaModelVersionElement}
685                                         ${contrailServiceInstanceFqdnElement}
686                                         ${personaModelCustomizationIdElement}
687                                 </UpdateAAIVfModuleRequest>
688                         """
689                         
690                         logDebug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest, isDebugLogEnabled)
691                         updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
692                         execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
693                         utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
694                         logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled)
695
696                         logDebug('Exited ' + method, isDebugLogEnabled)
697                 } catch (BpmnError e) {
698                         throw e;
699                 } catch (Exception e) {
700                         logError('Caught exception in ' + method, e)
701                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
702                 }
703         }
704
705         /**
706          * Prepare a Request for invoking the SDNC Adapter subflow to perform
707          * a VNF topology 'activate' operation.
708          *
709          * @param execution The flow's execution instance.
710          */
711         public void prepSDNCTopologyAct(Execution execution) {
712                 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
713                         'execution=' + execution.getId() +
714                         ')'
715                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
716                 logDebug('Entered ' + method, isDebugLogEnabled)
717
718                 try {
719                         def requestId = execution.getVariable('DOUPVfMod_requestId')
720                         def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
721                         def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
722                         def serviceId = execution.getVariable('DOUPVfMod_serviceId')
723                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
724                         def vnfName = execution.getVariable('DOUPVfMod_vnfName')
725                         def vnfType = execution.getVariable('DOUPVfMod_vnfType')
726                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
727                         def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
728                         def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
729                         def vfModuleName = vfModule.getElementText('vf-module-name')
730                         def tenantId = execution.getVariable('DOUPVfMod_tenantId')
731                         def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
732
733                         def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
734                         def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
735
736                         String sdncTopologyRequest = """
737                                 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
738                                                 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
739                                                 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
740                                         <sdncadapter:RequestHeader>
741                                                 <sdncadapter:RequestId>${requestId}</sdncadapter:RequestId>
742                                                 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
743                                                 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
744                                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
745                                                 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
746                                         </sdncadapter:RequestHeader>
747                                         <sdncadapterworkflow:SDNCRequestData>
748                                               <request-information>
749                                                  <request-id>${requestId}</request-id>
750                                                  <request-action>ChangeVNFActivateRequest</request-action>
751                                                  <source>PORTAL</source>
752                                                  <notification-url/>
753                                                  <order-number/>
754                                                  <order-version/>
755                                               </request-information>
756                                               <service-information>
757                                                  <service-type>${serviceId}</service-type>
758                                                  <service-instance-id>${vnfId}</service-instance-id>
759                                                  <subscriber-name>dontcare</subscriber-name>
760                                               </service-information>
761                                               <vnf-request-information>
762                                                  <vnf-id>${vfModuleId}</vnf-id>
763                                                  <vnf-type>${vfModuleModelName}</vnf-type>
764                                                  <vnf-name>${vfModuleName}</vnf-name>
765                                                  <generic-vnf-id>${vnfId}</generic-vnf-id>
766                                                  <generic-vnf-name>${vnfName}</generic-vnf-name>
767                                                          <generic-vnf-type>${vnfType}</generic-vnf-type>
768                                                  <tenant>${tenantId}</tenant>
769                                                  <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
770                                               </vnf-request-information>
771                                         </sdncadapterworkflow:SDNCRequestData>
772                                 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
773                         """
774                         sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
775                         execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
776                         utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)
777                         logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)
778
779
780                         logDebug('Exited ' + method, isDebugLogEnabled)
781                 } catch (BpmnError e) {
782                         throw e;
783                 } catch (Exception e) {
784                         logError('Caught exception in ' + method, e)
785                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
786                 }
787         }
788
789         /**
790          * Log a WorkflowException that has been created.
791          *
792          * @param execution The flow's execution instance.
793          */
794         public void handleWorkflowException(Execution execution) {
795                 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
796                         'execution=' + execution.getId() +
797                         ')'
798                 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
799                 logDebug('Entered ' + method, isDebugLogEnabled)
800
801                 try {
802                         def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
803                         logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage())
804
805                         logDebug('Exited ' + method, isDebugLogEnabled)
806                 } catch (BpmnError e) {
807                         throw e;
808                 } catch (Exception e) {
809                         logError('Caught exception in ' + method, e)
810                         exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
811                 }
812         }
813
814         public void validateSDNCResponse(Execution execution, String response, String method){
815                 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
816                 def prefix = execution.getVariable("prefix")
817
818                 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
819
820                 WorkflowException workflowException = execution.getVariable("WorkflowException")
821                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
822
823                 utils.logAudit("workflowException: " + workflowException)
824
825                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
826                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
827
828                 utils.logAudit("SDNCResponse: " + response)
829
830                 String sdncResponse = response
831                 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
832                         logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse, isDebugLogEnabled)
833                 }else{
834                         logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
835                         throw new BpmnError("MSOWorkflowException")
836                 }
837                 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
838         }
839
840         /**
841          * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
842          * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
843          *
844          * @param execution The flow's execution instance.
845          */
846         public void queryAAIVfModule(Execution execution) {
847                 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
848                 def method = getClass().getSimpleName() + '.getVfModule(' +
849                         'execution=' + execution.getId() +
850                         ')'
851                 logDebug('Entered ' + method, isDebugLogEnabled)
852
853                 try {
854                         def vnfId = execution.getVariable('DOUPVfMod_vnfId')
855                         def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
856
857                         AaiUtil aaiUriUtil = new AaiUtil(this)
858                         String  aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
859                         logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)
860
861                         String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
862                         utils.logAudit("AAI endPoint: " + endPoint)
863
864                         try {
865                                 def aaiRequestId = UUID.randomUUID().toString()
866                                 logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled)
867                                 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
868                                 utils.logAudit("createVfModule - invoking httpGet() to AAI")
869
870                                 def responseData = response.getResponseBodyAsString()
871                                 if (responseData != null) {
872                                         logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled)
873
874                                 }
875
876                                 utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData)
877                                 utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
878
879                                 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
880                                 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
881                                 logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)
882                                 logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)
883                                 if (response.getStatusCode() == 200) {
884                                         // Parse the VNF record from A&AI to find base module info
885                                         logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)
886                                         if (responseData != null) {
887                                                 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
888                                                 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
889                                                 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
890                                                 int vfModulesSize = 0
891                                                 for (i in 0..vfModules.size()-1) {
892                                                         def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
893                                                         def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
894
895                                                         if (isBaseVfModule == "true") {
896                                                             String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")
897                                                             execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
898                                                             logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled)
899                                                             String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id")
900                                                             execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
901                                                             logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled)
902                                                         }
903                                                 }
904                                         }
905                                 }
906                         } catch (Exception ex) {
907                                 ex.printStackTrace()
908                                 logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled)
909                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
910                         }
911                         logDebug('Exited ' + method, isDebugLogEnabled)
912                 } catch (BpmnError e) {
913                         throw e;
914                 } catch (Exception e) {
915                         logError('Caught exception in ' + method, e)
916                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
917                 }
918         }
919
920
921 }