2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.bpmn.infrastructure.scripts
23 import org.camunda.bpm.engine.delegate.BpmnError
24 import org.camunda.bpm.engine.delegate.DelegateExecution
25 import org.onap.aai.domain.yang.GenericVnf
26 import org.onap.so.bpmn.common.scripts.AaiUtil
27 import org.onap.so.bpmn.common.scripts.CatalogDbUtils
28 import org.onap.so.bpmn.common.scripts.CatalogDbUtilsFactory
29 import org.onap.so.bpmn.common.scripts.ExceptionUtil
30 import org.onap.so.bpmn.common.scripts.MsoUtils
31 import org.onap.so.bpmn.common.scripts.NetworkUtils
32 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
33 import org.onap.so.bpmn.common.scripts.VfModuleBase
34 import org.onap.so.bpmn.core.UrnPropertiesReader
35 import org.onap.so.bpmn.core.WorkflowException
36 import org.onap.so.bpmn.core.json.JsonUtils;
37 import org.onap.so.client.graphinventory.entities.uri.Depth
38 import org.onap.so.client.aai.AAIObjectType;
39 import org.onap.so.client.aai.AAIResourcesClient
40 import org.onap.so.client.aai.entities.AAIResultWrapper
41 import org.onap.so.client.aai.entities.uri.AAIUri
42 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
43 import org.onap.so.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.constants.Defaults
45 import org.onap.so.logger.MessageEnum
46 import org.onap.so.logger.MsoLogger
48 public class DoUpdateVfModule extends VfModuleBase {
49 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateVfModule.class);
51 ExceptionUtil exceptionUtil = new ExceptionUtil()
52 JsonUtils jsonUtil = new JsonUtils()
53 CatalogDbUtils catalogDbUtils = new CatalogDbUtilsFactory().create()
56 * Initialize the flow's variables.
58 * @param execution The flow's execution instance.
60 public void initProcessVariables(DelegateExecution execution) {
61 execution.setVariable('prefix', 'DOUPVfMod_')
62 execution.setVariable('DOUPVfMod_requestInfo', null)
63 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
64 execution.setVariable('DOUPVfMod_requestId', null)
65 execution.setVariable('DOUPVfMod_vnfInputs', null)
66 execution.setVariable('DOUPVfMod_vnfId', null)
67 execution.setVariable('DOUPVfMod_vnfName', null)
68 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
69 execution.setVariable('DOUPVfMod_vfModuleName', null)
70 execution.setVariable('DOUPVfMod_vfModuleId', null)
71 execution.setVariable('DOUPVfMod_vnfType', null)
72 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
73 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
74 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
75 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
76 execution.setVariable('DOUPVfMod_serviceId', null)
77 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
78 execution.setVariable('DOUPVfMod_tenantId', null)
79 execution.setVariable('DOUPVfMod_volumeGroupId', null)
80 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
81 execution.setVariable('DOUPVfMod_vfModule', null)
82 execution.setVariable('DOUPVfMod_vnfParams', null)
83 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
84 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
85 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
86 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
87 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
88 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
89 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
90 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
91 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
92 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
93 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
94 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
95 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
96 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
100 * Check for missing elements in the received request.
102 * @param execution The flow's execution instance.
104 public void preProcessRequest(DelegateExecution execution) {
105 def method = getClass().getSimpleName() + '.preProcessRequest(' +
106 'execution=' + execution.getId() +
109 msoLogger.trace('Entered ' + method)
112 initProcessVariables(execution)
113 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
114 msoLogger.debug("DoUpdateVfModule request: " + xml)
115 msoLogger.debug('Received request xml:\n' + xml)
117 if (xml == null || xml.isEmpty()) {
118 // Building Block-type request
120 String cloudConfiguration = execution.getVariable("cloudConfiguration")
121 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
123 def serviceModelInfo = execution.getVariable("serviceModelInfo")
124 msoLogger.debug("serviceModelInfo: " + serviceModelInfo)
125 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
126 msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid)
127 def vnfModelInfo = execution.getVariable("vnfModelInfo")
130 def tenantId = execution.getVariable("tenantId")
131 execution.setVariable("DOUPVfMod_tenantId", tenantId)
134 def volumeGroupId = execution.getVariable("volumeGroupId")
135 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
138 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
139 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
141 msoLogger.debug("cloudSiteId: " + cloudSiteId)
143 def vnfType = execution.getVariable("vnfType")
144 execution.setVariable("DOUPVfMod_vnfType", vnfType)
146 msoLogger.debug("vnfType: " + vnfType)
148 def vnfName = execution.getVariable("vnfName")
149 execution.setVariable("DOUPVfMod_vnfName", vnfName)
151 msoLogger.debug("vnfName: " + vnfName)
153 def vnfId = execution.getVariable("vnfId")
154 execution.setVariable("DOUPVfMod_vnfId", vnfId)
156 msoLogger.debug("vnfId: " + vnfId)
158 def vfModuleName = execution.getVariable("vfModuleName")
159 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
161 msoLogger.debug("vfModuleName: " + vfModuleName)
163 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
164 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
166 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
167 //modelCustomizationUuid
168 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
169 if (modelCustomizationUuid == null) {
170 modelCustomizationUuid = ""
172 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
174 msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
176 def vfModuleId = execution.getVariable("vfModuleId")
177 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
178 msoLogger.debug("vfModuleId: " + vfModuleId)
179 def requestId = execution.getVariable("msoRequestId")
180 execution.setVariable("DOUPVfMod_requestId", requestId)
181 msoLogger.debug("requestId: " + requestId)
182 // Set mso-request-id to request-id for VNF Adapter interface
183 execution.setVariable("mso-request-id", requestId)
185 def serviceId = execution.getVariable("serviceId")
186 execution.setVariable("DOUPVfMod_serviceId", serviceId)
187 msoLogger.debug("serviceId: " + serviceId)
189 def serviceInstanceId = execution.getVariable("serviceInstanceId")
190 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
192 msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
195 execution.setVariable("DOUPVfMod_source", source)
197 msoLogger.debug("source: " + source)
199 def disableRollback = execution.getVariable("disableRollback")
200 def backoutOnFailure = true
201 if (disableRollback != null && disableRollback.equals("true")) {
202 backoutOnFailure = false
204 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
205 msoLogger.debug("backoutOnFailure: " + backoutOnFailure)
207 def isBaseVfModule = execution.getVariable("isBaseVfModule")
208 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
209 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
210 //asdcServiceModelVersion
211 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
212 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
213 msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
215 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
216 //personaModelVersion
217 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
218 //Get or Generate UUID
219 String uuid = execution.getVariable("DOUPVfMod_uuid")
221 uuid = UUID.randomUUID()
222 msoLogger.debug("Generated messageId (UUID) is: " + uuid)
224 msoLogger.debug("Found messageId (UUID) is: " + uuid)
227 String isVidRequest = execution.getVariable("isVidRequest")
229 if (isVidRequest == null || isVidRequest.isEmpty()) {
230 execution.setVariable("isVidRequest", "true")
233 def usePreload = execution.getVariable("usePreload")
234 execution.setVariable("DOUPVfMod_usePreload", usePreload)
235 msoLogger.debug("usePreload: " + usePreload)
237 String globalSubscriberId = execution.getVariable("globalSubscriberId")
238 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
239 msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
241 String vnfQueryPath = execution.getVariable("vnfQueryPath")
242 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
243 msoLogger.debug("vnfQueryPath: " + vnfQueryPath)
245 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
246 if (vfModuleInputParams != null) {
247 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
249 //get workload and environment context from parent SI
250 String environmentContext = ""
251 String workloadContext =""
252 String serviceType =""
255 String json = catalogDbUtils.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
256 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
259 } catch (Exception ex){
260 String msg = "Exception in preProcessRequest " + ex.getMessage()
262 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
266 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
267 AAIResourcesClient aaiRC = new AAIResourcesClient()
268 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
269 Map<String, Object> aaiJson = aaiRW.asMap()
270 environmentContext = aaiJson.getOrDefault("environment-context","")
271 workloadContext = aaiJson.getOrDefault("workload-context","")
273 }catch (Exception ex) {
274 msoLogger.debug("Error retreiving parent service instance information")
277 execution.setVariable("DCVFM_environmentContext",environmentContext)
278 execution.setVariable("DCVFM_workloadContext",workloadContext)
282 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
283 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
284 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
285 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
286 if (serviceInstanceId == null) {
287 serviceInstanceId = ''
289 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
291 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
292 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
293 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
294 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
295 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
296 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
297 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
298 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
299 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
300 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
301 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
302 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
303 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
305 def isBaseVfModule = "false"
306 if (utils.nodeExists(xml, "is-base-vf-module")) {
307 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
308 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
310 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
312 NetworkUtils networkUtils = new NetworkUtils()
313 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
314 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
316 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
317 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
319 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
322 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
323 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
324 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
325 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
326 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
329 msoLogger.trace('Exited ' + method)
330 } catch (BpmnError e) {
332 } catch (Exception e) {
333 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
334 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
339 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
340 * set the orchestration-status to 'pending-update'.
342 * @param execution The flow's execution instance.
344 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
345 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
346 'execution=' + execution.getId() +
349 msoLogger.trace('Entered ' + method)
352 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
353 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
354 def orchestrationStatus = 'pending-update'
356 String prepareUpdateAAIVfModuleRequest = """
357 <PrepareUpdateAAIVfModuleRequest>
358 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
359 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
360 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
361 </PrepareUpdateAAIVfModuleRequest>
363 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
364 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
365 msoLogger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
366 msoLogger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
368 msoLogger.trace('Exited ' + method)
369 } catch (BpmnError e) {
371 } catch (Exception e) {
372 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
373 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
378 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
379 * Determine cloud region id for the volume group.
381 * @param execution The flow's execution instance.
383 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
384 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
385 'execution=' + execution.getId() +
388 def prefix = execution.getVariable("prefix")
390 msoLogger.trace('Entered ' + method)
393 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
396 AaiUtil aaiUtil = new AaiUtil(this)
398 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
399 def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
401 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
403 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
405 if ((cloudRegion != "ERROR")) {
406 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
407 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
409 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
411 execution.setVariable(prefix + "isCloudRegionGood", true)
413 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
414 msoLogger.debug(errorMessage)
415 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
416 execution.setVariable(prefix + "isCloudRegionGood", false)
418 msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"))
420 } catch(BpmnError b){
421 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + b);
423 }catch (Exception e) {
425 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
426 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " AAI Query Cloud Region Failed. Exception - " + "\n" + errorMessage, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
427 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
429 msoLogger.trace('Exited ' + method)
434 * Prepare a Request for invoking the SDNC Adapter subflow to perform
435 * a VNF topology 'changeassign' operation.
437 * @param execution The flow's execution instance.
439 public void prepSDNCTopologyChg(DelegateExecution execution) {
440 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
441 'execution=' + execution.getId() +
444 msoLogger.trace('Entered ' + method)
447 def requestId = execution.getVariable('DOUPVfMod_requestId')
448 String uuid = execution.getVariable('testReqId') // for junits
450 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
452 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
453 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
454 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
455 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
456 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
457 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
458 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
459 def vfModuleName = ""
460 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
461 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
462 vfModuleName = vfModule.getVfModuleName()
464 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
465 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
466 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
467 String usePreloadToSDNC = usePreload ? "Y" : "N"
468 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
469 def modelCustomizationUuidString = ""
471 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
474 // Retrieve vnf name from AAI response
475 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
476 execution.setVariable('DOUPVfMod_vnfName', vnfName)
478 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
479 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
481 String sdncTopologyRequest = """
482 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
483 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
484 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
485 <sdncadapter:RequestHeader>
486 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
487 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
488 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
489 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
490 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
491 </sdncadapter:RequestHeader>
492 <sdncadapterworkflow:SDNCRequestData>
493 <request-information>
494 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
495 <request-action>ChangeVNFActivateRequest</request-action>
496 <source>PORTAL</source>
500 </request-information>
501 <service-information>
502 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
503 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
504 <subscriber-name>dontcare</subscriber-name>
505 </service-information>
506 <vnf-request-information>
507 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
508 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
509 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
510 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
511 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
512 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
513 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
514 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
515 ${modelCustomizationUuidString}
516 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
518 </vnf-request-information>
519 </sdncadapterworkflow:SDNCRequestData>
520 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
522 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
523 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
524 msoLogger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
525 msoLogger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
527 msoLogger.trace('Exited ' + method)
528 } catch (BpmnError e) {
530 } catch (Exception e) {
531 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
532 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
537 * Prepare a Request for invoking the SDNC Adapter subflow to perform
538 * a VNF topology 'query' operation.
540 * @param execution The flow's execution instance.
542 public void prepSDNCTopologyQuery(DelegateExecution execution) {
543 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
544 'execution=' + execution.getId() +
547 msoLogger.trace('Entered ' + method)
550 String uuid = execution.getVariable('testReqId') // for junits
552 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
554 def requestId = execution.getVariable('DOUPVfMod_requestId')
555 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
556 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
557 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
560 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
561 svcInstId = vfModuleId
564 svcInstId = serviceInstanceId
567 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
570 String sdncTopologyRequest = """
571 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
572 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
573 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
574 <sdncadapter:RequestHeader>
575 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
576 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
577 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
578 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
579 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
580 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
581 </sdncadapter:RequestHeader>
582 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
584 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
585 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
586 msoLogger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
587 msoLogger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
589 msoLogger.trace('Exited ' + method)
590 } catch (BpmnError e) {
592 } catch (Exception e) {
593 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
594 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
599 * Prepare a Request for invoking the VnfAdapterRest subflow.
601 * @param execution The flow's execution instance.
603 public void prepVnfAdapterRest(DelegateExecution execution) {
604 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
605 'execution=' + execution.getId() +
608 msoLogger.trace('Entered ' + method)
611 def requestId = execution.getVariable('DOUPVfMod_requestId')
612 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
613 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
614 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
615 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
616 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
617 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
618 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
619 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
621 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
622 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
623 heatStackId = vfModule.getHeatStackId()
625 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
626 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
627 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
628 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
629 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
630 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
631 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
632 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
633 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
635 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
636 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
637 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
638 if ('true'.equals(useQualifiedHostName)) {
639 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
642 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
643 String workloadContext = execution.getVariable("DOUPVWorkload_context")
644 msoLogger.debug("workloadContext: " + workloadContext)
645 msoLogger.debug("environmentContext: " + environmentContext)
647 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
649 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
651 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
652 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
655 String vnfAdapterRestRequest = """
656 <updateVfModuleRequest>
657 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
658 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
659 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
660 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
661 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
662 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
663 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
664 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
665 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
666 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
667 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
668 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
669 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
670 <skipAAI>true</skipAAI>
671 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
672 <failIfExists>false</failIfExists>
677 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
678 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
680 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
681 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
682 </updateVfModuleRequest>
684 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
685 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
686 msoLogger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
687 msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
689 msoLogger.trace('Exited ' + method)
690 } catch (BpmnError e) {
692 } catch (Exception e) {
693 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
694 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
699 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
701 * @param execution The flow's execution instance.
703 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
704 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
705 'execution=' + execution.getId() +
707 msoLogger.trace('Entered ' + method)
710 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
711 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
713 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
714 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
715 if ((personaModelId == null) || (personaModelVersion == null)) {
716 msoLogger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
717 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
719 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
720 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
722 String updateAAIGenericVnfRequest = """
723 <UpdateAAIGenericVnfRequest>
724 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
725 ${personaModelIdElement}
726 ${personaModelVersionElement}
727 </UpdateAAIGenericVnfRequest>
729 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
730 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
731 msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
732 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
735 msoLogger.trace('Exited ' + method)
736 } catch (BpmnError e) {
738 } catch (Exception e) {
739 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
740 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
745 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
747 * @param execution The flow's execution instance.
749 public void prepUpdateAAIVfModule(DelegateExecution execution) {
750 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
751 'execution=' + execution.getId() +
754 msoLogger.trace('Entered ' + method)
757 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
758 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
759 def orchestrationStatus = 'updated'
760 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
762 def volumeGroupIdElement = ''
763 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
764 if (volumeGroupId != null) {
765 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
767 def personaModelIdElement = ''
768 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
769 if (personaModelId != null) {
770 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
772 def personaModelVersionElement = ''
773 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
774 if (personaModelVersion != null) {
775 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
777 def contrailServiceInstanceFqdnElement = ''
778 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
779 if (contrailServiceInstanceFqdn != null) {
780 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
782 def personaModelCustomizationIdElement = ''
783 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
784 if (modelCustomizationId != null) {
785 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
788 String updateAAIVfModuleRequest = """
789 <UpdateAAIVfModuleRequest>
790 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
791 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
792 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
793 ${volumeGroupIdElement}
794 ${personaModelIdElement}
795 ${personaModelVersionElement}
796 ${contrailServiceInstanceFqdnElement}
797 ${personaModelCustomizationIdElement}
798 </UpdateAAIVfModuleRequest>
801 msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
802 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
803 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
804 msoLogger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
805 msoLogger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
807 msoLogger.trace('Exited ' + method)
808 } catch (BpmnError e) {
810 } catch (Exception e) {
811 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
812 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
817 * Prepare a Request for invoking the SDNC Adapter subflow to perform
818 * a VNF topology 'activate' operation.
820 * @param execution The flow's execution instance.
822 public void prepSDNCTopologyAct(DelegateExecution execution) {
823 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
824 'execution=' + execution.getId() +
827 msoLogger.trace('Entered ' + method)
830 String uuid = execution.getVariable('testReqId') // for junits
832 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
834 def requestId = execution.getVariable('DOUPVfMod_requestId')
835 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
836 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
837 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
838 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
839 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
840 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
841 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
842 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
843 def vfModuleName = ""
844 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
845 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
846 vfModuleName = vfModule.getVfModuleName()
848 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
849 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
851 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
852 String usePreloadToSDNC = usePreload ? "Y" : "N"
853 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
854 def modelCustomizationUuidString = ""
856 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
859 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
860 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
862 String sdncTopologyRequest = """
863 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
864 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
865 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
866 <sdncadapter:RequestHeader>
867 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
868 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
869 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
870 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
871 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
872 </sdncadapter:RequestHeader>
873 <sdncadapterworkflow:SDNCRequestData>
874 <request-information>
875 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
876 <request-action>ChangeVNFActivateRequest</request-action>
877 <source>PORTAL</source>
881 </request-information>
882 <service-information>
883 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
884 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
885 <subscriber-name>dontcare</subscriber-name>
886 </service-information>
887 <vnf-request-information>
888 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
889 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
890 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
891 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
892 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
893 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
894 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
895 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
896 ${modelCustomizationUuidString}
897 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
898 </vnf-request-information>
899 </sdncadapterworkflow:SDNCRequestData>
900 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
902 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
903 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
904 msoLogger.debug("sdncActivateRequest : " + sdncTopologyRequest)
905 msoLogger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
908 msoLogger.trace('Exited ' + method)
909 } catch (BpmnError e) {
911 } catch (Exception e) {
912 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
913 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
918 * Log a WorkflowException that has been created.
920 * @param execution The flow's execution instance.
922 public void handleWorkflowException(DelegateExecution execution) {
923 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
924 'execution=' + execution.getId() +
927 msoLogger.trace('Entered ' + method)
930 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
931 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
933 msoLogger.trace('Exited ' + method)
934 } catch (BpmnError e) {
936 } catch (Exception e) {
937 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
938 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
942 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
944 def prefix = execution.getVariable("prefix")
946 msoLogger.trace("STARTED ValidateSDNCResponse Process")
948 WorkflowException workflowException = execution.getVariable("WorkflowException")
949 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
951 msoLogger.debug("workflowException: " + workflowException)
953 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
954 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
956 msoLogger.debug("SDNCResponse: " + response)
958 String sdncResponse = response
959 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
960 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
962 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
963 throw new BpmnError("MSOWorkflowException")
965 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
969 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
970 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
972 * @param execution The flow's execution instance.
974 public void queryAAIVfModule(DelegateExecution execution) {
976 def method = getClass().getSimpleName() + '.getVfModule(' +
977 'execution=' + execution.getId() +
979 msoLogger.trace('Entered ' + method)
982 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
983 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
986 Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
987 if (genericVnf.isPresent()) {
988 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', 200)
989 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', genericVnf.get())
990 // Parse the VNF record from A&AI to find base module info
991 msoLogger.debug('Parsing the VNF data to find base module info')
992 if (genericVnf.get().getVfModules()!=null && !genericVnf.get().getVfModules().getVfModule().isEmpty()) {
993 Optional<org.onap.aai.domain.yang.VfModule> vfmodule = genericVnf.get().getVfModules().getVfModule().stream().
994 filter{v-> v.isIsBaseVfModule()}.findFirst()
995 if (vfmodule.isPresent()) {
996 String baseModuleId = vfmodule.get().getVfModuleId()
997 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
998 msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
999 String baseModuleHeatStackId = vfmodule.get().getHeatStackId()
1000 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1001 msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1005 } catch (Exception ex) {
1006 ex.printStackTrace()
1007 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
1008 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1010 msoLogger.trace('Exited ' + method)
1011 } catch (BpmnError e) {
1013 } catch (Exception e) {
1014 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1015 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())