Merge "Sonar fixes"
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoDeleteVnfAndModules.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
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=========================================================
21  */
22
23 package org.onap.so.bpmn.infrastructure.scripts
24
25 import org.onap.so.logger.LoggingAnchor
26 import org.onap.aai.domain.yang.GenericVnf
27 import org.onap.aai.domain.yang.VfModule
28 import org.camunda.bpm.engine.delegate.BpmnError
29 import org.camunda.bpm.engine.delegate.DelegateExecution;
30 import org.json.JSONArray;
31 import org.json.JSONObject
32 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
33 import org.onap.so.bpmn.common.scripts.ExceptionUtil
34 import org.onap.so.bpmn.common.scripts.MsoUtils
35 import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
36 import org.onap.so.bpmn.common.scripts.VidUtils
37 import org.onap.so.bpmn.core.UrnPropertiesReader
38 import org.onap.so.bpmn.core.WorkflowException
39 import org.onap.so.bpmn.core.domain.ModelInfo
40 import org.onap.so.bpmn.core.domain.ModuleResource
41 import org.onap.so.bpmn.core.domain.ServiceDecomposition
42 import org.onap.so.bpmn.core.domain.VnfResource
43 import org.onap.so.bpmn.core.json.JsonUtils
44 import org.onap.aaiclient.client.graphinventory.entities.uri.Depth
45 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
46 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
47 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
48 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
49 import org.onap.aaiclient.client.aai.AAIObjectType
50 import org.onap.logging.filter.base.ErrorCode
51 import org.onap.so.logger.MessageEnum
52 import org.slf4j.Logger
53 import org.slf4j.LoggerFactory
54
55 /**
56  * This class supports the macro VID Flow
57  * with the deletion of a generic vnf and related VF modules.
58  */
59 class DoDeleteVnfAndModules extends AbstractServiceTaskProcessor {
60     private static final Logger logger = LoggerFactory.getLogger( DoDeleteVnfAndModules.class);
61
62         String Prefix="DDVAM_"
63         ExceptionUtil exceptionUtil = new ExceptionUtil()
64         JsonUtils jsonUtil = new JsonUtils()
65         VidUtils vidUtils = new VidUtils(this)
66         SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
67
68         /**
69          * This method gets and validates the incoming
70          * request.
71          *
72          * @param - execution
73          *      
74          */
75         public void preProcessRequest(DelegateExecution execution) {
76
77                 execution.setVariable("prefix",Prefix)
78                 logger.trace("STARTED DoDeleteVnfAndModules PreProcessRequest Process")
79
80                 try{
81                         // Get Variables                                
82                         
83                         String cloudConfiguration = execution.getVariable("cloudConfiguration")         
84                         logger.debug("Cloud Configuration: " + cloudConfiguration)      
85                         
86                         String requestId = execution.getVariable("msoRequestId")
87                         execution.setVariable("requestId", requestId)                   
88                         execution.setVariable("mso-request-id", requestId)
89                         logger.debug("Incoming Request Id is: " + requestId)
90
91                         String serviceInstanceId = execution.getVariable("serviceInstanceId")                   
92                         logger.debug("Incoming Service Instance Id is: " + serviceInstanceId)
93
94                         String vnfId = execution.getVariable("vnfId")                   
95                         logger.debug("Incoming Vnf Id is: " + vnfId)                    
96                         
97                         String source = "VID"
98                         execution.setVariable("DDVAM_source", source)
99                         logger.debug("Incoming Source is: " + source)
100                         
101                         execution.setVariable("DDVAM_isVidRequest", "true")
102                         
103                         String sdncVersion = execution.getVariable("sdncVersion")
104                         if (sdncVersion == null) {
105                                 sdncVersion = "1702"
106                         }
107                         execution.setVariable("DDVAM_sdncVersion", sdncVersion)
108                         logger.debug("Incoming Sdnc Version is: " + sdncVersion)
109                         
110                         // Set aLaCarte flag to false
111                         execution.setVariable("aLaCarte", false)
112                         
113                         String sdncCallbackUrl = (String) UrnPropertiesReader.getVariable("mso.workflow.sdncadapter.callback", execution)
114                         if (sdncCallbackUrl == null || sdncCallbackUrl.trim().isEmpty()) {
115                                 def msg = 'Required variable \'mso.workflow.sdncadapter.callback\' is missing'
116                                 logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
117                                                 ErrorCode.UnknownError.getValue(), "Exception");
118                                 exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
119                         }
120                         execution.setVariable("sdncCallbackUrl", sdncCallbackUrl)
121                         logger.debug("SDNC Callback URL: " + sdncCallbackUrl)
122                         logger.debug("SDNC Callback URL is: " + sdncCallbackUrl)        
123                         
124                         
125                         if (!sdncVersion.equals("1702")) {
126                                 //String vnfModelInfo = execution.getVariable("vnfModelInfo")
127                                 //String serviceModelInfo = execution.getVariable("serviceModelInfo")
128                                 
129                                 String serviceId = execution.getVariable("productFamilyId")
130                                 execution.setVariable("DDVAM_serviceId", serviceId)
131                                 logger.debug("Incoming Service Id is: " + serviceId)
132                                 
133                                         
134                                 //String modelInvariantId = jsonUtil.getJsonValue(vnfModelInfo, "modelInvariantId")
135                                 //execution.setVariable("DDVAM_modelInvariantId", modelInvariantId)
136                                 //logger.debug("Incoming Invariant Id is: " + modelInvariantId)
137                                 
138                                 //String modelVersionId = jsonUtil.getJsonValue(vnfModelInfo, "modelVersionId")
139                                 //if (modelVersionId == null) {
140                                 //      modelVersionId = ""
141                                 //}
142                                 //execution.setVariable("DDVAM_modelVersionId", modelVersionId)
143                                 //logger.debug("Incoming Version Id is: " + modelVersionId)
144         
145                                 //String modelVersion = jsonUtil.getJsonValue(vnfModelInfo, "modelVersion")
146                                 //execution.setVariable("DDVAM_modelVersion", modelVersion)
147                                 //logger.debug("Incoming Model Version is: " + modelVersion)
148                                 
149                                 //String modelName = jsonUtil.getJsonValue(vnfModelInfo, "modelName")
150                                 //execution.setVariable("DDVAM_modelName", modelName)
151                                 //logger.debug("Incoming Model Name is: " + modelName)
152                                 
153                                 //String modelCustomizationId = jsonUtil.getJsonValue(vnfModelInfo, "modelCustomizationId")
154                                 //if (modelCustomizationId == null) {
155                                 //      modelCustomizationId = ""
156                                 //}
157                                 //execution.setVariable("DDVAM_modelCustomizationId", modelCustomizationId)
158                                 //logger.debug("Incoming Model Customization Id is: " + modelCustomizationId)
159                                         
160                                 String cloudSiteId = execution.getVariable("lcpCloudRegionId")
161                                 execution.setVariable("DDVAM_cloudSiteId", cloudSiteId)
162                                 logger.debug("Incoming Cloud Site Id is: " + cloudSiteId)
163                                         
164                                 String tenantId = execution.getVariable("tenantId")
165                                 execution.setVariable("DDVAM_tenantId", tenantId)
166                                 logger.debug("Incoming Tenant Id is: " + tenantId)
167                                 
168                                 String globalSubscriberId = execution.getVariable("globalSubscriberId")
169                                 if (globalSubscriberId == null) {
170                                         globalSubscriberId = ""
171                                 }
172                                 execution.setVariable("DDVAM_globalSubscriberId", globalSubscriberId)
173                                 logger.debug("Incoming Global Subscriber Id is: " + globalSubscriberId)         
174                                 
175                         }
176                         execution.setVariable("DDVAM_vfModulesFromDecomposition", null)
177                         // Retrieve serviceDecomposition if present
178                         ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
179                         if (serviceDecomposition != null) {
180                                 logger.debug("Getting Catalog DB data from ServiceDecomposition object: " + serviceDecomposition.toJsonString())
181                                 List<VnfResource> vnfs = serviceDecomposition.getVnfResources()
182                                 logger.debug("Read vnfs")
183                                 if (vnfs == null) {
184                                         logger.debug("Error - vnfs are empty in serviceDecomposition object")
185                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnfs are empty")
186                                 }
187                                 VnfResource vnf = vnfs[0]
188                                 
189                                 if (vnf == null) {
190                                         logger.debug("Error - vnf is empty in serviceDecomposition object")
191                                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in preProcessRequest - vnf is empty")
192                                 }
193                                 
194                                 List<ModuleResource> vfModules = vnf.getAllVfModuleObjects()
195                                 
196                                 execution.setVariable("DDVAM_vfModulesFromDecomposition", vfModules)                            
197                         }
198                         
199                         execution.setVariable("DDVAM_moduleCount", 0)
200                         execution.setVariable("DDVAM_nextModule", 0)
201                         
202                         
203                 }catch(BpmnError b){
204                         logger.debug("Rethrowing MSOWorkflowException")
205                         throw b
206                 }catch(Exception e){
207                         logger.debug(" Error Occured in DoCreateVnfAndModules PreProcessRequest method!" + e.getMessage())
208                         exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Internal Error - Occured in DoCreateVnf PreProcessRequest")
209
210                 }
211                 logger.trace("COMPLETED DoDeleteVnfAndModules PreProcessRequest Process ")
212         }       
213
214         
215         
216         public void preProcessAddOnModule(DelegateExecution execution){
217
218                 execution.setVariable("prefix", Prefix)
219                 logger.trace("STARTED preProcessAddOnModule ")
220                 
221                 try {                   
222                         JSONArray addOnModules = (JSONArray) execution.getVariable("addOnModules")
223                         int addOnIndex = (int) execution.getVariable("addOnModulesDeployed")
224                         
225                         JSONObject addOnModule = addOnModules[addOnIndex]
226                         
227                         def newVfModuleId = UUID.randomUUID().toString()
228                         execution.setVariable("addOnVfModuleId", newVfModuleId)
229                         
230                         execution.setVariable("instancesOfThisModelDeployed", 0)
231                         
232                         JSONObject addOnVfModuleModelInfoObject = jsonUtil.getJsonValueForKey(addOnModule, "modelInfo")
233                         String addOnVfModuleModelInfo = addOnVfModuleModelInfoObject.toString()
234                         execution.setVariable("addOnVfModuleModelInfo", addOnVfModuleModelInfo)
235                         String addOnVfModuleLabel = jsonUtil.getJsonValueForKey(addOnModule, "vfModuleLabel")
236                         execution.setVariable("addOnVfModuleLabel", addOnVfModuleLabel)
237                         String addOnPersonaModelId = jsonUtil.getJsonValueForKey(addOnVfModuleModelInfoObject, "modelInvariantUuid")
238                         execution.setVariable("addOnPersonaModelId", addOnPersonaModelId)
239                         String addOnInitialCount = jsonUtil.getJsonValueForKey(addOnModule, "initialCount")
240                         execution.setVariable("initialCount", addOnInitialCount)
241                                         
242                 
243                 }catch(Exception e){
244                         logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
245                                         "Exception Occured Processing preProcessAddOnModule." + e, "BPMN",
246                                         ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
247                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessAddOnModule Method:\n" + e.getMessage())
248                 }
249                 logger.trace("COMPLETED preProcessSDNCAssignRequest ")
250         }
251         
252         /**
253          * Using the received vnfId and vfModuleId, query AAI to get the corresponding VNF info.
254          * A 200 response is expected with the VNF info in the response body. Will find out the base module info.
255          *
256          * @param execution The flow's execution instance.
257          */
258         public void queryAAIVfModule(DelegateExecution execution) {
259
260                 def method = getClass().getSimpleName() + '.queryAAIVfModule(' +
261                         'execution=' + execution.getId() +
262                         ')'
263                 logger.trace('Entered ' + method)
264
265                 try {
266                         def vnfId = execution.getVariable('vnfId')
267                         
268                         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)).depth(Depth.ONE)
269
270                         try {
271                                 Optional<GenericVnf> genericVnfOp = getAAIClient().get(GenericVnf.class,uri)
272                                 //Map<String, String>[] vfModules = new HashMap<String,String>[]
273                                 List<ModuleResource> vfModulesFromDecomposition = execution.getVariable("DDVAM_vfModulesFromDecomposition")
274                                 def vfModulesList = new ArrayList<Map<String,String>>()
275                                 def vfModuleBaseEntry = null
276                                 if (genericVnfOp.isPresent()) {
277                                         execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 200)
278                                         execution.setVariable('DCVFM_queryAAIVfModuleResponse', genericVnfOp.get())
279
280                                         // Parse the VNF record from A&AI to find base module info
281                                                 if (genericVnfOp.get().getVfModules()!= null && !genericVnfOp.get().getVfModules().getVfModule().isEmpty() ) {
282                                                         List<VfModule> vfModules = genericVnfOp.get().getVfModules().getVfModule()
283                                                         execution.setVariable("DDVAM_moduleCount", vfModules.size())
284                                                         ModelInfo vfModuleModelInfo = null
285                                                         for (VfModule vfModule : vfModules) {
286                                                                 Map<String, String> vfModuleEntry = new HashMap<String, String>()
287                                                                 vfModuleEntry.put("vfModuleId", vfModule.getVfModuleId())
288                                                                 vfModuleEntry.put("vfModuleName", vfModule.getVfModuleName())
289                                                                 
290                                                                 // Find the model for this vf module in decomposition if specified
291                                                                 if (vfModulesFromDecomposition != null) {
292                                                                         logger.debug("vfModulesFromDecomposition is not null")
293                                                                         def vfModuleUuid = vfModule.getModelVersionId()
294                                                                         if (vfModuleUuid == null) {
295                                                                                 vfModuleUuid = vfModule.getPersonaModelVersion()
296                                                                         }
297                                                                         logger.debug("vfModule UUID is: " + vfModuleUuid)
298                                                                         for (j in 0..vfModulesFromDecomposition.size()-1) {
299                                                                                 ModuleResource mr = vfModulesFromDecomposition[j]
300                                                                                 if (mr.getModelInfo().getModelUuid() == vfModuleUuid) {
301                                                                                         logger.debug("Found modelInfo")
302                                                                                         vfModuleModelInfo = mr.getModelInfo()
303                                                                                         break                                                                                   
304                                                                                 }
305                                                                                 
306                                                                         }                                                                       
307                                                                 }
308                                                                 if (vfModuleModelInfo != null) {
309                                                                         String vfModuleModelInfoString = vfModuleModelInfo.toString()
310                                                                         def vfModuleModelInfoValue = jsonUtil.getJsonValue(vfModuleModelInfoString, "modelInfo")
311                                                                         vfModuleEntry.put("vfModuleModelInfo", vfModuleModelInfoValue)
312                                                                 }
313                                                                 else {
314                                                                         vfModuleEntry.put("vfModuleModelInfo", null)
315                                                                 }
316                                                                 
317                                                                 
318                                                                 // Save base vf module for last
319                                                                 if (vfModule.isIsBaseVfModule()) {
320                                                                         vfModuleBaseEntry = vfModuleEntry
321                                                                 }
322                                                                 else {                                          
323                                                                         vfModulesList.add(vfModuleEntry)
324                                                                 }
325                                                         }
326                                                         if (vfModuleBaseEntry != null) {
327                                                                 vfModulesList.add(vfModuleBaseEntry)
328                                                         }
329                                                 }
330                                 }else{
331                                         execution.setVariable('DCVFM_queryAAIVfModuleResponseCode', 404)
332                                         execution.setVariable('DCVFM_queryAAIVfModuleResponse', "Generic Vnf not found")
333
334                                 }
335                                 execution.setVariable("DDVAM_vfModules", vfModulesList)
336                         } catch (Exception ex) {
337                                 logger.debug('Exception occurred while executing AAI GET: {}', ex.getMessage(), ex)
338                                 exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'AAI GET Failed:' + ex.getMessage())
339                         }
340                         logger.trace('Exited ' + method)
341                 } catch (BpmnError e) {
342                         throw e;
343                 } catch (Exception e) {
344                         logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
345                                         'Caught exception in ' + method, "BPMN",
346                                         ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
347                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in queryAAIVfModule(): ' + e.getMessage())
348                 }
349         }
350         
351         public void prepareNextModuleToDelete(DelegateExecution execution){
352
353                 execution.setVariable("prefix", Prefix)
354                 logger.trace("STARTED prepareNextModuleToDelete ")
355                 
356                 try {
357                         int i = execution.getVariable("DDVAM_nextModule")
358                         def vfModules = execution.getVariable("DDVAM_vfModules")
359                         def vfModule = vfModules[i]
360                         
361                         def vfModuleId = vfModule.get("vfModuleId")
362                         execution.setVariable("DDVAM_vfModuleId", vfModuleId)
363                         
364                         def vfModuleName = vfModule.get("vfModuleName")
365                         execution.setVariable("DDVAM_vfModuleName", vfModuleName)                       
366                         
367                         def vfModuleModelInfo = vfModule.get("vfModuleModelInfo")
368                         logger.debug("vfModuleModelInfo for module delete: " + vfModuleModelInfo)
369                         execution.setVariable("DDVAM_vfModuleModelInfo", vfModuleModelInfo)                     
370                         
371                 }catch(Exception e){
372                         logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
373                                         "Exception Occured Processing preProcessAddOnModule." + e, "BPMN",
374                                         ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
375                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during prepareNextModuleToDelete Method:\n" + e.getMessage())
376                 }
377                 logger.trace("COMPLETED prepareNextModuleToDelete ")
378         }
379         
380         public void preProcessSDNCDeactivateRequest(DelegateExecution execution){
381
382                 execution.setVariable("prefix", Prefix)
383                 logger.trace("STARTED preProcessSDNCDeactivateRequest ")
384                 def vnfId = execution.getVariable("vnfId")
385                 def serviceInstanceId = execution.getVariable("serviceInstanceId")              
386
387                 try{
388                         //Build SDNC Request
389                         
390                         String deactivateSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "deactivate")
391
392                         deactivateSDNCRequest = utils.formatXml(deactivateSDNCRequest)
393                         execution.setVariable("DDVAM_deactivateSDNCRequest", deactivateSDNCRequest)
394                         logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
395                         logger.debug("Outgoing DeactivateSDNCRequest is: \n" + deactivateSDNCRequest)
396
397                 }catch(Exception e){
398                         logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
399                                         "Exception Occured Processing preProcessSDNCDeactivateRequest." + e, "BPMN",
400                                         ErrorCode.UnknownError.getValue(), "Exception is:\n" + e);
401                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occurred during preProcessSDNCDeactivateRequest Method:\n" + e.getMessage())
402                 }
403                 logger.trace("COMPLETED preProcessSDNCDeactivateRequest ")
404         }
405         
406         public void preProcessSDNCUnassignRequest(DelegateExecution execution) {
407                 def method = getClass().getSimpleName() + '.preProcessSDNCUnassignRequest(' +
408                         'execution=' + execution.getId() +
409                         ')'
410
411                 logger.trace('Entered ' + method)
412                 execution.setVariable("prefix", Prefix)
413                 logger.trace("STARTED preProcessSDNCUnassignRequest Process ")
414                 try{
415                         String vnfId = execution.getVariable("vnfId")
416                         String serviceInstanceId = execution.getVariable("serviceInstanceId")
417
418                         String unassignSDNCRequest = buildSDNCRequest(execution, serviceInstanceId, "unassign")
419
420                         execution.setVariable("DDVAM_unassignSDNCRequest", unassignSDNCRequest)
421                         logger.debug("Outgoing UnassignSDNCRequest is: \n" + unassignSDNCRequest)
422                         logger.debug("Outgoing UnassignSDNCRequest is: \n"  + unassignSDNCRequest)
423
424                 }catch(Exception e){
425                         logger.debug("Exception Occured Processing preProcessSDNCUnassignRequest. Exception is:\n" + e)
426                         exceptionUtil.buildAndThrowWorkflowException(execution, 1002, "Error Occured during  preProcessSDNCUnassignRequest Method:\n" + e.getMessage())
427                 }
428                 logger.trace("COMPLETED  preProcessSDNCUnassignRequest Process ")
429         }
430         
431         public String buildSDNCRequest(DelegateExecution execution, String svcInstId, String action){
432                 
433                                 String uuid = execution.getVariable('testReqId') // for junits
434                                 if(uuid==null){
435                                         uuid = execution.getVariable("msoRequestId") + "-" +    System.currentTimeMillis()
436                                 }
437                                 def callbackURL = execution.getVariable("sdncCallbackUrl")
438                                 def requestId = execution.getVariable("msoRequestId")
439                                 def serviceId = execution.getVariable("DDVAM_serviceId")                                
440                                 def tenantId = execution.getVariable("DDVAM_tenantId")
441                                 def source = execution.getVariable("DDVAM_source")
442                                 def vnfId = execution.getVariable("vnfId")
443                                 def serviceInstanceId = execution.getVariable("serviceInstanceId")
444                                 def cloudSiteId = execution.getVariable("DDVAM_cloudSiteId")                            
445                                 def modelCustomizationId = execution.getVariable("DDVAM_modelCustomizationId")                          
446                                 //def serviceModelInfo = execution.getVariable("serviceModelInfo")
447                                 //def vnfModelInfo = execution.getVariable("vnfModelInfo")
448                                 //String serviceEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(serviceModelInfo)
449                                 //String vnfEcompModelInformation = sdncAdapterUtils.modelInfoToEcompModelInformation(vnfModelInfo)                             
450                                 def globalSubscriberId = execution.getVariable("DDVAM_globalSubscriberId")
451                                 def sdncVersion = execution.getVariable("DDVAM_sdncVersion")                                            
452                                 
453                                 String sdncRequest =
454                                 """<sdncadapterworkflow:SDNCAdapterWorkflowRequest xmlns:ns5="http://org.onap/so/request/types/v1"
455                                                                                                         xmlns:sdncadapterworkflow="http://org.onap/so/workflow/schema/v1"
456                                                                                                         xmlns:sdncadapter="http://org.onap/workflow/sdnc/adapter/schema/v1">
457            <sdncadapter:RequestHeader>
458                                 <sdncadapter:RequestId>${MsoUtils.xmlEscape(uuid)}</sdncadapter:RequestId>
459                                 <sdncadapter:SvcInstanceId>${MsoUtils.xmlEscape(svcInstId)}</sdncadapter:SvcInstanceId>
460                                 <sdncadapter:SvcAction>${MsoUtils.xmlEscape(action)}</sdncadapter:SvcAction>
461                                 <sdncadapter:SvcOperation>vnf-topology-operation</sdncadapter:SvcOperation>
462                                 <sdncadapter:CallbackUrl>${MsoUtils.xmlEscape(callbackURL)}</sdncadapter:CallbackUrl>
463                                 <sdncadapter:MsoAction>generic-resource</sdncadapter:MsoAction>
464                 </sdncadapter:RequestHeader>
465         <sdncadapterworkflow:SDNCRequestData>
466                 <request-information>
467                         <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
468                         <request-action>DeleteVnfInstance</request-action>
469                         <source>${MsoUtils.xmlEscape(source)}</source>
470                         <notification-url/>
471                         <order-number/>
472                         <order-version/>
473                 </request-information>
474                 <service-information>
475                         <service-id/>
476                         <subscription-service-type/>                    
477                         <service-instance-id>${MsoUtils.xmlEscape(serviceInstanceId)}</service-instance-id>
478                         <global-customer-id/>
479                 </service-information>
480                 <vnf-information>
481                         <vnf-id>${MsoUtils.xmlEscape(vnfId)}</vnf-id>
482                         <vnf-type/>                     
483                 </vnf-information>
484                 <vnf-request-input>                     
485                         <vnf-name/>
486                         <tenant>${MsoUtils.xmlEscape(tenantId)}</tenant>
487                         <aic-cloud-region>${MsoUtils.xmlEscape(cloudSiteId)}</aic-cloud-region>                 
488                 </vnf-request-input>
489         </sdncadapterworkflow:SDNCRequestData>
490         </sdncadapterworkflow:SDNCAdapterWorkflowRequest>"""
491                 
492                         logger.debug("sdncRequest:  " + sdncRequest)
493                         return sdncRequest
494         }
495                 
496         public void validateSDNCResponse(DelegateExecution execution, String response, String method){
497
498                 execution.setVariable("prefix",Prefix)
499                 logger.trace("STARTED ValidateSDNCResponse Process")
500
501                 WorkflowException workflowException = execution.getVariable("WorkflowException")
502                 boolean successIndicator = execution.getVariable("SDNCA_SuccessIndicator")
503
504                 logger.debug("workflowException: " + workflowException)
505
506                 SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils()
507                 sdncAdapterUtils.validateSDNCResponse(execution, response, workflowException, successIndicator)
508
509                 logger.debug("SDNCResponse: " + response)
510
511                 String sdncResponse = response
512                 if(execution.getVariable(Prefix + 'sdncResponseSuccess') == true){
513                         logger.debug("Received a Good Response from SDNC Adapter for " + method + " SDNC Call.  Response is: \n" + sdncResponse)                        
514                 }else{
515                         logger.debug("Received a BAD Response from SDNC Adapter for " + method + " SDNC Call.")
516                         throw new BpmnError("MSOWorkflowException")
517                 }
518                 logger.trace("COMPLETED ValidateSDNCResponse Process")
519         }
520         
521         
522         
523         
524         
525         
526         
527 }