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 vfModuleName = ""
462 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
463 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
464 vfModuleName = vfModule.getVfModuleName()
466 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
467 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
468 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
469 String usePreloadToSDNC = usePreload ? "Y" : "N"
470 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
471 def modelCustomizationUuidString = ""
473 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
476 // Retrieve vnf name from AAI response
477 def vnfName = execution.getVariable('DOUPVfMod_vnfNameFromAAI')
478 execution.setVariable('DOUPVfMod_vnfName', vnfName)
480 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
481 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
483 String sdncTopologyRequest = """
484 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
485 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
486 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
487 <sdncadapter:RequestHeader>
488 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
489 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
490 <sdncadapter:SvcAction>changeassign</sdncadapter:SvcAction>
491 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
492 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
493 </sdncadapter:RequestHeader>
494 <sdncadapterworkflow:SDNCRequestData>
495 <request-information>
496 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
497 <request-action>ChangeVNFActivateRequest</request-action>
498 <source>PORTAL</source>
502 </request-information>
503 <service-information>
504 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
505 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
506 <subscriber-name>dontcare</subscriber-name>
507 </service-information>
508 <vnf-request-information>
509 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
510 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
511 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
512 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
513 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
514 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
515 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
516 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
517 ${modelCustomizationUuidString}
518 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
520 </vnf-request-information>
521 </sdncadapterworkflow:SDNCRequestData>
522 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
524 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
525 execution.setVariable('DOUPVfMod_sdncChangeAssignRequest', sdncTopologyRequest)
526 msoLogger.debug("sdncChangeAssignRequest : " + sdncTopologyRequest)
527 msoLogger.debug('Request for SDNCAdapter topology/changeassign:\n' + sdncTopologyRequest)
529 msoLogger.trace('Exited ' + method)
530 } catch (BpmnError e) {
532 } catch (Exception e) {
533 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
534 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyChg(): ' + e.getMessage())
539 * Prepare a Request for invoking the SDNC Adapter subflow to perform
540 * a VNF topology 'query' operation.
542 * @param execution The flow's execution instance.
544 public void prepSDNCTopologyQuery(DelegateExecution execution) {
545 def method = getClass().getSimpleName() + '.prepSDNCTopologyQuery(' +
546 'execution=' + execution.getId() +
549 msoLogger.trace('Entered ' + method)
552 String uuid = execution.getVariable('testReqId') // for junits
554 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
556 def requestId = execution.getVariable('DOUPVfMod_requestId')
557 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
558 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
559 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
562 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
563 svcInstId = vfModuleId
566 svcInstId = serviceInstanceId
569 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
572 String sdncTopologyRequest = """
573 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
574 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
575 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
576 <sdncadapter:RequestHeader>
577 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
578 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
579 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
580 <sdncadapter:SvcOperation>/VNF-API:vnfs/vnf-list/${vfModuleId}</sdncadapter:SvcOperation>
581 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
582 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
583 </sdncadapter:RequestHeader>
584 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
586 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
587 execution.setVariable('DOUPVfMod_sdncTopologyRequest', sdncTopologyRequest)
588 msoLogger.debug("sdncTopologyRequest : " + sdncTopologyRequest)
589 msoLogger.debug('Request for SDNCAdapter query:\n' + sdncTopologyRequest)
591 msoLogger.trace('Exited ' + method)
592 } catch (BpmnError e) {
594 } catch (Exception e) {
595 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
596 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyQuery(): ' + e.getMessage())
601 * Prepare a Request for invoking the VnfAdapterRest subflow.
603 * @param execution The flow's execution instance.
605 public void prepVnfAdapterRest(DelegateExecution execution) {
606 def method = getClass().getSimpleName() + '.prepVnfAdapterRest(' +
607 'execution=' + execution.getId() +
610 msoLogger.trace('Entered ' + method)
613 def requestId = execution.getVariable('DOUPVfMod_requestId')
614 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
615 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
616 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
617 def vfModuleName = execution.getVariable('DOUPVfMod_vfModuleName')
618 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
619 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
620 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
621 def volumeGroupStackId = execution.getVariable('DOUPVfMod_volumeGroupStackId')
623 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
624 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
625 heatStackId = vfModule.getHeatStackId()
627 def cloudId = execution.getVariable('DOUPVfMod_aicCloudRegion')
628 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
629 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
630 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
631 def baseVfModuleId = execution.getVariable("DOUPVfMod_baseVfModuleId")
632 def baseVfModuleStackId = execution.getVariable("DOUPVfMod_baseVfModuleHeatStackId")
633 def asdcServiceModelVersion = execution.getVariable('DOUPVfMod_asdcServiceModelVersion')
634 def modelCustomizationUuid = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
635 def backoutOnFailure = execution.getVariable("DOUPVfMod_backoutOnFailure")
637 def messageId = execution.getVariable('mso-request-id') + '-' + System.currentTimeMillis()
638 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
639 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
640 if ('true'.equals(useQualifiedHostName)) {
641 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
644 String environmentContext = execution.getVariable("DOUPVEnvironment_context")
645 String workloadContext = execution.getVariable("DOUPVWorkload_context")
646 msoLogger.debug("workloadContext: " + workloadContext)
647 msoLogger.debug("environmentContext: " + environmentContext)
649 Map<String, String> vnfParamsMap = execution.getVariable("DOUPVfMod_vnfParamsMap")
651 String sdncGetResponse = execution.getVariable('DOUPVfMod_sdncTopologyResponse')
653 String vfModuleParams = buildVfModuleParams(vnfParamsMap, sdncGetResponse, vnfId, vnfName,
654 vfModuleId, vfModuleName, null, environmentContext, workloadContext)
657 String vnfAdapterRestRequest = """
658 <updateVfModuleRequest>
659 <cloudSiteId>${MsoUtils.xmlEscape(cloudId)}</cloudSiteId>
660 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
661 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
662 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
663 <vfModuleStackId>${MsoUtils.xmlEscape(heatStackId)}</vfModuleStackId>
664 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
665 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
666 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
667 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
668 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
669 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
670 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
671 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
672 <skipAAI>true</skipAAI>
673 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
674 <failIfExists>false</failIfExists>
679 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
680 <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
682 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
683 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
684 </updateVfModuleRequest>
686 vnfAdapterRestRequest = utils.formatXml(vnfAdapterRestRequest)
687 execution.setVariable('DOUPVfMod_vnfAdapterRestRequest', vnfAdapterRestRequest)
688 msoLogger.debug("vnfAdapterRestRequest : " + vnfAdapterRestRequest)
689 msoLogger.debug('Request for VNFAdapter Rest:\n' + vnfAdapterRestRequest)
691 msoLogger.trace('Exited ' + method)
692 } catch (BpmnError e) {
694 } catch (Exception e) {
695 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
696 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepVnfAdapterRest(): ' + e.getMessage())
701 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
703 * @param execution The flow's execution instance.
705 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
706 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
707 'execution=' + execution.getId() +
709 msoLogger.trace('Entered ' + method)
712 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
713 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
715 def personaModelId = utils.getNodeText(vnfInputs, 'vnf-persona-model-id')
716 def personaModelVersion = utils.getNodeText(vnfInputs, 'vnf-persona-model-version')
717 if ((personaModelId == null) || (personaModelVersion == null)) {
718 msoLogger.debug("Skipping update for Generic VNF ' + vnfId + ' because either \'vnf-persona-model-id\' or \'vnf-persona-model-version\' is absent")
719 execution.setVariable('DOUPVfMod_skipUpdateGenericVnf', true)
721 def personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
722 def personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
724 String updateAAIGenericVnfRequest = """
725 <UpdateAAIGenericVnfRequest>
726 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
727 ${personaModelIdElement}
728 ${personaModelVersionElement}
729 </UpdateAAIGenericVnfRequest>
731 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
732 execution.setVariable('DOUPVfMod_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
733 msoLogger.debug("updateAAIGenericVnfRequest : " + updateAAIGenericVnfRequest)
734 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
737 msoLogger.trace('Exited ' + method)
738 } catch (BpmnError e) {
740 } catch (Exception e) {
741 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
742 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
747 * Prepare a Request for invoking the UpdateAAIVfModule subflow.
749 * @param execution The flow's execution instance.
751 public void prepUpdateAAIVfModule(DelegateExecution execution) {
752 def method = getClass().getSimpleName() + '.prepUpdateAAIVfModule(' +
753 'execution=' + execution.getId() +
756 msoLogger.trace('Entered ' + method)
759 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
760 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
761 def orchestrationStatus = 'updated'
762 def vnfInputs = execution.getVariable('DOUPVfMod_vnfInputs')
764 def volumeGroupIdElement = ''
765 def volumeGroupId = execution.getVariable('DOUPVfMod_volumeGroupId')
766 if (volumeGroupId != null) {
767 volumeGroupIdElement = '<volume-group-id>' + volumeGroupId + '</volume-group-id>'
769 def personaModelIdElement = ''
770 def personaModelId = utils.getNodeText(vnfInputs, 'persona-model-id')
771 if (personaModelId != null) {
772 personaModelIdElement = '<model-invariant-id>' + personaModelId + '</model-invariant-id>'
774 def personaModelVersionElement = ''
775 def personaModelVersion = utils.getNodeText(vnfInputs, 'persona-model-version')
776 if (personaModelVersion != null) {
777 personaModelVersionElement = '<model-version-id>' + personaModelVersion + '</model-version-id>'
779 def contrailServiceInstanceFqdnElement = ''
780 def contrailServiceInstanceFqdn = utils.getNodeText(vnfInputs, 'contrail-service-instance-fqdn')
781 if (contrailServiceInstanceFqdn != null) {
782 contrailServiceInstanceFqdnElement = '<contrail-service-instance-fqdn>' + contrailServiceInstanceFqdn + '</contrail-service-instance-fqdn>'
784 def personaModelCustomizationIdElement = ''
785 def modelCustomizationId = execution.getVariable('DOUPVfMod_modelCustomizationUuid')
786 if (modelCustomizationId != null) {
787 personaModelCustomizationIdElement = '<model-customization-id>' + modelCustomizationId + '</model-customization-id>'
790 String updateAAIVfModuleRequest = """
791 <UpdateAAIVfModuleRequest>
792 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
793 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
794 <orchestration-status>${MsoUtils.xmlEscape(orchestrationStatus)}</orchestration-status>
795 ${volumeGroupIdElement}
796 ${personaModelIdElement}
797 ${personaModelVersionElement}
798 ${contrailServiceInstanceFqdnElement}
799 ${personaModelCustomizationIdElement}
800 </UpdateAAIVfModuleRequest>
803 msoLogger.debug('Unformatted updateAAIVfModuleRequest: ' + updateAAIVfModuleRequest)
804 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
805 execution.setVariable('DOUPVfMod_updateAAIVfModuleRequest', updateAAIVfModuleRequest)
806 msoLogger.debug("updateAAIVfModuleRequest : " + updateAAIVfModuleRequest)
807 msoLogger.debug('Request for UpdateAAIVfModule:\n' + updateAAIVfModuleRequest)
809 msoLogger.trace('Exited ' + method)
810 } catch (BpmnError e) {
812 } catch (Exception e) {
813 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
814 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIVfModule(): ' + e.getMessage())
819 * Prepare a Request for invoking the SDNC Adapter subflow to perform
820 * a VNF topology 'activate' operation.
822 * @param execution The flow's execution instance.
824 public void prepSDNCTopologyAct(DelegateExecution execution) {
825 def method = getClass().getSimpleName() + '.prepSDNCTopologyAct(' +
826 'execution=' + execution.getId() +
829 msoLogger.trace('Entered ' + method)
832 String uuid = execution.getVariable('testReqId') // for junits
834 uuid = execution.getVariable("DOUPVfMod_requestId") + "-" + System.currentTimeMillis()
836 def requestId = execution.getVariable('DOUPVfMod_requestId')
837 def serviceInstanceId = execution.getVariable('DOUPVfMod_serviceInstanceId')
838 def callbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
839 def serviceId = execution.getVariable('DOUPVfMod_serviceId')
840 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
841 def vnfName = execution.getVariable('DOUPVfMod_vnfName')
842 def vnfType = execution.getVariable('DOUPVfMod_vnfType')
843 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
844 def vfModuleModelName = execution.getVariable('DOUPVfMod_vfModuleModelName')
845 def vfModuleName = ""
846 if (execution.getVariable('DOUPVfMod_vfModule') != null) {
847 org.onap.aai.domain.yang.VfModule vfModule = execution.getVariable('DOUPVfMod_vfModule')
848 vfModuleName = vfModule.getVfModuleName()
850 def tenantId = execution.getVariable('DOUPVfMod_tenantId')
851 def aicCloudRegion = execution.getVariable('DOUPVfMod_aicCloudRegion')
853 boolean usePreload = execution.getVariable("DOUPVfMod_usePreload")
854 String usePreloadToSDNC = usePreload ? "Y" : "N"
855 def modelCustomizationUuid = execution.getVariable("DoUPVfMod_modelCustomizationUuid")
856 def modelCustomizationUuidString = ""
858 modelCustomizationUuidString = "<modelCustomizationUuid>" + modelCustomizationUuid + "</modelCustomizationUuid>"
861 def vnfParamsXml = execution.getVariable('DOUPVfMod_vnfParams')
862 def vnfNetworks = transformNetworkParamsToVnfNetworks(vnfParamsXml)
864 String sdncTopologyRequest = """
865 <sdncadapterworkflow:SDNCAdapterWorkflowRequest
866 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
867 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
868 <sdncadapter:RequestHeader>
869 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
870 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</sdncadapter:SvcInstanceId>
871 <sdncadapter:SvcAction>activate</sdncadapter:SvcAction>
872 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
873 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
874 </sdncadapter:RequestHeader>
875 <sdncadapterworkflow:SDNCRequestData>
876 <request-information>
877 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
878 <request-action>ChangeVNFActivateRequest</request-action>
879 <source>PORTAL</source>
883 </request-information>
884 <service-information>
885 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
886 <service-instance-id>${MsoUtils.xmlEscape(vnfId)}</service-instance-id>
887 <subscriber-name>dontcare</subscriber-name>
888 </service-information>
889 <vnf-request-information>
890 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
891 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
892 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
893 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
894 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
895 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
896 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
897 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
898 ${modelCustomizationUuidString}
899 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
900 </vnf-request-information>
901 </sdncadapterworkflow:SDNCRequestData>
902 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>
904 sdncTopologyRequest = utils.formatXml(sdncTopologyRequest)
905 execution.setVariable('DOUPVfMod_sdncActivateRequest', sdncTopologyRequest)
906 msoLogger.debug("sdncActivateRequest : " + sdncTopologyRequest)
907 msoLogger.debug('Request for SDNCAdapter topology/activate:\n' + sdncTopologyRequest)
910 msoLogger.trace('Exited ' + method)
911 } catch (BpmnError e) {
913 } catch (Exception e) {
914 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
915 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepSDNCTopologyAct(): ' + e.getMessage())
920 * Log a WorkflowException that has been created.
922 * @param execution The flow's execution instance.
924 public void handleWorkflowException(DelegateExecution execution) {
925 def method = getClass().getSimpleName() + '.handleWorkflowException(' +
926 'execution=' + execution.getId() +
929 msoLogger.trace('Entered ' + method)
932 def WorkflowException workflowException = (WorkflowException) execution.getVariable('WorkflowException')
933 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, method + ' caught WorkflowException: ' + workflowException.getErrorMessage(), "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "");
935 msoLogger.trace('Exited ' + method)
936 } catch (BpmnError e) {
938 } catch (Exception e) {
939 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
940 exceptionUtil.buildWorkflowException(execution, 1002, 'Error in handleWorkflowException(): ' + e.getMessage())
944 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
946 def prefix = execution.getVariable("prefix")
948 msoLogger.trace("STARTED ValidateSDNCResponse Process")
950 WorkflowException workflowException = execution.getVariable("WorkflowException")
951 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
953 msoLogger.debug("workflowException: " + workflowException)
955 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
956 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
958 msoLogger.debug("SDNCResponse: " + response)
960 String sdncResponse = response
961 if(execution.getVariable(prefix + 'sdncResponseSuccess') == true){
962 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
964 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
965 throw new BpmnError("MSOWorkflowException")
967 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
971 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
972 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
974 * @param execution The flow's execution instance.
976 public void queryAAIVfModule(DelegateExecution execution) {
978 def method = getClass().getSimpleName() + '.getVfModule(' +
979 'execution=' + execution.getId() +
981 msoLogger.trace('Entered ' + method)
984 def vnfId = execution.getVariable('DOUPVfMod_vnfId')
985 def vfModuleId = execution.getVariable('DOUPVfMod_vfModuleId')
987 AaiUtil aaiUriUtil = new AaiUtil(this)
989 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE)
990 String endPoint = aaiUriUtil.createAaiUri(uri)
992 msoLogger.debug("AAI endPoint: " + endPoint)
995 def aaiRequestId = UUID.randomUUID().toString()
996 msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
997 APIResponse response = aaiUriUtil.executeAAIGetCall(execution, endPoint)
998 msoLogger.debug("createVfModule - invoking httpGet() to AAI")
1000 def responseData = response.getResponseBodyAsString()
1001 if (responseData != null) {
1002 msoLogger.debug("Received generic VNF data: " + responseData)
1006 msoLogger.debug("createVfModule - queryAAIVfModule Response: " + responseData)
1007 msoLogger.debug("createVfModule - queryAAIVfModule ResponseCode: " + response.getStatusCode())
1009 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponseCode', response.getStatusCode())
1010 execution.setVariable('DOUPVfMod_queryAAIVfModuleResponse', responseData)
1011 msoLogger.debug('Response code:' + response.getStatusCode())
1012 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
1013 if (response.getStatusCode() == 200) {
1014 // Parse the VNF record from A&AI to find base module info
1015 msoLogger.debug('Parsing the VNF data to find base module info')
1016 if (responseData != null) {
1017 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
1018 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
1019 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
1020 int vfModulesSize = 0
1021 for (i in 0..vfModules.size()-1) {
1022 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
1023 def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
1025 if (isBaseVfModule == "true") {
1026 String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
1027 execution.setVariable("DOUPVfMod_baseVfModuleId", baseModuleId)
1028 msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
1029 String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id")
1030 execution.setVariable("DOUPVfMod_baseVfModuleHeatStackId", baseModuleHeatStackId)
1031 msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
1036 } catch (Exception ex) {
1037 ex.printStackTrace()
1038 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
1039 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
1041 msoLogger.trace('Exited ' + method)
1042 } catch (BpmnError e) {
1044 } catch (Exception e) {
1045 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1046 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())