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.MessageEnum
36 import org.onap.so.logger.MsoLogger
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) {
223 logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
224 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createGenericVnf.")
228 // construct and send a PUT request to A&AI to create a Base or Add-on VF Module
229 public void createVfModule(DelegateExecution execution, Boolean isBaseModule) {
230 // TBD - is this how we want to generate the Id for the new (Base) VF Module?
232 // Generate the new VF Module ID here if it has not been provided by the parent process
233 def newModuleId = execution.getVariable('newVfModuleId')
234 if (newModuleId == null || newModuleId.isEmpty()) {
235 newModuleId = UUID.randomUUID().toString()
238 String vnfId = execution.getVariable("CAAIVfMod_vnfId")
242 GenericVnf aaiVnfResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
243 moduleIndex = getLowestUnusedVfModuleIndexFromAAIVnfResponse(aaiVnfResponse,execution)
246 // if we get to this point, we may be about to create the Vf Module,
247 // add rollback information about the Generic VNF for this base/add-on module
248 def rollbackData = execution.getVariable("RollbackData")
249 if (rollbackData == null) {
250 rollbackData = new RollbackData();
252 rollbackData.put("VFMODULE", "vnfId", execution.getVariable("CAAIVfMod_vnfId"))
253 rollbackData.put("VFMODULE", "vnfName", execution.getVariable("CAAIVfMod_vnfName"))
254 rollbackData.put("VFMODULE", "isBaseModule", isBaseModule.toString())
255 execution.setVariable("RollbackData", rollbackData)
256 logger.debug("RollbackData:" + rollbackData)
258 org.onap.aai.domain.yang.VfModule vfModule = new org.onap.aai.domain.yang.VfModule()
259 vfModule.setVfModuleId(newModuleId)
260 vfModule.setVfModuleName(execution.getVariable("CAAIVfMod_moduleName"))
261 vfModule.setModelInvariantId(execution.getVariable("CAAIVfMod_personaId"))
262 vfModule.setModelVersionId(execution.getVariable("CAAIVfMod_personaVer"))
263 vfModule.setModelCustomizationId(execution.getVariable("CAAIVfMod_modelCustomizationId"))
264 vfModule.setIsBaseVfModule(isBaseModule)
265 vfModule.setOrchestrationStatus(OrchestrationStatus.PENDING_CREATE.toString())
266 vfModule.setModuleIndex(moduleIndex)
270 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, newModuleId)
271 getAAIClient().create(uri,vfModule)
273 execution.setVariable("CAAIVfMod_createVfModuleResponseCode", statusCode)
274 execution.setVariable("CAAIVfMod_createVfModuleResponse", "Vf Module Created")
277 // the base or add-on VF Module was successfully created,
278 // add the module name to the rollback data and the response
279 if (isOneOf(statusCode, 200, 201)) {
280 rollbackData.put("VFMODULE", "vfModuleId", newModuleId)
281 rollbackData.put("VFMODULE", "vfModuleName", execution.getVariable("CAAIVfMod_moduleName"))
282 execution.setVariable("RollbackData", rollbackData)
283 logger.debug("RollbackData:" + rollbackData)
285 String responseOut = ""
287 String isVidRequest = execution.getVariable("isVidRequest")
288 def moduleIndexString = String.valueOf(moduleIndex)
289 if (isBaseModule && (isVidRequest == null || "false".equals(isVidRequest))) {
291 responseOut = """<CreateAAIVfModuleResponse>
292 <vnf-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfId"))}</vnf-id>
293 <vf-module-id>${MsoUtils.xmlEscape(newModuleId)}</vf-module-id>
294 <vf-module-index>${MsoUtils.xmlEscape(moduleIndexString)}</vf-module-index>
295 </CreateAAIVfModuleResponse>""" as String
298 responseOut = """<CreateAAIVfModuleResponse>
299 <vnf-name>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfNameFromAAI"))}</vnf-name>
300 <vnf-id>${MsoUtils.xmlEscape(execution.getVariable("CAAIVfMod_vnfId"))}</vnf-id>
301 <vf-module-id>${MsoUtils.xmlEscape(newModuleId)}</vf-module-id>
302 <vf-module-index>${MsoUtils.xmlEscape(moduleIndexString)}</vf-module-index>
303 </CreateAAIVfModuleResponse>""" as String
306 execution.setVariable("CreateAAIVfModuleResponse", responseOut)
307 logger.debug("CreateAAIVfModuleResponse:" + System.lineSeparator()+responseOut)
308 logger.debug("CreateAAIVfModule Response /n " + responseOut)
310 } catch (Exception ex) {
311 execution.setVariable("CAAIVfMod_createVfModuleResponseCode", 500)
312 execution.setVariable("CAAIVfMod_createVfModuleResponse", ex.getMessage())
313 logger.debug("Exception occurred while executing AAI PUT:" + ex.getMessage())
314 exceptionUtil.buildAndThrowWorkflowException(execution, 5000, "Internal Error - Occured in createVfModule.")
318 private int getLowestUnusedVfModuleIndexFromAAIVnfResponse(GenericVnf genericVnf,DelegateExecution execution){
319 String personaModelId = execution.getVariable("CAAIVfMod_personaId")
320 if(genericVnf!=null && genericVnf.getVfModules()!= null &&
321 !genericVnf.getVfModules().getVfModule().isEmpty()){
322 Set<Integer> moduleIndices = new TreeSet<>()
323 for(org.onap.aai.domain.yang.VfModule vfModule in genericVnf.getVfModules().getVfModule()){
324 if(genericVnf.getModelInvariantId()==null){
325 if(vfModule.getPersonaModelVersion().equals(personaModelId) && vfModule.getModuleIndex()!=null)
326 moduleIndices.add(vfModule.getModuleIndex())
328 if(vfModule.getModelInvariantId().equals(personaModelId) && vfModule.getModuleIndex()!=null)
329 moduleIndices.add(vfModule.getModuleIndex())
332 for(i in 0..moduleIndices.size()-1){
333 if(moduleIndices.getAt(i) != i){
337 return moduleIndices.size()
344 // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name
345 // requested for an Add-on VF Module does not already exist for the specified Generic VNF
346 // also retrieves VNF name from AAI response for existing VNF
347 public void parseForAddOnModule(DelegateExecution execution) {
348 GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
349 def vnfNameFromAAI = genericVnf.getVnfName()
350 execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI)
351 logger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
352 def newModuleName = execution.getVariable("CAAIVfMod_moduleName")
353 logger.debug("VF Module to be added: " + newModuleName)
354 execution.setVariable("CAAIVfMod_moduleExists", false)
355 if (genericVnf !=null && genericVnf.getVfModules()!=null && !genericVnf.getVfModules().getVfModule().isEmpty()) {
356 def qryModuleList = genericVnf.getVfModules().getVfModule()
357 logger.debug("Existing VF Module List: " + qryModuleList)
358 for (org.onap.aai.domain.yang.VfModule qryModule : qryModuleList) {
359 def qryModuleName = qryModule.getVfModuleName()
360 if (newModuleName.equals(qryModuleName)) {
361 // a module with the requested name already exists - failure
362 logger.debug("VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
363 execution.setVariable("CAAIVfMod_moduleExists", true)
364 execution.setVariable("CAAIVfMod_parseModuleResponse",
365 "VF Module " + qryModuleName + " already exists for Generic VNF " + vnfNameFromAAI)
370 if (execution.getVariable("CAAIVfMod_moduleExists") == false) {
371 logger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + vnfNameFromAAI)
372 execution.setVariable("CAAIVfMod_parseModuleResponse",
373 "VF Module " + newModuleName + " does not exist for Generic VNF " + vnfNameFromAAI)
377 // parses the output from the result from queryAAIForGenericVnf() to determine if the vf-module-name
378 // requested for an Add-on VF Module does not already exist for the specified Generic VNF;
379 // also retrieves VNF name from AAI response for existing VNF
380 public void parseForBaseModule(DelegateExecution execution) {
381 GenericVnf genericVnf = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
382 def vnfNameFromAAI = genericVnf.getVnfName()
383 execution.setVariable("CAAIVfMod_vnfNameFromAAI", vnfNameFromAAI)
384 logger.debug("Obtained vnf-name from AAI for existing VNF: " + vnfNameFromAAI)
385 def newModuleName = execution.getVariable("CAAIVfMod_moduleName")
386 logger.debug("VF Module to be added: " + newModuleName)
387 def qryModuleList = genericVnf !=null ? genericVnf.getVfModules():null;
388 execution.setVariable("CAAIVfMod_moduleExists", false)
389 if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty()) {
390 def qryModules = qryModuleList.getVfModule()
391 logger.debug("Existing VF Module List: " + qryModules)
392 for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) {
393 if (newModuleName.equals(qryModule.getVfModuleName())) {
394 // a module with the requested name already exists - failure
395 logger.debug("VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
396 execution.setVariable("CAAIVfMod_baseModuleConflict", true)
397 execution.setVariable("CAAIVfMod_parseModuleResponse",
398 "VF Module " + qryModule.getVfModuleName() + " already exists for Generic VNF " + vnfNameFromAAI)
404 if (qryModuleList != null && !qryModuleList.getVfModule().isEmpty() && !execution.getVariable("CAAIVfMod_baseModuleConflict")) {
405 def qryModules = qryModuleList.getVfModule()
406 for (org.onap.aai.domain.yang.VfModule qryModule : qryModules) {
407 if (qryModule.isBaseVfModule) {
408 // a base module already exists in this VNF - failure
409 logger.debug("Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
410 execution.setVariable("CAAIVfMod_baseModuleConflict", true)
411 execution.setVariable("CAAIVfMod_parseModuleResponse",
412 "Base VF Module already exists for Generic VNF " + vnfNameFromAAI)
418 if (execution.getVariable("CAAIVfMod_baseModuleConflict") == false) {
419 logger.debug("VF Module " + execution.getVariable("CAAIVfMod_moduleName") + " does not exist for Generic VNF " + execution.getVariable("CAAIVfMod_vnfNameFromAAI"))
420 execution.setVariable("CAAIVfMod_parseModuleResponse",
421 "VF Module " + newModuleName + " does not exist for Generic VNF " + vnfNameFromAAI)
425 // generates a WorkflowException when the A&AI query returns a response code other than 200 or 404
426 public void handleAAIQueryFailure(DelegateExecution execution) {
427 logger.error("{} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
428 "Error occurred attempting to query AAI, Response Code " + execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") + ", Error Response " + execution.getVariable("CAAIVfMod_queryGenericVnfResponse"),
429 "BPMN", MsoLogger.getServiceName(), MsoLogger.ErrorCode.UnknownError.getValue());
430 int code = execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode")
431 exceptionUtil.buildAndThrowWorkflowException(execution, code, "Error occurred attempting to query AAI")
435 // generates a WorkflowException if
436 // - the A&AI Generic VNF PUT returns a response code other than 200 or 201
437 // - the requested Generic VNF already exists but vnf-id == null
438 // - the requested Generic VNF does not exist but vnf-id != null
439 // - the A&AI VF Module PUT returns a response code other than 200 or 201
440 // - the requested VF Module already exists for the Generic VNF
441 public void handleCreateVfModuleFailure(DelegateExecution execution) {
444 if (execution.getVariable("CAAIVfMod_createGenericVnfResponseCode") != null &&
445 !isOneOf(execution.getVariable("CAAIVfMod_createGenericVnfResponseCode"), 200, 201)) {
446 logger.debug("Failure creating Generic VNF: " + execution.getVariable("CAAIVfMod_createGenericVnfResponse"))
447 errorResponse = execution.getVariable("CAAIVfMod_createGenericVnfResponse")
449 } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponse") != null &&
450 execution.getVariable("CAAIVfMod_newGenericVnf") == true) {
451 // attempted to create a Generic VNF that already exists but vnf-id == null
452 logger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
453 errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
455 } else if (execution.getVariable("CAAIVfMod_queryGenericVnfResponseCode") == 404 &&
456 execution.getVariable("CAAIVfMod_newGenericVnf") == false) {
457 // attempted to create a Generic VNF where vnf-name does not exist but vnf-id != null
458 logger.debug(execution.getVariable("CAAIVfMod_queryGenericVnfResponse"))
459 errorResponse = execution.getVariable("CAAIVfMod_queryGenericVnfResponse")
461 } else if (execution.getVariable("CAAIVfMod_createVfModuleResponseCode") != null) {
462 logger.debug("Failed to add VF Module: " + execution.getVariable("CAAIVfMod_createVfModuleResponse"))
463 errorResponse = execution.getVariable("CAAIVfMod_createVfModuleResponse")
465 } else if (execution.getVariable("CAAIVfMod_moduleExists") == true) {
466 logger.debug("Attempting to add VF Module that already exists: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
467 errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse")
469 } else if (execution.getVariable("CAAIVfMod_baseModuleConflict") == true) {
470 logger.debug("Attempting to add Base VF Module to VNF that already has a Base VF Module: " + execution.getVariable("CAAIVfMod_parseModuleResponse"))
471 errorResponse = execution.getVariable("CAAIVfMod_parseModuleResponse")
474 // if the responses get populated corerctly, we should never get here
475 errorResponse = "Unknown error occurred during CreateAAIVfModule flow"
479 logger.error("{} {} {} {} {} {}", MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
480 "Error occurred during CreateAAIVfModule flow", "BPMN", MsoLogger.getServiceName(),
481 MsoLogger.ErrorCode.UnknownError.getValue(), errorResponse);
482 exceptionUtil.buildAndThrowWorkflowException(execution, errorCode, errorResponse)
483 logger.debug("Workflow exception occurred in CreateAAIVfModule: " + errorResponse)