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)
148 def cloudOwner = execution.getVariable("cloudOwner")
149 execution.setVariable("DOUPVfMod_cloudOwner", cloudOwner)
150 logger.debug("cloudOwner: " + cloudOwner)
153 def vnfType = execution.getVariable("vnfType")
154 execution.setVariable("DOUPVfMod_vnfType", vnfType)
156 logger.debug("vnfType: " + vnfType)
158 def vnfName = execution.getVariable("vnfName")
159 execution.setVariable("DOUPVfMod_vnfName", vnfName)
161 logger.debug("vnfName: " + vnfName)
163 def vnfId = execution.getVariable("vnfId")
164 execution.setVariable("DOUPVfMod_vnfId", vnfId)
166 logger.debug("vnfId: " + vnfId)
168 def vfModuleName = execution.getVariable("vfModuleName")
169 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
171 logger.debug("vfModuleName: " + vfModuleName)
173 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
174 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
176 logger.debug("vfModuleModelName: " + vfModuleModelName)
177 //modelCustomizationUuid
178 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
179 if (modelCustomizationUuid == null) {
180 modelCustomizationUuid = ""
182 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
184 logger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
186 def vfModuleId = execution.getVariable("vfModuleId")
187 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
188 logger.debug("vfModuleId: " + vfModuleId)
189 def requestId = execution.getVariable("msoRequestId")
190 execution.setVariable("DOUPVfMod_requestId", requestId)
191 logger.debug("requestId: " + requestId)
192 // Set mso-request-id to request-id for VNF Adapter interface
193 execution.setVariable("mso-request-id", requestId)
195 def serviceId = execution.getVariable("serviceId")
196 execution.setVariable("DOUPVfMod_serviceId", serviceId)
197 logger.debug("serviceId: " + serviceId)
199 def serviceInstanceId = execution.getVariable("serviceInstanceId")
200 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
202 logger.debug("serviceInstanceId: " + serviceInstanceId)
205 execution.setVariable("DOUPVfMod_source", source)
207 logger.debug("source: " + source)
209 def disableRollback = execution.getVariable("disableRollback")
210 def backoutOnFailure = true
211 if (disableRollback != null && disableRollback.equals("true")) {
212 backoutOnFailure = false
214 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
215 logger.debug("backoutOnFailure: " + backoutOnFailure)
217 def isBaseVfModule = execution.getVariable("isBaseVfModule")
218 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
219 logger.debug("isBaseVfModule: " + isBaseVfModule)
220 //asdcServiceModelVersion
221 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
222 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
223 logger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
225 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
226 //personaModelVersion
227 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
228 //Get or Generate UUID
229 String uuid = execution.getVariable("DOUPVfMod_uuid")
231 uuid = UUID.randomUUID()
232 logger.debug("Generated messageId (UUID) is: " + uuid)
234 logger.debug("Found messageId (UUID) is: " + uuid)
237 String isVidRequest = execution.getVariable("isVidRequest")
239 if (isVidRequest == null || isVidRequest.isEmpty()) {
240 execution.setVariable("isVidRequest", "true")
243 def usePreload = execution.getVariable("usePreload")
244 execution.setVariable("DOUPVfMod_usePreload", usePreload)
245 logger.debug("usePreload: " + usePreload)
247 String globalSubscriberId = execution.getVariable("globalSubscriberId")
248 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
249 logger.debug("globalSubsrciberId: " + globalSubscriberId)
251 String vnfQueryPath = execution.getVariable("vnfQueryPath")
252 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
253 logger.debug("vnfQueryPath: " + vnfQueryPath)
255 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
256 if (vfModuleInputParams != null) {
257 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
259 //get workload and environment context from parent SI
260 String environmentContext = ""
261 String workloadContext =""
262 String serviceType =""
265 String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
266 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
269 } catch (Exception ex){
270 String msg = "Exception in preProcessRequest " + ex.getMessage()
272 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
276 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
277 AAIResourcesClient aaiRC = new AAIResourcesClient()
278 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
279 Map<String, Object> aaiJson = aaiRW.asMap()
280 environmentContext = aaiJson.getOrDefault("environment-context","")
281 workloadContext = aaiJson.getOrDefault("workload-context","")
283 }catch (Exception ex) {
284 logger.debug("Error retreiving parent service instance information")
287 execution.setVariable("DCVFM_environmentContext",environmentContext)
288 execution.setVariable("DCVFM_workloadContext",workloadContext)
292 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
293 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
294 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
295 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
296 if (serviceInstanceId == null) {
297 serviceInstanceId = ''
299 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
301 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
302 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
303 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
304 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
305 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
306 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
307 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
308 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
309 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
310 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
311 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
312 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
313 execution.setVariable('DOUPVfMod_cloudOwner', getRequiredNodeText(execution, vnfInputs, 'cloud-owner'))
314 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
316 def isBaseVfModule = "false"
317 if (utils.nodeExists(xml, "is-base-vf-module")) {
318 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
319 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
321 logger.debug("isBaseVfModule: " + isBaseVfModule)
323 NetworkUtils networkUtils = new NetworkUtils()
324 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
325 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
327 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
328 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
330 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
333 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
334 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
335 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
336 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
337 ErrorCode.UnknownError.getValue());
338 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
341 logger.trace('Exited ' + method)
342 } catch (BpmnError e) {
344 } catch (Exception e) {
345 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
346 'Caught exception in ' + method, "BPMN",
347 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
348 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
353 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
354 * set the orchestration-status to 'pending-update'.
356 * @param execution The flow's execution instance.
358 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
359 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
360 'execution=' + execution.getId() +
363 logger.trace('Entered ' + method)
366 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
367 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
368 def orchestrationStatus = 'pending-update'
370 String prepareUpdateAAIVfModuleRequest = """
371 <PrepareUpdateAAIVfModuleRequest>
372 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
373 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
374 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
375 </PrepareUpdateAAIVfModuleRequest>
377 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
378 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
379 logger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
380 logger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
382 logger.trace('Exited ' + method)
383 } catch (BpmnError e) {
385 } catch (Exception e) {
386 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
387 'Caught exception in ' + method, "BPMN",
388 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
389 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
394 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
395 * Determine cloud region id for the volume group.
397 * @param execution The flow's execution instance.
399 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
400 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
401 'execution=' + execution.getId() +
404 def prefix = execution.getVariable("prefix")
406 logger.trace('Entered ' + method)
409 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
412 AaiUtil aaiUtil = new AaiUtil(this)
414 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
415 def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
417 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
419 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
421 if ((cloudRegion != "ERROR")) {
422 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
423 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
425 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
427 execution.setVariable(prefix + "isCloudRegionGood", true)
429 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
430 logger.debug(errorMessage)
431 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
432 execution.setVariable(prefix + "isCloudRegionGood", false)
434 logger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"))
436 } catch(BpmnError b){
437 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
438 "Rethrowing MSOWorkflowException", "BPMN",
439 ErrorCode.UnknownError.getValue(), "Exception is:\n" + b);
441 }catch (Exception e) {
443 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
444 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
445 "AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, "BPMN",
446 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
447 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
449 logger.trace('Exited ' + method)
454 * Prepare a Request for invoking the SDNC Adapter subflow to perform
455 * a VNF topology 'changeassign' operation.
457 * @param execution The flow's execution instance.
459 public void prepSDNCTopologyChg(DelegateExecution execution) {
460 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
461 'execution=' + execution.getId() +
464 logger.trace('Entered ' + method)
467 def requestId = execution.getVariable('DOUPVfMod_requestId')
468 String uuid = execution.getVariable('testReqId') // for junits
470 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
472 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
473 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
474 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
475 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
476 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
477 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
478 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
479 def vfModuleName = ""
480 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
481 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
482 vfModuleName = vfModule.getVfModuleName()
484 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
485 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
486 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
487 String usePreloadToSDNC = usePreload ? "Y" : "N"
488 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
489 def modelCustomizationUuidString = ""
491 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
494 // Retrieve vnf name from AAI response
495 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
496 execution.setVariable('DOUPVfMod_vnfName', vnfName)
498 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
499 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
501 String sdncTopologyRequest = """
502 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
503 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
504 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
505 <sdncadapter:RequestHeader>
506 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
507 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
508 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
509 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
510 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
511 </sdncadapter:RequestHeader>
512 <sdncadapterworkflow:SDNCRequestData>
513 <request-information>
514 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
515 <request-action>ChangeVNFActivateRequest</request-action>
516 <source>PORTAL</source>
520 </request-information>
521 <service-information>
522 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
523 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
524 <subscriber-name>dontcare</subscriber-name>
525 </service-information>
526 <vnf-request-information>
527 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
528 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
529 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
530 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
531 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
532 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
533 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
534 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
535 ${modelCustomizationUuidString}
536 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
538 </vnf-request-information>
539 </sdncadapterworkflow:SDNCRequestData>
540 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
542 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
543 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
544 logger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
545 logger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
547 logger.trace('Exited ' + method)
548 } catch (BpmnError e) {
550 } catch (Exception e) {
551 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
552 'Caught exception in ' + method, "BPMN",
553 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
554 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
559 * Prepare a Request for invoking the SDNC Adapter subflow to perform
560 * a VNF topology 'query' operation.
562 * @param execution The flow's execution instance.
564 public void prepSDNCTopologyQuery(DelegateExecution execution) {
565 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
566 'execution=' + execution.getId() +
569 logger.trace('Entered ' + method)
572 String uuid = execution.getVariable('testReqId') // for junits
574 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
576 def requestId = execution.getVariable('DOUPVfMod_requestId')
577 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
578 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
579 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
582 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
583 svcInstId = vfModuleId
586 svcInstId = serviceInstanceId
589 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
592 String sdncTopologyRequest = """
593 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
594 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
595 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
596 <sdncadapter:RequestHeader>
597 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
598 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
599 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
600 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
601 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
602 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
603 </sdncadapter:RequestHeader>
604 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
606 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
607 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
608 logger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
609 logger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
611 logger.trace('Exited ' + method)
612 } catch (BpmnError e) {
614 } catch (Exception e) {
615 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
616 'Caught exception in ' + method, "BPMN",
617 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
618 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
623 * Prepare a Request for invoking the VnfAdapterRest subflow.
625 * @param execution The flow's execution instance.
627 public void prepVnfAdapterRest(DelegateExecution execution) {
628 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
629 'execution=' + execution.getId() +
632 logger.trace('Entered ' + method)
635 def requestId = execution.getVariable('DOUPVfMod_requestId')
636 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
637 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
638 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
639 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
640 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
641 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
642 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
643 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
645 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
646 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
647 heatStackId = vfModule.getHeatStackId()
649 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
650 def cloudOwner = execution.getVariable('DOUPVfMod_cloudOwner')
651 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
652 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
653 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
654 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
655 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
656 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
657 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
658 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
660 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
661 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
662 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
663 if ('true'.equals(useQualifiedHostName)) {
664 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
667 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
668 String workloadContext = execution.getVariable("DOUPVWorkload_context")
669 logger.debug("workloadContext: " + workloadContext)
670 logger.debug("environmentContext: " + environmentContext)
672 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
674 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
676 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
677 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
680 String vnfAdapterRestRequest = """
681 <updateVfModuleRequest>
682 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
683 <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner>
684 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
685 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
686 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
687 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
688 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
689 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
690 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
691 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
692 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
693 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
694 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
695 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
696 <skipAAI>true</skipAAI>
697 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
698 <failIfExists>false</failIfExists>
703 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
704 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
706 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
707 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
708 </updateVfModuleRequest>
710 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
711 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
712 logger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
713 logger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
715 logger.trace('Exited ' + method)
716 } catch (BpmnError e) {
718 } catch (Exception e) {
719 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
720 'Caught exception in ' + method, "BPMN",
721 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
722 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
727 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
729 * @param execution The flow's execution instance.
731 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
732 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
733 'execution=' + execution.getId() +
735 logger.trace('Entered ' + method)
738 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
739 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
741 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
742 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
743 if ((personaModelId == null) || (personaModelVersion == null)) {
744 logger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
745 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
747 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
748 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
750 String updateAAIGenericVnfRequest = """
751 <UpdateAAIGenericVnfRequest>
752 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
753 ${personaModelIdElement}
754 ${personaModelVersionElement}
755 </UpdateAAIGenericVnfRequest>
757 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
758 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
759 logger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
760 logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
763 logger.trace('Exited ' + method)
764 } catch (BpmnError e) {
766 } catch (Exception e) {
767 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
768 'Caught exception in ' + method, "BPMN",
769 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
770 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
775 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
777 * @param execution The flow's execution instance.
779 public void prepUpdateAAIVfModule(DelegateExecution execution) {
780 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
781 'execution=' + execution.getId() +
784 logger.trace('Entered ' + method)
787 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
788 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
789 def orchestrationStatus = 'updated'
790 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
792 def volumeGroupIdElement = ''
793 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
794 if (volumeGroupId != null) {
795 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
797 def personaModelIdElement = ''
798 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
799 if (personaModelId != null) {
800 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
802 def personaModelVersionElement = ''
803 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
804 if (personaModelVersion != null) {
805 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
807 def contrailServiceInstanceFqdnElement = ''
808 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
809 if (contrailServiceInstanceFqdn != null) {
810 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
812 def personaModelCustomizationIdElement = ''
813 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
814 if (modelCustomizationId != null) {
815 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
818 String updateAAIVfModuleRequest = """
819 <UpdateAAIVfModuleRequest>
820 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
821 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
822 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
823 ${volumeGroupIdElement}
824 ${personaModelIdElement}
825 ${personaModelVersionElement}
826 ${contrailServiceInstanceFqdnElement}
827 ${personaModelCustomizationIdElement}
828 </UpdateAAIVfModuleRequest>
831 logger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
832 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
833 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
834 logger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
835 logger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
837 logger.trace('Exited ' + method)
838 } catch (BpmnError e) {
840 } catch (Exception e) {
841 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
842 'Caught exception in ' + method, "BPMN",
843 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
844 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
849 * Prepare a Request for invoking the SDNC Adapter subflow to perform
850 * a VNF topology 'activate' operation.
852 * @param execution The flow's execution instance.
854 public void prepSDNCTopologyAct(DelegateExecution execution) {
855 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
856 'execution=' + execution.getId() +
859 logger.trace('Entered ' + method)
862 String uuid = execution.getVariable('testReqId') // for junits
864 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
866 def requestId = execution.getVariable('DOUPVfMod_requestId')
867 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
868 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
869 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
870 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
871 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
872 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
873 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
874 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
875 def vfModuleName = ""
876 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
877 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
878 vfModuleName = vfModule.getVfModuleName()
880 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
881 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
883 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
884 String usePreloadToSDNC = usePreload ? "Y" : "N"
885 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
886 def modelCustomizationUuidString = ""
888 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
891 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
892 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
894 String sdncTopologyRequest = """
895 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
896 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
897 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
898 <sdncadapter:RequestHeader>
899 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
900 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
901 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
902 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
903 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
904 </sdncadapter:RequestHeader>
905 <sdncadapterworkflow:SDNCRequestData>
906 <request-information>
907 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
908 <request-action>ChangeVNFActivateRequest</request-action>
909 <source>PORTAL</source>
913 </request-information>
914 <service-information>
915 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
916 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
917 <subscriber-name>dontcare</subscriber-name>
918 </service-information>
919 <vnf-request-information>
920 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
921 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
922 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
923 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
924 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
925 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
926 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
927 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
928 ${modelCustomizationUuidString}
929 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
930 </vnf-request-information>
931 </sdncadapterworkflow:SDNCRequestData>
932 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
934 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
935 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
936 logger.debug("sdncActivateRequest : " + sdncTopologyRequest)
937 logger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
940 logger.trace('Exited ' + method)
941 } catch (BpmnError e) {
943 } catch (Exception e) {
944 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
945 'Caught exception in ' + method, "BPMN",
946 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
947 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
952 * Log a WorkflowException that has been created.
954 * @param execution The flow's execution instance.
956 public void handleWorkflowException(DelegateExecution execution) {
957 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
958 'execution=' + execution.getId() +
961 logger.trace('Entered ' + method)
964 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
965 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
966 method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN",
967 ErrorCode.UnknownError.getValue());
969 logger.trace('Exited ' + method)
970 } catch (BpmnError e) {
972 } catch (Exception e) {
973 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
974 'Caught exception in ' + method, "BPMN",
975 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
976 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
980 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
982 def prefix = execution.getVariable("prefix")
984 logger.trace("STARTED ValidateSDNCResponse Process")
986 WorkflowException workflowException = execution.getVariable("WorkflowException")
987 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
989 logger.debug("workflowException: " + workflowException)
991 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
992 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
994 logger.debug("SDNCResponse: " + response)
996 String sdncResponse = response
997 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
998 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
1000 logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
1001 throw new BpmnError("MSOWorkflowException")
1003 logger.trace("COMPLETED ValidateSDNCResponse Process")
1007 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
1008 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
1010 * @param execution The flow's execution instance.
1012 public void queryAAIVfModule(DelegateExecution execution) {
1014 def method = getClass().getSimpleName() + '.getVfModule(' +
1015 'execution=' + execution.getId() +
1017 logger.trace('Entered ' + method)
1020 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
1021 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
1024 Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
1025 if (genericVnf.isPresent()) {
1026 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', 200)
1027 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', genericVnf.get())
1028 // Parse the VNF record from A&AI to find base module info
1029 logger.debug('Parsing the VNF data to find base module info')
1030 if (genericVnf.get().getVfModules()!=null && !genericVnf.get().getVfModules().getVfModule().isEmpty()) {
1031 Optional<org.onap.aai.domain.yang.VfModule> vfmodule = genericVnf.get().getVfModules().getVfModule().stream().
1032 filter{v-> v.isIsBaseVfModule()}.findFirst()
1033 if (vfmodule.isPresent()) {
1034 String baseModuleId = vfmodule.get().getVfModuleId()
1035 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1036 logger.debug('Received baseVfModuleId: ' + baseModuleId)
1037 String baseModuleHeatStackId = vfmodule.get().getHeatStackId()
1038 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1039 logger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1043 } catch (Exception ex) {
1044 logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
1045 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1047 logger.trace('Exited ' + method)
1048 } catch (BpmnError e) {
1050 } catch (Exception e) {
1051 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
1052 'Caught exception in ' + method, "BPMN",
1053 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e);
1054 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())