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.onap.so.logger.LoggingAnchor
26 import org.camunda.bpm.engine.delegate.BpmnError
27 import org.camunda.bpm.engine.delegate.DelegateExecution
28 import org.onap.aai.domain.yang.GenericVnf
29 import org.onap.so.bpmn.common.scripts.AaiUtil
30 import org.onap.so.bpmn.common.scripts.CatalogDbUtils
31 import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
32 import org.onap.so.bpmn.common.scripts.ExceptionUtil
33 import org.onap.so.bpmn.common.scripts.MsoUtils
34 import org.onap.so.bpmn.common.scripts.NetworkUtils
35 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
36 import org.onap.so.bpmn.common.scripts.VfModuleBase
37 import org.onap.so.bpmn.core.UrnPropertiesReader
38 import org.onap.so.bpmn.core.WorkflowException
39 import org.onap.so.bpmn.core.json.JsonUtils;
40 import org.onap.so.client.graphinventory.entities.uri.Depth
41 import org.onap.so.client.aai.AAIObjectType;
42 import org.onap.so.client.aai.AAIResourcesClient
43 import org.onap.so.client.aai.entities.AAIResultWrapper
44 import org.onap.so.client.aai.entities.uri.AAIUri
45 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
46 import org.onap.so.client.aai.entities.uri.AAIResourceUri
47 import org.onap.so.constants.Defaults
48 import org.onap.logging.filter.base.ErrorCode
49 import org.onap.so.logger.MessageEnum
50 import org.slf4j.Logger
51 import org.slf4j.LoggerFactory
53 public class DoUpdateVfModule extends VfModuleBase {
54 private static final Logger logger = LoggerFactory.getLogger( DoUpdateVfModule.class);
56 ExceptionUtil exceptionUtil = new ExceptionUtil()
57 JsonUtils jsonUtil = new JsonUtils()
58 CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
61 * Initialize the flow's variables.
63 * @param execution The flow's execution instance.
65 public void initProcessVariables(DelegateExecution execution) {
66 execution.setVariable('prefix', 'DOUPVfMod_')
67 execution.setVariable('DOUPVfMod_requestInfo', null)
68 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
69 execution.setVariable('DOUPVfMod_requestId', null)
70 execution.setVariable('DOUPVfMod_vnfInputs', null)
71 execution.setVariable('DOUPVfMod_vnfId', null)
72 execution.setVariable('DOUPVfMod_vnfName', null)
73 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
74 execution.setVariable('DOUPVfMod_vfModuleName', null)
75 execution.setVariable('DOUPVfMod_vfModuleId', null)
76 execution.setVariable('DOUPVfMod_vnfType', null)
77 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
78 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
79 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
80 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
81 execution.setVariable('DOUPVfMod_serviceId', null)
82 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
83 execution.setVariable('DOUPVfMod_tenantId', null)
84 execution.setVariable('DOUPVfMod_volumeGroupId', null)
85 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
86 execution.setVariable('DOUPVfMod_vfModule', null)
87 execution.setVariable('DOUPVfMod_vnfParams', null)
88 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
89 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
90 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
91 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
92 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
93 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
94 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
95 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
96 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
97 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
98 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
99 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
100 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
101 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
105 * Check for missing elements in the received request.
107 * @param execution The flow's execution instance.
109 public void preProcessRequest(DelegateExecution execution) {
110 def method = getClass().getSimpleName() + '.preProcessRequest(' +
111 'execution=' + execution.getId() +
114 logger.trace('Entered ' + method)
117 initProcessVariables(execution)
118 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
119 logger.debug("DoUpdateVfModule request: " + xml)
120 logger.debug('Received request xml:\n' + xml)
122 if (xml == null || xml.isEmpty()) {
123 // Building Block-type request
125 String cloudConfiguration = execution.getVariable("cloudConfiguration")
126 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
128 def serviceModelInfo = execution.getVariable("serviceModelInfo")
129 logger.debug("serviceModelInfo: " + serviceModelInfo)
130 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
131 logger.debug("modelInvariantUuid: " + modelInvariantUuid)
132 def vnfModelInfo = execution.getVariable("vnfModelInfo")
135 def tenantId = execution.getVariable("tenantId")
136 execution.setVariable("DOUPVfMod_tenantId", tenantId)
139 def volumeGroupId = execution.getVariable("volumeGroupId")
140 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
143 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
144 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
146 logger.debug("cloudSiteId: " + cloudSiteId)
149 def cloudOwner = execution.getVariable("cloudOwner")
150 execution.setVariable("DOUPVfMod_cloudOwner", cloudOwner)
151 logger.debug("cloudOwner: " + cloudOwner)
154 def vnfType = execution.getVariable("vnfType")
155 execution.setVariable("DOUPVfMod_vnfType", vnfType)
157 logger.debug("vnfType: " + vnfType)
159 def vnfName = execution.getVariable("vnfName")
160 execution.setVariable("DOUPVfMod_vnfName", vnfName)
162 logger.debug("vnfName: " + vnfName)
164 def vnfId = execution.getVariable("vnfId")
165 execution.setVariable("DOUPVfMod_vnfId", vnfId)
167 logger.debug("vnfId: " + vnfId)
169 def vfModuleName = execution.getVariable("vfModuleName")
170 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
172 logger.debug("vfModuleName: " + vfModuleName)
174 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
175 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
177 logger.debug("vfModuleModelName: " + vfModuleModelName)
178 //modelCustomizationUuid
179 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
180 if (modelCustomizationUuid == null) {
181 modelCustomizationUuid = ""
183 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
185 logger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
187 def vfModuleId = execution.getVariable("vfModuleId")
188 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
189 logger.debug("vfModuleId: " + vfModuleId)
190 def requestId = execution.getVariable("msoRequestId")
191 execution.setVariable("DOUPVfMod_requestId", requestId)
192 logger.debug("requestId: " + requestId)
193 // Set mso-request-id to request-id for VNF Adapter interface
194 execution.setVariable("mso-request-id", requestId)
196 def serviceId = execution.getVariable("serviceId")
197 execution.setVariable("DOUPVfMod_serviceId", serviceId)
198 logger.debug("serviceId: " + serviceId)
200 def serviceInstanceId = execution.getVariable("serviceInstanceId")
201 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
203 logger.debug("serviceInstanceId: " + serviceInstanceId)
206 execution.setVariable("DOUPVfMod_source", source)
208 logger.debug("source: " + source)
210 def disableRollback = execution.getVariable("disableRollback")
211 def backoutOnFailure = true
212 if (disableRollback != null && disableRollback.equals("true")) {
213 backoutOnFailure = false
215 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
216 logger.debug("backoutOnFailure: " + backoutOnFailure)
218 def isBaseVfModule = execution.getVariable("isBaseVfModule")
219 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
220 logger.debug("isBaseVfModule: " + isBaseVfModule)
221 //asdcServiceModelVersion
222 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
223 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
224 logger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
226 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
227 //personaModelVersion
228 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
229 //Get or Generate UUID
230 String uuid = execution.getVariable("DOUPVfMod_uuid")
232 uuid = UUID.randomUUID()
233 logger.debug("Generated messageId (UUID) is: " + uuid)
235 logger.debug("Found messageId (UUID) is: " + uuid)
238 String isVidRequest = execution.getVariable("isVidRequest")
240 if (isVidRequest == null || isVidRequest.isEmpty()) {
241 execution.setVariable("isVidRequest", "true")
244 def usePreload = execution.getVariable("usePreload")
245 execution.setVariable("DOUPVfMod_usePreload", usePreload)
246 logger.debug("usePreload: " + usePreload)
248 String globalSubscriberId = execution.getVariable("globalSubscriberId")
249 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
250 logger.debug("globalSubsrciberId: " + globalSubscriberId)
252 String vnfQueryPath = execution.getVariable("vnfQueryPath")
253 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
254 logger.debug("vnfQueryPath: " + vnfQueryPath)
256 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
257 if (vfModuleInputParams != null) {
258 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
260 //get workload and environment context from parent SI
261 String environmentContext = ""
262 String workloadContext =""
263 String serviceType =""
266 String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
267 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
270 } catch (Exception ex){
271 String msg = "Exception in preProcessRequest " + ex.getMessage()
273 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
277 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
278 AAIResourcesClient aaiRC = new AAIResourcesClient()
279 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
280 Map<String, Object> aaiJson = aaiRW.asMap()
281 environmentContext = aaiJson.getOrDefault("environment-context","")
282 workloadContext = aaiJson.getOrDefault("workload-context","")
284 }catch (Exception ex) {
285 logger.debug("Error retreiving parent service instance information")
288 execution.setVariable("DCVFM_environmentContext",environmentContext)
289 execution.setVariable("DCVFM_workloadContext",workloadContext)
293 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
294 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
295 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
296 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
297 if (serviceInstanceId == null) {
298 serviceInstanceId = ''
300 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
302 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
303 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
304 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
305 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
306 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
307 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
308 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
309 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
310 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
311 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
312 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
313 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
314 execution.setVariable('DOUPVfMod_cloudOwner', getRequiredNodeText(execution, vnfInputs, 'cloud-owner'))
315 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
317 def isBaseVfModule = "false"
318 if (utils.nodeExists(xml, "is-base-vf-module")) {
319 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
320 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
322 logger.debug("isBaseVfModule: " + isBaseVfModule)
324 NetworkUtils networkUtils = new NetworkUtils()
325 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
326 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
328 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
329 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
331 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
334 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
335 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
336 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
337 logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
338 ErrorCode.UnknownError.getValue());
339 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
342 logger.trace('Exited ' + method)
343 } catch (BpmnError e) {
345 } catch (Exception e) {
346 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
347 'Caught exception in ' + method, "BPMN",
348 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
349 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
354 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
355 * set the orchestration-status to 'pending-update'.
357 * @param execution The flow's execution instance.
359 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
360 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
361 'execution=' + execution.getId() +
364 logger.trace('Entered ' + method)
367 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
368 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
369 def orchestrationStatus = 'pending-update'
371 String prepareUpdateAAIVfModuleRequest = """
372 <PrepareUpdateAAIVfModuleRequest>
373 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
374 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
375 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
376 </PrepareUpdateAAIVfModuleRequest>
378 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
379 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
380 logger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
381 logger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
383 logger.trace('Exited ' + method)
384 } catch (BpmnError e) {
386 } catch (Exception e) {
387 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
388 'Caught exception in ' + method, "BPMN",
389 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
390 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
395 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
396 * Determine cloud region id for the volume group.
398 * @param execution The flow's execution instance.
400 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
401 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
402 'execution=' + execution.getId() +
405 def prefix = execution.getVariable("prefix")
407 logger.trace('Entered ' + method)
410 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
413 AaiUtil aaiUtil = new AaiUtil(this)
415 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
416 def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
418 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
420 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
422 if ((cloudRegion != "ERROR")) {
423 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
424 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
426 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
428 execution.setVariable(prefix + "isCloudRegionGood", true)
430 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
431 logger.debug(errorMessage)
432 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
433 execution.setVariable(prefix + "isCloudRegionGood", false)
435 logger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"))
437 } catch(BpmnError b){
438 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
439 "Rethrowing MSOWorkflowException", "BPMN",
440 ErrorCode.UnknownError.getValue(), "Exception is:\n" + b);
442 }catch (Exception e) {
444 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
445 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
446 "AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, "BPMN",
447 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
448 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
450 logger.trace('Exited ' + method)
455 * Prepare a Request for invoking the SDNC Adapter subflow to perform
456 * a VNF topology 'changeassign' operation.
458 * @param execution The flow's execution instance.
460 public void prepSDNCTopologyChg(DelegateExecution execution) {
461 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
462 'execution=' + execution.getId() +
465 logger.trace('Entered ' + method)
468 def requestId = execution.getVariable('DOUPVfMod_requestId')
469 String uuid = execution.getVariable('testReqId') // for junits
471 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
473 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
474 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
475 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
476 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
477 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
478 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
479 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
480 def vfModuleName = ""
481 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
482 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
483 vfModuleName = vfModule.getVfModuleName()
485 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
486 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
487 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
488 String usePreloadToSDNC = usePreload ? "Y" : "N"
489 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
490 def modelCustomizationUuidString = ""
492 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
495 // Retrieve vnf name from AAI response
496 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
497 execution.setVariable('DOUPVfMod_vnfName', vnfName)
499 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
500 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
502 String sdncTopologyRequest = """
503 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
504 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
505 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
506 <sdncadapter:RequestHeader>
507 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
508 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
509 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
510 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
511 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
512 </sdncadapter:RequestHeader>
513 <sdncadapterworkflow:SDNCRequestData>
514 <request-information>
515 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
516 <request-action>ChangeVNFActivateRequest</request-action>
517 <source>PORTAL</source>
521 </request-information>
522 <service-information>
523 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
524 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
525 <subscriber-name>dontcare</subscriber-name>
526 </service-information>
527 <vnf-request-information>
528 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
529 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
530 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
531 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
532 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
533 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
534 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
535 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
536 ${modelCustomizationUuidString}
537 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
539 </vnf-request-information>
540 </sdncadapterworkflow:SDNCRequestData>
541 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
543 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
544 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
545 logger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
546 logger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
548 logger.trace('Exited ' + method)
549 } catch (BpmnError e) {
551 } catch (Exception e) {
552 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
553 'Caught exception in ' + method, "BPMN",
554 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
555 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
560 * Prepare a Request for invoking the SDNC Adapter subflow to perform
561 * a VNF topology 'query' operation.
563 * @param execution The flow's execution instance.
565 public void prepSDNCTopologyQuery(DelegateExecution execution) {
566 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
567 'execution=' + execution.getId() +
570 logger.trace('Entered ' + method)
573 String uuid = execution.getVariable('testReqId') // for junits
575 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
577 def requestId = execution.getVariable('DOUPVfMod_requestId')
578 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
579 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
580 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
583 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
584 svcInstId = vfModuleId
587 svcInstId = serviceInstanceId
590 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
593 String sdncTopologyRequest = """
594 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
595 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
596 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
597 <sdncadapter:RequestHeader>
598 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
599 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
600 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
601 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
602 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
603 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
604 </sdncadapter:RequestHeader>
605 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
607 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
608 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
609 logger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
610 logger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
612 logger.trace('Exited ' + method)
613 } catch (BpmnError e) {
615 } catch (Exception e) {
616 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
617 'Caught exception in ' + method, "BPMN",
618 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
619 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
624 * Prepare a Request for invoking the VnfAdapterRest subflow.
626 * @param execution The flow's execution instance.
628 public void prepVnfAdapterRest(DelegateExecution execution) {
629 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
630 'execution=' + execution.getId() +
633 logger.trace('Entered ' + method)
636 def requestId = execution.getVariable('DOUPVfMod_requestId')
637 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
638 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
639 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
640 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
641 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
642 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
643 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
644 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
646 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
647 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
648 heatStackId = vfModule.getHeatStackId()
650 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
651 def cloudOwner = execution.getVariable('DOUPVfMod_cloudOwner')
652 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
653 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
654 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
655 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
656 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
657 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
658 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
659 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
661 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
662 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
663 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
664 if ('true'.equals(useQualifiedHostName)) {
665 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
668 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
669 String workloadContext = execution.getVariable("DOUPVWorkload_context")
670 logger.debug("workloadContext: " + workloadContext)
671 logger.debug("environmentContext: " + environmentContext)
673 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
675 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
677 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
678 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
681 String vnfAdapterRestRequest = """
682 <updateVfModuleRequest>
683 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
684 <cloudOwner>${MsoUtils.xmlEscape(cloudOwner)}</cloudOwner>
685 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
686 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
687 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
688 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
689 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
690 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
691 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
692 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
693 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
694 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
695 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
696 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
697 <skipAAI>true</skipAAI>
698 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
699 <failIfExists>false</failIfExists>
704 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
705 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
707 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
708 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
709 </updateVfModuleRequest>
711 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
712 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
713 logger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
714 logger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
716 logger.trace('Exited ' + method)
717 } catch (BpmnError e) {
719 } catch (Exception e) {
720 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
721 'Caught exception in ' + method, "BPMN",
722 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
723 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
728 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
730 * @param execution The flow's execution instance.
732 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
733 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
734 'execution=' + execution.getId() +
736 logger.trace('Entered ' + method)
739 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
740 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
742 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
743 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
744 if ((personaModelId == null) || (personaModelVersion == null)) {
745 logger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
746 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
748 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
749 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
751 String updateAAIGenericVnfRequest = """
752 <UpdateAAIGenericVnfRequest>
753 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
754 ${personaModelIdElement}
755 ${personaModelVersionElement}
756 </UpdateAAIGenericVnfRequest>
758 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
759 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
760 logger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
761 logger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
764 logger.trace('Exited ' + method)
765 } catch (BpmnError e) {
767 } catch (Exception e) {
768 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
769 'Caught exception in ' + method, "BPMN",
770 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
771 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
776 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
778 * @param execution The flow's execution instance.
780 public void prepUpdateAAIVfModule(DelegateExecution execution) {
781 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
782 'execution=' + execution.getId() +
785 logger.trace('Entered ' + method)
788 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
789 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
790 def orchestrationStatus = 'updated'
791 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
793 def volumeGroupIdElement = ''
794 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
795 if (volumeGroupId != null) {
796 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
798 def personaModelIdElement = ''
799 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
800 if (personaModelId != null) {
801 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
803 def personaModelVersionElement = ''
804 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
805 if (personaModelVersion != null) {
806 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
808 def contrailServiceInstanceFqdnElement = ''
809 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
810 if (contrailServiceInstanceFqdn != null) {
811 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
813 def personaModelCustomizationIdElement = ''
814 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
815 if (modelCustomizationId != null) {
816 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
819 String updateAAIVfModuleRequest = """
820 <UpdateAAIVfModuleRequest>
821 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
822 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
823 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
824 ${volumeGroupIdElement}
825 ${personaModelIdElement}
826 ${personaModelVersionElement}
827 ${contrailServiceInstanceFqdnElement}
828 ${personaModelCustomizationIdElement}
829 </UpdateAAIVfModuleRequest>
832 logger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
833 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
834 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
835 logger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
836 logger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
838 logger.trace('Exited ' + method)
839 } catch (BpmnError e) {
841 } catch (Exception e) {
842 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
843 'Caught exception in ' + method, "BPMN",
844 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
845 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
850 * Prepare a Request for invoking the SDNC Adapter subflow to perform
851 * a VNF topology 'activate' operation.
853 * @param execution The flow's execution instance.
855 public void prepSDNCTopologyAct(DelegateExecution execution) {
856 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
857 'execution=' + execution.getId() +
860 logger.trace('Entered ' + method)
863 String uuid = execution.getVariable('testReqId') // for junits
865 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
867 def requestId = execution.getVariable('DOUPVfMod_requestId')
868 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
869 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
870 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
871 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
872 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
873 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
874 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
875 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
876 def vfModuleName = ""
877 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
878 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
879 vfModuleName = vfModule.getVfModuleName()
881 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
882 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
884 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
885 String usePreloadToSDNC = usePreload ? "Y" : "N"
886 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
887 def modelCustomizationUuidString = ""
889 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
892 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
893 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
895 String sdncTopologyRequest = """
896 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
897 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
898 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
899 <sdncadapter:RequestHeader>
900 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
901 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
902 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
903 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
904 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
905 </sdncadapter:RequestHeader>
906 <sdncadapterworkflow:SDNCRequestData>
907 <request-information>
908 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
909 <request-action>ChangeVNFActivateRequest</request-action>
910 <source>PORTAL</source>
914 </request-information>
915 <service-information>
916 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
917 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
918 <subscriber-name>dontcare</subscriber-name>
919 </service-information>
920 <vnf-request-information>
921 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
922 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
923 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
924 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
925 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
926 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
927 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
928 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
929 ${modelCustomizationUuidString}
930 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
931 </vnf-request-information>
932 </sdncadapterworkflow:SDNCRequestData>
933 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
935 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
936 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
937 logger.debug("sdncActivateRequest : " + sdncTopologyRequest)
938 logger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
941 logger.trace('Exited ' + method)
942 } catch (BpmnError e) {
944 } catch (Exception e) {
945 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
946 'Caught exception in ' + method, "BPMN",
947 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
948 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
953 * Log a WorkflowException that has been created.
955 * @param execution The flow's execution instance.
957 public void handleWorkflowException(DelegateExecution execution) {
958 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
959 'execution=' + execution.getId() +
962 logger.trace('Entered ' + method)
965 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
966 logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
967 method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN",
968 ErrorCode.UnknownError.getValue());
970 logger.trace('Exited ' + method)
971 } catch (BpmnError e) {
973 } catch (Exception e) {
974 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
975 'Caught exception in ' + method, "BPMN",
976 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
977 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
981 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
983 def prefix = execution.getVariable("prefix")
985 logger.trace("STARTED ValidateSDNCResponse Process")
987 WorkflowException workflowException = execution.getVariable("WorkflowException")
988 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
990 logger.debug("workflowException: " + workflowException)
992 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
993 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
995 logger.debug("SDNCResponse: " + response)
997 String sdncResponse = response
998 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
999 logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
1001 logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
1002 throw new BpmnError("MSOWorkflowException")
1004 logger.trace("COMPLETED ValidateSDNCResponse Process")
1008 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
1009 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
1011 * @param execution The flow's execution instance.
1013 public void queryAAIVfModule(DelegateExecution execution) {
1015 def method = getClass().getSimpleName() + '.getVfModule(' +
1016 'execution=' + execution.getId() +
1018 logger.trace('Entered ' + method)
1021 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
1022 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
1025 Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
1026 if (genericVnf.isPresent()) {
1027 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', 200)
1028 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', genericVnf.get())
1029 // Parse the VNF record from A&AI to find base module info
1030 logger.debug('Parsing the VNF data to find base module info')
1031 if (genericVnf.get().getVfModules()!=null && !genericVnf.get().getVfModules().getVfModule().isEmpty()) {
1032 Optional<org.onap.aai.domain.yang.VfModule> vfmodule = genericVnf.get().getVfModules().getVfModule().stream().
1033 filter{v-> v.isIsBaseVfModule()}.findFirst()
1034 if (vfmodule.isPresent()) {
1035 String baseModuleId = vfmodule.get().getVfModuleId()
1036 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1037 logger.debug('Received baseVfModuleId: ' + baseModuleId)
1038 String baseModuleHeatStackId = vfmodule.get().getHeatStackId()
1039 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1040 logger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1044 } catch (Exception ex) {
1045 logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
1046 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1048 logger.trace('Exited ' + method)
1049 } catch (BpmnError e) {
1051 } catch (Exception e) {
1052 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
1053 'Caught exception in ' + method, "BPMN",
1054 ErrorCode.UnknownError.getValue(), "Exception is:\n" + e, e);
1055 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())