2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.infrastructure.scripts
25 import org.camunda.bpm.engine.delegate.BpmnError
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.onap.aai.domain.yang.GenericVnf
28 import org.onap.so.bpmn.common.scripts.AaiUtil
29 import org.onap.so.bpmn.common.scripts.CatalogDbUtils
30 import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
31 import org.onap.so.bpmn.common.scripts.ExceptionUtil
32 import org.onap.so.bpmn.common.scripts.MsoUtils
33 import org.onap.so.bpmn.common.scripts.NetworkUtils
34 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
35 import org.onap.so.bpmn.common.scripts.VfModuleBase
36 import org.onap.so.bpmn.core.UrnPropertiesReader
37 import org.onap.so.bpmn.core.WorkflowException
38 import org.onap.so.bpmn.core.json.JsonUtils;
39 import org.onap.so.client.graphinventory.entities.uri.Depth
40 import org.onap.so.client.aai.AAIObjectType;
41 import org.onap.so.client.aai.AAIResourcesClient
42 import org.onap.so.client.aai.entities.AAIResultWrapper
43 import org.onap.so.client.aai.entities.uri.AAIUri
44 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
45 import org.onap.so.client.aai.entities.uri.AAIResourceUri
46 import org.onap.so.constants.Defaults
47 import org.onap.so.logger.ErrorCode
48 import org.onap.so.logger.MessageEnum
49 import org.slf4j.Logger
50 import org.slf4j.LoggerFactory
52 public class DoUpdateVfModule extends VfModuleBase {
53 private static final Logger logger = LoggerFactory.getLogger( DoUpdateVfModule.class);
55 ExceptionUtil exceptionUtil = new ExceptionUtil()
56 JsonUtils jsonUtil = new JsonUtils()
57 CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
60 * Initialize the flow's variables.
62 * @param execution The flow's execution instance.
64 public void initProcessVariables(DelegateExecution execution) {
65 execution.setVariable('prefix', 'DOUPVfMod_')
66 execution.setVariable('DOUPVfMod_requestInfo', null)
67 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
68 execution.setVariable('DOUPVfMod_requestId', null)
69 execution.setVariable('DOUPVfMod_vnfInputs', null)
70 execution.setVariable('DOUPVfMod_vnfId', null)
71 execution.setVariable('DOUPVfMod_vnfName', null)
72 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
73 execution.setVariable('DOUPVfMod_vfModuleName', null)
74 execution.setVariable('DOUPVfMod_vfModuleId', null)
75 execution.setVariable('DOUPVfMod_vnfType', null)
76 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
77 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
78 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
79 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
80 execution.setVariable('DOUPVfMod_serviceId', null)
81 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
82 execution.setVariable('DOUPVfMod_tenantId', null)
83 execution.setVariable('DOUPVfMod_volumeGroupId', null)
84 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
85 execution.setVariable('DOUPVfMod_vfModule', null)
86 execution.setVariable('DOUPVfMod_vnfParams', null)
87 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
88 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
89 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
90 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
91 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
92 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
93 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
94 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
95 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
96 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
97 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
98 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
99 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
100 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
104 * Check for missing elements in the received request.
106 * @param execution The flow's execution instance.
108 public void preProcessRequest(DelegateExecution execution) {
109 def method = getClass().getSimpleName() + '.preProcessRequest(' +
110 'execution=' + execution.getId() +
113 logger.trace('Entered ' + method)
116 initProcessVariables(execution)
117 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
118 logger.debug("DoUpdateVfModule request: " + xml)
119 logger.debug('Received request xml:\n' + xml)
121 if (xml == null || xml.isEmpty()) {
122 // Building Block-type request
124 String cloudConfiguration = execution.getVariable("cloudConfiguration")
125 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
127 def serviceModelInfo = execution.getVariable("serviceModelInfo")
128 logger.debug("serviceModelInfo: " + serviceModelInfo)
129 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
130 logger.debug("modelInvariantUuid: " + modelInvariantUuid)
131 def vnfModelInfo = execution.getVariable("vnfModelInfo")
134 def tenantId = execution.getVariable("tenantId")
135 execution.setVariable("DOUPVfMod_tenantId", tenantId)
138 def volumeGroupId = execution.getVariable("volumeGroupId")
139 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
142 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
143 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
145 logger.debug("cloudSiteId: " + cloudSiteId)
147 def vnfType = execution.getVariable("vnfType")
148 execution.setVariable("DOUPVfMod_vnfType", vnfType)
150 logger.debug("vnfType: " + vnfType)
152 def vnfName = execution.getVariable("vnfName")
153 execution.setVariable("DOUPVfMod_vnfName", vnfName)
155 logger.debug("vnfName: " + vnfName)
157 def vnfId = execution.getVariable("vnfId")
158 execution.setVariable("DOUPVfMod_vnfId", vnfId)
160 logger.debug("vnfId: " + vnfId)
162 def vfModuleName = execution.getVariable("vfModuleName")
163 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
165 logger.debug("vfModuleName: " + vfModuleName)
167 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
168 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
170 logger.debug("vfModuleModelName: " + vfModuleModelName)
171 //modelCustomizationUuid
172 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
173 if (modelCustomizationUuid == null) {
174 modelCustomizationUuid = ""
176 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
178 logger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
180 def vfModuleId = execution.getVariable("vfModuleId")
181 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
182 logger.debug("vfModuleId: " + vfModuleId)
183 def requestId = execution.getVariable("msoRequestId")
184 execution.setVariable("DOUPVfMod_requestId", requestId)
185 logger.debug("requestId: " + requestId)
186 // Set mso-request-id to request-id for VNF Adapter interface
187 execution.setVariable("mso-request-id", requestId)
189 def serviceId = execution.getVariable("serviceId")
190 execution.setVariable("DOUPVfMod_serviceId", serviceId)
191 logger.debug("serviceId: " + serviceId)
193 def serviceInstanceId = execution.getVariable("serviceInstanceId")
194 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
196 logger.debug("serviceInstanceId: " + serviceInstanceId)
199 execution.setVariable("DOUPVfMod_source", source)
201 logger.debug("source: " + source)
203 def disableRollback = execution.getVariable("disableRollback")
204 def backoutOnFailure = true
205 if (disableRollback != null && disableRollback.equals("true")) {
206 backoutOnFailure = false
208 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
209 logger.debug("backoutOnFailure: " + backoutOnFailure)
211 def isBaseVfModule = execution.getVariable("isBaseVfModule")
212 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
213 logger.debug("isBaseVfModule: " + isBaseVfModule)
214 //asdcServiceModelVersion
215 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
216 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
217 logger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
219 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
220 //personaModelVersion
221 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
222 //Get or Generate UUID
223 String uuid = execution.getVariable("DOUPVfMod_uuid")
225 uuid = UUID.randomUUID()
226 logger.debug("Generated messageId (UUID) is: " + uuid)
228 logger.debug("Found messageId (UUID) is: " + uuid)
231 String isVidRequest = execution.getVariable("isVidRequest")
233 if (isVidRequest == null || isVidRequest.isEmpty()) {
234 execution.setVariable("isVidRequest", "true")
237 def usePreload = execution.getVariable("usePreload")
238 execution.setVariable("DOUPVfMod_usePreload", usePreload)
239 logger.debug("usePreload: " + usePreload)
241 String globalSubscriberId = execution.getVariable("globalSubscriberId")
242 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
243 logger.debug("globalSubsrciberId: " + globalSubscriberId)
245 String vnfQueryPath = execution.getVariable("vnfQueryPath")
246 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
247 logger.debug("vnfQueryPath: " + vnfQueryPath)
249 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
250 if (vfModuleInputParams != null) {
251 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
253 //get workload and environment context from parent SI
254 String environmentContext = ""
255 String workloadContext =""
256 String serviceType =""
259 String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
260 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
263 } catch (Exception ex){
264 String msg = "Exception in preProcessRequest " + ex.getMessage()
266 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
270 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
271 AAIResourcesClient aaiRC = new AAIResourcesClient()
272 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
273 Map<String, Object> aaiJson = aaiRW.asMap()
274 environmentContext = aaiJson.getOrDefault("environment-context","")
275 workloadContext = aaiJson.getOrDefault("workload-context","")
277 }catch (Exception ex) {
278 logger.debug("Error retreiving parent service instance information")
281 execution.setVariable("DCVFM_environmentContext",environmentContext)
282 execution.setVariable("DCVFM_workloadContext",workloadContext)
286 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
287 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
288 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
289 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
290 if (serviceInstanceId == null) {
291 serviceInstanceId = ''
293 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
295 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
296 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
297 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
298 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
299 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
300 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
301 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
302 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
303 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
304 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
305 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
306 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
307 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
309 def isBaseVfModule = "false"
310 if (utils.nodeExists(xml, "is-base-vf-module")) {
311 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
312 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
314 logger.debug("isBaseVfModule: " + isBaseVfModule)
316 NetworkUtils networkUtils = new NetworkUtils()
317 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
318 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
320 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
321 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
323 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
326 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
327 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
328 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
329 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
330 ErrorCode.UnknownError.getValue());
331 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
334 logger.trace('Exited ' + method)
335 } catch (BpmnError e) {
337 } catch (Exception e) {
338 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
339 'Caught exception in ' + method, "BPMN",
340 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
341 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
346 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
347 * set the orchestration-status to 'pending-update'.
349 * @param execution The flow's execution instance.
351 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
352 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
353 'execution=' + execution.getId() +
356 logger.trace('Entered ' + method)
359 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
360 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
361 def orchestrationStatus = 'pending-update'
363 String prepareUpdateAAIVfModuleRequest = """
364 <PrepareUpdateAAIVfModuleRequest>
365 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
366 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
367 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
368 </PrepareUpdateAAIVfModuleRequest>
370 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
371 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
372 logger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
373 logger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
375 logger.trace('Exited ' + method)
376 } catch (BpmnError e) {
378 } catch (Exception e) {
379 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
380 'Caught exception in ' + method, "BPMN",
381 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
382 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
387 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
388 * Determine cloud region id for the volume group.
390 * @param execution The flow's execution instance.
392 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
393 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
394 'execution=' + execution.getId() +
397 def prefix = execution.getVariable("prefix")
399 logger.trace('Entered ' + method)
402 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
405 AaiUtil aaiUtil = new AaiUtil(this)
407 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
408 def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
410 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
412 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
414 if ((cloudRegion != "ERROR")) {
415 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
416 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
418 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
420 execution.setVariable(prefix + "isCloudRegionGood", true)
422 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
423 logger.debug(errorMessage)
424 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
425 execution.setVariable(prefix + "isCloudRegionGood", false)
427 logger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"))
429 } catch(BpmnError b){
430 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
431 "Rethrowing MSOWorkflowException", "BPMN",
432 ErrorCode.UnknownError.getValue(), "Exception is:\n" + b);
434 }catch (Exception e) {
436 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
437 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
438 "AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, "BPMN",
439 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
440 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
442 logger.trace('Exited ' + method)
447 * Prepare a Request for invoking the SDNC Adapter subflow to perform
448 * a VNF topology 'changeassign' operation.
450 * @param execution The flow's execution instance.
452 public void prepSDNCTopologyChg(DelegateExecution execution) {
453 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
454 'execution=' + execution.getId() +
457 logger.trace('Entered ' + method)
460 def requestId = execution.getVariable('DOUPVfMod_requestId')
461 String uuid = execution.getVariable('testReqId') // for junits
463 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
465 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
466 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
467 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
468 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
469 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
470 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
471 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
472 def vfModuleName = ""
473 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
474 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
475 vfModuleName = vfModule.getVfModuleName()
477 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
478 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
479 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
480 String usePreloadToSDNC = usePreload ? "Y" : "N"
481 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
482 def modelCustomizationUuidString = ""
484 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
487 // Retrieve vnf name from AAI response
488 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
489 execution.setVariable('DOUPVfMod_vnfName', vnfName)
491 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
492 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
494 String sdncTopologyRequest = """
495 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
496 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
497 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
498 <sdncadapter:RequestHeader>
499 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
500 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
501 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
502 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
503 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
504 </sdncadapter:RequestHeader>
505 <sdncadapterworkflow:SDNCRequestData>
506 <request-information>
507 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
508 <request-action>ChangeVNFActivateRequest</request-action>
509 <source>PORTAL</source>
513 </request-information>
514 <service-information>
515 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
516 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
517 <subscriber-name>dontcare</subscriber-name>
518 </service-information>
519 <vnf-request-information>
520 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
521 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
522 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
523 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
524 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
525 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
526 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
527 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
528 ${modelCustomizationUuidString}
529 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
531 </vnf-request-information>
532 </sdncadapterworkflow:SDNCRequestData>
533 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
535 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
536 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
537 logger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
538 logger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
540 logger.trace('Exited ' + method)
541 } catch (BpmnError e) {
543 } catch (Exception e) {
544 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
545 'Caught exception in ' + method, "BPMN",
546 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
547 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
552 * Prepare a Request for invoking the SDNC Adapter subflow to perform
553 * a VNF topology 'query' operation.
555 * @param execution The flow's execution instance.
557 public void prepSDNCTopologyQuery(DelegateExecution execution) {
558 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
559 'execution=' + execution.getId() +
562 logger.trace('Entered ' + method)
565 String uuid = execution.getVariable('testReqId') // for junits
567 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
569 def requestId = execution.getVariable('DOUPVfMod_requestId')
570 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
571 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
572 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
575 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
576 svcInstId = vfModuleId
579 svcInstId = serviceInstanceId
582 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
585 String sdncTopologyRequest = """
586 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
587 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
588 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
589 <sdncadapter:RequestHeader>
590 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
591 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
592 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
593 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
594 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
595 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
596 </sdncadapter:RequestHeader>
597 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
599 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
600 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
601 logger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
602 logger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
604 logger.trace('Exited ' + method)
605 } catch (BpmnError e) {
607 } catch (Exception e) {
608 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
609 'Caught exception in ' + method, "BPMN",
610 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
611 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
616 * Prepare a Request for invoking the VnfAdapterRest subflow.
618 * @param execution The flow's execution instance.
620 public void prepVnfAdapterRest(DelegateExecution execution) {
621 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
622 'execution=' + execution.getId() +
625 logger.trace('Entered ' + method)
628 def requestId = execution.getVariable('DOUPVfMod_requestId')
629 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
630 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
631 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
632 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
633 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
634 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
635 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
636 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
638 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
639 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
640 heatStackId = vfModule.getHeatStackId()
642 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
643 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
644 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
645 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
646 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
647 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
648 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
649 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
650 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
652 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
653 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
654 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
655 if ('true'.equals(useQualifiedHostName)) {
656 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
659 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
660 String workloadContext = execution.getVariable("DOUPVWorkload_context")
661 logger.debug("workloadContext: " + workloadContext)
662 logger.debug("environmentContext: " + environmentContext)
664 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
666 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
668 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
669 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
672 String vnfAdapterRestRequest = """
673 <updateVfModuleRequest>
674 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
675 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
676 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
677 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
678 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
679 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
680 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
681 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
682 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
683 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
684 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
685 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
686 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
687 <skipAAI>true</skipAAI>
688 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
689 <failIfExists>false</failIfExists>
694 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
695 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
697 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
698 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
699 </updateVfModuleRequest>
701 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
702 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
703 logger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
704 logger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
706 logger.trace('Exited ' + method)
707 } catch (BpmnError e) {
709 } catch (Exception e) {
710 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
711 'Caught exception in ' + method, "BPMN",
712 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
713 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
718 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
720 * @param execution The flow's execution instance.
722 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
723 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
724 'execution=' + execution.getId() +
726 logger.trace('Entered ' + method)
729 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
730 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
732 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
733 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
734 if ((personaModelId == null) || (personaModelVersion == null)) {
735 logger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
736 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
738 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
739 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
741 String updateAAIGenericVnfRequest = """
742 <UpdateAAIGenericVnfRequest>
743 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
744 ${personaModelIdElement}
745 ${personaModelVersionElement}
746 </UpdateAAIGenericVnfRequest>
748 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
749 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
750 logger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
751 logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
754 logger.trace('Exited ' + method)
755 } catch (BpmnError e) {
757 } catch (Exception e) {
758 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
759 'Caught exception in ' + method, "BPMN",
760 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
761 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
766 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
768 * @param execution The flow's execution instance.
770 public void prepUpdateAAIVfModule(DelegateExecution execution) {
771 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
772 'execution=' + execution.getId() +
775 logger.trace('Entered ' + method)
778 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
779 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
780 def orchestrationStatus = 'updated'
781 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
783 def volumeGroupIdElement = ''
784 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
785 if (volumeGroupId != null) {
786 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
788 def personaModelIdElement = ''
789 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
790 if (personaModelId != null) {
791 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
793 def personaModelVersionElement = ''
794 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
795 if (personaModelVersion != null) {
796 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
798 def contrailServiceInstanceFqdnElement = ''
799 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
800 if (contrailServiceInstanceFqdn != null) {
801 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
803 def personaModelCustomizationIdElement = ''
804 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
805 if (modelCustomizationId != null) {
806 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
809 String updateAAIVfModuleRequest = """
810 <UpdateAAIVfModuleRequest>
811 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
812 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
813 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
814 ${volumeGroupIdElement}
815 ${personaModelIdElement}
816 ${personaModelVersionElement}
817 ${contrailServiceInstanceFqdnElement}
818 ${personaModelCustomizationIdElement}
819 </UpdateAAIVfModuleRequest>
822 logger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
823 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
824 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
825 logger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
826 logger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
828 logger.trace('Exited ' + method)
829 } catch (BpmnError e) {
831 } catch (Exception e) {
832 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
833 'Caught exception in ' + method, "BPMN",
834 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
835 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
840 * Prepare a Request for invoking the SDNC Adapter subflow to perform
841 * a VNF topology 'activate' operation.
843 * @param execution The flow's execution instance.
845 public void prepSDNCTopologyAct(DelegateExecution execution) {
846 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
847 'execution=' + execution.getId() +
850 logger.trace('Entered ' + method)
853 String uuid = execution.getVariable('testReqId') // for junits
855 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
857 def requestId = execution.getVariable('DOUPVfMod_requestId')
858 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
859 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
860 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
861 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
862 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
863 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
864 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
865 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
866 def vfModuleName = ""
867 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
868 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
869 vfModuleName = vfModule.getVfModuleName()
871 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
872 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
874 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
875 String usePreloadToSDNC = usePreload ? "Y" : "N"
876 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
877 def modelCustomizationUuidString = ""
879 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
882 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
883 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
885 String sdncTopologyRequest = """
886 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
887 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
888 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
889 <sdncadapter:RequestHeader>
890 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
891 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
892 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
893 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
894 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
895 </sdncadapter:RequestHeader>
896 <sdncadapterworkflow:SDNCRequestData>
897 <request-information>
898 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
899 <request-action>ChangeVNFActivateRequest</request-action>
900 <source>PORTAL</source>
904 </request-information>
905 <service-information>
906 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
907 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
908 <subscriber-name>dontcare</subscriber-name>
909 </service-information>
910 <vnf-request-information>
911 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
912 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
913 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
914 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
915 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
916 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
917 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
918 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
919 ${modelCustomizationUuidString}
920 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
921 </vnf-request-information>
922 </sdncadapterworkflow:SDNCRequestData>
923 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
925 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
926 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
927 logger.debug("sdncActivateRequest : " + sdncTopologyRequest)
928 logger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
931 logger.trace('Exited ' + method)
932 } catch (BpmnError e) {
934 } catch (Exception e) {
935 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
936 'Caught exception in ' + method, "BPMN",
937 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
938 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
943 * Log a WorkflowException that has been created.
945 * @param execution The flow's execution instance.
947 public void handleWorkflowException(DelegateExecution execution) {
948 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
949 'execution=' + execution.getId() +
952 logger.trace('Entered ' + method)
955 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
956 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
957 method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN",
958 ErrorCode.UnknownError.getValue());
960 logger.trace('Exited ' + method)
961 } catch (BpmnError e) {
963 } catch (Exception e) {
964 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
965 'Caught exception in ' + method, "BPMN",
966 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
967 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
971 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
973 def prefix = execution.getVariable("prefix")
975 logger.trace("STARTED ValidateSDNCResponse Process")
977 WorkflowException workflowException = execution.getVariable("WorkflowException")
978 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
980 logger.debug("workflowException: " + workflowException)
982 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
983 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
985 logger.debug("SDNCResponse: " + response)
987 String sdncResponse = response
988 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
989 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
991 logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
992 throw new BpmnError("MSOWorkflowException")
994 logger.trace("COMPLETED ValidateSDNCResponse Process")
998 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
999 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
1001 * @param execution The flow's execution instance.
1003 public void queryAAIVfModule(DelegateExecution execution) {
1005 def method = getClass().getSimpleName() + '.getVfModule(' +
1006 'execution=' + execution.getId() +
1008 logger.trace('Entered ' + method)
1011 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
1012 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
1015 Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
1016 if (genericVnf.isPresent()) {
1017 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', 200)
1018 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', genericVnf.get())
1019 // Parse the VNF record from A&AI to find base module info
1020 logger.debug('Parsing the VNF data to find base module info')
1021 if (genericVnf.get().getVfModules()!=null && !genericVnf.get().getVfModules().getVfModule().isEmpty()) {
1022 Optional<org.onap.aai.domain.yang.VfModule> vfmodule = genericVnf.get().getVfModules().getVfModule().stream().
1023 filter{v-> v.isIsBaseVfModule()}.findFirst()
1024 if (vfmodule.isPresent()) {
1025 String baseModuleId = vfmodule.get().getVfModuleId()
1026 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1027 logger.debug('Received baseVfModuleId: ' + baseModuleId)
1028 String baseModuleHeatStackId = vfmodule.get().getHeatStackId()
1029 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1030 logger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1034 } catch (Exception ex) {
1035 ex.printStackTrace()
1036 logger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
1037 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1039 logger.trace('Exited ' + method)
1040 } catch (BpmnError e) {
1042 } catch (Exception e) {
1043 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
1044 'Caught exception in ' + method, "BPMN",
1045 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
1046 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())