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.ExceptionUtil
29 import org.onap.so.bpmn.common.scripts.MsoUtils
30 import org.onap.so.bpmn.common.scripts.NetworkUtils
31 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
32 import org.onap.so.bpmn.common.scripts.VfModule
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.AAIResourceUri
42 import org.onap.so.client.aai.entities.uri.AAIUri
43 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
44 import org.onap.so.client.aai.entities.uri.AAIResourceUri
45 import org.onap.so.constants.Defaults
46 import org.onap.so.logger.MessageEnum
47 import org.onap.so.logger.MsoLogger
48 import org.onap.so.rest.APIResponse
49 import org.springframework.web.util.UriUtils
51 public class DoUpdateVfModule extends VfModuleBase {
52 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateVfModule.class);
54 ExceptionUtil exceptionUtil = new ExceptionUtil()
55 JsonUtils jsonUtil = new JsonUtils()
56 CatalogDbUtils catalog = new CatalogDbUtils()
59 * Initialize the flow's variables.
61 * @param execution The flow's execution instance.
63 public void initProcessVariables(DelegateExecution execution) {
64 execution.setVariable('prefix', 'DOUPVfMod_')
65 execution.setVariable('DOUPVfMod_requestInfo', null)
66 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
67 execution.setVariable('DOUPVfMod_requestId', null)
68 execution.setVariable('DOUPVfMod_vnfInputs', null)
69 execution.setVariable('DOUPVfMod_vnfId', null)
70 execution.setVariable('DOUPVfMod_vnfName', null)
71 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
72 execution.setVariable('DOUPVfMod_vfModuleName', null)
73 execution.setVariable('DOUPVfMod_vfModuleId', null)
74 execution.setVariable('DOUPVfMod_vnfType', null)
75 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
76 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
77 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
78 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
79 execution.setVariable('DOUPVfMod_serviceId', null)
80 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
81 execution.setVariable('DOUPVfMod_tenantId', null)
82 execution.setVariable('DOUPVfMod_volumeGroupId', null)
83 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
84 execution.setVariable('DOUPVfMod_vfModule', null)
85 execution.setVariable('DOUPVfMod_vnfParams', null)
86 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
87 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
88 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
89 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
90 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
91 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
92 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
93 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
94 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
95 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
96 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
97 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
98 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
99 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
103 * Check for missing elements in the received request.
105 * @param execution The flow's execution instance.
107 public void preProcessRequest(DelegateExecution execution) {
108 def method = getClass().getSimpleName() + '.preProcessRequest(' +
109 'execution=' + execution.getId() +
112 msoLogger.trace('Entered ' + method)
115 initProcessVariables(execution)
116 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
117 msoLogger.debug("DoUpdateVfModule request: " + xml)
118 msoLogger.debug('Received request xml:\n' + xml)
120 if (xml == null || xml.isEmpty()) {
121 // Building Block-type request
123 String cloudConfiguration = execution.getVariable("cloudConfiguration")
124 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
126 def serviceModelInfo = execution.getVariable("serviceModelInfo")
127 msoLogger.debug("serviceModelInfo: " + serviceModelInfo)
128 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
129 msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid)
130 def vnfModelInfo = execution.getVariable("vnfModelInfo")
133 def tenantId = execution.getVariable("tenantId")
134 execution.setVariable("DOUPVfMod_tenantId", tenantId)
137 def volumeGroupId = execution.getVariable("volumeGroupId")
138 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
141 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
142 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
144 msoLogger.debug("cloudSiteId: " + cloudSiteId)
146 def vnfType = execution.getVariable("vnfType")
147 execution.setVariable("DOUPVfMod_vnfType", vnfType)
149 msoLogger.debug("vnfType: " + vnfType)
151 def vnfName = execution.getVariable("vnfName")
152 execution.setVariable("DOUPVfMod_vnfName", vnfName)
154 msoLogger.debug("vnfName: " + vnfName)
156 def vnfId = execution.getVariable("vnfId")
157 execution.setVariable("DOUPVfMod_vnfId", vnfId)
159 msoLogger.debug("vnfId: " + vnfId)
161 def vfModuleName = execution.getVariable("vfModuleName")
162 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
164 msoLogger.debug("vfModuleName: " + vfModuleName)
166 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
167 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
169 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
170 //modelCustomizationUuid
171 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
172 if (modelCustomizationUuid == null) {
173 modelCustomizationUuid = ""
175 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
177 msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
179 def vfModuleId = execution.getVariable("vfModuleId")
180 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
181 msoLogger.debug("vfModuleId: " + vfModuleId)
182 def requestId = execution.getVariable("msoRequestId")
183 execution.setVariable("DOUPVfMod_requestId", requestId)
184 msoLogger.debug("requestId: " + requestId)
185 // Set mso-request-id to request-id for VNF Adapter interface
186 execution.setVariable("mso-request-id", requestId)
188 def serviceId = execution.getVariable("serviceId")
189 execution.setVariable("DOUPVfMod_serviceId", serviceId)
190 msoLogger.debug("serviceId: " + serviceId)
192 def serviceInstanceId = execution.getVariable("serviceInstanceId")
193 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
195 msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
198 execution.setVariable("DOUPVfMod_source", source)
200 msoLogger.debug("source: " + source)
202 def disableRollback = execution.getVariable("disableRollback")
203 def backoutOnFailure = true
204 if (disableRollback != null && disableRollback.equals("true")) {
205 backoutOnFailure = false
207 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
208 msoLogger.debug("backoutOnFailure: " + backoutOnFailure)
210 def isBaseVfModule = execution.getVariable("isBaseVfModule")
211 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
212 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
213 //asdcServiceModelVersion
214 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
215 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
216 msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
218 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
219 //personaModelVersion
220 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
221 //Get or Generate UUID
222 String uuid = execution.getVariable("DOUPVfMod_uuid")
224 uuid = UUID.randomUUID()
225 msoLogger.debug("Generated messageId (UUID) is: " + uuid)
227 msoLogger.debug("Found messageId (UUID) is: " + uuid)
230 String isVidRequest = execution.getVariable("isVidRequest")
232 if (isVidRequest == null || isVidRequest.isEmpty()) {
233 execution.setVariable("isVidRequest", "true")
236 def usePreload = execution.getVariable("usePreload")
237 execution.setVariable("DOUPVfMod_usePreload", usePreload)
238 msoLogger.debug("usePreload: " + usePreload)
240 String globalSubscriberId = execution.getVariable("globalSubscriberId")
241 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
242 msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
244 String vnfQueryPath = execution.getVariable("vnfQueryPath")
245 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
246 msoLogger.debug("vnfQueryPath: " + vnfQueryPath)
248 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
249 if (vfModuleInputParams != null) {
250 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
252 //get workload and environment context from parent SI
253 String environmentContext = ""
254 String workloadContext =""
255 String serviceType =""
258 String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
259 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
262 } catch (Exception ex){
263 String msg = "Exception in preProcessRequest " + ex.getMessage()
265 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
269 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
270 AAIResourcesClient aaiRC = new AAIResourcesClient()
271 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
272 Map<String, Object> aaiJson = aaiRW.asMap()
273 environmentContext = aaiJson.getOrDefault("environment-context","")
274 workloadContext = aaiJson.getOrDefault("workload-context","")
276 }catch (Exception ex) {
277 msoLogger.debug("Error retreiving parent service instance information")
280 execution.setVariable("DCVFM_environmentContext",environmentContext)
281 execution.setVariable("DCVFM_workloadContext",workloadContext)
285 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
286 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
287 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
288 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
289 if (serviceInstanceId == null) {
290 serviceInstanceId = ''
292 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
294 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
295 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
296 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
297 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
298 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
299 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
300 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
301 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
302 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
303 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
304 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
305 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
306 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
308 def isBaseVfModule = "false"
309 if (utils.nodeExists(xml, "is-base-vf-module")) {
310 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
311 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
313 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
315 NetworkUtils networkUtils = new NetworkUtils()
316 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
317 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
319 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
320 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
322 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
325 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
326 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
327 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
328 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
329 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
332 msoLogger.trace('Exited ' + method)
333 } catch (BpmnError e) {
335 } catch (Exception e) {
336 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
337 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
342 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
343 * set the orchestration-status to 'pending-update'.
345 * @param execution The flow's execution instance.
347 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
348 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
349 'execution=' + execution.getId() +
352 msoLogger.trace('Entered ' + method)
355 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
356 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
357 def orchestrationStatus = 'pending-update'
359 String prepareUpdateAAIVfModuleRequest = """
360 <PrepareUpdateAAIVfModuleRequest>
361 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
362 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
363 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
364 </PrepareUpdateAAIVfModuleRequest>
366 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
367 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
368 msoLogger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
369 msoLogger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
371 msoLogger.trace('Exited ' + method)
372 } catch (BpmnError e) {
374 } catch (Exception e) {
375 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
376 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
381 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
382 * Determine cloud region id for the volume group.
384 * @param execution The flow's execution instance.
386 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
387 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
388 'execution=' + execution.getId() +
391 def prefix = execution.getVariable("prefix")
393 msoLogger.trace('Entered ' + method)
396 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
399 AaiUtil aaiUtil = new AaiUtil(this)
401 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
402 def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
404 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
406 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
408 if ((cloudRegion != "ERROR")) {
409 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
410 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
412 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
414 execution.setVariable(prefix + "isCloudRegionGood", true)
416 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
417 msoLogger.debug(errorMessage)
418 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
419 execution.setVariable(prefix + "isCloudRegionGood", false)
421 msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"))
423 } catch(BpmnError b){
424 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + b);
426 }catch (Exception e) {
428 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
429 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);
430 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
432 msoLogger.trace('Exited ' + method)
437 * Prepare a Request for invoking the SDNC Adapter subflow to perform
438 * a VNF topology 'changeassign' operation.
440 * @param execution The flow's execution instance.
442 public void prepSDNCTopologyChg(DelegateExecution execution) {
443 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
444 'execution=' + execution.getId() +
447 msoLogger.trace('Entered ' + method)
450 def requestId = execution.getVariable('DOUPVfMod_requestId')
451 String uuid = execution.getVariable('testReqId') // for junits
453 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
455 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
456 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
457 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
458 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
459 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
460 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
461 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
462 def vfModuleName = ""
463 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
464 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
465 vfModuleName = vfModule.getVfModuleName()
467 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
468 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
469 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
470 String usePreloadToSDNC = usePreload ? "Y" : "N"
471 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
472 def modelCustomizationUuidString = ""
474 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
477 // Retrieve vnf name from AAI response
478 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
479 execution.setVariable('DOUPVfMod_vnfName', vnfName)
481 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
482 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
484 String sdncTopologyRequest = """
485 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
486 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
487 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
488 <sdncadapter:RequestHeader>
489 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
490 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
491 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
492 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
493 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
494 </sdncadapter:RequestHeader>
495 <sdncadapterworkflow:SDNCRequestData>
496 <request-information>
497 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
498 <request-action>ChangeVNFActivateRequest</request-action>
499 <source>PORTAL</source>
503 </request-information>
504 <service-information>
505 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
506 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
507 <subscriber-name>dontcare</subscriber-name>
508 </service-information>
509 <vnf-request-information>
510 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
511 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
512 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
513 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
514 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
515 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
516 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
517 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
518 ${modelCustomizationUuidString}
519 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
521 </vnf-request-information>
522 </sdncadapterworkflow:SDNCRequestData>
523 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
525 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
526 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
527 msoLogger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
528 msoLogger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
530 msoLogger.trace('Exited ' + method)
531 } catch (BpmnError e) {
533 } catch (Exception e) {
534 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
535 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
540 * Prepare a Request for invoking the SDNC Adapter subflow to perform
541 * a VNF topology 'query' operation.
543 * @param execution The flow's execution instance.
545 public void prepSDNCTopologyQuery(DelegateExecution execution) {
546 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
547 'execution=' + execution.getId() +
550 msoLogger.trace('Entered ' + method)
553 String uuid = execution.getVariable('testReqId') // for junits
555 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
557 def requestId = execution.getVariable('DOUPVfMod_requestId')
558 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
559 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
560 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
563 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
564 svcInstId = vfModuleId
567 svcInstId = serviceInstanceId
570 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
573 String sdncTopologyRequest = """
574 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
575 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
576 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
577 <sdncadapter:RequestHeader>
578 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
579 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
580 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
581 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
582 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
583 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
584 </sdncadapter:RequestHeader>
585 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
587 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
588 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
589 msoLogger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
590 msoLogger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
592 msoLogger.trace('Exited ' + method)
593 } catch (BpmnError e) {
595 } catch (Exception e) {
596 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
597 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
602 * Prepare a Request for invoking the VnfAdapterRest subflow.
604 * @param execution The flow's execution instance.
606 public void prepVnfAdapterRest(DelegateExecution execution) {
607 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
608 'execution=' + execution.getId() +
611 msoLogger.trace('Entered ' + method)
614 def requestId = execution.getVariable('DOUPVfMod_requestId')
615 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
616 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
617 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
618 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
619 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
620 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
621 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
622 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
624 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
625 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
626 heatStackId = vfModule.getHeatStackId()
628 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
629 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
630 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
631 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
632 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
633 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
634 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
635 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
636 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
638 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
639 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
640 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
641 if ('true'.equals(useQualifiedHostName)) {
642 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
645 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
646 String workloadContext = execution.getVariable("DOUPVWorkload_context")
647 msoLogger.debug("workloadContext: " + workloadContext)
648 msoLogger.debug("environmentContext: " + environmentContext)
650 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
652 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
654 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
655 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
658 String vnfAdapterRestRequest = """
659 <updateVfModuleRequest>
660 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
661 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
662 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
663 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
664 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
665 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
666 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
667 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
668 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
669 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
670 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
671 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
672 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
673 <skipAAI>true</skipAAI>
674 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
675 <failIfExists>false</failIfExists>
680 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
681 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
683 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
684 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
685 </updateVfModuleRequest>
687 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
688 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
689 msoLogger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
690 msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
692 msoLogger.trace('Exited ' + method)
693 } catch (BpmnError e) {
695 } catch (Exception e) {
696 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
697 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
702 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
704 * @param execution The flow's execution instance.
706 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
707 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
708 'execution=' + execution.getId() +
710 msoLogger.trace('Entered ' + method)
713 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
714 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
716 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
717 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
718 if ((personaModelId == null) || (personaModelVersion == null)) {
719 msoLogger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
720 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
722 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
723 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
725 String updateAAIGenericVnfRequest = """
726 <UpdateAAIGenericVnfRequest>
727 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
728 ${personaModelIdElement}
729 ${personaModelVersionElement}
730 </UpdateAAIGenericVnfRequest>
732 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
733 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
734 msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
735 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
738 msoLogger.trace('Exited ' + method)
739 } catch (BpmnError e) {
741 } catch (Exception e) {
742 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
743 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
748 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
750 * @param execution The flow's execution instance.
752 public void prepUpdateAAIVfModule(DelegateExecution execution) {
753 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
754 'execution=' + execution.getId() +
757 msoLogger.trace('Entered ' + method)
760 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
761 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
762 def orchestrationStatus = 'updated'
763 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
765 def volumeGroupIdElement = ''
766 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
767 if (volumeGroupId != null) {
768 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
770 def personaModelIdElement = ''
771 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
772 if (personaModelId != null) {
773 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
775 def personaModelVersionElement = ''
776 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
777 if (personaModelVersion != null) {
778 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
780 def contrailServiceInstanceFqdnElement = ''
781 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
782 if (contrailServiceInstanceFqdn != null) {
783 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
785 def personaModelCustomizationIdElement = ''
786 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
787 if (modelCustomizationId != null) {
788 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
791 String updateAAIVfModuleRequest = """
792 <UpdateAAIVfModuleRequest>
793 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
794 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
795 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
796 ${volumeGroupIdElement}
797 ${personaModelIdElement}
798 ${personaModelVersionElement}
799 ${contrailServiceInstanceFqdnElement}
800 ${personaModelCustomizationIdElement}
801 </UpdateAAIVfModuleRequest>
804 msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
805 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
806 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
807 msoLogger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
808 msoLogger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
810 msoLogger.trace('Exited ' + method)
811 } catch (BpmnError e) {
813 } catch (Exception e) {
814 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
815 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
820 * Prepare a Request for invoking the SDNC Adapter subflow to perform
821 * a VNF topology 'activate' operation.
823 * @param execution The flow's execution instance.
825 public void prepSDNCTopologyAct(DelegateExecution execution) {
826 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
827 'execution=' + execution.getId() +
830 msoLogger.trace('Entered ' + method)
833 String uuid = execution.getVariable('testReqId') // for junits
835 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
837 def requestId = execution.getVariable('DOUPVfMod_requestId')
838 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
839 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
840 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
841 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
842 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
843 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
844 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
845 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
846 def vfModuleName = ""
847 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
848 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
849 vfModuleName = vfModule.getVfModuleName()
851 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
852 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
854 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
855 String usePreloadToSDNC = usePreload ? "Y" : "N"
856 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
857 def modelCustomizationUuidString = ""
859 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
862 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
863 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
865 String sdncTopologyRequest = """
866 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
867 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
868 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
869 <sdncadapter:RequestHeader>
870 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
871 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
872 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
873 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
874 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
875 </sdncadapter:RequestHeader>
876 <sdncadapterworkflow:SDNCRequestData>
877 <request-information>
878 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
879 <request-action>ChangeVNFActivateRequest</request-action>
880 <source>PORTAL</source>
884 </request-information>
885 <service-information>
886 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
887 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
888 <subscriber-name>dontcare</subscriber-name>
889 </service-information>
890 <vnf-request-information>
891 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
892 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
893 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
894 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
895 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
896 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
897 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
898 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
899 ${modelCustomizationUuidString}
900 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
901 </vnf-request-information>
902 </sdncadapterworkflow:SDNCRequestData>
903 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
905 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
906 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
907 msoLogger.debug("sdncActivateRequest : " + sdncTopologyRequest)
908 msoLogger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
911 msoLogger.trace('Exited ' + method)
912 } catch (BpmnError e) {
914 } catch (Exception e) {
915 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
916 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
921 * Log a WorkflowException that has been created.
923 * @param execution The flow's execution instance.
925 public void handleWorkflowException(DelegateExecution execution) {
926 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
927 'execution=' + execution.getId() +
930 msoLogger.trace('Entered ' + method)
933 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
934 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
936 msoLogger.trace('Exited ' + method)
937 } catch (BpmnError e) {
939 } catch (Exception e) {
940 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
941 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
945 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
947 def prefix = execution.getVariable("prefix")
949 msoLogger.trace("STARTED ValidateSDNCResponse Process")
951 WorkflowException workflowException = execution.getVariable("WorkflowException")
952 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
954 msoLogger.debug("workflowException: " + workflowException)
956 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
957 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
959 msoLogger.debug("SDNCResponse: " + response)
961 String sdncResponse = response
962 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
963 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
965 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
966 throw new BpmnError("MSOWorkflowException")
968 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
972 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
973 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
975 * @param execution The flow's execution instance.
977 public void queryAAIVfModule(DelegateExecution execution) {
979 def method = getClass().getSimpleName() + '.getVfModule(' +
980 'execution=' + execution.getId() +
982 msoLogger.trace('Entered ' + method)
985 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
986 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
989 Optional<GenericVnf> genericVnf = getAAIClient().get(GenericVnf.class,uri)
990 if (genericVnf.isPresent()) {
991 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', 200)
992 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', genericVnf.get())
993 // Parse the VNF record from A&AI to find base module info
994 msoLogger.debug('Parsing the VNF data to find base module info')
995 if (genericVnf.get().getVfModules()!=null && !genericVnf.get().getVfModules().getVfModule().isEmpty()) {
996 Optional<org.onap.aai.domain.yang.VfModule> vfmodule = genericVnf.get().getVfModules().getVfModule().stream().
997 filter{v-> v.isIsBaseVfModule()}.findFirst()
998 if (vfmodule.isPresent()) {
999 String baseModuleId = vfmodule.get().getVfModuleId()
1000 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1001 msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
1002 String baseModuleHeatStackId = vfmodule.get().getHeatStackId()
1003 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1004 msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1008 } catch (Exception ex) {
1009 ex.printStackTrace()
1010 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
1011 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1013 msoLogger.trace('Exited ' + method)
1014 } catch (BpmnError e) {
1016 } catch (Exception e) {
1017 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1018 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())