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