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.delegate.DelegateExecution
25 import org.openecomp.mso.bpmn.common.scripts.AaiUtil
26 import org.openecomp.mso.bpmn.common.scripts.CatalogDbUtils
27 import org.openecomp.mso.bpmn.common.scripts.ExceptionUtil
28 import org.openecomp.mso.bpmn.common.scripts.NetworkUtils
29 import org.openecomp.mso.bpmn.common.scripts.SDNCAdapterUtils
30 import org.openecomp.mso.bpmn.common.scripts.VfModule
31 import org.openecomp.mso.bpmn.common.scripts.VfModuleBase
32 import org.openecomp.mso.bpmn.core.WorkflowException
33 import org.openecomp.mso.bpmn.core.json.JsonUtils;
34 import org.openecomp.mso.client.aai.AAIResourcesClient
35 import org.openecomp.mso.client.aai.entities.AAIResultWrapper
36 import org.openecomp.mso.client.aai.entities.uri.AAIUri
37 import org.openecomp.mso.rest.APIResponse
38 import org.springframework.web.util.UriUtils
39 import org.openecomp.mso.client.aai.AAIObjectType;
40 import org.openecomp.mso.client.aai.entities.uri.AAIUriFactory;
43 public class DoUpdateVfModule extends VfModuleBase {
45 ExceptionUtil exceptionUtil = new ExceptionUtil()
46 JsonUtils jsonUtil = new JsonUtils()
47 CatalogDbUtils catalog = new CatalogDbUtils()
50 * Initialize the flow's variables.
52 * @param execution The flow's execution instance.
54 public void initProcessVariables(DelegateExecution execution) {
55 execution.setVariable('prefix', 'DOUPVfMod_')
56 execution.setVariable('DOUPVfMod_requestInfo', null)
57 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
58 execution.setVariable('DOUPVfMod_requestId', null)
59 execution.setVariable('DOUPVfMod_vnfInputs', null)
60 execution.setVariable('DOUPVfMod_vnfId', null)
61 execution.setVariable('DOUPVfMod_vnfName', null)
62 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
63 execution.setVariable('DOUPVfMod_vfModuleName', null)
64 execution.setVariable('DOUPVfMod_vfModuleId', null)
65 execution.setVariable('DOUPVfMod_vnfType', null)
66 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
67 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
68 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
69 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
70 execution.setVariable('DOUPVfMod_serviceId', null)
71 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
72 execution.setVariable('DOUPVfMod_tenantId', null)
73 execution.setVariable('DOUPVfMod_volumeGroupId', null)
74 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
75 execution.setVariable('DOUPVfMod_vfModule', null)
76 execution.setVariable('DOUPVfMod_vnfParams', null)
77 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
78 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
79 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
80 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
81 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
82 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
83 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
84 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
85 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
86 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
87 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
88 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
89 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
90 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
94 * Check for missing elements in the received request.
96 * @param execution The flow's execution instance.
98 public void preProcessRequest(DelegateExecution execution) {
99 def method = getClass().getSimpleName() + '.preProcessRequest(' +
100 'execution=' + execution.getId() +
102 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
103 logDebug('Entered ' + method, isDebugLogEnabled)
106 initProcessVariables(execution)
107 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
108 utils.logAudit("DoUpdateVfModule request: " + xml)
109 logDebug('Received request xml:\n' + xml, isDebugLogEnabled)
111 if (xml == null || xml.isEmpty()) {
112 // Building Block-type request
114 String cloudConfiguration = execution.getVariable("cloudConfiguration")
115 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
117 def serviceModelInfo = execution.getVariable("serviceModelInfo")
118 logDebug("serviceModelInfo: " + serviceModelInfo, isDebugLogEnabled)
119 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
120 logDebug("modelInvariantUuid: " + modelInvariantUuid, isDebugLogEnabled)
121 def vnfModelInfo = execution.getVariable("vnfModelInfo")
124 def tenantId = execution.getVariable("tenantId")
125 execution.setVariable("DOUPVfMod_tenantId", tenantId)
128 def volumeGroupId = execution.getVariable("volumeGroupId")
129 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
132 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
133 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
135 logDebug("cloudSiteId: " + cloudSiteId, isDebugLogEnabled)
137 def vnfType = execution.getVariable("vnfType")
138 execution.setVariable("DOUPVfMod_vnfType", vnfType)
140 logDebug("vnfType: " + vnfType, isDebugLogEnabled)
142 def vnfName = execution.getVariable("vnfName")
143 execution.setVariable("DOUPVfMod_vnfName", vnfName)
145 logDebug("vnfName: " + vnfName, isDebugLogEnabled)
147 def vnfId = execution.getVariable("vnfId")
148 execution.setVariable("DOUPVfMod_vnfId", vnfId)
150 logDebug("vnfId: " + vnfId, isDebugLogEnabled)
152 def vfModuleName = execution.getVariable("vfModuleName")
153 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
155 logDebug("vfModuleName: " + vfModuleName, isDebugLogEnabled)
157 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
158 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
160 logDebug("vfModuleModelName: " + vfModuleModelName, isDebugLogEnabled)
161 //modelCustomizationUuid
162 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
163 if (modelCustomizationUuid == null) {
164 modelCustomizationUuid = ""
166 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
168 logDebug("modelCustomizationUuid: " + modelCustomizationUuid, isDebugLogEnabled)
170 def vfModuleId = execution.getVariable("vfModuleId")
171 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
172 logDebug("vfModuleId: " + vfModuleId, isDebugLogEnabled)
173 def requestId = execution.getVariable("msoRequestId")
174 execution.setVariable("DOUPVfMod_requestId", requestId)
175 logDebug("requestId: " + requestId, isDebugLogEnabled)
176 // Set mso-request-id to request-id for VNF Adapter interface
177 execution.setVariable("mso-request-id", requestId)
179 def serviceId = execution.getVariable("serviceId")
180 execution.setVariable("DOUPVfMod_serviceId", serviceId)
181 logDebug("serviceId: " + serviceId, isDebugLogEnabled)
183 def serviceInstanceId = execution.getVariable("serviceInstanceId")
184 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
186 logDebug("serviceInstanceId: " + serviceInstanceId, isDebugLogEnabled)
189 execution.setVariable("DOUPVfMod_source", source)
191 logDebug("source: " + source, isDebugLogEnabled)
193 def disableRollback = execution.getVariable("disableRollback")
194 def backoutOnFailure = true
195 if (disableRollback != null && disableRollback.equals("true")) {
196 backoutOnFailure = false
198 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
199 logDebug("backoutOnFailure: " + backoutOnFailure, isDebugLogEnabled)
201 def isBaseVfModule = execution.getVariable("isBaseVfModule")
202 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
203 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)
204 //asdcServiceModelVersion
205 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
206 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
207 logDebug("asdcServiceModelVersion: " + asdcServiceModelVersion, isDebugLogEnabled)
209 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
210 //personaModelVersion
211 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
212 //Get or Generate UUID
213 String uuid = execution.getVariable("DOUPVfMod_uuid")
215 uuid = UUID.randomUUID()
216 logDebug("Generated messageId (UUID) is: " + uuid, isDebugLogEnabled)
218 logDebug("Found messageId (UUID) is: " + uuid, isDebugLogEnabled)
221 String isVidRequest = execution.getVariable("isVidRequest")
223 if (isVidRequest == null || isVidRequest.isEmpty()) {
224 execution.setVariable("isVidRequest", "true")
227 def usePreload = execution.getVariable("usePreload")
228 execution.setVariable("DOUPVfMod_usePreload", usePreload)
229 logDebug("usePreload: " + usePreload, isDebugLogEnabled)
231 String globalSubscriberId = execution.getVariable("globalSubscriberId")
232 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
233 logDebug("globalSubsrciberId: " + globalSubscriberId, isDebugLogEnabled)
235 String vnfQueryPath = execution.getVariable("vnfQueryPath")
236 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
237 logDebug("vnfQueryPath: " + vnfQueryPath, isDebugLogEnabled)
239 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
240 if (vfModuleInputParams != null) {
241 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
243 //get workload and environment context from parent SI
244 String environmentContext = ""
245 String workloadContext =""
246 String serviceType =""
249 String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
250 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
253 } catch (Exception ex){
254 String msg = "Exception in preProcessRequest " + ex.getMessage()
255 utils.log("DEBUG", msg, isDebugLogEnabled)
256 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
260 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
261 AAIResourcesClient aaiRC = new AAIResourcesClient()
262 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
263 Map<String, Object> aaiJson = aaiRW.asMap()
264 environmentContext = aaiJson.getOrDefault("environment-context","")
265 workloadContext = aaiJson.getOrDefault("workload-context","")
267 }catch (Exception ex) {
268 utils.log("DEBUG","Error retreiving parent service instance information", isDebugLogEnabled)
271 execution.setVariable("DCVFM_environmentContext",environmentContext)
272 execution.setVariable("DCVFM_workloadContext",workloadContext)
276 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
277 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
278 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
279 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
280 if (serviceInstanceId == null) {
281 serviceInstanceId = ''
283 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
285 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
286 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
287 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
288 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
289 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
290 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
291 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
292 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
293 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
294 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
295 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
296 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
297 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
299 def isBaseVfModule = "false"
300 if (utils.nodeExists(xml, "is-base-vf-module")) {
301 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
302 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
304 logDebug("isBaseVfModule: " + isBaseVfModule, isDebugLogEnabled)
306 NetworkUtils networkUtils = new NetworkUtils()
307 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
308 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
310 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
311 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
313 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
316 def sdncCallbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
317 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
318 def msg = 'Required variable \'URN_mso_workflow_sdncadapter_callback\' is missing'
320 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
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 preProcessRequest(): ' + e.getMessage())
333 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
334 * set the orchestration-status to 'pending-update'.
336 * @param execution The flow's execution instance.
338 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
339 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
340 'execution=' + execution.getId() +
342 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
343 logDebug('Entered ' + method, isDebugLogEnabled)
346 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
347 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
348 def orchestrationStatus = 'pending-update'
350 String prepareUpdateAAIVfModuleRequest = """
351 <PrepareUpdateAAIVfModuleRequest>
352 <vnf-id>${vnfId}</vnf-id>
353 <vf-module-id>${vfModuleId}</vf-module-id>
354 <orchestration-status>${orchestrationStatus}</orchestration-status>
355 </PrepareUpdateAAIVfModuleRequest>
357 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
358 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
359 utils.logAudit("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
360 logDebug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest, isDebugLogEnabled)
362 logDebug('Exited ' + method, isDebugLogEnabled)
363 } catch (BpmnError e) {
365 } catch (Exception e) {
366 logError('Caught exception in ' + method, e)
367 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
372 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
373 * Determine cloud region id for the volume group.
375 * @param execution The flow's execution instance.
377 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
378 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
379 'execution=' + execution.getId() +
382 def prefix = execution.getVariable("prefix")
383 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
384 logDebug('Entered ' + method, isDebugLogEnabled)
387 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
390 String aai_endpoint = execution.getVariable("URN_aai_endpoint")
391 AaiUtil aaiUtil = new AaiUtil(this)
392 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
393 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
394 utils.logAudit("CloudRegion Request: " + queryCloudRegionRequest)
396 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
397 utils.log("DEBUG", prefix + "queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest, isDebugLogEnabled)
399 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
401 if ((cloudRegion != "ERROR")) {
402 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
403 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
405 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
407 execution.setVariable(prefix + "isCloudRegionGood", true)
409 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
410 utils.log("DEBUG", errorMessage, isDebugLogEnabled)
411 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
412 execution.setVariable(prefix + "isCloudRegionGood", false)
414 utils.log("DEBUG", " is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"), isDebugLogEnabled)
416 } catch(BpmnError b){
417 utils.log("ERROR", "Rethrowing MSOWorkflowException", isDebugLogEnabled)
419 }catch (Exception e) {
421 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
422 utils.log("ERROR", " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, isDebugLogEnabled)
423 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
425 logDebug('Exited ' + method, isDebugLogEnabled)
430 * Prepare a Request for invoking the SDNC Adapter subflow to perform
431 * a VNF topology 'changeassign' operation.
433 * @param execution The flow's execution instance.
435 public void prepSDNCTopologyChg(DelegateExecution execution) {
436 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
437 'execution=' + execution.getId() +
439 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
440 logDebug('Entered ' + method, isDebugLogEnabled)
443 def requestId = execution.getVariable('DOUPVfMod_requestId')
444 String uuid = execution.getVariable('testReqId') // for junits
446 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
448 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
449 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
450 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
451 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
452 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
453 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
454 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
455 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
456 def vfModuleName = vfModule.getElementText('vf-module-name')
457 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
458 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
459 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
460 String usePreloadToSDNC = usePreload ? "Y" : "N"
461 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
462 def modelCustomizationUuidString = ""
464 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
467 // Retrieve vnf name from AAI response
468 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
469 execution.setVariable('DOUPVfMod_vnfName', vnfName)
471 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
472 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
474 String sdncTopologyRequest = """
475 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
476 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
477 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
478 <sdncadapter:RequestHeader>
479 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
480 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
481 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
482 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
483 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
484 </sdncadapter:RequestHeader>
485 <sdncadapterworkflow:SDNCRequestData>
486 <request-information>
487 <request-id>${requestId}</request-id>
488 <request-action>ChangeVNFActivateRequest</request-action>
489 <source>PORTAL</source>
493 </request-information>
494 <service-information>
495 <service-type>${serviceId}</service-type>
496 <service-instance-id>${vnfId}</service-instance-id>
497 <subscriber-name>dontcare</subscriber-name>
498 </service-information>
499 <vnf-request-information>
500 <vnf-id>${vfModuleId}</vnf-id>
501 <vnf-type>${vfModuleModelName}</vnf-type>
502 <vnf-name>${vfModuleName}</vnf-name>
503 <generic-vnf-id>${vnfId}</generic-vnf-id>
504 <generic-vnf-name>${vnfName}</generic-vnf-name>
505 <generic-vnf-type>${vnfType}</generic-vnf-type>
506 <tenant>${tenantId}</tenant>
507 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
508 ${modelCustomizationUuidString}
509 <use-preload>${usePreloadToSDNC}</use-preload>
511 </vnf-request-information>
512 </sdncadapterworkflow:SDNCRequestData>
513 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
515 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
516 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
517 utils.logAudit("sdncChangeAssignRequest : " + sdncTopologyRequest)
518 logDebug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest, isDebugLogEnabled)
520 logDebug('Exited ' + method, isDebugLogEnabled)
521 } catch (BpmnError e) {
523 } catch (Exception e) {
524 logError('Caught exception in ' + method, e)
525 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
530 * Prepare a Request for invoking the SDNC Adapter subflow to perform
531 * a VNF topology 'query' operation.
533 * @param execution The flow's execution instance.
535 public void prepSDNCTopologyQuery(DelegateExecution execution) {
536 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
537 'execution=' + execution.getId() +
539 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
540 logDebug('Entered ' + method, isDebugLogEnabled)
543 String uuid = execution.getVariable('testReqId') // for junits
545 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
547 def requestId = execution.getVariable('DOUPVfMod_requestId')
548 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
549 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
550 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
553 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
554 svcInstId = vfModuleId
557 svcInstId = serviceInstanceId
560 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
563 String sdncTopologyRequest = """
564 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
565 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
566 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
567 <sdncadapter:RequestHeader>
568 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
569 <sdncadapter:SvcInstanceId>${svcInstId}</sdncadapter:SvcInstanceId>
570 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
571 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
572 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
573 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
574 </sdncadapter:RequestHeader>
575 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
577 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
578 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
579 utils.logAudit("sdncTopologyRequest : " + sdncTopologyRequest)
580 logDebug('Request for SDNCAdapter query:\n' + sdncTopologyRequest, isDebugLogEnabled)
582 logDebug('Exited ' + method, isDebugLogEnabled)
583 } catch (BpmnError e) {
585 } catch (Exception e) {
586 logError('Caught exception in ' + method, e)
587 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
592 * Prepare a Request for invoking the VnfAdapterRest subflow.
594 * @param execution The flow's execution instance.
596 public void prepVnfAdapterRest(DelegateExecution execution) {
597 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
598 'execution=' + execution.getId() +
600 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
601 logDebug('Entered ' + method, isDebugLogEnabled)
604 def requestId = execution.getVariable('DOUPVfMod_requestId')
605 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
606 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
607 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
608 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
609 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
610 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
611 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
612 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
613 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
614 def heatStackId = vfModule.getElementText('heat-stack-id')
615 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
616 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
617 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
618 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
619 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
620 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
621 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
622 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
623 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
625 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
626 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
627 def useQualifiedHostName = execution.getVariable("URN_mso_use_qualified_host")
628 if ('true'.equals(useQualifiedHostName)) {
629 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
632 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
633 String workloadContext = execution.getVariable("DOUPVWorkload_context")
634 logDebug("workloadContext: " + workloadContext, isDebugLogEnabled)
635 logDebug("environmentContext: " + environmentContext, isDebugLogEnabled)
637 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
639 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
641 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
642 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
645 String vnfAdapterRestRequest = """
646 <updateVfModuleRequest>
647 <cloudSiteId>${cloudId}</cloudSiteId>
648 <tenantId>${tenantId}</tenantId>
649 <vnfId>${vnfId}</vnfId>
650 <vfModuleId>${vfModuleId}</vfModuleId>
651 <vfModuleStackId>${heatStackId}</vfModuleStackId>
652 <vnfType>${vnfType}</vnfType>
653 <vnfVersion>${asdcServiceModelVersion}</vnfVersion>
654 <modelCustomizationUuid>${modelCustomizationUuid}</modelCustomizationUuid>
655 <vfModuleType>${vfModuleModelName}</vfModuleType>
656 <volumeGroupId>${volumeGroupId}</volumeGroupId>
657 <volumeGroupStackId>${volumeGroupStackId}</volumeGroupStackId>
658 <baseVfModuleId>${baseVfModuleId}</baseVfModuleId>
659 <baseVfModuleStackId>${baseVfModuleStackId}</baseVfModuleStackId>
660 <skipAAI>true</skipAAI>
661 <backout>${backoutOnFailure}</backout>
662 <failIfExists>false</failIfExists>
667 <requestId>${requestId}</requestId>
668 <serviceInstanceId>${serviceInstanceId}</serviceInstanceId>
670 <messageId>${messageId}</messageId>
671 <notificationUrl>${notificationUrl}</notificationUrl>
672 </updateVfModuleRequest>
674 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
675 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
676 utils.logAudit("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
677 logDebug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest, isDebugLogEnabled)
679 logDebug('Exited ' + method, isDebugLogEnabled)
680 } catch (BpmnError e) {
682 } catch (Exception e) {
683 logError('Caught exception in ' + method, e)
684 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
689 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
691 * @param execution The flow's execution instance.
693 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
694 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
695 'execution=' + execution.getId() +
697 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
698 logDebug('Entered ' + method, isDebugLogEnabled)
701 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
702 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
704 def personaModelId = utils.getNodeText1(vnfInputs, 'vnf-persona-model-id')
705 def personaModelVersion = utils.getNodeText1(vnfInputs, 'vnf-persona-model-version')
706 if ((personaModelId == null) || (personaModelVersion == null)) {
707 logDebug('Skipping update for Generic VNF ' + vnfId +
708 ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent', isDebugLogEnabled)
709 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
711 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
712 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
714 String updateAAIGenericVnfRequest = """
715 <UpdateAAIGenericVnfRequest>
716 <vnf-id>${vnfId}</vnf-id>
717 ${personaModelIdElement}
718 ${personaModelVersionElement}
719 </UpdateAAIGenericVnfRequest>
721 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
722 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
723 utils.logAudit("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
724 logDebug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest, isDebugLogEnabled)
727 logDebug('Exited ' + method, isDebugLogEnabled)
728 } catch (BpmnError e) {
730 } catch (Exception e) {
731 logError('Caught exception in ' + method, e)
732 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
737 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
739 * @param execution The flow's execution instance.
741 public void prepUpdateAAIVfModule(DelegateExecution execution) {
742 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
743 'execution=' + execution.getId() +
745 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
746 logDebug('Entered ' + method, isDebugLogEnabled)
749 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
750 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
751 def orchestrationStatus = 'updated'
752 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
754 def volumeGroupIdElement = ''
755 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
756 if (volumeGroupId != null) {
757 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
759 def personaModelIdElement = ''
760 def personaModelId = utils.getNodeText1(vnfInputs, 'persona-model-id')
761 if (personaModelId != null) {
762 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
764 def personaModelVersionElement = ''
765 def personaModelVersion = utils.getNodeText1(vnfInputs, 'persona-model-version')
766 if (personaModelVersion != null) {
767 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
769 def contrailServiceInstanceFqdnElement = ''
770 def contrailServiceInstanceFqdn = utils.getNodeText1(vnfInputs, 'contrail-service-instance-fqdn')
771 if (contrailServiceInstanceFqdn != null) {
772 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
774 def personaModelCustomizationIdElement = ''
775 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
776 if (modelCustomizationId != null) {
777 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
780 String updateAAIVfModuleRequest = """
781 <UpdateAAIVfModuleRequest>
782 <vnf-id>${vnfId}</vnf-id>
783 <vf-module-id>${vfModuleId}</vf-module-id>
784 <orchestration-status>${orchestrationStatus}</orchestration-status>
785 ${volumeGroupIdElement}
786 ${personaModelIdElement}
787 ${personaModelVersionElement}
788 ${contrailServiceInstanceFqdnElement}
789 ${personaModelCustomizationIdElement}
790 </UpdateAAIVfModuleRequest>
793 logDebug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest, isDebugLogEnabled)
794 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
795 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
796 utils.logAudit("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
797 logDebug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest, isDebugLogEnabled)
799 logDebug('Exited ' + method, isDebugLogEnabled)
800 } catch (BpmnError e) {
802 } catch (Exception e) {
803 logError('Caught exception in ' + method, e)
804 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
809 * Prepare a Request for invoking the SDNC Adapter subflow to perform
810 * a VNF topology 'activate' operation.
812 * @param execution The flow's execution instance.
814 public void prepSDNCTopologyAct(DelegateExecution execution) {
815 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
816 'execution=' + execution.getId() +
818 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
819 logDebug('Entered ' + method, isDebugLogEnabled)
822 String uuid = execution.getVariable('testReqId') // for junits
824 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
826 def requestId = execution.getVariable('DOUPVfMod_requestId')
827 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
828 def callbackUrl = (String) execution.getVariable('URN_mso_workflow_sdncadapter_callback')
829 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
830 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
831 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
832 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
833 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
834 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
835 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
836 def vfModuleName = vfModule.getElementText('vf-module-name')
837 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
838 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
840 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
841 String usePreloadToSDNC = usePreload ? "Y" : "N"
842 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
843 def modelCustomizationUuidString = ""
845 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
848 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
849 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
851 String sdncTopologyRequest = """
852 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
853 xmlns:sdncadapterworkflow="http://org.openecomp/mso/workflow/schema/v1"
854 xmlns:sdncadapter="http://org.openecomp/workflow/sdnc/adapter/schema/v1">
855 <sdncadapter:RequestHeader>
856 <sdncadapter:RequestId>${uuid}</sdncadapter:RequestId>
857 <sdncadapter:SvcInstanceId>${serviceInstanceId}</sdncadapter:SvcInstanceId>
858 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
859 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
860 <sdncadapter:CallbackUrl>${callbackUrl}</sdncadapter:CallbackUrl>
861 </sdncadapter:RequestHeader>
862 <sdncadapterworkflow:SDNCRequestData>
863 <request-information>
864 <request-id>${requestId}</request-id>
865 <request-action>ChangeVNFActivateRequest</request-action>
866 <source>PORTAL</source>
870 </request-information>
871 <service-information>
872 <service-type>${serviceId}</service-type>
873 <service-instance-id>${vnfId}</service-instance-id>
874 <subscriber-name>dontcare</subscriber-name>
875 </service-information>
876 <vnf-request-information>
877 <vnf-id>${vfModuleId}</vnf-id>
878 <vnf-type>${vfModuleModelName}</vnf-type>
879 <vnf-name>${vfModuleName}</vnf-name>
880 <generic-vnf-id>${vnfId}</generic-vnf-id>
881 <generic-vnf-name>${vnfName}</generic-vnf-name>
882 <generic-vnf-type>${vnfType}</generic-vnf-type>
883 <tenant>${tenantId}</tenant>
884 <aic-cloud-region>${aicCloudRegion}</aic-cloud-region>
885 ${modelCustomizationUuidString}
886 <use-preload>${usePreloadToSDNC}</use-preload>
887 </vnf-request-information>
888 </sdncadapterworkflow:SDNCRequestData>
889 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
891 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
892 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
893 utils.logAudit("sdncActivateRequest : " + sdncTopologyRequest)
894 logDebug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest, isDebugLogEnabled)
897 logDebug('Exited ' + method, isDebugLogEnabled)
898 } catch (BpmnError e) {
900 } catch (Exception e) {
901 logError('Caught exception in ' + method, e)
902 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
907 * Log a WorkflowException that has been created.
909 * @param execution The flow's execution instance.
911 public void handleWorkflowException(DelegateExecution execution) {
912 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
913 'execution=' + execution.getId() +
915 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
916 logDebug('Entered ' + method, isDebugLogEnabled)
919 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
920 logError(method + ' caught WorkflowException: ' + workflowException.getErrorMessage())
922 logDebug('Exited ' + method, isDebugLogEnabled)
923 } catch (BpmnError e) {
925 } catch (Exception e) {
926 logError('Caught exception in ' + method, e)
927 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
931 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
932 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
933 def prefix = execution.getVariable("prefix")
935 logDebug(" *** STARTED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
937 WorkflowException workflowException = execution.getVariable("WorkflowException")
938 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
940 utils.logAudit("workflowException: " + workflowException)
942 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
943 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
945 utils.logAudit("SDNCResponse: " + response)
947 String sdncResponse = response
948 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
949 logDebug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse, isDebugLogEnabled)
951 logDebug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.", isDebugLogEnabled)
952 throw new BpmnError("MSOWorkflowException")
954 logDebug(" *** COMPLETED ValidateSDNCResponse Process*** ", isDebugLogEnabled)
958 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
959 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
961 * @param execution The flow's execution instance.
963 public void queryAAIVfModule(DelegateExecution execution) {
964 def isDebugLogEnabled=execution.getVariable("isDebugLogEnabled")
965 def method = getClass().getSimpleName() + '.getVfModule(' +
966 'execution=' + execution.getId() +
968 logDebug('Entered ' + method, isDebugLogEnabled)
971 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
972 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
974 AaiUtil aaiUriUtil = new AaiUtil(this)
975 String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
976 logDebug('AAI URI is: ' + aai_uri, isDebugLogEnabled)
978 String endPoint = execution.getVariable("URN_aai_endpoint") + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
979 utils.logAudit("AAI endPoint: " + endPoint)
982 def aaiRequestId = UUID.randomUUID().toString()
983 logDebug('sending GET to AAI endpoint \'' + endPoint + '\'', isDebugLogEnabled)
984 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
985 utils.logAudit("createVfModule - invoking httpGet() to AAI")
987 def responseData = response.getResponseBodyAsString()
988 if (responseData != null) {
989 logDebug("Received generic VNF data: " + responseData, isDebugLogEnabled)
993 utils.logAudit("createVfModule - queryAAIVfModule Response: " + responseData)
994 utils.logAudit("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
996 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
997 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
998 logDebug('Response code:' + response.getStatusCode(), isDebugLogEnabled)
999 logDebug('Response:' + System.lineSeparator() + responseData, isDebugLogEnabled)
1000 if (response.getStatusCode() == 200) {
1001 // Parse the VNF record from A&AI to find base module info
1002 logDebug('Parsing the VNF data to find base module info', isDebugLogEnabled)
1003 if (responseData != null) {
1004 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
1005 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
1006 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
1007 int vfModulesSize = 0
1008 for (i in 0..vfModules.size()-1) {
1009 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
1010 def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
1012 if (isBaseVfModule == "true") {
1013 String baseModuleId = utils.getNodeText1(vfModuleXml, "vf-module-id")
1014 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1015 logDebug('Received baseVfModuleId: ' + baseModuleId, isDebugLogEnabled)
1016 String baseModuleHeatStackId = utils.getNodeText1(vfModuleXml, "heat-stack-id")
1017 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1018 logDebug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId, isDebugLogEnabled)
1023 } catch (Exception ex) {
1024 ex.printStackTrace()
1025 logDebug('Exception occurred while executing AAI GET:' + ex.getMessage(),isDebugLogEnabled)
1026 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1028 logDebug('Exited ' + method, isDebugLogEnabled)
1029 } catch (BpmnError e) {
1031 } catch (Exception e) {
1032 logError('Caught exception in ' + method, e)
1033 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())