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 javax.xml.parsers.DocumentBuilder
24 import javax.xml.parsers.DocumentBuilderFactory
26 import org.camunda.bpm.engine.delegate.BpmnError
27 import org.camunda.bpm.engine.delegate.DelegateExecution
28 import org.json.JSONArray
29 import org.json.JSONObject
30 import org.onap.so.bpmn.common.scripts.AaiUtil
31 import org.onap.so.bpmn.common.scripts.CatalogDbUtils
32 import org.onap.so.bpmn.common.scripts.ExceptionUtil
33 import org.onap.so.bpmn.common.scripts.MsoUtils
34 import org.onap.so.bpmn.common.scripts.NetworkUtils
35 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
36 import org.onap.so.bpmn.common.scripts.VfModuleBase
37 import org.onap.so.bpmn.core.RollbackData
38 import org.onap.so.bpmn.core.UrnPropertiesReader
39 import org.onap.so.bpmn.core.WorkflowException
41 import org.onap.so.bpmn.core.domain.VnfResource
42 import org.onap.so.bpmn.core.json.DecomposeJsonUtil
43 import org.onap.so.bpmn.core.json.JsonUtils
44 import org.onap.so.client.aai.AAIObjectType;
45 import org.onap.so.client.aai.AAIResourcesClient
46 import org.onap.so.client.aai.entities.AAIResultWrapper
47 import org.onap.so.client.aai.entities.uri.AAIUri
48 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
49 import org.onap.so.logger.MessageEnum
50 import org.onap.so.logger.MsoLogger
51 import org.onap.so.rest.APIResponse
52 import org.onap.so.rest.RESTClient
53 import org.onap.so.rest.RESTConfig
54 import org.springframework.web.util.UriUtils
55 import org.w3c.dom.Document
56 import org.w3c.dom.Element
57 import org.w3c.dom.NamedNodeMap
58 import org.w3c.dom.Node
59 import org.w3c.dom.NodeList
60 import org.xml.sax.InputSource
62 import com.fasterxml.jackson.databind.ObjectMapper
66 public class DoCreateVfModule extends VfModuleBase {
67 private static final MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, DoCreateVfModule.class);
69 String Prefix="DCVFM_"
70 ExceptionUtil exceptionUtil = new ExceptionUtil()
71 JsonUtils jsonUtil = new JsonUtils()
72 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
73 CatalogDbUtils catalog = new CatalogDbUtils()
74 DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil()
77 * Validates the request message and sets up the workflow.
78 * @param execution the execution
80 public void preProcessRequest(DelegateExecution execution) {
81 def method = getClass().getSimpleName() + '.preProcessRequest(' +
82 'execution=' + execution.getId() +
85 msoLogger.trace('Entered ' + method)
87 execution.setVariable('prefix', Prefix)
89 def rollbackData = execution.getVariable("rollbackData")
90 if (rollbackData == null) {
91 rollbackData = new RollbackData()
94 execution.setVariable("DCVFM_vnfParamsExistFlag", false)
95 execution.setVariable("DCVFM_oamManagementV4Address", "")
96 execution.setVariable("DCVFM_oamManagementV6Address", "")
98 String request = execution.getVariable("DoCreateVfModuleRequest")
100 if (request == null || request.isEmpty()) {
101 // Building Block-type request
103 String vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
105 def serviceModelInfo = execution.getVariable("serviceModelInfo")
106 msoLogger.debug("serviceModelInfo: " + serviceModelInfo)
107 String modelInvariantUuid = jsonUtil.getJsonValue(serviceModelInfo, "modelInvariantUuid")
108 msoLogger.debug("modelInvariantUuid: " + modelInvariantUuid)
110 def vnfModelInfo = execution.getVariable("vnfModelInfo")
113 def tenantId = execution.getVariable("tenantId")
114 execution.setVariable("DCVFM_tenantId", tenantId)
115 rollbackData.put("VFMODULE", "tenantid", tenantId)
117 def volumeGroupId = execution.getVariable("volumeGroupId")
118 execution.setVariable("DCVFM_volumeGroupId", volumeGroupId)
120 def volumeGroupName = execution.getVariable("volumeGroupName")
121 execution.setVariable("DCVFM_volumeGroupName", volumeGroupName)
123 def cloudSiteId = execution.getVariable("lcpCloudRegionId")
124 execution.setVariable("DCVFM_cloudSiteId", cloudSiteId)
125 rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId)
126 msoLogger.debug("cloudSiteId: " + cloudSiteId)
128 def vnfType = execution.getVariable("vnfType")
129 execution.setVariable("DCVFM_vnfType", vnfType)
130 rollbackData.put("VFMODULE", "vnftype", vnfType)
131 msoLogger.debug("vnfType: " + vnfType)
133 def vnfName = execution.getVariable("vnfName")
134 execution.setVariable("DCVFM_vnfName", vnfName)
135 rollbackData.put("VFMODULE", "vnfname", vnfName)
136 msoLogger.debug("vnfName: " + vnfName)
138 def vnfId = execution.getVariable("vnfId")
139 execution.setVariable("DCVFM_vnfId", vnfId)
140 rollbackData.put("VFMODULE", "vnfid", vnfId)
141 msoLogger.debug("vnfId: " + vnfId)
143 def vfModuleName = execution.getVariable("vfModuleName")
144 execution.setVariable("DCVFM_vfModuleName", vfModuleName)
145 rollbackData.put("VFMODULE", "vfmodulename", vfModuleName)
146 msoLogger.debug("vfModuleName: " + vfModuleName)
148 def vfModuleModelName = jsonUtil.getJsonValue(vfModuleModelInfo, "modelName")
149 execution.setVariable("DCVFM_vfModuleModelName", vfModuleModelName)
150 rollbackData.put("VFMODULE", "vfmodulemodelname", vfModuleModelName)
151 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
152 //modelCustomizationUuid
153 def modelCustomizationUuid = jsonUtil.getJsonValue(vfModuleModelInfo, "modelCustomizationUuid")
154 execution.setVariable("DCVFM_modelCustomizationUuid", modelCustomizationUuid)
155 rollbackData.put("VFMODULE", "modelcustomizationuuid", modelCustomizationUuid)
156 msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
158 def vfModuleId = execution.getVariable("vfModuleId")
159 execution.setVariable("DCVFM_vfModuleId", vfModuleId)
160 msoLogger.debug("vfModuleId: " + vfModuleId)
161 def requestId = execution.getVariable("msoRequestId")
162 execution.setVariable("DCVFM_requestId", requestId)
163 msoLogger.debug("requestId: " + requestId)
164 rollbackData.put("VFMODULE", "msorequestid", requestId)
165 // Set mso-request-id to request-id for VNF Adapter interface
166 execution.setVariable("mso-request-id", requestId)
168 def serviceId = execution.getVariable("serviceId")
169 execution.setVariable("DCVFM_serviceId", serviceId)
170 msoLogger.debug("serviceId: " + serviceId)
172 def serviceInstanceId = execution.getVariable("serviceInstanceId")
173 execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId)
174 rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId)
175 msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
177 String oofDirectives = execution.getVariable(cloudSiteId + "_oofDirectives")
178 if (flavorList != null) {
179 execution.setVariable("DCVFM_flavorList", flavorList)
180 logDebug("flavorList is: " + flavorList, isDebugLogEnabled)
184 execution.setVariable("DCVFM_source", source)
185 rollbackData.put("VFMODULE", "source", source)
186 msoLogger.debug("source: " + source)
188 def disableRollback = execution.getVariable("disableRollback")
189 def backoutOnFailure = true
190 if (disableRollback != null && disableRollback == true) {
191 backoutOnFailure = false
193 execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure)
194 msoLogger.debug("backoutOnFailure: " + backoutOnFailure)
196 def isBaseVfModule = execution.getVariable("isBaseVfModule")
197 execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule)
198 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
199 //asdcServiceModelVersion
200 def asdcServiceModelVersion = execution.getVariable("asdcServiceModelVersion")
201 execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion)
202 msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
204 execution.setVariable("DCVFM_personaModelId", jsonUtil.getJsonValue(vfModuleModelInfo, "modelInvariantUuid"))
205 //personaModelVersion
206 execution.setVariable("DCVFM_personaModelVersion", jsonUtil.getJsonValue(vfModuleModelInfo, "modelUuid"))
208 def vfModuleLabel = execution.getVariable("vfModuleLabel")
209 if (vfModuleLabel != null) {
210 execution.setVariable("DCVFM_vfModuleLabel", vfModuleLabel)
211 msoLogger.debug("vfModuleLabel: " + vfModuleLabel)
213 //Get or Generate UUID
214 String uuid = execution.getVariable("DCVFM_uuid")
216 uuid = UUID.randomUUID()
217 msoLogger.debug("Generated messageId (UUID) is: " + uuid)
219 msoLogger.debug("Found messageId (UUID) is: " + uuid)
222 String isVidRequest = execution.getVariable("isVidRequest")
224 if (isVidRequest == null || isVidRequest.isEmpty()) {
225 execution.setVariable("isVidRequest", "true")
228 String globalSubscriberId = execution.getVariable("globalSubscriberId")
229 execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId)
230 msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
231 Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
232 if (vfModuleInputParams != null) {
233 execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams)
234 execution.setVariable("DCVFM_vnfParamsExistFlag", true)
237 def usePreload = execution.getVariable("usePreload")
238 execution.setVariable("DCVFM_usePreload", usePreload)
239 msoLogger.debug("usePreload: " + usePreload)
241 def aLaCarte = execution.getVariable("aLaCarte")
242 execution.setVariable("DCVFM_aLaCarte", aLaCarte)
243 msoLogger.debug("aLaCarte: " + aLaCarte)
245 //get workload and environment context from parent SI
246 String environmentContext = ""
247 String workloadContext =""
248 String serviceType =""
251 String json = catalog.getServiceResourcesByServiceModelInvariantUuidString(execution,modelInvariantUuid )
252 serviceType = jsonUtil.getJsonValue(json, "serviceResources.serviceType")
255 } catch (Exception ex){
256 String msg = "Exception in preProcessRequest " + ex.getMessage()
258 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
262 AAIUri serviceInstanceURI = AAIUriFactory.create(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId,serviceType,serviceInstanceId)
263 AAIResourcesClient aaiRC = new AAIResourcesClient()
264 AAIResultWrapper aaiRW = aaiRC.get(serviceInstanceURI)
265 Map<String, Object> aaiJson = aaiRW.asMap()
266 environmentContext = aaiJson.getOrDefault("environment-context","")
267 workloadContext = aaiJson.getOrDefault("workload-context","")
269 }catch (Exception ex) {
270 msoLogger.debug("Error retreiving parent service instance information")
273 execution.setVariable("DCVFM_environmentContext",environmentContext)
274 execution.setVariable("DCVFM_workloadContext",workloadContext)
278 // The info is inside the request - DEAD CODE
279 msoLogger.debug("DoCreateVfModule request: " + request)
283 if (utils.nodeExists(request, "tenant-id")) {
284 tenantId = utils.getNodeText(request, "tenant-id")
286 execution.setVariable("DCVFM_tenantId", tenantId)
287 rollbackData.put("VFMODULE", "tenantid", tenantId)
289 def volumeGroupId = ""
290 if (utils.nodeExists(request, "volume-group-id")) {
291 volumeGroupId = utils.getNodeText(request, "volume-group-id")
293 execution.setVariable("DCVFM_volumeGroupId", volumeGroupId)
295 def volumeGroupName = ""
296 if (utils.nodeExists(request, "volume-group-name")) {
297 volumeGroupName = utils.getNodeText(request, "volume-group-name")
299 execution.setVariable("DCVFM_volumeGroupName", volumeGroupName)
302 if (utils.nodeExists(request, "aic-cloud-region")) {
303 cloudSiteId = utils.getNodeText(request, "aic-cloud-region")
305 execution.setVariable("DCVFM_cloudSiteId", cloudSiteId)
306 rollbackData.put("VFMODULE", "aiccloudregion", cloudSiteId)
307 msoLogger.debug("cloudSiteId: " + cloudSiteId)
310 if (utils.nodeExists(request, "vnf-type")) {
311 vnfType = utils.getNodeText(request, "vnf-type")
313 execution.setVariable("DCVFM_vnfType", vnfType)
314 rollbackData.put("VFMODULE", "vnftype", vnfType)
315 msoLogger.debug("vnfType: " + vnfType)
318 if (utils.nodeExists(request, "vnf-name")) {
319 vnfName = utils.getNodeText(request, "vnf-name")
321 execution.setVariable("DCVFM_vnfName", vnfName)
322 rollbackData.put("VFMODULE", "vnfname", vnfName)
323 msoLogger.debug("vnfName: " + vnfName)
326 if (utils.nodeExists(request, "vnf-id")) {
327 vnfId = utils.getNodeText(request, "vnf-id")
329 execution.setVariable("DCVFM_vnfId", vnfId)
330 rollbackData.put("VFMODULE", "vnfid", vnfId)
331 msoLogger.debug("vnfId: " + vnfId)
333 def vfModuleName = ""
334 if (utils.nodeExists(request, "vf-module-name")) {
335 vfModuleName = utils.getNodeText(request, "vf-module-name")
337 execution.setVariable("DCVFM_vfModuleName", vfModuleName)
338 rollbackData.put("VFMODULE", "vfmodulename", vfModuleName)
339 msoLogger.debug("vfModuleName: " + vfModuleName)
341 def vfModuleModelName = ""
342 if (utils.nodeExists(request, "vf-module-model-name")) {
343 vfModuleModelName = utils.getNodeText(request, "vf-module-model-name")
345 execution.setVariable("DCVFM_vfModuleModelName", vfModuleModelName)
346 rollbackData.put("VFMODULE", "vfmodulemodelname", vfModuleModelName)
347 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
348 //modelCustomizationUuid
349 def modelCustomizationUuid = ""
350 if (utils.nodeExists(request, "model-customization-id")) {
351 modelCustomizationUuid = utils.getNodeText(request, "model-customization-id")
353 execution.setVariable("DCVFM_modelCustomizationUuid", modelCustomizationUuid)
354 rollbackData.put("VFMODULE", "modelcustomizationuuid", modelCustomizationUuid)
355 msoLogger.debug("modelCustomizationUuid: " + modelCustomizationUuid)
358 if (utils.nodeExists(request, "vf-module-id")) {
359 vfModuleId = utils.getNodeText(request, "vf-module-id")
361 execution.setVariable("DCVFM_vfModuleId", vfModuleId)
362 msoLogger.debug("vfModuleId: " + vfModuleId)
364 if (utils.nodeExists(request, "request-id")) {
365 requestId = utils.getNodeText(request, "request-id")
367 execution.setVariable("DCVFM_requestId", requestId)
368 msoLogger.debug("requestId: " + requestId)
371 if (utils.nodeExists(request, "service-id")) {
372 serviceId = utils.getNodeText(request, "service-id")
374 execution.setVariable("DCVFM_serviceId", serviceId)
375 msoLogger.debug("serviceId: " + serviceId)
377 def serviceInstanceId = ""
378 if (utils.nodeExists(request, "service-instance-id")) {
379 serviceInstanceId = utils.getNodeText(request, "service-instance-id")
381 execution.setVariable("DCVFM_serviceInstanceId", serviceInstanceId)
382 rollbackData.put("VFMODULE", "serviceInstanceId", serviceInstanceId)
383 msoLogger.debug("serviceInstanceId: " + serviceInstanceId)
386 if (utils.nodeExists(request, "source")) {
387 source = utils.getNodeText(request, "source")
389 execution.setVariable("DCVFM_source", source)
390 rollbackData.put("VFMODULE", "source", source)
391 msoLogger.debug("source: " + source)
393 NetworkUtils networkUtils = new NetworkUtils()
394 def backoutOnFailure = networkUtils.isRollbackEnabled(execution,request)
395 execution.setVariable("DCVFM_backoutOnFailure", backoutOnFailure)
396 msoLogger.debug("backoutOnFailure: " + backoutOnFailure)
398 def isBaseVfModule = "false"
399 if (utils.nodeExists(request, "is-base-vf-module")) {
400 isBaseVfModule = utils.getNodeText(request, "is-base-vf-module")
402 execution.setVariable("DCVFM_isBaseVfModule", isBaseVfModule)
403 msoLogger.debug("isBaseVfModule: " + isBaseVfModule)
404 //asdcServiceModelVersion
405 def asdcServiceModelVersion = ""
406 if (utils.nodeExists(request, "asdc-service-model-version")) {
407 asdcServiceModelVersion = utils.getNodeText(request, "asdc-service-model-version")
409 execution.setVariable("DCVFM_asdcServiceModelVersion", asdcServiceModelVersion)
410 msoLogger.debug("asdcServiceModelVersion: " + asdcServiceModelVersion)
413 def personaModelId = ""
414 if (utils.nodeExists(request, "persona-model-id")) {
415 personaModelId = utils.getNodeText(request, "persona-model-id")
417 execution.setVariable("DCVFM_personaModelId", personaModelId)
418 msoLogger.debug("personaModelId: " + personaModelId)
420 //personaModelVersion
421 def personaModelVersion = ""
422 if (utils.nodeExists(request, "persona-model-version")) {
423 personaModelVersion = utils.getNodeText(request, "persona-model-version")
425 execution.setVariable("DCVFM_personaModelVersion", personaModelVersion)
426 msoLogger.debug("personaModelVersion: " + personaModelVersion)
428 // Process the parameters
430 String vnfParamsChildNodes = utils.getChildNodes(request, "vnf-params")
431 if(vnfParamsChildNodes == null || vnfParamsChildNodes.length() < 1){
432 msoLogger.debug("Request contains NO VNF Params")
434 msoLogger.debug("Request does contain VNF Params")
435 execution.setVariable("DCVFM_vnfParamsExistFlag", true)
437 InputSource xmlSource = new InputSource(new StringReader(request));
438 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
439 docFactory.setNamespaceAware(true)
440 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
441 Document xml = docBuilder.parse(xmlSource)
442 //Get params, build map
443 Map<String, String> paramsMap = new HashMap<String, String>()
444 NodeList paramsList = xml.getElementsByTagNameNS("*", "param")
446 for (int z = 0; z < paramsList.getLength(); z++) {
447 Node node = paramsList.item(z)
448 String paramValue = node.getTextContent()
449 NamedNodeMap e = node.getAttributes()
450 String paramName = e.getNamedItem("name").getTextContent()
451 paramsMap.put(paramName, paramValue)
453 execution.setVariable("DCVFM_vnfParamsMap", paramsMap)
457 //Get or Generate UUID
458 String uuid = execution.getVariable("DCVFM_uuid")
460 uuid = UUID.randomUUID()
461 msoLogger.debug("Generated messageId (UUID) is: " + uuid)
463 msoLogger.debug("Found messageId (UUID) is: " + uuid)
465 // Get sdncVersion, default to empty
466 String sdncVersion = execution.getVariable("sdncVersion")
467 if (sdncVersion == null) {
470 msoLogger.debug("sdncVersion: " + sdncVersion)
471 execution.setVariable("DCVFM_sdncVersion", sdncVersion)
473 execution.setVariable("DCVFM_uuid", uuid)
474 execution.setVariable("DCVFM_baseVfModuleId", "")
475 execution.setVariable("DCVFM_baseVfModuleHeatStackId", "")
476 execution.setVariable("DCVFM_heatStackId", "")
477 execution.setVariable("DCVFM_contrailServiceInstanceFqdn", "")
478 execution.setVariable("DCVFM_volumeGroupStackId", "")
479 execution.setVariable("DCVFM_cloudRegionForVolume", "")
480 execution.setVariable("DCVFM_contrailNetworkPolicyFqdnList", "")
481 execution.setVariable("DCVFM_vnfTypeToQuery", "generic-vnf")
482 rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "false")
483 rollbackData.put("VFMODULE", "rollbackUpdateAAIVfModule", "false")
484 rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "false")
485 rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "false")
486 rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "false")
487 rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "false")
488 rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "false")
489 rollbackData.put("VFMODULE", "rollbackUpdateVnfAAI", "false")
490 rollbackData.put("VFMODULE", "heatstackid", "")
492 String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback",execution)
493 if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
494 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
495 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, msg, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, msg);
497 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
499 execution.setVariable("DCVFM_sdncCallbackUrl", sdncCallbackUrl)
500 msoLogger.debug("SDNC Callback URL is: " + sdncCallbackUrl)
503 execution.setVariable("rollbackData", rollbackData)
507 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, "Internal Error encountered in PreProcess method!")
510 msoLogger.trace('Exited ' + method)
514 * Validates a workflow response.
515 * @param execution the execution
516 * @param responseVar the execution variable in which the response is stored
517 * @param responseCodeVar the execution variable in which the response code is stored
518 * @param errorResponseVar the execution variable in which the error response is stored
520 public void validateWorkflowResponse(DelegateExecution execution, String responseVar,
521 String responseCodeVar, String errorResponseVar) {
522 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
523 sdncAdapterUtils.validateSDNCResponse(execution, responseVar, responseCodeVar, errorResponseVar)
528 * Sends the empty, synchronous response back to the API Handler.
529 * @param execution the execution
531 public void sendResponse(DelegateExecution execution) {
532 def method = getClass().getSimpleName() + '.sendResponse(' +
533 'execution=' + execution.getId() +
536 msoLogger.trace('Entered ' + method)
539 sendWorkflowResponse(execution, 200, "")
540 msoLogger.trace('Exited ' + method)
541 } catch (BpmnError e) {
543 } catch (Exception e) {
544 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
546 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Internal Error')
551 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
552 * A 200 response is expected with the VNF info in the response body. Will find out the base module info
553 * and existing VNF's name for add-on modules
555 * @param execution The flow's execution instance.
557 public void postProcessCreateAAIVfModule(DelegateExecution execution) {
558 def method = getClass().getSimpleName() + '.getVfModule(' +
559 'execution=' + execution.getId() +
562 msoLogger.trace('Entered ' + method)
565 def createResponse = execution.getVariable('DCVFM_createVfModuleResponse')
566 msoLogger.debug("createVfModule Response: " + createResponse)
568 def rollbackData = execution.getVariable("rollbackData")
569 String vnfName = utils.getNodeText(createResponse, 'vnf-name')
570 if (vnfName != null) {
571 execution.setVariable('DCVFM_vnfName', vnfName)
572 msoLogger.debug("vnfName retrieved from AAI is: " + vnfName)
573 rollbackData.put("VFMODULE", "vnfname", vnfName)
575 String vnfId = utils.getNodeText(createResponse, 'vnf-id')
576 execution.setVariable('DCVFM_vnfId', vnfId)
577 msoLogger.debug("vnfId is: " + vnfId)
578 String vfModuleId = utils.getNodeText(createResponse, 'vf-module-id')
579 execution.setVariable('DCVFM_vfModuleId', vfModuleId)
580 msoLogger.debug("vfModuleId is: " + vfModuleId)
581 String vfModuleIndex= utils.getNodeText(createResponse, 'vf-module-index')
582 execution.setVariable('DCVFM_vfModuleIndex', vfModuleIndex)
583 msoLogger.debug("vfModuleIndex is: " + vfModuleIndex)
584 rollbackData.put("VFMODULE", "vnfid", vnfId)
585 rollbackData.put("VFMODULE", "vfmoduleid", vfModuleId)
586 rollbackData.put("VFMODULE", "rollbackCreateAAIVfModule", "true")
587 rollbackData.put("VFMODULE", "rollbackPrepareUpdateVfModule", "true")
588 execution.setVariable("rollbackData", rollbackData)
589 } catch (Exception ex) {
591 msoLogger.debug('Exception occurred while postProcessing CreateAAIVfModule request:' + ex.getMessage())
592 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Bad response from CreateAAIVfModule' + ex.getMessage())
594 msoLogger.trace('Exited ' + method)
599 * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
600 * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
602 * @param execution The flow's execution instance.
604 public void queryAAIVfModule(DelegateExecution execution) {
606 def method = getClass().getSimpleName() + '.getVfModule(' +
607 'execution=' + execution.getId() +
609 msoLogger.trace('Entered ' + method)
612 def vnfId = execution.getVariable('DCVFM_vnfId')
613 def vfModuleId = execution.getVariable('DCVFM_vfModuleId')
615 AaiUtil aaiUriUtil = new AaiUtil(this)
616 String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
617 msoLogger.debug('AAI URI is: ' + aai_uri)
619 String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") + "?depth=1"
622 RESTConfig config = new RESTConfig(endPoint);
623 def responseData = ''
624 def aaiRequestId = UUID.randomUUID().toString()
625 RESTClient client = new RESTClient(config).
626 addHeader('X-TransactionId', aaiRequestId).
627 addHeader('X-FromAppId', 'MSO').
628 addHeader('Content-Type', 'application/xml').
629 addHeader('Accept','application/xml');
630 msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
631 APIResponse response = client.httpGet()
633 responseData = response.getResponseBodyAsString()
634 if (responseData != null) {
635 msoLogger.debug("Received generic VNF data: " + responseData)
639 execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', response.getStatusCode())
640 execution.setVariable('DCVFM_queryAAIVfModuleResponse', responseData)
641 msoLogger.debug('Response code:' + response.getStatusCode())
642 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
643 if (response.getStatusCode() == 200) {
644 // Parse the VNF record from A&AI to find base module info
645 msoLogger.debug('Parsing the VNF data to find base module info')
646 if (responseData != null) {
647 def vfModulesText = utils.getNodeXml(responseData, "vf-modules")
648 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
649 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
650 int vfModulesSize = 0
651 for (i in 0..vfModules.size()-1) {
652 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
653 def isBaseVfModule = utils.getNodeText(vfModuleXml, "is-base-vf-module")
655 if (isBaseVfModule == "true") {
656 String baseModuleId = utils.getNodeText(vfModuleXml, "vf-module-id")
657 execution.setVariable("DCVFM_baseVfModuleId", baseModuleId)
658 msoLogger.debug('Received baseVfModuleId: ' + baseModuleId)
659 String baseModuleHeatStackId = utils.getNodeText(vfModuleXml, "heat-stack-id")
660 execution.setVariable("DCVFM_baseVfModuleHeatStackId", baseModuleHeatStackId)
661 msoLogger.debug('Received baseVfModuleHeatStackId: ' + baseModuleHeatStackId)
666 } catch (Exception ex) {
668 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
669 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
671 msoLogger.trace('Exited ' + method)
672 } catch (BpmnError e) {
674 } catch (Exception e) {
675 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
676 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
681 * Using the vnfId and vfModuleName provided in the inputs,
682 * query AAI to get the corresponding VF Module info.
683 * A 200 response is expected with the VF Module info in the response body,
684 * or a 404 response if the module does not exist yet. Will determine VF Module's
685 * orchestration status if one exists
687 * @param execution The flow's execution instance.
689 public void queryAAIVfModuleForStatus(DelegateExecution execution) {
691 def method = getClass().getSimpleName() + '.queryAAIVfModuleForStatus(' +
692 'execution=' + execution.getId() +
694 msoLogger.trace('Entered ' + method)
696 execution.setVariable('DCVFM_orchestrationStatus', '')
699 def vnfId = execution.getVariable('DCVFM_vnfId')
700 def vfModuleName = execution.getVariable('DCVFM_vfModuleName')
702 AaiUtil aaiUriUtil = new AaiUtil(this)
703 String aai_uri = aaiUriUtil.getNetworkGenericVnfUri(execution)
704 msoLogger.debug('AAI URI is: ' + aai_uri)
706 String endPoint = UrnPropertiesReader.getVariable("aai.endpoint", execution) + "${aai_uri}/" + UriUtils.encode(vnfId, "UTF-8") +
707 "/vf-modules/vf-module?vf-module-name=" + UriUtils.encode(vfModuleName, "UTF-8")
708 msoLogger.debug("AAI endPoint: " + endPoint)
711 RESTConfig config = new RESTConfig(endPoint);
712 def responseData = ''
713 def aaiRequestId = UUID.randomUUID().toString()
714 RESTClient client = new RESTClient(config).
715 addHeader('X-TransactionId', aaiRequestId).
716 addHeader('X-FromAppId', 'MSO').
717 addHeader('Content-Type', 'application/xml').
718 addHeader('Accept','application/xml');
719 msoLogger.debug('sending GET to AAI endpoint \'' + endPoint + '\'')
720 APIResponse response = client.httpGet()
721 msoLogger.debug("createVfModule - invoking httpGet() to AAI")
723 responseData = response.getResponseBodyAsString()
724 if (responseData != null) {
725 msoLogger.debug("Received generic VNF data: " + responseData)
729 execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponseCode', response.getStatusCode())
730 execution.setVariable('DCVFM_queryAAIVfModuleForStatusResponse', responseData)
731 msoLogger.debug('Response code:' + response.getStatusCode())
732 msoLogger.debug('Response:' + System.lineSeparator() + responseData)
733 // Retrieve VF Module info and its orchestration status; if not found, do nothing
734 if (response.getStatusCode() == 200) {
735 // Parse the VNF record from A&AI to find base module info
736 msoLogger.debug('Parsing the VNF data to find orchestration status')
737 if (responseData != null) {
738 def vfModuleText = utils.getNodeXml(responseData, "vf-module")
739 //def xmlVfModule= new XmlSlurper().parseText(vfModuleText)
740 def orchestrationStatus = utils.getNodeText(vfModuleText, "orchestration-status")
741 execution.setVariable("DCVFM_orchestrationStatus", orchestrationStatus)
742 // Also retrieve vfModuleId
743 def vfModuleId = utils.getNodeText(vfModuleText, "vf-module-id")
744 execution.setVariable("DCVFM_vfModuleId", vfModuleId)
745 msoLogger.debug("Received orchestration status from A&AI: " + orchestrationStatus)
749 } catch (Exception ex) {
751 msoLogger.debug('Exception occurred while executing AAI GET:' + ex.getMessage())
752 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
754 msoLogger.trace('Exited ' + method)
755 } catch (BpmnError e) {
757 } catch (Exception e) {
758 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
759 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModuleForStatus(): ' + e.getMessage())
764 public void preProcessSDNCAssignRequest(DelegateExecution execution){
766 execution.setVariable("prefix", Prefix)
767 msoLogger.trace("STARTED preProcessSDNCAssignRequest")
768 def vnfId = execution.getVariable("DCVFM_vnfId")
769 def vfModuleId = execution.getVariable("DCVFM_vfModuleId")
770 def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId")
771 msoLogger.debug("NEW VNF ID: " + vnfId)
778 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
779 svcInstId = vfModuleId
782 svcInstId = serviceInstanceId
785 String assignSDNCRequest = buildSDNCRequest(execution, svcInstId, "assign")
787 assignSDNCRequest = utils.formatXml(assignSDNCRequest)
788 execution.setVariable("DCVFM_assignSDNCRequest", assignSDNCRequest)
789 msoLogger.debug("Outgoing AssignSDNCRequest is: \n" + assignSDNCRequest)
792 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Occurred Processing preProcessSDNCAssignRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
793 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareProvision Method:\n" + e.getMessage())
795 msoLogger.trace("COMPLETED preProcessSDNCAssignRequest")
798 public void preProcessSDNCGetRequest(DelegateExecution execution, String element){
800 String sdncVersion = execution.getVariable("DCVFM_sdncVersion")
801 execution.setVariable("prefix", Prefix)
802 msoLogger.trace("STARTED preProcessSDNCGetRequest Process")
804 def serviceInstanceId = execution.getVariable('DCVFM_serviceInstanceId')
806 String uuid = execution.getVariable('testReqId') // for junits
808 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
811 def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl")
812 msoLogger.debug("callbackUrl:" + callbackUrl)
814 def vfModuleId = execution.getVariable('DCVFM_vfModuleId')
817 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
818 svcInstId = vfModuleId
821 svcInstId = serviceInstanceId
825 if (!sdncVersion.equals("1707")) {
826 msoAction = "mobility"
829 msoAction = "vfmodule"
831 // For VNF, serviceOperation (URI for topology GET) will be retrieved from "selflink" element
832 // in the response from GenericGetVnf
833 // For VF Module, in 1707 serviceOperation will be retrieved from "object-path" element
834 // in SDNC Assign Response
835 // For VF Module for older versions, serviceOperation is constructed using vfModuleId
837 String serviceOperation = ""
838 if (element.equals("vnf")) {
839 def vnfQueryResponse = execution.getVariable("DCVFM_vnfQueryResponse")
840 serviceOperation = utils.getNodeText(vnfQueryResponse, "selflink")
841 msoLogger.debug("VNF - service operation: " + serviceOperation)
843 else if (element.equals("vfmodule")) {
844 String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse")
845 msoLogger.debug("DCVFM_assignSDNCAdapterResponse is: \n" + response)
847 if (!sdncVersion.equals("1707")) {
848 serviceOperation = "/VNF-API:vnfs/vnf-list/" + vfModuleId
849 msoLogger.debug("VF Module with sdncVersion before 1707 - service operation: " + serviceOperation)
852 String data = utils.getNodeXml(response, "response-data")
853 msoLogger.debug("responseData: " + data)
854 serviceOperation = utils.getNodeText(data, "object-path")
855 msoLogger.debug("VF Module with sdncVersion of 1707 - service operation: " + serviceOperation)
859 //!!!! TEMPORARY WORKAROUND FOR SDNC REPLICATION ISSUE
862 String SDNCGetRequest =
863 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
864 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
865 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
866 <sdncadapter:RequestHeader>
867 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
868 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
869 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
870 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
871 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
872 <sdncadapter:MsoAction>${MsoUtils.xmlEscape(msoAction)}</sdncadapter:MsoAction>
873 </sdncadapter:RequestHeader>
874 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
875 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
877 execution.setVariable("DCVFM_getSDNCRequest", SDNCGetRequest)
878 msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
881 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occurred Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
882 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
884 msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process")
888 public void preProcessVNFAdapterRequest(DelegateExecution execution) {
889 def method = getClass().getSimpleName() + '.VNFAdapterCreateVfModule(' +
890 'execution=' + execution.getId() +
893 msoLogger.trace('Entered ' + method)
895 //def xml = execution.getVariable("DoCreateVfModuleRequest")
896 //msoLogger.debug('VNF REQUEST is: ' + xml)
900 def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId")
902 def tenantId = execution.getVariable("DCVFM_tenantId")
904 def vnfType = execution.getVariable("DCVFM_vnfType")
906 def vnfName = execution.getVariable("DCVFM_vnfName")
908 def vnfId = execution.getVariable("DCVFM_vnfId")
910 def vfModuleName = execution.getVariable("DCVFM_vfModuleName")
912 def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName")
914 def vfModuleId = execution.getVariable("DCVFM_vfModuleId")
916 def vfModuleIndex = execution.getVariable("DCVFM_vfModuleIndex")
918 def requestId = execution.getVariable("DCVFM_requestId")
920 def serviceId = execution.getVariable("DCVFM_serviceId")
922 def serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId")
924 String oofDirectives = execution.getVariable("DCVFM_oofDirectives")
926 def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure")
928 def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId")
930 def baseVfModuleId = execution.getVariable("DCVFM_baseVfModuleId")
931 // baseVfModuleStackId
932 def baseVfModuleStackId = execution.getVariable("DCVFM_baseVfModuleHeatStackId")
933 // asdcServiceModelVersion
934 def asdcServiceModelVersion = execution.getVariable("DCVFM_asdcServiceModelVersion")
936 def volumeGroupStackId = execution.getVariable("DCVFM_volumeGroupStackId")
937 //modelCustomizationUuid
938 def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid")
940 String environmentContext = execution.getVariable("DCVFM_environmentContext")
942 String workloadContext = execution.getVariable("DCVFM_workloadContext")
943 msoLogger.debug("workloadContext: " + workloadContext)
944 msoLogger.debug("environmentContext: " + environmentContext)
946 def messageId = execution.getVariable('mso-request-id') + '-' +
947 System.currentTimeMillis()
949 def notificationUrl = createCallbackURL(execution, "VNFAResponse", messageId)
950 def useQualifiedHostName = UrnPropertiesReader.getVariable("mso.use.qualified.host",execution)
952 msoLogger.debug("notificationUrl: " + notificationUrl)
953 msoLogger.debug("QualifiedHostName: " + useQualifiedHostName)
955 if ('true'.equals(useQualifiedHostName)) {
956 notificationUrl = utils.getQualifiedHostNameForCallback(notificationUrl)
959 Map<String, String> vnfParamsMap = execution.getVariable("DCVFM_vnfParamsMap")
960 // Add flavorLabel List to vnfParamsMap
961 flavorList.each { cloudFlavor ->
962 vnfParamsMap.put("label_" + cloudFlavor.getFlavorLabel(), cloudFlavor.getFlavor())
964 String vfModuleParams = ""
965 //Get SDNC Response Data for VF Module Topology
966 String vfModuleSdncGetResponse = execution.getVariable('DCVFM_getSDNCAdapterResponse')
967 msoLogger.debug("sdncGetResponse: " + vfModuleSdncGetResponse)
968 def sdncVersion = execution.getVariable("sdncVersion")
970 if (!sdncVersion.equals("1707")) {
972 vfModuleParams = buildVfModuleParams(vnfParamsMap, vfModuleSdncGetResponse, vnfId, vnfName,
973 vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext)
976 //Get SDNC Response Data for Vnf Topology
977 String vnfSdncGetResponse = execution.getVariable('DCVFM_getVnfSDNCAdapterResponse')
978 msoLogger.debug("vnfSdncGetResponse: " + vnfSdncGetResponse)
980 vfModuleParams = buildVfModuleParamsFromCombinedTopologies(vnfParamsMap, vnfSdncGetResponse, vfModuleSdncGetResponse, vnfId, vnfName,
981 vfModuleId, vfModuleName, vfModuleIndex, environmentContext, workloadContext)
985 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
986 svcInstId = serviceId
989 svcInstId = serviceInstanceId
992 def createVnfARequest = """
993 <createVfModuleRequest>
994 <cloudSiteId>${MsoUtils.xmlEscape(cloudSiteId)}</cloudSiteId>
995 <tenantId>${MsoUtils.xmlEscape(tenantId)}</tenantId>
996 <vnfId>${MsoUtils.xmlEscape(vnfId)}</vnfId>
997 <vnfName>${MsoUtils.xmlEscape(vnfName)}</vnfName>
998 <vfModuleName>${MsoUtils.xmlEscape(vfModuleName)}</vfModuleName>
999 <vfModuleId>${MsoUtils.xmlEscape(vfModuleId)}</vfModuleId>
1000 <vnfType>${MsoUtils.xmlEscape(vnfType)}</vnfType>
1001 <vfModuleType>${MsoUtils.xmlEscape(vfModuleModelName)}</vfModuleType>
1002 <vnfVersion>${MsoUtils.xmlEscape(asdcServiceModelVersion)}</vnfVersion>
1003 <modelCustomizationUuid>${MsoUtils.xmlEscape(modelCustomizationUuid)}</modelCustomizationUuid>
1004 <requestType></requestType>
1005 <volumeGroupId>${MsoUtils.xmlEscape(volumeGroupId)}</volumeGroupId>
1006 <volumeGroupStackId>${MsoUtils.xmlEscape(volumeGroupStackId)}</volumeGroupStackId>
1007 <baseVfModuleId>${MsoUtils.xmlEscape(baseVfModuleId)}</baseVfModuleId>
1008 <baseVfModuleStackId>${MsoUtils.xmlEscape(baseVfModuleStackId)}</baseVfModuleStackId>
1009 <skipAAI>true</skipAAI>
1010 <backout>${MsoUtils.xmlEscape(backoutOnFailure)}</backout>
1011 <failIfExists>true</failIfExists>
1016 <requestId>${MsoUtils.xmlEscape(requestId)}</requestId>
1017 <serviceInstanceId>${MsoUtils.xmlEscape(svcInstId)}</serviceInstanceId>
1019 <messageId>${MsoUtils.xmlEscape(messageId)}</messageId>
1020 <notificationUrl>${MsoUtils.xmlEscape(notificationUrl)}</notificationUrl>
1021 </createVfModuleRequest>"""
1023 msoLogger.debug("Create VfModule Request to VNF Adapter: " + createVnfARequest)
1024 execution.setVariable("DCVFM_createVnfARequest", createVnfARequest)
1028 * Validates the request, request id and service instance id. If a problem is found,
1029 * a WorkflowException is generated and an MSOWorkflowException event is thrown. This
1030 * method also sets up the log context for the workflow.
1031 * @param execution the execution
1032 * @return the validated request
1034 public String validateInfraRequest(DelegateExecution execution) {
1035 def method = getClass().getSimpleName() + '.validateInfraRequest(' +
1036 'execution=' + execution.getId() +
1039 msoLogger.trace('Entered ' + method)
1041 String processKey = getProcessKey(execution);
1042 def prefix = execution.getVariable("prefix")
1044 if (prefix == null) {
1045 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " prefix is null")
1049 def request = execution.getVariable(prefix + 'Request')
1051 if (request == null) {
1052 request = execution.getVariable(processKey + 'Request')
1054 if (request == null) {
1055 request = execution.getVariable('bpmnRequest')
1058 setVariable(execution, processKey + 'Request', null);
1059 setVariable(execution, 'bpmnRequest', null);
1060 setVariable(execution, prefix + 'Request', request);
1063 if (request == null) {
1064 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request is null")
1066 msoLogger.debug("DoCreateVfModule Request: " + request)
1070 def requestId = execution.getVariable("mso-request-id")
1072 if (requestId == null) {
1073 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request has no mso-request-id")
1076 def serviceInstanceId = execution.getVariable("mso-service-instance-id")
1078 if (serviceInstanceId == null) {
1079 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, processKey + " request message has no mso-service-instance-id")
1082 utils.logContext(requestId, serviceInstanceId)
1084 msoLogger.debug('Incoming message: ' + System.lineSeparator() + request)
1085 msoLogger.trace('Exited ' + method)
1087 } catch (BpmnError e) {
1089 } catch (Exception e) {
1090 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1091 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Invalid Message")
1095 public boolean isVolumeGroupIdPresent(DelegateExecution execution) {
1097 def method = getClass().getSimpleName() + '.isVolumeGroupIdPresent(' +
1098 'execution=' + execution.getId() +
1101 msoLogger.trace('Entered ' + method)
1103 def request = execution.getVariable('DoCreateVfModuleRequest')
1104 String volumeGroupId = utils.getNodeText(request, "volume-group-id")
1105 if (volumeGroupId == null || volumeGroupId.isEmpty()) {
1106 msoLogger.debug('No volume group id is present')
1110 msoLogger.debug('Volume group id is present')
1116 public boolean isVolumeGroupNamePresent(DelegateExecution execution) {
1118 def method = getClass().getSimpleName() + '.isVolumeGroupNamePresent(' +
1119 'execution=' + execution.getId() +
1122 msoLogger.trace('Entered ' + method)
1124 def request = execution.getVariable('DoCreateVfModuleRequest')
1125 String volumeGroupName = utils.getNodeText(request, "volume-group-name")
1126 if (volumeGroupName == null || volumeGroupName.isEmpty()) {
1127 msoLogger.debug('No volume group name is present')
1131 msoLogger.debug('Volume group name is present')
1137 public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
1139 String uuid = execution.getVariable('testReqId') // for junits
1141 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
1143 def callbackURL = execution.getVariable("DCVFM_sdncCallbackUrl")
1144 def requestId = execution.getVariable("DCVFM_requestId")
1145 def serviceId = execution.getVariable("DCVFM_serviceId")
1146 def vnfType = execution.getVariable("DCVFM_vnfType")
1147 def vnfName = execution.getVariable("DCVFM_vnfName")
1148 def tenantId = execution.getVariable("DCVFM_tenantId")
1149 def source = execution.getVariable("DCVFM_source")
1150 def backoutOnFailure = execution.getVariable("DCVFM_backoutOnFailure")
1151 def vfModuleId = execution.getVariable("DCVFM_vfModuleId")
1152 def vfModuleName = execution.getVariable("DCVFM_vfModuleName")
1153 def vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName")
1154 def vnfId = execution.getVariable("DCVFM_vnfId")
1155 def cloudSiteId = execution.getVariable("DCVFM_cloudSiteId")
1156 def sdncVersion = execution.getVariable("DCVFM_sdncVersion")
1157 def serviceModelInfo = execution.getVariable("serviceModelInfo")
1158 def vnfModelInfo = execution.getVariable("vnfModelInfo")
1159 def vfModuleModelInfo = execution.getVariable("vfModuleModelInfo")
1160 String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
1161 String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)
1162 String vfModuleEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vfModuleModelInfo)
1163 def globalSubscriberId = execution.getVariable("DCVFM_globalSubscriberId")
1164 boolean usePreload = execution.getVariable("DCVFM_usePreload")
1165 String usePreloadToSDNC = usePreload ? "Y" : "N"
1166 def modelCustomizationUuid = execution.getVariable("DCVFM_modelCustomizationUuid")
1167 def modelCustomizationUuidString = ""
1169 modelCustomizationUuidString = "<model-customization-uuid>" + modelCustomizationUuid + "</model-customization-uuid>"
1172 String sdncVNFParamsXml = ""
1174 if(execution.getVariable("DCVFM_vnfParamsExistFlag") == true){
1175 if (!sdncVersion.equals("1707")) {
1176 sdncVNFParamsXml = buildSDNCParamsXml(execution)
1179 sdncVNFParamsXml = buildCompleteSDNCParamsXml(execution)
1182 sdncVNFParamsXml = ""
1185 String sdncRequest = ""
1187 if (!sdncVersion.equals("1707")) {
1190 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
1191 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
1192 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
1193 <sdncadapter:RequestHeader>
1194 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
1195 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
1196 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
1197 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
1198 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
1199 </sdncadapter:RequestHeader>
1200 <sdncadapterworkflow:SDNCRequestData>
1201 <request-information>
1202 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
1203 <request-action>VNFActivateRequest</request-action>
1204 <source>${MsoUtils.xmlEscape(source)}</source>
1206 </request-information>
1207 <service-information>
1208 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
1209 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
1210 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
1211 <subscriber-name>notsurewecare</subscriber-name>
1212 </service-information>
1213 <vnf-request-information>
1214 <vnf-id>${MsoUtils.xmlEscape(vfModuleId)}</vnf-id>
1215 <vnf-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vnf-type>
1216 <vnf-name>${MsoUtils.xmlEscape(vfModuleName)}</vnf-name>
1217 <generic-vnf-id>${MsoUtils.xmlEscape(vnfId)}</generic-vnf-id>
1218 <generic-vnf-name>${MsoUtils.xmlEscape(vnfName)}</generic-vnf-name>
1219 <generic-vnf-type>${MsoUtils.xmlEscape(vnfType)}</generic-vnf-type>
1220 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
1221 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
1222 ${modelCustomizationUuidString}
1223 <use-preload>${MsoUtils.xmlEscape(usePreloadToSDNC)}</use-preload>
1225 </vnf-request-information>
1226 </sdncadapterworkflow:SDNCRequestData>
1227 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
1233 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
1234 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
1235 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
1236 <sdncadapter:RequestHeader>
1237 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
1238 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
1239 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
1240 <sdncadapter:SvcOperation>vf-module-topology-operation</sdncadapter:SvcOperation>
1241 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
1242 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
1243 </sdncadapter:RequestHeader>
1244 <sdncadapterworkflow:SDNCRequestData>
1245 <request-information>
1246 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
1247 <request-action>CreateVfModuleInstance</request-action>
1248 <source>${MsoUtils.xmlEscape(source)}</source>
1250 </request-information>
1251 <service-information>
1252 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
1253 <subscription-service-type>${MsoUtils.xmlEscape(serviceId)}</subscription-service-type>
1254 ${serviceEcompModelInformation}
1255 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
1256 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
1257 </service-information>
1259 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
1260 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
1261 ${vnfEcompModelInformation}
1263 <vf-module-information>
1264 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
1265 <vf-module-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vf-module-type>
1266 ${vfModuleEcompModelInformation}
1267 </vf-module-information>
1268 <vf-module-request-input>
1269 <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name>
1270 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
1271 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
1273 </vf-module-request-input>
1274 </sdncadapterworkflow:SDNCRequestData>
1275 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
1280 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
1281 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
1282 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
1283 <sdncadapter:RequestHeader>
1284 <sdncadapter:RequestId>${MsoUtils.xmlEscape(requestId)}</sdncadapter:RequestId>
1285 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
1286 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
1287 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
1288 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
1289 </sdncadapter:RequestHeader>
1290 <sdncadapterworkflow:SDNCRequestData>
1291 <request-information>
1292 <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
1293 <request-action>CreateVfModuleInstance</request-action>
1294 <source>${MsoUtils.xmlEscape(source)}</source>
1296 </request-information>
1297 <service-information>
1298 <service-id>${MsoUtils.xmlEscape(serviceId)}</service-id>
1299 <service-type>${MsoUtils.xmlEscape(serviceId)}</service-type>
1300 ${serviceEcompModelInformation}
1301 <service-instance-id>${MsoUtils.xmlEscape(svcInstId)}</service-instance-id>
1302 <global-customer-id>${MsoUtils.xmlEscape(globalSubscriberId)}</global-customer-id>
1303 </service-information>
1305 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
1306 <vnf-type>${MsoUtils.xmlEscape(vnfType)}</vnf-type>
1307 ${vnfEcompModelInformation}
1309 <vf-module-information>
1310 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
1311 <vf-module-type>${MsoUtils.xmlEscape(vfModuleModelName)}</vf-module-type>
1312 ${vfModuleEcompModelInformation}
1313 </vf-module-information>
1314 <vf-module-request-input>
1315 <vf-module-name>${MsoUtils.xmlEscape(vfModuleName)}</vf-module-name>
1316 <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
1317 <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>
1319 </vf-module-request-input>
1320 </sdncadapterworkflow:SDNCRequestData>
1321 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
1326 msoLogger.debug("sdncRequest: " + sdncRequest)
1331 public void preProcessSDNCActivateRequest(DelegateExecution execution) {
1332 def method = getClass().getSimpleName() + '.preProcessSDNCActivateRequest(' +
1333 'execution=' + execution.getId() +
1336 msoLogger.trace('Entered ' + method)
1337 execution.setVariable("prefix", Prefix)
1338 msoLogger.trace("STARTED preProcessSDNCActivateRequest Process")
1340 String vnfId = execution.getVariable("DCVFM_vnfId")
1341 String vfModuleId = execution.getVariable("DCVFM_vfModuleId")
1342 String serviceInstanceId = execution.getVariable("DCVFM_serviceInstanceId")
1345 if (serviceInstanceId == null || serviceInstanceId.isEmpty()) {
1346 svcInstId = vfModuleId
1349 svcInstId = serviceInstanceId
1351 String activateSDNCRequest = buildSDNCRequest(execution, svcInstId, "activate")
1353 execution.setVariable("DCVFM_activateSDNCRequest", activateSDNCRequest)
1354 msoLogger.debug("Outgoing CommitSDNCRequest is: \n" + activateSDNCRequest)
1356 }catch(Exception e){
1357 msoLogger.debug("Exception Occured Processing preProcessSDNCActivateRequest. Exception is:\n" + e)
1358 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessSDNCActivateRequest Method:\n" + e.getMessage())
1360 msoLogger.trace("COMPLETED preProcessSDNCActivateRequest Process")
1363 public void postProcessVNFAdapterRequest(DelegateExecution execution) {
1364 def method = getClass().getSimpleName() + '.postProcessVNFAdapterRequest(' +
1365 'execution=' + execution.getId() +
1368 msoLogger.trace('Entered ' + method)
1369 execution.setVariable("prefix",Prefix)
1371 msoLogger.debug("STARTED postProcessVNFAdapterRequest Process")
1373 String vnfResponse = execution.getVariable("DCVFM_createVnfAResponse")
1374 msoLogger.debug("VNF Adapter Response is: " + vnfResponse)
1376 RollbackData rollbackData = execution.getVariable("rollbackData")
1377 if(vnfResponse != null){
1379 if(vnfResponse.contains("createVfModuleResponse")){
1380 msoLogger.debug("Received a Good Response from VNF Adapter for CREATE_VF_MODULE Call.")
1381 execution.setVariable("DCVFM_vnfVfModuleCreateCompleted", true)
1382 String heatStackId = utils.getNodeText(vnfResponse, "vfModuleStackId")
1383 execution.setVariable("DCVFM_heatStackId", heatStackId)
1384 msoLogger.debug("Received heat stack id from VNF Adapter: " + heatStackId)
1385 rollbackData.put("VFMODULE", "heatstackid", heatStackId)
1386 // Parse vnfOutputs for network_fqdn
1387 if (vnfResponse.contains("vfModuleOutputs")) {
1388 def vfModuleOutputsXml = utils.getNodeXml(vnfResponse, "vfModuleOutputs")
1389 InputSource source = new InputSource(new StringReader(vfModuleOutputsXml));
1390 DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
1391 docFactory.setNamespaceAware(true)
1392 DocumentBuilder docBuilder = docFactory.newDocumentBuilder()
1393 Document outputsXml = docBuilder.parse(source)
1395 NodeList entries = outputsXml.getElementsByTagNameNS("*", "entry")
1396 List contrailNetworkPolicyFqdnList = []
1397 for (int i = 0; i< entries.getLength(); i++) {
1398 Node node = entries.item(i)
1399 if (node.getNodeType() == Node.ELEMENT_NODE) {
1400 Element element = (Element) node
1401 String key = element.getElementsByTagNameNS("*", "key").item(0).getTextContent()
1402 if (key.equals("contrail-service-instance-fqdn")) {
1403 String contrailServiceInstanceFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent()
1404 msoLogger.debug("Obtained contrailServiceInstanceFqdn: " + contrailServiceInstanceFqdn)
1405 execution.setVariable("DCVFM_contrailServiceInstanceFqdn", contrailServiceInstanceFqdn)
1407 else if (key.endsWith("contrail_network_policy_fqdn")) {
1408 String contrailNetworkPolicyFqdn = element.getElementsByTagNameNS("*", "value").item(0).getTextContent()
1409 msoLogger.debug("Obtained contrailNetworkPolicyFqdn: " + contrailNetworkPolicyFqdn)
1410 contrailNetworkPolicyFqdnList.add(contrailNetworkPolicyFqdn)
1412 else if (key.equals("oam_management_v4_address")) {
1413 String oamManagementV4Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent()
1414 msoLogger.debug("Obtained oamManagementV4Address: " + oamManagementV4Address)
1415 execution.setVariable("DCVFM_oamManagementV4Address", oamManagementV4Address)
1417 else if (key.equals("oam_management_v6_address")) {
1418 String oamManagementV6Address = element.getElementsByTagNameNS("*", "value").item(0).getTextContent()
1419 msoLogger.debug("Obtained oamManagementV6Address: " + oamManagementV6Address)
1420 execution.setVariable("DCVFM_oamManagementV6Address", oamManagementV6Address)
1425 if (!contrailNetworkPolicyFqdnList.isEmpty()) {
1426 execution.setVariable("DCVFM_contrailNetworkPolicyFqdnList", contrailNetworkPolicyFqdnList)
1430 msoLogger.debug("Received a BAD Response from VNF Adapter for CREATE_VF_MODULE Call.")
1431 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "VNF Adapter Error")
1434 msoLogger.debug("Response from VNF Adapter is Null for CREATE_VF_MODULE Call.")
1435 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Empty response from VNF Adapter")
1438 rollbackData.put("VFMODULE", "rollbackVnfAdapterCreate", "true")
1439 execution.setVariable("rollbackData", rollbackData)
1441 }catch(BpmnError b){
1443 }catch(Exception e){
1444 msoLogger.debug("Internal Error Occured in PostProcess Method")
1445 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Internal Error Occured in PostProcess Method")
1447 msoLogger.trace("COMPLETED postProcessVnfAdapterResponse Process")
1451 public void preProcessUpdateAAIVfModuleRequestOrch(DelegateExecution execution) {
1452 def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestOrch(' +
1453 'execution=' + execution.getId() +
1456 msoLogger.trace('Entered ' + method)
1457 execution.setVariable("prefix", Prefix)
1458 msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestOrch")
1462 //Build UpdateAAIVfModule Request
1463 boolean setContrailServiceInstanceFqdn = false
1464 def contrailServiceInstanceFqdn = execution.getVariable("DCVFM_contrailServiceInstanceFqdn")
1465 if (!contrailServiceInstanceFqdn.equals("")) {
1466 setContrailServiceInstanceFqdn = true
1469 execution.setVariable("DCVFM_orchestrationStatus", "Created")
1471 String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, true, setContrailServiceInstanceFqdn)
1473 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
1474 execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest)
1475 msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest)
1477 }catch(Exception e){
1478 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestOrch", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1479 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestOrch Method:\n" + e.getMessage())
1481 msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestOrch")
1485 public void preProcessUpdateAAIVfModuleRequestStatus(DelegateExecution execution, String status) {
1486 def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleStatus(' +
1487 'execution=' + execution.getId() +
1490 msoLogger.trace('Entered ' + method)
1491 execution.setVariable("prefix", Prefix)
1492 msoLogger.trace("STARTED preProcessUpdateAAIVfModuleStatus")
1496 //Build UpdateAAIVfModule Request
1497 execution.setVariable("DCVFM_orchestrationStatus", status)
1499 String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, false, true, false, false)
1501 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
1502 execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest)
1503 msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest)
1505 }catch(Exception e){
1506 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleStatus", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1507 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleStatus Method:\n" + e.getMessage())
1509 msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleStatus")
1514 public void preProcessUpdateAAIVfModuleRequestGroup(DelegateExecution execution) {
1515 def method = getClass().getSimpleName() + '.preProcessUpdateAAIVfModuleRequestGroup(' +
1516 'execution=' + execution.getId() +
1519 msoLogger.trace('Entered ' + method)
1520 execution.setVariable("prefix", Prefix)
1521 msoLogger.trace("STARTED preProcessUpdateAAIVfModuleRequestGroup")
1525 //Build UpdateAAIVfModule Request
1527 String updateAAIVfModuleRequest = buildUpdateAAIVfModuleRequest(execution, true, false, false, false)
1529 updateAAIVfModuleRequest = utils.formatXml(updateAAIVfModuleRequest)
1530 execution.setVariable("DCVFM_updateAAIVfModuleRequest", updateAAIVfModuleRequest)
1531 msoLogger.debug("Outgoing UpdateAAIVfModuleRequest is: \n" + updateAAIVfModuleRequest)
1533 }catch(Exception e){
1534 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessUpdateAAIVfModuleRequestGroup", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1535 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during preProcessUpdateAAIVfModuleRequestGroup Method:\n" + e.getMessage())
1537 msoLogger.trace("COMPLETED preProcessUpdateAAIVfModuleRequestGroup")
1541 public void validateSDNCResponse(DelegateExecution execution, String response, String method){
1543 execution.setVariable("prefix",Prefix)
1544 msoLogger.debug("STARTED ValidateSDNCResponse Process")
1546 WorkflowException workflowException = execution.getVariable("WorkflowException")
1547 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
1549 msoLogger.debug("workflowException: " + workflowException)
1551 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
1552 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
1554 String sdncResponse = response
1555 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
1556 msoLogger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call. Response is: \n" + sdncResponse)
1557 RollbackData rollbackData = execution.getVariable("rollbackData")
1559 if(method.equals("assign")){
1560 rollbackData.put("VFMODULE", "rollbackSDNCRequestAssign", "true")
1561 execution.setVariable("CRTGVNF_sdncAssignCompleted", true)
1563 else if (method.equals("activate")) {
1564 rollbackData.put("VFMODULE", "rollbackSDNCRequestActivate", "true")
1566 execution.setVariable("rollbackData", rollbackData)
1568 msoLogger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
1569 throw new BpmnError("MSOWorkflowException")
1571 msoLogger.trace("COMPLETED ValidateSDNCResponse Process")
1574 public void preProcessUpdateAfterCreateRequest(DelegateExecution execution){
1576 execution.setVariable("prefix", Prefix)
1577 msoLogger.trace("STARTED preProcessRequest Process")
1579 String response = execution.getVariable("DCVFM_assignSDNCAdapterResponse")
1580 msoLogger.debug("DCVFM_assignSDNCAdapterResponse: " + response)
1582 String data = utils.getNodeXml(response, "response-data")
1583 String vnfId = utils.getNodeText(data, "vnf-id")
1585 String uuid = execution.getVariable('testReqId') // for junits
1587 uuid = execution.getVariable("mso-request-id") + "-" + System.currentTimeMillis()
1590 String serviceOperation = "/VNF-API:vnfs/vnf-list/" + vnfId
1591 def callbackUrl = execution.getVariable("DCVFM_sdncCallbackUrl")
1592 msoLogger.debug("callbackUrl: " + callbackUrl)
1594 String SDNCGetRequest =
1595 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
1596 xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
1597 xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
1598 <sdncadapter:RequestHeader>
1599 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
1600 <sdncadapter:SvcAction>query</sdncadapter:SvcAction>
1601 <sdncadapter:SvcOperation>${MsoUtils.xmlEscape(serviceOperation)}</sdncadapter:SvcOperation>
1602 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackUrl)}</sdncadapter:CallbackUrl>
1603 <sdncadapter:MsoAction>mobility</sdncadapter:MsoAction>
1604 </sdncadapter:RequestHeader>
1605 <sdncadapterworkflow:SDNCRequestData></sdncadapterworkflow:SDNCRequestData>
1606 </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
1608 execution.setVariable("DCVFM_getSDNCRequest", SDNCGetRequest)
1609 msoLogger.debug("Outgoing GetSDNCRequest is: \n" + SDNCGetRequest)
1611 }catch(Exception e){
1612 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Exception Occured Processing preProcessSDNCGetRequest", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1613 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareProvision Method:\n" + e.getMessage())
1615 msoLogger.trace("COMPLETED preProcessSDNCGetRequest Process")
1618 public String buildUpdateAAIVfModuleRequest(DelegateExecution execution, boolean updateVolumeGroupId,
1619 boolean updateOrchestrationStatus, boolean updateHeatStackId, boolean updateContrailFqdn){
1621 def vnfId = execution.getVariable("DCVFM_vnfId")
1622 def vfModuleId = execution.getVariable("DCVFM_vfModuleId")
1623 def volumeGroupIdString = ""
1624 if (updateVolumeGroupId) {
1625 volumeGroupIdString = "<volume-group-id>" + execution.getVariable("DCVFM_volumeGroupId") +
1626 "</volume-group-id>"
1628 def orchestrationStatusString = ""
1629 if (updateOrchestrationStatus) {
1630 orchestrationStatusString = "<orchestration-status>" + execution.getVariable("DCVFM_orchestrationStatus") + "</orchestration-status>"
1632 def heatStackIdString = ""
1633 if (updateHeatStackId) {
1634 heatStackIdString = "<heat-stack-id>" + execution.getVariable("DCVFM_heatStackId") + "</heat-stack-id>"
1636 def contrailFqdnString = ""
1637 if (updateContrailFqdn) {
1638 contrailFqdnString = "<contrail-service-instance-fqdn>" + execution.getVariable("DCVFM_contrailServiceInstanceFqdn") +
1639 "</contrail-service-instance-fqdn>"
1642 String updateAAIVfModuleRequest =
1643 """<UpdateAAIVfModuleRequest>
1644 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
1645 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
1646 ${heatStackIdString}
1647 ${orchestrationStatusString}
1648 ${volumeGroupIdString}
1649 ${contrailFqdnString}
1650 </UpdateAAIVfModuleRequest>"""
1652 msoLogger.trace("updateAAIVfModule Request: " + updateAAIVfModuleRequest)
1653 return updateAAIVfModuleRequest
1657 public String buildSDNCParamsXml(DelegateExecution execution){
1660 StringBuilder sb = new StringBuilder()
1661 Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap")
1663 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
1665 String key = entry.getKey();
1666 if(key.endsWith("_network")){
1667 String requestKey = key.substring(0, key.indexOf("_network"))
1668 String requestValue = entry.getValue()
1671 <network-role>{ functx:substring-before-match(data($param/@name), '_network') }</network-role>
1672 <network-name>{ $param/text() }</network-name>
1677 params = sb.append(paramsXml)
1682 public String buildCompleteSDNCParamsXml(DelegateExecution execution){
1685 StringBuilder sb = new StringBuilder()
1686 Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap")
1688 for (Map.Entry<String, String> entry : paramsMap.entrySet()) {
1690 String key = entry.getKey();
1691 String value = entry.getValue()
1692 paramsXml = """<${key}>$value</$key>"""
1693 params = sb.append(paramsXml)
1698 public void queryCloudRegion (DelegateExecution execution) {
1700 execution.setVariable("prefix", Prefix)
1701 msoLogger.trace("STARTED queryCloudRegion")
1704 String cloudRegion = execution.getVariable("DCVFM_cloudSiteId")
1707 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
1708 AaiUtil aaiUtil = new AaiUtil(this)
1709 String aai_uri = aaiUtil.getCloudInfrastructureCloudRegionUri(execution)
1710 String queryCloudRegionRequest = "${aai_endpoint}${aai_uri}/" + cloudRegion
1712 execution.setVariable("DCVFM_queryCloudRegionRequest", queryCloudRegionRequest)
1713 msoLogger.debug("DCVFM_queryCloudRegionRequest - " + "\n" + queryCloudRegionRequest)
1715 cloudRegion = aaiUtil.getAAICloudReqion(execution, queryCloudRegionRequest, "PO", cloudRegion)
1717 if ((cloudRegion != "ERROR")) {
1718 if(execution.getVariable("DCVFM_queryCloudRegionReturnCode") == "404"){
1719 execution.setVariable("DCVFM_cloudRegionForVolume", "AAIAIC25")
1721 execution.setVariable("DCVFM_cloudRegionForVolume", cloudRegion)
1723 execution.setVariable("DCVFM_isCloudRegionGood", true)
1725 String errorMessage = "AAI Query Cloud Region Unsuccessful. AAI Response Code: " + execution.getVariable("DCVFM_queryCloudRegionReturnCode")
1726 msoLogger.debug(errorMessage)
1727 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, errorMessage)
1728 execution.setVariable("DCVFM_isCloudRegionGood", false)
1730 msoLogger.debug(" is Cloud Region Good: " + execution.getVariable("DCVFM_isCloudRegionGood"))
1732 } catch(BpmnError b){
1733 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "Rethrowing MSOWorkflowException", "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + b.getMessage());
1735 }catch (Exception ex) {
1737 String errorMessage = "Bpmn error encountered in CreateVfModule flow. Unexpected Response from AAI - " + ex.getMessage()
1738 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, "AAI Query Cloud Region Failed "+errorMessage, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + ex);
1739 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during queryCloudRegion method")
1745 *This method occurs when an MSOWorkflowException is caught. It logs the
1746 *variables and ensures that the "WorkflowException" Variable is set.
1749 public void processBPMNException(DelegateExecution execution){
1751 execution.setVariable("prefix",Prefix)
1753 msoLogger.debug("Caught a BPMN Exception")
1754 msoLogger.debug("Started processBPMNException Method")
1755 msoLogger.debug("Variables List: " + execution.getVariables())
1756 if(execution.getVariable("WorkflowException") == null){
1757 exceptionUtil.buildAndThrowWorkflowException(execution, 500, "Exception occured during DoCreateVfModule Sub Process")
1760 }catch(Exception e){
1761 msoLogger.debug("Caught Exception during processBPMNException Method: " + e)
1763 msoLogger.debug("Completed processBPMNException Method")
1766 public void prepareCreateAAIVfModuleVolumeGroupRequest(DelegateExecution execution) {
1767 def method = getClass().getSimpleName() + '.prepareCreateAAIVfModuleVolumeGroupRequest(' +
1768 'execution=' + execution.getId() +
1771 msoLogger.trace('Entered ' + method)
1772 execution.setVariable("prefix", Prefix)
1773 msoLogger.trace("STARTED prepareCreateAAIVfModuleVolumeGroupRequest")
1777 //Build CreateAAIVfModuleVolumeGroup Request
1779 def vnfId = execution.getVariable("DCVFM_vnfId")
1780 def vfModuleId = execution.getVariable("DCVFM_vfModuleId")
1781 def volumeGroupId = execution.getVariable("DCVFM_volumeGroupId")
1782 //def aicCloudRegion = execution.getVariable("DCVFM_cloudSiteId")
1783 def aicCloudRegion = execution.getVariable("DCVFM_cloudRegionForVolume")
1784 String createAAIVfModuleVolumeGroupRequest =
1785 """<CreateAAIVfModuleVolumeGroupRequest>
1786 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
1787 <vf-module-id>${MsoUtils.xmlEscape(vfModuleId)}</vf-module-id>
1788 <volume-group-id>${MsoUtils.xmlEscape(volumeGroupId)}</volume-group-id>
1789 <aic-cloud-region>${MsoUtils.xmlEscape(aicCloudRegion)}</aic-cloud-region>
1790 </CreateAAIVfModuleVolumeGroupRequest>"""
1792 createAAIVfModuleVolumeGroupRequest = utils.formatXml(createAAIVfModuleVolumeGroupRequest)
1793 execution.setVariable("DCVFM_createAAIVfModuleVolumeGroupRequest", createAAIVfModuleVolumeGroupRequest)
1794 msoLogger.debug("Outgoing CreateAAIVfModuleVolumeGroupRequest is: \n" + createAAIVfModuleVolumeGroupRequest)
1796 }catch(Exception e){
1797 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Exception Occured Processing prepareCreateAAIVfModuleVolumeGroupRequest', "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1798 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during prepareCreateAAIVfModuleVolumeGroupRequest Method:\n" + e.getMessage())
1800 msoLogger.trace("COMPLETED prepareCreateAAIVfModuleVolumeGroupRequest")
1804 public void createNetworkPoliciesInAAI(DelegateExecution execution) {
1805 def method = getClass().getSimpleName() + '.createNetworkPoliciesInAAI(' +
1806 'execution=' + execution.getId() +
1809 msoLogger.trace('Entered ' + method)
1810 execution.setVariable("prefix", Prefix)
1811 msoLogger.trace("STARTED createNetworkPoliciesInAAI")
1815 List fqdnList = execution.getVariable("DCVFM_contrailNetworkPolicyFqdnList")
1816 int fqdnCount = fqdnList.size()
1817 def rollbackData = execution.getVariable("rollbackData")
1819 execution.setVariable("DCVFM_networkPolicyFqdnCount", fqdnCount)
1820 msoLogger.debug("DCVFM_networkPolicyFqdnCount - " + fqdnCount)
1822 String aai_endpoint = UrnPropertiesReader.getVariable("aai.endpoint", execution)
1823 AaiUtil aaiUriUtil = new AaiUtil(this)
1824 String aai_uri = aaiUriUtil.getNetworkPolicyUri(execution)
1826 if (fqdnCount > 0) {
1828 // AII loop call over contrail network policy fqdn list
1829 for (i in 0..fqdnCount-1) {
1832 String fqdn = fqdnList[i]
1834 // Query AAI for this network policy FQDN
1836 String queryNetworkPolicyByFqdnAAIRequest = "${aai_endpoint}${aai_uri}?network-policy-fqdn=" + UriUtils.encode(fqdn, "UTF-8")
1838 def aaiRequestId = UUID.randomUUID().toString()
1839 RESTConfig config = new RESTConfig(queryNetworkPolicyByFqdnAAIRequest);
1840 RESTClient client = new RESTClient(config).addHeader("X-TransactionId", aaiRequestId)
1841 .addHeader("X-FromAppId", "MSO")
1842 .addHeader("Content-Type", "application/xml")
1843 .addHeader("Accept","application/xml");
1844 APIResponse response = client.get()
1845 int returnCode = response.getStatusCode()
1846 execution.setVariable("DCVFM_aaiQqueryNetworkPolicyByFqdnReturnCode", returnCode)
1847 msoLogger.debug(" ***** AAI query network policy Response Code, NetworkPolicy #" + counting + " : " + returnCode)
1849 String aaiResponseAsString = response.getResponseBodyAsString()
1851 if (isOneOf(returnCode, 200, 201)) {
1852 msoLogger.debug("The return code is: " + returnCode)
1853 // This network policy FQDN already exists in AAI
1854 execution.setVariable("DCVFM_queryNetworkPolicyByFqdnAAIResponse", aaiResponseAsString)
1855 msoLogger.debug(" QueryAAINetworkPolicyByFQDN Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsString)
1858 if (returnCode == 404) {
1859 // This network policy FQDN is not in AAI yet. Add it now
1860 msoLogger.debug("The return code is: " + returnCode)
1861 msoLogger.debug("This network policy FQDN is not in AAI yet: " + fqdn)
1862 // Add the network policy with this FQDN to AAI
1863 def networkPolicyId = UUID.randomUUID().toString()
1864 msoLogger.debug("Adding network-policy with network-policy-id " + networkPolicyId)
1866 String aaiNamespace = aaiUriUtil.getNamespaceFromUri(execution, aai_uri)
1867 msoLogger.debug('AAI namespace is: ' + aaiNamespace)
1868 String payload = """<network-policy xmlns="${aaiNamespace}">
1869 <network-policy-id>${MsoUtils.xmlEscape(networkPolicyId)}</network-policy-id>
1870 <network-policy-fqdn>${MsoUtils.xmlEscape(fqdn)}</network-policy-fqdn>
1871 <heat-stack-id>${MsoUtils.xmlEscape(execution.getVariable("DCVFM_heatStackId"))}</heat-stack-id>
1872 </network-policy>""" as String
1874 execution.setVariable("DCVFM_addNetworkPolicyAAIRequestBody", payload)
1876 String addNetworkPolicyAAIRequest = "${aai_endpoint}${aai_uri}/" + UriUtils.encode(networkPolicyId, "UTF-8")
1877 msoLogger.debug("AAI request endpoint: " + addNetworkPolicyAAIRequest)
1879 def aaiRequestIdPut = UUID.randomUUID().toString()
1880 RESTConfig configPut = new RESTConfig(addNetworkPolicyAAIRequest);
1881 RESTClient clientPut = new RESTClient(configPut).addHeader("X-TransactionId", aaiRequestIdPut)
1882 .addHeader("X-FromAppId", "MSO")
1883 .addHeader("Content-Type", "application/xml")
1884 .addHeader("Accept","application/xml");
1885 msoLogger.debug("invoking PUT call to AAI with payload:"+System.lineSeparator()+payload)
1886 APIResponse responsePut = clientPut.httpPut(payload)
1887 int returnCodePut = responsePut.getStatusCode()
1888 execution.setVariable("DCVFM_aaiAddNetworkPolicyReturnCode", returnCodePut)
1889 msoLogger.debug(" ***** AAI add network policy Response Code, NetworkPolicy #" + counting + " : " + returnCodePut)
1891 String aaiResponseAsStringPut = responsePut.getResponseBodyAsString()
1892 if (isOneOf(returnCodePut, 200, 201)) {
1893 msoLogger.debug("The return code from adding network policy is: " + returnCodePut)
1894 // This network policy was created in AAI successfully
1895 execution.setVariable("DCVFM_addNetworkPolicyAAIResponse", aaiResponseAsStringPut)
1896 msoLogger.debug(" AddAAINetworkPolicy Success REST Response, , NetworkPolicy #" + counting + " : " + "\n" + aaiResponseAsStringPut)
1897 rollbackData.put("VFMODULE", "rollbackCreateNetworkPoliciesAAI", "true")
1898 rollbackData.put("VFMODULE", "contrailNetworkPolicyFqdn" + i, fqdn)
1899 execution.setVariable("rollbackData", rollbackData)
1903 String putErrorMessage = "Unable to add network-policy to AAI createNetworkPoliciesInAAI - " + returnCodePut
1904 msoLogger.debug(putErrorMessage)
1905 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, putErrorMessage)
1909 if (aaiResponseAsString.contains("RESTFault")) {
1910 WorkflowException exceptionObject = exceptionUtil.MapAAIExceptionToWorkflowException(aaiResponseAsString, execution)
1911 execution.setVariable("WorkflowException", exceptionObject)
1912 throw new BpmnError("MSOWorkflowException")
1916 String dataErrorMessage = "Unexpected Response from createNetworkPoliciesInAAI - " + returnCode
1917 msoLogger.debug(dataErrorMessage)
1918 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, dataErrorMessage)
1928 msoLogger.debug("No contrail network policies to query/create")
1932 } catch (BpmnError e) {
1935 } catch (Exception ex) {
1936 String exceptionMessage = "Bpmn error encountered in DoCreateVfModule flow. createNetworkPoliciesInAAI() - " + ex.getMessage()
1937 msoLogger.debug(exceptionMessage)
1938 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, exceptionMessage)
1944 * Prepare a Request for invoking the UpdateAAIGenericVnf subflow.
1946 * @param execution The flow's execution instance.
1948 public void prepUpdateAAIGenericVnf(DelegateExecution execution) {
1949 def method = getClass().getSimpleName() + '.prepUpdateAAIGenericVnf(' +
1950 'execution=' + execution.getId() +
1953 msoLogger.trace('Entered ' + method)
1956 def rollbackData = execution.getVariable("rollbackData")
1957 def vnfId = execution.getVariable('DCVFM_vnfId')
1958 def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address")
1959 def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address")
1960 def ipv4OamAddressElement = ''
1961 def managementV6AddressElement = ''
1963 if (oamManagementV4Address != null && !oamManagementV4Address.isEmpty()) {
1964 ipv4OamAddressElement = '<ipv4-oam-address>' + oamManagementV4Address + '</ipv4-oam-address>'
1967 if (oamManagementV6Address != null && !oamManagementV6Address.isEmpty()) {
1968 managementV6AddressElement = '<management-v6-address>' + oamManagementV6Address + '</management-v6-address>'
1971 rollbackData.put("VFMODULE", "oamManagementV4Address", oamManagementV4Address)
1974 String updateAAIGenericVnfRequest = """
1975 <UpdateAAIGenericVnfRequest>
1976 <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
1977 ${ipv4OamAddressElement}
1978 ${managementV6AddressElement}
1979 </UpdateAAIGenericVnfRequest>
1981 updateAAIGenericVnfRequest = utils.formatXml(updateAAIGenericVnfRequest)
1982 execution.setVariable('DCVM_updateAAIGenericVnfRequest', updateAAIGenericVnfRequest)
1983 msoLogger.debug('Request for UpdateAAIGenericVnf:\n' + updateAAIGenericVnfRequest)
1986 msoLogger.trace('Exited ' + method)
1987 } catch (BpmnError e) {
1989 } catch (Exception e) {
1990 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, " Exception Encountered in " + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
1992 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in prepUpdateAAIGenericVnf(): ' + e.getMessage())
1997 * Post process a result from invoking the UpdateAAIGenericVnf subflow.
1999 * @param execution The flow's execution instance.
2001 public void postProcessUpdateAAIGenericVnf(DelegateExecution execution) {
2002 def method = getClass().getSimpleName() + '.postProcessUpdateAAIGenericVnf(' +
2003 'execution=' + execution.getId() +
2006 msoLogger.trace('Entered ' + method)
2009 def rollbackData = execution.getVariable("rollbackData")
2011 rollbackData.put("VFMODULE", "rollbackUpdateVnfAAI", "true")
2013 def vnfId = execution.getVariable('DCVFM_vnfId')
2014 def oamManagementV4Address = execution.getVariable("DCVFM_oamManagementV4Address")
2015 def oamManagementV6Address = execution.getVariable("DCVFM_oamManagementV6Address")
2016 def ipv4OamAddressElement = ''
2017 def managementV6AddressElement = ''
2019 if (oamManagementV4Address != null && !oamManagementV4Address.isEmpty()) {
2020 rollbackData.put("VFMODULE", "oamManagementV4Address", oamManagementV4Address)
2023 if (oamManagementV6Address != null && !oamManagementV6Address.isEmpty()) {
2024 rollbackData.put("VFMODULE", "oamManagementV6Address", oamManagementV6Address)
2027 execution.setVariable("rollbackData", rollbackData)
2029 msoLogger.trace('Exited ' + method)
2030 } catch (BpmnError e) {
2032 } catch (Exception e) {
2033 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in ' + method, "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
2034 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in postProcessUpdateAAIGenericVnf(): ' + e.getMessage())
2038 public void queryCatalogDB (DelegateExecution execution) {
2041 msoLogger.trace("queryCatalogDB ")
2044 boolean twoPhaseDesign = false
2047 String vfModuleModelName = execution.getVariable("DCVFM_vfModuleModelName")
2048 msoLogger.debug("vfModuleModelName: " + vfModuleModelName)
2049 def vnfModelInfo = execution.getVariable("vnfModelInfo")
2050 def vnfModelCustomizationUuid = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationUuid")
2052 msoLogger.debug("vnfModelCustomizationUuid: " + vnfModelCustomizationUuid)
2054 JSONArray vnfs = catalog.getAllVnfsByVnfModelCustomizationUuid(execution, vnfModelCustomizationUuid, "v2")
2056 msoLogger.debug("Incoming Query Catalog DB for Vnf Response is: " + vnfModelCustomizationUuid)
2057 // Only one match here
2059 JSONObject vnfObject = vnfs.get(0)
2060 if (vnfObject != null) {
2061 String vnfJson = vnfObject.toString()
2063 ObjectMapper om = new ObjectMapper();
2064 VnfResource vnf = om.readValue(vnfJson, VnfResource.class);
2066 // Get multiStageDesign flag
2068 String multiStageDesignValue = vnf.getMultiStageDesign()
2069 msoLogger.debug("multiStageDesign value from Catalog DB is: " + multiStageDesignValue)
2070 if (multiStageDesignValue != null) {
2071 if (multiStageDesignValue.equalsIgnoreCase("true")) {
2072 twoPhaseDesign = true
2078 msoLogger.debug("setting twoPhaseDesign flag to: " + twoPhaseDesign)
2080 execution.setVariable("DCVFM_twoPhaseDesign", twoPhaseDesign)
2081 } catch (BpmnError e) {
2083 } catch (Exception e) {
2084 msoLogger.error(MessageEnum.BPMN_GENERAL_EXCEPTION_ARG, 'Caught exception in queryCatalogDB', "BPMN", MsoLogger.getServiceName(),MsoLogger.ErrorCode.UnknownError, "Exception is:\n" + e);
2085 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryCatalogDB(): ' + e.getMessage())
2090 public void preProcessRollback (DelegateExecution execution) {
2092 msoLogger.trace("preProcessRollback")
2095 Object workflowException = execution.getVariable("WorkflowException");
2097 if (workflowException instanceof WorkflowException) {
2098 msoLogger.debug("Prev workflowException: " + workflowException.getErrorMessage())
2099 execution.setVariable("prevWorkflowException", workflowException);
2100 //execution.setVariable("WorkflowException", null);
2102 } catch (BpmnError e) {
2103 msoLogger.debug("BPMN Error during preProcessRollback")
2104 } catch(Exception ex) {
2105 String msg = "Exception in preProcessRollback. " + ex.getMessage()
2106 msoLogger.debug(msg)
2108 msoLogger.trace("Exit preProcessRollback")
2111 public void postProcessRollback (DelegateExecution execution) {
2113 msoLogger.trace("postProcessRollback")
2116 Object workflowException = execution.getVariable("prevWorkflowException");
2117 if (workflowException instanceof WorkflowException) {
2118 msoLogger.debug("Setting prevException to WorkflowException: ")
2119 execution.setVariable("WorkflowException", workflowException);
2121 execution.setVariable("rollbackData", null)
2122 } catch (BpmnError b) {
2123 msoLogger.debug("BPMN Error during postProcessRollback")
2125 } catch(Exception ex) {
2126 msg = "Exception in postProcessRollback. " + ex.getMessage()
2127 msoLogger.debug(msg)
2129 msoLogger.trace("Exit postProcessRollback")