2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Modifications Copyright (c) 2019 Samsung
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.so.bpmn.common.scripts
25 import org.apache.commons.lang.StringUtils
26 import org.camunda.bpm.engine.delegate.DelegateExecution
27 import org.onap.aai.domain.yang.GenericVnf
28 import org.onap.so.bpmn.core.RollbackData
29 import org.onap.so.client.aai.AAIObjectPlurals
30 import org.onap.so.client.aai.AAIObjectType
31 import org.onap.so.client.aai.entities.uri.AAIResourceUri
32 import org.onap.so.client.aai.entities.uri.AAIUriFactory
33 import org.onap.so.client.graphinventory.entities.uri.Depth
34 import org.onap.so.db.catalog.beans.OrchestrationStatus
35 import org.onap.so.logger.ErrorCode
36 import org.onap.so.logger.MessageEnum
37 import org.slf4j.Logger
38 import org.slf4j.LoggerFactory
40 public class CreateAAIVfModule extends AbstractServiceTaskProcessor{
41 private static final Logger logger = LoggerFactory.getLogger( CreateAAIVfModule.class);
43 def prefix="CAAIVfMod_"
44 ExceptionUtil exceptionUtil = new ExceptionUtil()
45 public void initProcessVariables(DelegateExecution execution) {
46 execution.setVariable("prefix",prefix)
47 execution.setVariable("CAAIVfMod_vnfId",null)
48 execution.setVariable("CAAIVfMod_vnfName",null)
49 execution.setVariable("CAAIVfMod_vnfType",null)
50 execution.setVariable("CAAIVfMod_serviceId",null)
51 execution.setVariable("CAAIVfMod_personaId",null)
52 execution.setVariable("CAAIVfMod_personaVer",null)
53 execution.setVariable("CAAIVfMod_modelCustomizationId",null)
54 execution.setVariable("CAAIVfMod_vnfPersonaId",null)
55 execution.setVariable("CAAIVfMod_vnfPersonaVer",null)
56 execution.setVariable("CAAIVfMod_isBaseVfModule", false)
57 execution.setVariable("CAAIVfMod_moduleName",null)
58 execution.setVariable("CAAIVfMod_moduleModelName",null)
59 execution.setVariable("CAAIVfMod_newGenericVnf",false)
60 execution.setVariable("CAAIVfMod_genericVnfGetEndpoint",null)
61 execution.setVariable("CAAIVfMod_genericVnfPutEndpoint",null)
62 execution.setVariable("CAAIVfMod_aaiNamespace",null)
63 execution.setVariable("CAAIVfMod_moduleExists",false)
64 execution.setVariable("CAAIVfMod_baseModuleConflict", false)
65 execution.setVariable("CAAIVfMod_vnfNameFromAAI", null)
68 // CreateAAIVfModule workflow response variable placeholders
69 execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode",null)
70 execution.setVariable("CAAIVfMod_queryGenericVnfResponse","")
71 execution.setVariable("CAAIVfMod_createGenericVnfResponseCode",null)
72 execution.setVariable("CAAIVfMod_createGenericVnfResponse","")
73 execution.setVariable("CAAIVfMod_createVfModuleResponseCode",null)
74 execution.setVariable("CAAIVfMod_createVfModuleResponse","")
75 execution.setVariable("CAAIVfMod_parseModuleResponse","")
76 execution.setVariable("CAAIVfMod_deleteGenericVnfResponseCode",null)
77 execution.setVariable("CAAIVfMod_deleteGenericVnfResponse","")
78 execution.setVariable("CAAIVfMod_deleteVfModuleResponseCode",null)
79 execution.setVariable("CAAIVfMod_deleteVfModuleResponse","")
80 execution.setVariable("CreateAAIVfModuleResponse","")
81 execution.setVariable("RollbackData", null)
85 // parse the incoming CREATE_VF_MODULE request and store the Generic VNF
86 // and VF Module data in the flow DelegateExecution
87 public void preProcessRequest(DelegateExecution execution) {
88 initProcessVariables(execution)
90 def vnfId = execution.getVariable("vnfId")
91 if (vnfId == null || vnfId.isEmpty()) {
92 execution.setVariable("CAAIVfMod_newGenericVnf", true)
93 execution.setVariable("CAAIVfMod_vnfId","")
96 execution.setVariable("CAAIVfMod_vnfId",vnfId)
99 def vnfName = execution.getVariable("vnfName")
100 execution.setVariable("CAAIVfMod_vnfName", vnfName)
102 String vnfType = execution.getVariable("vnfType")
103 execution.setVariable("CAAIVfMod_vnfType", StringUtils.defaultString(vnfType))
105 execution.setVariable("CAAIVfMod_serviceId", execution.getVariable("serviceId"))
107 String personaModelId = execution.getVariable("personaModelId")
108 execution.setVariable("CAAIVfMod_personaId",StringUtils.defaultString(personaModelId))
110 String personaModelVersion = execution.getVariable("personaModelVersion")
111 execution.setVariable("CAAIVfMod_personaVer", StringUtils.defaultString(personaModelVersion))
113 String modelCustomizationId = execution.getVariable("modelCustomizationId")
114 execution.setVariable("CAAIVfMod_modelCustomizationId",StringUtils.defaultString(modelCustomizationId))
116 String vnfPersonaModelId = execution.getVariable("vnfPersonaModelId")
117 execution.setVariable("CAAIVfMod_vnfPersonaId", StringUtils.defaultString(vnfPersonaModelId))
119 String vnfPersonaModelVersion = execution.getVariable("vnfPersonaModelVersion")
120 execution.setVariable("CAAIVfMod_vnfPersonaVer", StringUtils.defaultString(vnfPersonaModelVersion))
123 Boolean isBaseVfModule = false
124 String isBaseVfModuleString = execution.getVariable("isBaseVfModule")
125 if (isBaseVfModuleString != null && isBaseVfModuleString.equals("true")) {
126 isBaseVfModule = true
128 execution.setVariable("CAAIVfMod_isBaseVfModule", isBaseVfModule)
130 String isVidRequest = execution.getVariable("isVidRequest")
131 if (isVidRequest != null && "true".equals(isVidRequest)) {
132 logger.debug("VID Request received")
135 execution.setVariable("CAAIVfMod_moduleName",execution.getVariable("vfModuleName"))
136 execution.setVariable("CAAIVfMod_moduleModelName",execution.getVariable("vfModuleModelName"))
138 AaiUtil aaiUriUtil = new AaiUtil(this)
139 String aaiNamespace = aaiUriUtil.getNamespace()
140 logger.debug('AAI namespace is: ' + aaiNamespace)
142 execution.setVariable("CAAIVfMod_aaiNamespace",aaiNamespace)
146 // send a GET request to AA&I to retrieve the Generic VNF/VF Module information based on a Vnf Name
147 // expect a 200 response with the information in the response body or a 404 if the Generic VNF does not exist
148 public void queryAAIForGenericVnf(DelegateExecution execution) {
151 def vnfId = execution.getVariable("CAAIVfMod_vnfId")
152 def vnfName = execution.getVariable("CAAIVfMod_vnfName")
153 if (vnfId == null || vnfId.isEmpty()) {
154 uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.GENERIC_VNF)
155 uri.queryParam("vnf-name", vnfName)
157 uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId)
161 Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class, uri)
162 if(genericVnfOp.isPresent()){
163 execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 200)
164 execution.setVariable("CAAIVfMod_queryGenericVnfResponse", genericVnfOp.get())
166 execution.setVariable("CAAIVfMod_queryGenericVnfResponseCode", 404)
167 execution.setVariable("CAAIVfMod_queryGenericVnfResponse", "Generic Vnf not Found!")
169 } catch (Exception ex) {
170 logger.debug("Exception occurred while executing AAI GET:" + ex.getMessage())
171 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in queryAAIForGenericVnf.")
176 // process the result from queryAAIForGenericVnf()
177 // note: this method is primarily for logging as the actual decision logic is embedded in the bpmn flow
178 public void processAAIGenericVnfQuery(DelegateExecution execution) {
179 if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
180 execution.getVariable("CAAIVfMod_vnfId").isEmpty()) {
181 logger.debug("New Generic VNF requested and it does not already exist")
182 } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200 &&
183 !execution.getVariable("CAAIVfMod_vnfId").isEmpty()) {
184 logger.debug("Adding module to existing Generic VNF")
185 } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 200 &&
186 execution.getVariable("CAAIVfMod_vnfId").isEmpty()) {
187 logger.debug("Invalid request for new Generic VNF which already exists")
188 execution.setVariable("CAAIVfMod_queryGenericVnfResponse",
189 "Invalid request for new Generic VNF which already exists, Vnf Name=" +
190 execution.getVariable("CAAIVfMod_vnfName"))
191 } else { // execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
192 // !execution.getVariable("CAAIVfMod_vnfId").isEmpty())
193 logger.debug("Invalid request for Add-on Module requested for non-existant Generic VNF")
194 execution.setVariable("CAAIVfMod_createVfModuleResponse",
195 "Invalid request for Add-on Module requested for non-existant Generic VNF, VNF Id=" +
196 execution.getVariable("CAAIVfMod_vnfId"))
200 // construct and send a PUT request to A&AI to create a new Generic VNF
201 // note: to get here, the vnf-id in the original CREATE_VF_MODULE request was absent or ""
202 public void createGenericVnf(DelegateExecution execution) {
203 // TBD - is this how we want to generate the Id for the new Generic VNF?
204 def newVnfId = UUID.randomUUID().toString()
205 execution.setVariable("CAAIVfMod_vnfId",newVnfId)
207 GenericVnf genericVnf = new GenericVnf()
208 genericVnf.setVnfId(newVnfId)
209 genericVnf.setVnfName(execution.getVariable("CAAIVfMod_vnfName"))
210 genericVnf.setVnfType(execution.getVariable("CAAIVfMod_vnfType"))
211 genericVnf.setServiceId(execution.getVariable("CAAIVfMod_serviceId"))
212 genericVnf.setOrchestrationStatus(OrchestrationStatus.ACTIVE.toString())
213 genericVnf.setModelInvariantId(execution.getVariable("CAAIVfMod_vnfPersonaId"))
214 genericVnf.setModelVersionId(execution.getVariable("CAAIVfMod_vnfPersonaVer"))
217 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, newVnfId)
218 getAAIClient().create(uri,genericVnf)
219 execution.setVariable("CAAIVfMod_createGenericVnfResponseCode", 201)
220 execution.setVariable("CAAIVfMod_createGenericVnfResponse", "Vnf Created")
221 } catch (Exception ex) {
222 logger.debug("Exception occurred while executing AAI PUT: {}", ex.getMessage(), ex)
223 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createGenericVnf.")
227 // construct and send a PUT request to A&AI to create a Base or Add-on VF Module
228 public void createVfModule(DelegateExecution execution, Boolean isBaseModule) {
229 // TBD - is this how we want to generate the Id for the new (Base) VF Module?
231 // Generate the new VF Module ID here if it has not been provided by the parent process
232 def newModuleId = execution.getVariable('newVfModuleId')
233 if (newModuleId == null || newModuleId.isEmpty()) {
234 newModuleId = UUID.randomUUID().toString()
237 String vnfId = execution.getVariable("CAAIVfMod_vnfId")
241 GenericVnf aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
242 moduleIndex = getLowestUnusedVfModuleIndexFromAAIVnfResponse(aaiVnfResponse,execution)
245 // if we get to this point, we may be about to create the Vf Module,
246 // add rollback information about the Generic VNF for this base/add-on module
247 def rollbackData = execution.getVariable("RollbackData")
248 if (rollbackData == null) {
249 rollbackData = new RollbackData();
251 rollbackData.put("VFMODULE", "vnfId", execution.getVariable("CAAIVfMod_vnfId"))
252 rollbackData.put("VFMODULE", "vnfName", execution.getVariable("CAAIVfMod_vnfName"))
253 rollbackData.put("VFMODULE", "isBaseModule", isBaseModule.toString())
254 execution.setVariable("RollbackData", rollbackData)
255 logger.debug("RollbackData:" + rollbackData)
257 org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule()
258 vfModule.setVfModuleId(newModuleId)
259 vfModule.setVfModuleName(execution.getVariable("CAAIVfMod_moduleName"))
260 vfModule.setModelInvariantId(execution.getVariable("CAAIVfMod_personaId"))
261 vfModule.setModelVersionId(execution.getVariable("CAAIVfMod_personaVer"))
262 vfModule.setModelCustomizationId(execution.getVariable("CAAIVfMod_modelCustomizationId"))
263 vfModule.setIsBaseVfModule(isBaseModule)
264 vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_CREATE.toString())
265 vfModule.setModuleIndex(moduleIndex)
269 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId)
270 getAAIClient().create(uri,vfModule)
272 execution.setVariable("CAAIVfMod_createVfModuleResponseCode", statusCode)
273 execution.setVariable("CAAIVfMod_createVfModuleResponse", "Vf Module Created")
276 // the base or add-on VF Module was successfully created,
277 // add the module name to the rollback data and the response
278 if (isOneOf(statusCode, 200, 201)) {
279 rollbackData.put("VFMODULE", "vfModuleId", newModuleId)
280 rollbackData.put("VFMODULE", "vfModuleName", execution.getVariable("CAAIVfMod_moduleName"))
281 execution.setVariable("RollbackData", rollbackData)
282 logger.debug("RollbackData:" + rollbackData)
284 String responseOut = ""
286 String isVidRequest = execution.getVariable("isVidRequest")
287 def moduleIndexString = String.valueOf(moduleIndex)
288 if (isBaseModule && (isVidRequest == null || "false".equals(isVidRequest))) {
290 responseOut = """<CreateAAIVfModuleResponse>
291 <vnf-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfId"))}</vnf-id>
292 <vf-module-id>${MsoUtils.xmlEscape(newModuleId)}</vf-module-id>
293 <vf-module-index>${MsoUtils.xmlEscape(moduleIndexString)}</vf-module-index>
294 </CreateAAIVfModuleResponse>""" as String
297 responseOut = """<CreateAAIVfModuleResponse>
298 <vnf-name>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfNameFromAAI"))}</vnf-name>
299 <vnf-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfId"))}</vnf-id>
300 <vf-module-id>${MsoUtils.xmlEscape(newModuleId)}</vf-module-id>
301 <vf-module-index>${MsoUtils.xmlEscape(moduleIndexString)}</vf-module-index>
302 </CreateAAIVfModuleResponse>""" as String
305 execution.setVariable("CreateAAIVfModuleResponse", responseOut)
306 logger.debug("CreateAAIVfModuleResponse:" + System.lineSeparator()+responseOut)
307 logger.debug("CreateAAIVfModule Response /n " + responseOut)
309 } catch (Exception ex) {
310 execution.setVariable("CAAIVfMod_createVfModuleResponseCode", 500)
311 execution.setVariable("CAAIVfMod_createVfModuleResponse", ex.getMessage())
312 logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
313 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createVfModule.")
317 private int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf,DelegateExecution execution){
318 String personaModelId = execution.getVariable("CAAIVfMod_personaId")
319 if(genericVnf!=null && genericVnf.getVfModules()!= null &&
320 !genericVnf.getVfModules().getVfModule().isEmpty()){
321 Set<Integer> moduleIndices = new TreeSet<>()
322 for(org.onap.aai.domain.yang.VfModule vfModule in genericVnf.getVfModules().getVfModule()){
323 if(genericVnf.getModelInvariantId()==null){
324 if(vfModule.getPersonaModelVersion().equals(personaModelId) && vfModule.getModuleIndex()!=null)
325 moduleIndices.add(vfModule.getModuleIndex())
327 if(vfModule.getModelInvariantId().equals(personaModelId) && vfModule.getModuleIndex()!=null)
328 moduleIndices.add(vfModule.getModuleIndex())
331 for(i in 0..moduleIndices.size()-1){
332 if(moduleIndices.getAt(i) != i){
336 return moduleIndices.size()
343 // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name
344 // requested for an Add-on VF Module does not already exist for the specified Generic VNF
345 // also retrieves VNF name from AAI response for existing VNF
346 public void parseForAddOnModule(DelegateExecution execution) {
347 GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
348 def vnfNameFromAAI = genericVnf.getVnfName()
349 execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI)
350 logger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
351 def newModuleName = execution.getVariable("CAAIVfMod_moduleName")
352 logger.debug("VF Module to be added: " + newModuleName)
353 execution.setVariable("CAAIVfMod_moduleExists", false)
354 if (genericVnf !=null && genericVnf.getVfModules()!=null && !genericVnf.getVfModules().getVfModule().isEmpty()) {
355 def qryModuleList = genericVnf.getVfModules().getVfModule()
356 logger.debug("Existing VF Module List: " + qryModuleList)
357 for (org.onap.aai.domain.yang.VfModule qryModule : qryModuleList) {
358 def qryModuleName = qryModule.getVfModuleName()
359 if (newModuleName.equals(qryModuleName)) {
360 // a module with the requested name already exists - failure
361 logger.debug("VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
362 execution.setVariable("CAAIVfMod_moduleExists", true)
363 execution.setVariable("CAAIVfMod_parseModuleResponse",
364 "VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
369 if (execution.getVariable("CAAIVfMod_moduleExists") == false) {
370 logger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + vnfNameFromAAI)
371 execution.setVariable("CAAIVfMod_parseModuleResponse",
372 "VF Module " + newModuleName + " does not exist for Generic VNF " + vnfNameFromAAI)
376 // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name
377 // requested for an Add-on VF Module does not already exist for the specified Generic VNF;
378 // also retrieves VNF name from AAI response for existing VNF
379 public void parseForBaseModule(DelegateExecution execution) {
380 GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
381 def vnfNameFromAAI = genericVnf.getVnfName()
382 execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI)
383 logger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
384 def newModuleName = execution.getVariable("CAAIVfMod_moduleName")
385 logger.debug("VF Module to be added: " + newModuleName)
386 def qryModuleList = genericVnf !=null ? genericVnf.getVfModules():null;
387 execution.setVariable("CAAIVfMod_moduleExists", false)
388 if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty()) {
389 def qryModules = qryModuleList.getVfModule()
390 logger.debug("Existing VF Module List: " + qryModules)
391 for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) {
392 if (newModuleName.equals(qryModule.getVfModuleName())) {
393 // a module with the requested name already exists - failure
394 logger.debug("VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
395 execution.setVariable("CAAIVfMod_baseModuleConflict", true)
396 execution.setVariable("CAAIVfMod_parseModuleResponse",
397 "VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
403 if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty() && !execution.getVariable("CAAIVfMod_baseModuleConflict")) {
404 def qryModules = qryModuleList.getVfModule()
405 for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) {
406 if (qryModule.isBaseVfModule) {
407 // a base module already exists in this VNF - failure
408 logger.debug("Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
409 execution.setVariable("CAAIVfMod_baseModuleConflict", true)
410 execution.setVariable("CAAIVfMod_parseModuleResponse",
411 "Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
417 if (execution.getVariable("CAAIVfMod_baseModuleConflict") == false) {
418 logger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + execution.getVariable("CAAIVfMod_vnfNameFromAAI"))
419 execution.setVariable("CAAIVfMod_parseModuleResponse",
420 "VF Module " + newModuleName + " does not exist for Generic VNF " + vnfNameFromAAI)
424 // generates a WorkflowException when the A&AI query returns a response code other than 200 or 404
425 public void handleAAIQueryFailure(DelegateExecution execution) {
426 logger.error("{} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
427 "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("CAAIVfMod_queryGenericVnfResponse"),
428 "BPMN", ErrorCode.UnknownError.getValue());
429 int code = execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode")
430 exceptionUtil.buildAndThrowWorkflowException(execution, code, "Error occurred attempting to query AAI")
434 // generates a WorkflowException if
435 // - the A&AI Generic VNF PUT returns a response code other than 200 or 201
436 // - the requested Generic VNF already exists but vnf-id == null
437 // - the requested Generic VNF does not exist but vnf-id != null
438 // - the A&AI VF Module PUT returns a response code other than 200 or 201
439 // - the requested VF Module already exists for the Generic VNF
440 public void handleCreateVfModuleFailure(DelegateExecution execution) {
443 if (execution.getVariable("CAAIVfMod_createGenericVnfResponseCode") != null &&
444 !isOneOf(execution.getVariable("CAAIVfMod_createGenericVnfResponseCode"), 200, 201)) {
445 logger.debug("Failure creating Generic VNF: " + execution.getVariable("CAAIVfMod_createGenericVnfResponse"))
446 errorResponse = execution.getVariable("CAAIVfMod_createGenericVnfResponse")
448 } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponse") != null &&
449 execution.getVariable("CAAIVfMod_newGenericVnf") == true) {
450 // attempted to create a Generic VNF that already exists but vnf-id == null
451 logger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
452 errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
454 } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
455 execution.getVariable("CAAIVfMod_newGenericVnf") == false) {
456 // attempted to create a Generic VNF where vnf-name does not exist but vnf-id != null
457 logger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
458 errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
460 } else if (execution.getVariable("CAAIVfMod_createVfModuleResponseCode") != null) {
461 logger.debug("Failed to add VF Module: " + execution.getVariable("CAAIVfMod_createVfModuleResponse"))
462 errorResponse = execution.getVariable("CAAIVfMod_createVfModuleResponse")
464 } else if (execution.getVariable("CAAIVfMod_moduleExists") == true) {
465 logger.debug("Attempting to add VF Module that already exists: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
466 errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse")
468 } else if (execution.getVariable("CAAIVfMod_baseModuleConflict") == true) {
469 logger.debug("Attempting to add Base VF Module to VNF that already has a Base VF Module: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
470 errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse")
473 // if the responses get populated corerctly, we should never get here
474 errorResponse = "Unknown error occurred during CreateAAIVfModule flow"
478 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
479 "Error occurred during CreateAAIVfModule flow", "BPMN",
480 ErrorCode.UnknownError.getValue(), errorResponse);
481 exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse)
482 logger.debug("Workflow exception occurred in CreateAAIVfModule: " + errorResponse)