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.so.bpmn.common.scripts.AaiUtil
26 import org.onap.so.bpmn.common.scripts.CatalogDbUtils
27 import org.onap.so.bpmn.common.scripts.ExceptionUtil
28 import org.onap.so.bpmn.common.scripts.MsoUtils
29 import org.onap.so.bpmn.common.scripts.NetworkUtils
30 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
31 import org.onap.so.bpmn.common.scripts.VfModule
32 import org.onap.so.bpmn.common.scripts.VfModuleBase
33 import org.onap.so.bpmn.core.UrnPropertiesReader
34 import org.onap.so.bpmn.core.WorkflowException
35 import org.onap.so.bpmn.core.json.JsonUtils;
36 import org.onap.so.client.aai.AAIObjectType;
37 import org.onap.so.client.aai.AAIResourcesClient
38 import org.onap.so.client.aai.entities.AAIResultWrapper
39 import org.onap.so.client.aai.entities.uri.AAIUri
40 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
41 import org.onap.so.logger.MessageEnum
42 import org.onap.so.logger.MsoLogger
43 import org.onap.so.rest.APIResponse
44 import org.springframework.web.util.UriUtils
46 public class DoUpdateVfModule extends VfModuleBase {
47 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateVfModule.class);
49 ExceptionUtil exceptionUtil = new ExceptionUtil()
50 JsonUtils jsonUtil = new JsonUtils()
51 CatalogDbUtils catalog = new CatalogDbUtils()
54 * Initialize the flow's variables.
56 * @param execution The flow's execution instance.
58 public void initProcessVariables(DelegateExecution execution) {
59 execution.setVariable('prefix', 'DOUPVfMod_')
60 execution.setVariable('DOUPVfMod_requestInfo', null)
61 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
62 execution.setVariable('DOUPVfMod_requestId', null)
63 execution.setVariable('DOUPVfMod_vnfInputs', null)
64 execution.setVariable('DOUPVfMod_vnfId', null)
65 execution.setVariable('DOUPVfMod_vnfName', null)
66 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
67 execution.setVariable('DOUPVfMod_vfModuleName', null)
68 execution.setVariable('DOUPVfMod_vfModuleId', null)
69 execution.setVariable('DOUPVfMod_vnfType', null)
70 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
71 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
72 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
73 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
74 execution.setVariable('DOUPVfMod_serviceId', null)
75 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
76 execution.setVariable('DOUPVfMod_tenantId', null)
77 execution.setVariable('DOUPVfMod_volumeGroupId', null)
78 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
79 execution.setVariable('DOUPVfMod_vfModule', null)
80 execution.setVariable('DOUPVfMod_vnfParams', null)
81 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
82 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
83 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
84 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
85 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
86 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
87 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
88 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
89 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
90 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
91 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
92 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
93 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
94 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
98 * Check for missing elements in the received request.
100 * @param execution The flow's execution instance.
102 public void preProcessRequest(DelegateExecution execution) {
103 def method = getClass().getSimpleName() + '.preProcessRequest(' +
104 'execution=' + execution.getId() +
107 msoLogger.trace('Entered ' + method)
110 initProcessVariables(execution)
111 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
112 msoLogger.debug("DoUpdateVfModule request: " + xml)
113 msoLogger.debug('Received request xml:\n' + xml)
115 if (xml == null || xml.isEmpty()) {
116 // Building Block-type request
118 String cloudConfiguration = execution.getVariable("cloudConfiguration")
119 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
121 def serviceModelInfo = execution.getVariable("serviceModelInfo")
122 msoLogger.debug("serviceModelInfo: " + serviceModelInfo)
123 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
124 msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid)
125 def vnfModelInfo = execution.getVariable("vnfModelInfo")
128 def tenantId = execution.getVariable("tenantId")
129 execution.setVariable("DOUPVfMod_tenantId", tenantId)
132 def volumeGroupId = execution.getVariable("volumeGroupId")
133 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
136 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
137 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
139 msoLogger.debug("cloudSiteId: " + cloudSiteId)
141 def vnfType = execution.getVariable("vnfType")
142 execution.setVariable("DOUPVfMod_vnfType", vnfType)
144 msoLogger.debug("vnfType: " + vnfType)
146 def vnfName = execution.getVariable("vnfName")
147 execution.setVariable("DOUPVfMod_vnfName", vnfName)
149 msoLogger.debug("vnfName: " + vnfName)
151 def vnfId = execution.getVariable("vnfId")
152 execution.setVariable("DOUPVfMod_vnfId", vnfId)
154 msoLogger.debug("vnfId: " + vnfId)
156 def vfModuleName = execution.getVariable("vfModuleName")
157 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
159 msoLogger.debug("vfModuleName: " + vfModuleName)
161 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
162 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
164 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
165 //modelCustomizationUuid
166 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
167 if (modelCustomizationUuid == null) {
168 modelCustomizationUuid = ""
170 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
172 msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
174 def vfModuleId = execution.getVariable("vfModuleId")
175 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
176 msoLogger.debug("vfModuleId: " + vfModuleId)
177 def requestId = execution.getVariable("msoRequestId")
178 execution.setVariable("DOUPVfMod_requestId", requestId)
179 msoLogger.debug("requestId: " + requestId)
180 // Set mso-request-id to request-id for VNF Adapter interface
181 execution.setVariable("mso-request-id", requestId)
183 def serviceId = execution.getVariable("serviceId")
184 execution.setVariable("DOUPVfMod_serviceId", serviceId)
185 msoLogger.debug("serviceId: " + serviceId)
187 def serviceInstanceId = execution.getVariable("serviceInstanceId")
188 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
190 msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
193 execution.setVariable("DOUPVfMod_source", source)
195 msoLogger.debug("source: " + source)
197 def disableRollback = execution.getVariable("disableRollback")
198 def backoutOnFailure = true
199 if (disableRollback != null && disableRollback.equals("true")) {
200 backoutOnFailure = false
202 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
203 msoLogger.debug("backoutOnFailure: " + backoutOnFailure)
205 def isBaseVfModule = execution.getVariable("isBaseVfModule")
206 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
207 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
208 //asdcServiceModelVersion
209 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
210 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
211 msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
213 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
214 //personaModelVersion
215 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
216 //Get or Generate UUID
217 String uuid = execution.getVariable("DOUPVfMod_uuid")
219 uuid = UUID.randomUUID()
220 msoLogger.debug("Generated messageId (UUID) is: " + uuid)
222 msoLogger.debug("Found messageId (UUID) is: " + uuid)
225 String isVidRequest = execution.getVariable("isVidRequest")
227 if (isVidRequest == null || isVidRequest.isEmpty()) {
228 execution.setVariable("isVidRequest", "true")
231 def usePreload = execution.getVariable("usePreload")
232 execution.setVariable("DOUPVfMod_usePreload", usePreload)
233 msoLogger.debug("usePreload: " + usePreload)
235 String globalSubscriberId = execution.getVariable("globalSubscriberId")
236 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
237 msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
239 String vnfQueryPath = execution.getVariable("vnfQueryPath")
240 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
241 msoLogger.debug("vnfQueryPath: " + vnfQueryPath)
243 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
244 if (vfModuleInputParams != null) {
245 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
247 //get workload and environment context from parent SI
248 String environmentContext = ""
249 String workloadContext =""
250 String serviceType =""
253 String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
254 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
257 } catch (Exception ex){
258 String msg = "Exception in preProcessRequest " + ex.getMessage()
260 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
264 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
265 AAIResourcesClient aaiRC = new AAIResourcesClient()
266 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
267 Map<String, Object> aaiJson = aaiRW.asMap()
268 environmentContext = aaiJson.getOrDefault("environment-context","")
269 workloadContext = aaiJson.getOrDefault("workload-context","")
271 }catch (Exception ex) {
272 msoLogger.debug("Error retreiving parent service instance information")
275 execution.setVariable("DCVFM_environmentContext",environmentContext)
276 execution.setVariable("DCVFM_workloadContext",workloadContext)
280 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
281 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
282 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
283 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
284 if (serviceInstanceId == null) {
285 serviceInstanceId = ''
287 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
289 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
290 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
291 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
292 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
293 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
294 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
295 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
296 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
297 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
298 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
299 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
300 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
301 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
303 def isBaseVfModule = "false"
304 if (utils.nodeExists(xml, "is-base-vf-module")) {
305 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
306 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
308 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
310 NetworkUtils networkUtils = new NetworkUtils()
311 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
312 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
314 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
315 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
317 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
320 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
321 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
322 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
323 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
324 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
327 msoLogger.trace('Exited ' + method)
328 } catch (BpmnError e) {
330 } catch (Exception e) {
331 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
332 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
337 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
338 * set the orchestration-status to 'pending-update'.
340 * @param execution The flow's execution instance.
342 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
343 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
344 'execution=' + execution.getId() +
347 msoLogger.trace('Entered ' + method)
350 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
351 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
352 def orchestrationStatus = 'pending-update'
354 String prepareUpdateAAIVfModuleRequest = """
355 <PrepareUpdateAAIVfModuleRequest>
356 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
357 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
358 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
359 </PrepareUpdateAAIVfModuleRequest>
361 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
362 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
363 msoLogger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
364 msoLogger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
366 msoLogger.trace('Exited ' + method)
367 } catch (BpmnError e) {
369 } catch (Exception e) {
370 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
371 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
376 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
377 * Determine cloud region id for the volume group.
379 * @param execution The flow's execution instance.
381 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
382 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
383 'execution=' + execution.getId() +
386 def prefix = execution.getVariable("prefix")
388 msoLogger.trace('Entered ' + method)
391 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
394 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
395 AaiUtil aaiUtil = new AaiUtil(this)
396 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
397 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
398 msoLogger.debug("CloudRegion Request: " + queryCloudRegionRequest)
400 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
401 msoLogger.debug(prefix + "queryCloudRegionRequest - " + "\n" + 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 VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
460 def vfModuleName = vfModule.getElementText('vf-module-name')
461 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
462 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
463 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
464 String usePreloadToSDNC = usePreload ? "Y" : "N"
465 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
466 def modelCustomizationUuidString = ""
468 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
471 // Retrieve vnf name from AAI response
472 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
473 execution.setVariable('DOUPVfMod_vnfName', vnfName)
475 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
476 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
478 String sdncTopologyRequest = """
479 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
480 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
481 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
482 <sdncadapter:RequestHeader>
483 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
484 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
485 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
486 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
487 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
488 </sdncadapter:RequestHeader>
489 <sdncadapterworkflow:SDNCRequestData>
490 <request-information>
491 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
492 <request-action>ChangeVNFActivateRequest</request-action>
493 <source>PORTAL</source>
497 </request-information>
498 <service-information>
499 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
500 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
501 <subscriber-name>dontcare</subscriber-name>
502 </service-information>
503 <vnf-request-information>
504 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
505 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
506 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
507 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
508 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
509 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
510 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
511 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
512 ${modelCustomizationUuidString}
513 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
515 </vnf-request-information>
516 </sdncadapterworkflow:SDNCRequestData>
517 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
519 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
520 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
521 msoLogger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
522 msoLogger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
524 msoLogger.trace('Exited ' + method)
525 } catch (BpmnError e) {
527 } catch (Exception e) {
528 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
529 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
534 * Prepare a Request for invoking the SDNC Adapter subflow to perform
535 * a VNF topology 'query' operation.
537 * @param execution The flow's execution instance.
539 public void prepSDNCTopologyQuery(DelegateExecution execution) {
540 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
541 'execution=' + execution.getId() +
544 msoLogger.trace('Entered ' + method)
547 String uuid = execution.getVariable('testReqId') // for junits
549 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
551 def requestId = execution.getVariable('DOUPVfMod_requestId')
552 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
553 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
554 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
557 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
558 svcInstId = vfModuleId
561 svcInstId = serviceInstanceId
564 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
567 String sdncTopologyRequest = """
568 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
569 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
570 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
571 <sdncadapter:RequestHeader>
572 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
573 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
574 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
575 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
576 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
577 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
578 </sdncadapter:RequestHeader>
579 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
581 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
582 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
583 msoLogger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
584 msoLogger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
586 msoLogger.trace('Exited ' + method)
587 } catch (BpmnError e) {
589 } catch (Exception e) {
590 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
591 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
596 * Prepare a Request for invoking the VnfAdapterRest subflow.
598 * @param execution The flow's execution instance.
600 public void prepVnfAdapterRest(DelegateExecution execution) {
601 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
602 'execution=' + execution.getId() +
605 msoLogger.trace('Entered ' + method)
608 def requestId = execution.getVariable('DOUPVfMod_requestId')
609 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
610 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
611 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
612 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
613 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
614 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
615 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
616 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
617 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
618 def heatStackId = vfModule.getElementText('heat-stack-id')
619 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
620 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
621 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
622 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
623 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
624 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
625 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
626 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
627 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
629 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
630 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
631 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
632 if ('true'.equals(useQualifiedHostName)) {
633 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
636 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
637 String workloadContext = execution.getVariable("DOUPVWorkload_context")
638 msoLogger.debug("workloadContext: " + workloadContext)
639 msoLogger.debug("environmentContext: " + environmentContext)
641 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
643 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
645 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
646 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
649 String vnfAdapterRestRequest = """
650 <updateVfModuleRequest>
651 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
652 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
653 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
654 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
655 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
656 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
657 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
658 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
659 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
660 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
661 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
662 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
663 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
664 <skipAAI>true</skipAAI>
665 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
666 <failIfExists>false</failIfExists>
671 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
672 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
674 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
675 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
676 </updateVfModuleRequest>
678 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
679 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
680 msoLogger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
681 msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
683 msoLogger.trace('Exited ' + method)
684 } catch (BpmnError e) {
686 } catch (Exception e) {
687 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
688 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
693 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
695 * @param execution The flow's execution instance.
697 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
698 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
699 'execution=' + execution.getId() +
701 msoLogger.trace('Entered ' + method)
704 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
705 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
707 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
708 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
709 if ((personaModelId == null) || (personaModelVersion == null)) {
710 msoLogger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
711 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
713 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
714 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
716 String updateAAIGenericVnfRequest = """
717 <UpdateAAIGenericVnfRequest>
718 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
719 ${personaModelIdElement}
720 ${personaModelVersionElement}
721 </UpdateAAIGenericVnfRequest>
723 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
724 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
725 msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
726 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
729 msoLogger.trace('Exited ' + method)
730 } catch (BpmnError e) {
732 } catch (Exception e) {
733 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
734 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
739 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
741 * @param execution The flow's execution instance.
743 public void prepUpdateAAIVfModule(DelegateExecution execution) {
744 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
745 'execution=' + execution.getId() +
748 msoLogger.trace('Entered ' + method)
751 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
752 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
753 def orchestrationStatus = 'updated'
754 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
756 def volumeGroupIdElement = ''
757 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
758 if (volumeGroupId != null) {
759 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
761 def personaModelIdElement = ''
762 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
763 if (personaModelId != null) {
764 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
766 def personaModelVersionElement = ''
767 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
768 if (personaModelVersion != null) {
769 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
771 def contrailServiceInstanceFqdnElement = ''
772 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
773 if (contrailServiceInstanceFqdn != null) {
774 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
776 def personaModelCustomizationIdElement = ''
777 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
778 if (modelCustomizationId != null) {
779 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
782 String updateAAIVfModuleRequest = """
783 <UpdateAAIVfModuleRequest>
784 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
785 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
786 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
787 ${volumeGroupIdElement}
788 ${personaModelIdElement}
789 ${personaModelVersionElement}
790 ${contrailServiceInstanceFqdnElement}
791 ${personaModelCustomizationIdElement}
792 </UpdateAAIVfModuleRequest>
795 msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
796 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
797 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
798 msoLogger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
799 msoLogger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
801 msoLogger.trace('Exited ' + method)
802 } catch (BpmnError e) {
804 } catch (Exception e) {
805 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
806 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
811 * Prepare a Request for invoking the SDNC Adapter subflow to perform
812 * a VNF topology 'activate' operation.
814 * @param execution The flow's execution instance.
816 public void prepSDNCTopologyAct(DelegateExecution execution) {
817 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
818 'execution=' + execution.getId() +
821 msoLogger.trace('Entered ' + method)
824 String uuid = execution.getVariable('testReqId') // for junits
826 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
828 def requestId = execution.getVariable('DOUPVfMod_requestId')
829 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
830 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
831 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
832 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
833 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
834 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
835 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
836 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
837 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
838 def vfModuleName = vfModule.getElementText('vf-module-name')
839 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
840 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
842 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
843 String usePreloadToSDNC = usePreload ? "Y" : "N"
844 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
845 def modelCustomizationUuidString = ""
847 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
850 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
851 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
853 String sdncTopologyRequest = """
854 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
855 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
856 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
857 <sdncadapter:RequestHeader>
858 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
859 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
860 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
861 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
862 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
863 </sdncadapter:RequestHeader>
864 <sdncadapterworkflow:SDNCRequestData>
865 <request-information>
866 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
867 <request-action>ChangeVNFActivateRequest</request-action>
868 <source>PORTAL</source>
872 </request-information>
873 <service-information>
874 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
875 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
876 <subscriber-name>dontcare</subscriber-name>
877 </service-information>
878 <vnf-request-information>
879 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
880 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
881 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
882 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
883 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
884 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
885 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
886 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
887 ${modelCustomizationUuidString}
888 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
889 </vnf-request-information>
890 </sdncadapterworkflow:SDNCRequestData>
891 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
893 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
894 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
895 msoLogger.debug("sdncActivateRequest : " + sdncTopologyRequest)
896 msoLogger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
899 msoLogger.trace('Exited ' + method)
900 } catch (BpmnError e) {
902 } catch (Exception e) {
903 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
904 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
909 * Log a WorkflowException that has been created.
911 * @param execution The flow's execution instance.
913 public void handleWorkflowException(DelegateExecution execution) {
914 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
915 'execution=' + execution.getId() +
918 msoLogger.trace('Entered ' + method)
921 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
922 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
924 msoLogger.trace('Exited ' + method)
925 } catch (BpmnError e) {
927 } catch (Exception e) {
928 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
929 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
933 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
935 def prefix = execution.getVariable("prefix")
937 msoLogger.trace("STARTED ValidateSDNCResponse Process")
939 WorkflowException workflowException = execution.getVariable("WorkflowException")
940 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
942 msoLogger.debug("workflowException: " + workflowException)
944 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
945 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
947 msoLogger.debug("SDNCResponse: " + response)
949 String sdncResponse = response
950 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
951 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
953 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
954 throw new BpmnError("MSOWorkflowException")
956 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
960 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
961 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
963 * @param execution The flow's execution instance.
965 public void queryAAIVfModule(DelegateExecution execution) {
967 def method = getClass().getSimpleName() + '.getVfModule(' +
968 'execution=' + execution.getId() +
970 msoLogger.trace('Entered ' + method)
973 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
974 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
976 AaiUtil aaiUriUtil = new AaiUtil(this)
977 String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
978 msoLogger.debug('AAI URI is: ' + aai_uri)
980 String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
981 msoLogger.debug("AAI endPoint: " + endPoint)
984 def aaiRequestId = UUID.randomUUID().toString()
985 msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
986 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
987 msoLogger.debug("createVfModule - invoking httpGet() to AAI")
989 def responseData = response.getResponseBodyAsString()
990 if (responseData != null) {
991 msoLogger.debug("Received generic VNF data: " + responseData)
995 msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData)
996 msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
998 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
999 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
1000 msoLogger.debug('Response code:' + response.getStatusCode())
1001 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
1002 if (response.getStatusCode() == 200) {
1003 // Parse the VNF record from A&AI to find base module info
1004 msoLogger.debug('Parsing the VNF data to find base module info')
1005 if (responseData != null) {
1006 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
1007 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
1008 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
1009 int vfModulesSize = 0
1010 for (i in 0..vfModules.size()-1) {
1011 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
1012 def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
1014 if (isBaseVfModule == "true") {
1015 String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
1016 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1017 msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
1018 String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id")
1019 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1020 msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1025 } catch (Exception ex) {
1026 ex.printStackTrace()
1027 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
1028 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1030 msoLogger.trace('Exited ' + method)
1031 } catch (BpmnError e) {
1033 } catch (Exception e) {
1034 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1035 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())