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.graphinventory.entities.uri.Depth
37 import org.onap.so.client.aai.AAIObjectType;
38 import org.onap.so.client.aai.AAIResourcesClient
39 import org.onap.so.client.aai.entities.AAIResultWrapper
40 import org.onap.so.client.aai.entities.uri.AAIResourceUri
41 import org.onap.so.client.aai.entities.uri.AAIUri
42 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
43 import org.onap.so.client.aai.entities.uri.AAIResourceUri
44 import org.onap.so.constants.Defaults
45 import org.onap.so.logger.MessageEnum
46 import org.onap.so.logger.MsoLogger
47 import org.onap.so.rest.APIResponse
48 import org.springframework.web.util.UriUtils
50 public class DoUpdateVfModule extends VfModuleBase {
51 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoUpdateVfModule.class);
53 ExceptionUtil exceptionUtil = new ExceptionUtil()
54 JsonUtils jsonUtil = new JsonUtils()
55 CatalogDbUtils catalog = new CatalogDbUtils()
58 * Initialize the flow's variables.
60 * @param execution The flow's execution instance.
62 public void initProcessVariables(DelegateExecution execution) {
63 execution.setVariable('prefix', 'DOUPVfMod_')
64 execution.setVariable('DOUPVfMod_requestInfo', null)
65 execution.setVariable('DOUPVfMod_serviceInstanceId', null)
66 execution.setVariable('DOUPVfMod_requestId', null)
67 execution.setVariable('DOUPVfMod_vnfInputs', null)
68 execution.setVariable('DOUPVfMod_vnfId', null)
69 execution.setVariable('DOUPVfMod_vnfName', null)
70 execution.setVariable('DOUPVfMod_vnfNameFromAAI', null)
71 execution.setVariable('DOUPVfMod_vfModuleName', null)
72 execution.setVariable('DOUPVfMod_vfModuleId', null)
73 execution.setVariable('DOUPVfMod_vnfType', null)
74 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', null)
75 execution.setVariable('DOUPVfMod_vfModuleModelName', null)
76 execution.setVariable('DOUPVfMod_modelCustomizationUuid', null)
77 execution.setVariable("DOUPVfMod_isBaseVfModule", "false")
78 execution.setVariable('DOUPVfMod_serviceId', null)
79 execution.setVariable('DOUPVfMod_aicCloudRegion', null)
80 execution.setVariable('DOUPVfMod_tenantId', null)
81 execution.setVariable('DOUPVfMod_volumeGroupId', null)
82 execution.setVariable("DOUPVfMod_volumeGroupStackId", "")
83 execution.setVariable('DOUPVfMod_vfModule', null)
84 execution.setVariable('DOUPVfMod_vnfParams', null)
85 execution.setVariable("DOUPVfMod_baseVfModuleId", "")
86 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", "")
87 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', null)
88 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', null)
89 execution.setVariable('DOUPVfMod_sdncChangeAssignResponse', null)
90 execution.setVariable('DOUPVfMod_sdncActivateRequest', null)
91 execution.setVariable('DOUPVfMod_sdncActivateResponse', null)
92 execution.setVariable('DOUPVfMod_sdncTopologyRequest', null)
93 execution.setVariable('DOUPVfMod_sdncTopologyResponse', null)
94 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', null)
95 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', null)
96 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', null)
97 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', false)
98 execution.setVariable('DoUpdateVfModuleSuccessIndicator', false)
102 * Check for missing elements in the received request.
104 * @param execution The flow's execution instance.
106 public void preProcessRequest(DelegateExecution execution) {
107 def method = getClass().getSimpleName() + '.preProcessRequest(' +
108 'execution=' + execution.getId() +
111 msoLogger.trace('Entered ' + method)
114 initProcessVariables(execution)
115 def xml = getVariable(execution, 'DoUpdateVfModuleRequest')
116 msoLogger.debug("DoUpdateVfModule request: " + xml)
117 msoLogger.debug('Received request xml:\n' + xml)
119 if (xml == null || xml.isEmpty()) {
120 // Building Block-type request
122 String cloudConfiguration = execution.getVariable("cloudConfiguration")
123 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
125 def serviceModelInfo = execution.getVariable("serviceModelInfo")
126 msoLogger.debug("serviceModelInfo: " + serviceModelInfo)
127 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
128 msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid)
129 def vnfModelInfo = execution.getVariable("vnfModelInfo")
132 def tenantId = execution.getVariable("tenantId")
133 execution.setVariable("DOUPVfMod_tenantId", tenantId)
136 def volumeGroupId = execution.getVariable("volumeGroupId")
137 execution.setVariable("DOUPVfMod_volumeGroupId", volumeGroupId)
140 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
141 execution.setVariable("DOUPVfMod_aicCloudRegion", cloudSiteId)
143 msoLogger.debug("cloudSiteId: " + cloudSiteId)
145 def vnfType = execution.getVariable("vnfType")
146 execution.setVariable("DOUPVfMod_vnfType", vnfType)
148 msoLogger.debug("vnfType: " + vnfType)
150 def vnfName = execution.getVariable("vnfName")
151 execution.setVariable("DOUPVfMod_vnfName", vnfName)
153 msoLogger.debug("vnfName: " + vnfName)
155 def vnfId = execution.getVariable("vnfId")
156 execution.setVariable("DOUPVfMod_vnfId", vnfId)
158 msoLogger.debug("vnfId: " + vnfId)
160 def vfModuleName = execution.getVariable("vfModuleName")
161 execution.setVariable("DOUPVfMod_vfModuleName", vfModuleName)
163 msoLogger.debug("vfModuleName: " + vfModuleName)
165 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
166 execution.setVariable("DOUPVfMod_vfModuleModelName", vfModuleModelName)
168 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
169 //modelCustomizationUuid
170 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
171 if (modelCustomizationUuid == null) {
172 modelCustomizationUuid = ""
174 execution.setVariable("DOUPVfMod_modelCustomizationUuid", modelCustomizationUuid)
176 msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
178 def vfModuleId = execution.getVariable("vfModuleId")
179 execution.setVariable("DOUPVfMod_vfModuleId", vfModuleId)
180 msoLogger.debug("vfModuleId: " + vfModuleId)
181 def requestId = execution.getVariable("msoRequestId")
182 execution.setVariable("DOUPVfMod_requestId", requestId)
183 msoLogger.debug("requestId: " + requestId)
184 // Set mso-request-id to request-id for VNF Adapter interface
185 execution.setVariable("mso-request-id", requestId)
187 def serviceId = execution.getVariable("serviceId")
188 execution.setVariable("DOUPVfMod_serviceId", serviceId)
189 msoLogger.debug("serviceId: " + serviceId)
191 def serviceInstanceId = execution.getVariable("serviceInstanceId")
192 execution.setVariable("DOUPVfMod_serviceInstanceId", serviceInstanceId)
194 msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
197 execution.setVariable("DOUPVfMod_source", source)
199 msoLogger.debug("source: " + source)
201 def disableRollback = execution.getVariable("disableRollback")
202 def backoutOnFailure = true
203 if (disableRollback != null && disableRollback.equals("true")) {
204 backoutOnFailure = false
206 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
207 msoLogger.debug("backoutOnFailure: " + backoutOnFailure)
209 def isBaseVfModule = execution.getVariable("isBaseVfModule")
210 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
211 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
212 //asdcServiceModelVersion
213 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
214 execution.setVariable("DOUPVfMod_asdcServiceModelVersion", asdcServiceModelVersion)
215 msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
217 execution.setVariable("DOUPVfMod_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
218 //personaModelVersion
219 execution.setVariable("DOUPVfMod_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelVersion"))
220 //Get or Generate UUID
221 String uuid = execution.getVariable("DOUPVfMod_uuid")
223 uuid = UUID.randomUUID()
224 msoLogger.debug("Generated messageId (UUID) is: " + uuid)
226 msoLogger.debug("Found messageId (UUID) is: " + uuid)
229 String isVidRequest = execution.getVariable("isVidRequest")
231 if (isVidRequest == null || isVidRequest.isEmpty()) {
232 execution.setVariable("isVidRequest", "true")
235 def usePreload = execution.getVariable("usePreload")
236 execution.setVariable("DOUPVfMod_usePreload", usePreload)
237 msoLogger.debug("usePreload: " + usePreload)
239 String globalSubscriberId = execution.getVariable("globalSubscriberId")
240 execution.setVariable("DOUPVfMod_globalSubscriberId", globalSubscriberId)
241 msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
243 String vnfQueryPath = execution.getVariable("vnfQueryPath")
244 execution.setVariable("DOUPVfMod_vnfQueryPath", vnfQueryPath)
245 msoLogger.debug("vnfQueryPath: " + vnfQueryPath)
247 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
248 if (vfModuleInputParams != null) {
249 execution.setVariable("DOUPVfMod_vnfParamsMap", vfModuleInputParams)
251 //get workload and environment context from parent SI
252 String environmentContext = ""
253 String workloadContext =""
254 String serviceType =""
257 String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
258 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
261 } catch (Exception ex){
262 String msg = "Exception in preProcessRequest " + ex.getMessage()
264 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
268 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
269 AAIResourcesClient aaiRC = new AAIResourcesClient()
270 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
271 Map<String, Object> aaiJson = aaiRW.asMap()
272 environmentContext = aaiJson.getOrDefault("environment-context","")
273 workloadContext = aaiJson.getOrDefault("workload-context","")
275 }catch (Exception ex) {
276 msoLogger.debug("Error retreiving parent service instance information")
279 execution.setVariable("DCVFM_environmentContext",environmentContext)
280 execution.setVariable("DCVFM_workloadContext",workloadContext)
284 def requestInfo = getRequiredNodeXml(execution, xml, 'request-info')
285 execution.setVariable('DOUPVfMod_requestInfo', requestInfo)
286 execution.setVariable('DOUPVfMod_requestId', getRequiredNodeText(execution, requestInfo, 'request-id'))
287 def serviceInstanceId = execution.getVariable('mso-service-instance-id')
288 if (serviceInstanceId == null) {
289 serviceInstanceId = ''
291 execution.setVariable('DOUPVfMod_serviceInstanceId', serviceInstanceId)
293 def vnfInputs = getRequiredNodeXml(execution, xml, 'vnf-inputs')
294 execution.setVariable('DOUPVfMod_vnfInputs', vnfInputs)
295 execution.setVariable('DOUPVfMod_vnfId', getRequiredNodeText(execution, vnfInputs, 'vnf-id'))
296 execution.setVariable('DOUPVfMod_vfModuleId', getRequiredNodeText(execution, vnfInputs, 'vf-module-id'))
297 execution.setVariable('DOUPVfMod_vfModuleName', getNodeTextForce(vnfInputs, 'vf-module-name'))
298 execution.setVariable('DOUPVfMod_vnfType', getNodeTextForce(vnfInputs, 'vnf-type'))
299 execution.setVariable('DOUPVfMod_vnfName', getNodeTextForce(vnfInputs, 'vnf-name'))
300 execution.setVariable('DOUPVfMod_asdcServiceModelVersion', getNodeTextForce(vnfInputs, 'asdc-service-model-version'))
301 execution.setVariable('DOUPVfMod_vfModuleModelName', getRequiredNodeText(execution, vnfInputs, 'vf-module-model-name'))
302 execution.setVariable('DOUPVfMod_modelCustomizationUuid', getNodeTextForce(vnfInputs, 'model-customization-id'))
303 execution.setVariable('DOUPVfMod_serviceId', getRequiredNodeText(execution, vnfInputs, 'service-id'))
304 execution.setVariable('DOUPVfMod_aicCloudRegion', getRequiredNodeText(execution, vnfInputs, 'aic-cloud-region'))
305 execution.setVariable('DOUPVfMod_tenantId', getRequiredNodeText(execution, vnfInputs, 'tenant-id'))
307 def isBaseVfModule = "false"
308 if (utils.nodeExists(xml, "is-base-vf-module")) {
309 isBaseVfModule = utils.getNodeText(xml, "is-base-vf-module")
310 execution.setVariable("DOUPVfMod_isBaseVfModule", isBaseVfModule)
312 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
314 NetworkUtils networkUtils = new NetworkUtils()
315 def backoutOnFailure = networkUtils.isRollbackEnabled(execution, xml)
316 execution.setVariable("DOUPVfMod_backoutOnFailure", backoutOnFailure)
318 def String vgi = getNodeTextForce(vnfInputs, 'volume-group-id')
319 execution.setVariable('DOUPVfMod_volumeGroupId', vgi)
321 execution.setVariable('DOUPVfMod_vnfParams', utils.getNodeXml(xml, 'vnf-params', false))
324 def sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
325 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
326 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
327 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
328 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
331 msoLogger.trace('Exited ' + method)
332 } catch (BpmnError e) {
334 } catch (Exception e) {
335 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
336 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preProcessRequest(): ' + e.getMessage())
341 * Prepare a Request for invoking the PrepareUpdateAAIVfModule subflow. This will
342 * set the orchestration-status to 'pending-update'.
344 * @param execution The flow's execution instance.
346 public void prepPrepareUpdateAAIVfModule(DelegateExecution execution) {
347 def method = getClass().getSimpleName() + '.preparePrepareUpdateAAIVfModule(' +
348 'execution=' + execution.getId() +
351 msoLogger.trace('Entered ' + method)
354 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
355 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
356 def orchestrationStatus = 'pending-update'
358 String prepareUpdateAAIVfModuleRequest = """
359 <PrepareUpdateAAIVfModuleRequest>
360 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
361 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
362 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
363 </PrepareUpdateAAIVfModuleRequest>
365 prepareUpdateAAIVfModuleRequest = utils.formatXml(prepareUpdateAAIVfModuleRequest)
366 execution.setVariable('DOUPVfMod_prepareUpdateAAIVfModuleRequest', prepareUpdateAAIVfModuleRequest)
367 msoLogger.debug("DoUpdateAAIVfModule request: " + prepareUpdateAAIVfModuleRequest)
368 msoLogger.debug('Request for PrepareUpdateAAIVfModule:\n' + prepareUpdateAAIVfModuleRequest)
370 msoLogger.trace('Exited ' + method)
371 } catch (BpmnError e) {
373 } catch (Exception e) {
374 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
375 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in preparePrepareUpdateAAIVfModule(): ' + e.getMessage())
380 * Prepare a Request for invoking the ConfirmVolumeGroupTenant subflow.
381 * Determine cloud region id for the volume group.
383 * @param execution The flow's execution instance.
385 public void prepConfirmVolumeGroupTenant(DelegateExecution execution) {
386 def method = getClass().getSimpleName() + '.prepConfirmVolumeGroupTenant(' +
387 'execution=' + execution.getId() +
390 def prefix = execution.getVariable("prefix")
392 msoLogger.trace('Entered ' + method)
395 String cloudRegion = execution.getVariable(prefix + "aicCloudRegion")
398 AaiUtil aaiUtil = new AaiUtil(this)
400 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, Defaults.CLOUD_OWNER.toString(), cloudRegion)
401 def queryCloudRegionRequest = aaiUtil.createAaiUri(uri)
403 execution.setVariable(prefix + "queryCloudRegionRequest", queryCloudRegionRequest)
405 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "AAI", cloudRegion)
407 if ((cloudRegion != "ERROR")) {
408 if(execution.getVariable(prefix + "queryCloudRegionReturnCode") == "404"){
409 execution.setVariable(prefix + "cloudRegionForVolume", "AAIAIC25")
411 execution.setVariable(prefix + "cloudRegionForVolume", cloudRegion)
413 execution.setVariable(prefix + "isCloudRegionGood", true)
415 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable(prefix + "queryCloudRegionReturnCode")
416 msoLogger.debug(errorMessage)
417 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
418 execution.setVariable(prefix + "isCloudRegionGood", false)
420 msoLogger.debug(" is Cloud Region Good: " + execution.getVariable(prefix + "isCloudRegionGood"))
422 } catch(BpmnError b){
423 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + b);
425 }catch (Exception e) {
427 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + e.getMessage()
428 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);
429 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during prepConfirmVolumeGroupTenant(): " + e.getMessage())
431 msoLogger.trace('Exited ' + method)
436 * Prepare a Request for invoking the SDNC Adapter subflow to perform
437 * a VNF topology 'changeassign' operation.
439 * @param execution The flow's execution instance.
441 public void prepSDNCTopologyChg(DelegateExecution execution) {
442 def method = getClass().getSimpleName() + '.prepSDNCTopologyChg(' +
443 'execution=' + execution.getId() +
446 msoLogger.trace('Entered ' + method)
449 def requestId = execution.getVariable('DOUPVfMod_requestId')
450 String uuid = execution.getVariable('testReqId') // for junits
452 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
454 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
455 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
456 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
457 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
458 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
459 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
460 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
461 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
462 def vfModuleName = vfModule.getElementText('vf-module-name')
463 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
464 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
465 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
466 String usePreloadToSDNC = usePreload ? "Y" : "N"
467 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
468 def modelCustomizationUuidString = ""
470 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
473 // Retrieve vnf name from AAI response
474 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
475 execution.setVariable('DOUPVfMod_vnfName', vnfName)
477 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
478 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
480 String sdncTopologyRequest = """
481 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
482 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
483 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
484 <sdncadapter:RequestHeader>
485 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
486 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
487 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
488 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
489 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
490 </sdncadapter:RequestHeader>
491 <sdncadapterworkflow:SDNCRequestData>
492 <request-information>
493 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
494 <request-action>ChangeVNFActivateRequest</request-action>
495 <source>PORTAL</source>
499 </request-information>
500 <service-information>
501 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
502 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
503 <subscriber-name>dontcare</subscriber-name>
504 </service-information>
505 <vnf-request-information>
506 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
507 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
508 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
509 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
510 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
511 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
512 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
513 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
514 ${modelCustomizationUuidString}
515 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
517 </vnf-request-information>
518 </sdncadapterworkflow:SDNCRequestData>
519 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
521 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
522 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
523 msoLogger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
524 msoLogger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
526 msoLogger.trace('Exited ' + method)
527 } catch (BpmnError e) {
529 } catch (Exception e) {
530 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
531 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
536 * Prepare a Request for invoking the SDNC Adapter subflow to perform
537 * a VNF topology 'query' operation.
539 * @param execution The flow's execution instance.
541 public void prepSDNCTopologyQuery(DelegateExecution execution) {
542 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
543 'execution=' + execution.getId() +
546 msoLogger.trace('Entered ' + method)
549 String uuid = execution.getVariable('testReqId') // for junits
551 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
553 def requestId = execution.getVariable('DOUPVfMod_requestId')
554 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
555 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
556 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
559 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
560 svcInstId = vfModuleId
563 svcInstId = serviceInstanceId
566 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
569 String sdncTopologyRequest = """
570 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
571 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
572 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
573 <sdncadapter:RequestHeader>
574 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
575 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
576 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
577 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
578 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
579 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
580 </sdncadapter:RequestHeader>
581 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
583 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
584 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
585 msoLogger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
586 msoLogger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
588 msoLogger.trace('Exited ' + method)
589 } catch (BpmnError e) {
591 } catch (Exception e) {
592 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
593 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
598 * Prepare a Request for invoking the VnfAdapterRest subflow.
600 * @param execution The flow's execution instance.
602 public void prepVnfAdapterRest(DelegateExecution execution) {
603 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
604 'execution=' + execution.getId() +
607 msoLogger.trace('Entered ' + method)
610 def requestId = execution.getVariable('DOUPVfMod_requestId')
611 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
612 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
613 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
614 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
615 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
616 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
617 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
618 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
619 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
620 def heatStackId = vfModule.getElementText('heat-stack-id')
621 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
622 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
623 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
624 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
625 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
626 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
627 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
628 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
629 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
631 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
632 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
633 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
634 if ('true'.equals(useQualifiedHostName)) {
635 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
638 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
639 String workloadContext = execution.getVariable("DOUPVWorkload_context")
640 msoLogger.debug("workloadContext: " + workloadContext)
641 msoLogger.debug("environmentContext: " + environmentContext)
643 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
645 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
647 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
648 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
651 String vnfAdapterRestRequest = """
652 <updateVfModuleRequest>
653 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
654 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
655 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
656 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
657 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
658 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
659 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
660 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
661 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
662 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
663 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
664 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
665 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
666 <skipAAI>true</skipAAI>
667 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
668 <failIfExists>false</failIfExists>
673 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
674 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
676 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
677 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
678 </updateVfModuleRequest>
680 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
681 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
682 msoLogger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
683 msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
685 msoLogger.trace('Exited ' + method)
686 } catch (BpmnError e) {
688 } catch (Exception e) {
689 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
690 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
695 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
697 * @param execution The flow's execution instance.
699 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
700 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
701 'execution=' + execution.getId() +
703 msoLogger.trace('Entered ' + method)
706 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
707 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
709 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
710 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
711 if ((personaModelId == null) || (personaModelVersion == null)) {
712 msoLogger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
713 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
715 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
716 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
718 String updateAAIGenericVnfRequest = """
719 <UpdateAAIGenericVnfRequest>
720 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
721 ${personaModelIdElement}
722 ${personaModelVersionElement}
723 </UpdateAAIGenericVnfRequest>
725 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
726 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
727 msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
728 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
731 msoLogger.trace('Exited ' + method)
732 } catch (BpmnError e) {
734 } catch (Exception e) {
735 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
736 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
741 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
743 * @param execution The flow's execution instance.
745 public void prepUpdateAAIVfModule(DelegateExecution execution) {
746 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
747 'execution=' + execution.getId() +
750 msoLogger.trace('Entered ' + method)
753 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
754 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
755 def orchestrationStatus = 'updated'
756 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
758 def volumeGroupIdElement = ''
759 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
760 if (volumeGroupId != null) {
761 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
763 def personaModelIdElement = ''
764 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
765 if (personaModelId != null) {
766 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
768 def personaModelVersionElement = ''
769 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
770 if (personaModelVersion != null) {
771 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
773 def contrailServiceInstanceFqdnElement = ''
774 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
775 if (contrailServiceInstanceFqdn != null) {
776 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
778 def personaModelCustomizationIdElement = ''
779 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
780 if (modelCustomizationId != null) {
781 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
784 String updateAAIVfModuleRequest = """
785 <UpdateAAIVfModuleRequest>
786 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
787 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
788 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
789 ${volumeGroupIdElement}
790 ${personaModelIdElement}
791 ${personaModelVersionElement}
792 ${contrailServiceInstanceFqdnElement}
793 ${personaModelCustomizationIdElement}
794 </UpdateAAIVfModuleRequest>
797 msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
798 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
799 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
800 msoLogger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
801 msoLogger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
803 msoLogger.trace('Exited ' + method)
804 } catch (BpmnError e) {
806 } catch (Exception e) {
807 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
808 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
813 * Prepare a Request for invoking the SDNC Adapter subflow to perform
814 * a VNF topology 'activate' operation.
816 * @param execution The flow's execution instance.
818 public void prepSDNCTopologyAct(DelegateExecution execution) {
819 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
820 'execution=' + execution.getId() +
823 msoLogger.trace('Entered ' + method)
826 String uuid = execution.getVariable('testReqId') // for junits
828 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
830 def requestId = execution.getVariable('DOUPVfMod_requestId')
831 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
832 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
833 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
834 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
835 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
836 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
837 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
838 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
839 def VfModule vfModule = (VfModule) execution.getVariable('DOUPVfMod_vfModule')
840 def vfModuleName = vfModule.getElementText('vf-module-name')
841 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
842 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
844 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
845 String usePreloadToSDNC = usePreload ? "Y" : "N"
846 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
847 def modelCustomizationUuidString = ""
849 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
852 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
853 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
855 String sdncTopologyRequest = """
856 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
857 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
858 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
859 <sdncadapter:RequestHeader>
860 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
861 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
862 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
863 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
864 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
865 </sdncadapter:RequestHeader>
866 <sdncadapterworkflow:SDNCRequestData>
867 <request-information>
868 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
869 <request-action>ChangeVNFActivateRequest</request-action>
870 <source>PORTAL</source>
874 </request-information>
875 <service-information>
876 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
877 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
878 <subscriber-name>dontcare</subscriber-name>
879 </service-information>
880 <vnf-request-information>
881 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
882 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
883 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
884 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
885 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
886 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
887 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
888 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
889 ${modelCustomizationUuidString}
890 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
891 </vnf-request-information>
892 </sdncadapterworkflow:SDNCRequestData>
893 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
895 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
896 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
897 msoLogger.debug("sdncActivateRequest : " + sdncTopologyRequest)
898 msoLogger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
901 msoLogger.trace('Exited ' + method)
902 } catch (BpmnError e) {
904 } catch (Exception e) {
905 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
906 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
911 * Log a WorkflowException that has been created.
913 * @param execution The flow's execution instance.
915 public void handleWorkflowException(DelegateExecution execution) {
916 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
917 'execution=' + execution.getId() +
920 msoLogger.trace('Entered ' + method)
923 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
924 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
926 msoLogger.trace('Exited ' + method)
927 } catch (BpmnError e) {
929 } catch (Exception e) {
930 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
931 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
935 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
937 def prefix = execution.getVariable("prefix")
939 msoLogger.trace("STARTED ValidateSDNCResponse Process")
941 WorkflowException workflowException = execution.getVariable("WorkflowException")
942 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
944 msoLogger.debug("workflowException: " + workflowException)
946 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
947 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
949 msoLogger.debug("SDNCResponse: " + response)
951 String sdncResponse = response
952 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
953 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
955 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
956 throw new BpmnError("MSOWorkflowException")
958 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
962 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
963 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
965 * @param execution The flow's execution instance.
967 public void queryAAIVfModule(DelegateExecution execution) {
969 def method = getClass().getSimpleName() + '.getVfModule(' +
970 'execution=' + execution.getId() +
972 msoLogger.trace('Entered ' + method)
975 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
976 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
978 AaiUtil aaiUriUtil = new AaiUtil(this)
980 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
981 String endPoint = aaiUriUtil.createAaiUri(uri)
983 msoLogger.debug("AAI endPoint: " + endPoint)
986 def aaiRequestId = UUID.randomUUID().toString()
987 msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
988 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
989 msoLogger.debug("createVfModule - invoking httpGet() to AAI")
991 def responseData = response.getResponseBodyAsString()
992 if (responseData != null) {
993 msoLogger.debug("Received generic VNF data: " + responseData)
997 msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData)
998 msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
1000 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
1001 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
1002 msoLogger.debug('Response code:' + response.getStatusCode())
1003 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
1004 if (response.getStatusCode() == 200) {
1005 // Parse the VNF record from A&AI to find base module info
1006 msoLogger.debug('Parsing the VNF data to find base module info')
1007 if (responseData != null) {
1008 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
1009 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
1010 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
1011 int vfModulesSize = 0
1012 for (i in 0..vfModules.size()-1) {
1013 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
1014 def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
1016 if (isBaseVfModule == "true") {
1017 String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
1018 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1019 msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
1020 String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id")
1021 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1022 msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1027 } catch (Exception ex) {
1028 ex.printStackTrace()
1029 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
1030 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1032 msoLogger.trace('Exited ' + method)
1033 } catch (BpmnError e) {
1035 } catch (Exception e) {
1036 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1037 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())