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