aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy
blob: e55ea139385737d9922884f852448fc0a4f23984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
/*-
 * ============LICENSE_START=======================================================
 * ONAP - SO
 * ================================================================================
 # Copyright (c) 2020, CMCC Technologies Co., Ltd.
 #
 # Licensed under the Apache License, Version 2.0 (the "License")
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
 #       http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
 * ============LICENSE_END=========================================================
 */

package org.onap.so.bpmn.infrastructure.scripts

import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.so.serviceinstancebeans.Service

import static org.apache.commons.lang3.StringUtils.*
import org.camunda.bpm.engine.delegate.BpmnError
import org.camunda.bpm.engine.delegate.DelegateExecution
import org.onap.aai.domain.yang.ServiceInstance
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ErrorCode
import org.onap.so.beans.nsmf.SliceTaskParams
import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
import org.onap.so.beans.nsmf.oof.TemplateInfo
import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils
import org.onap.so.bpmn.common.scripts.OofUtils
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.db.request.beans.OrchestrationTask
import org.onap.so.logger.LoggingAnchor
import org.onap.so.logger.MessageEnum
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.web.util.UriUtils
import com.fasterxml.jackson.databind.ObjectMapper
import groovy.json.JsonSlurper

public class CreateSliceService extends AbstractServiceTaskProcessor {
    String Prefix = "CRESS_"

    ExceptionUtil exceptionUtil = new ExceptionUtil()

    JsonUtils jsonUtil = new JsonUtils()

    JsonSlurper jsonSlurper = new JsonSlurper()

    ObjectMapper objectMapper = new ObjectMapper()

    OofUtils oofUtils = new OofUtils()

    AAIResourcesClient client = getAAIClient()

    private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class)

    public void preProcessRequest(DelegateExecution execution) {
        logger.debug("Start preProcessRequest")
        execution.setVariable("prefix", Prefix)
        String msg = ""

        try {
            String ssRequest = execution.getVariable("bpmnRequest")
            logger.debug(ssRequest)

            String requestId = execution.getVariable("mso-request-id")
            execution.setVariable("msoRequestId", requestId)
            logger.debug("Input Request:" + ssRequest + " reqId:" + requestId)

            String serviceInstanceId = execution.getVariable("serviceInstanceId")
            if (isBlank(serviceInstanceId)) {
                serviceInstanceId = UUID.randomUUID().toString()
            }

            String operationId = UUID.randomUUID().toString()
            execution.setVariable("operationId", operationId)

            logger.debug("Generated new Service Instance:" + serviceInstanceId)
            serviceInstanceId = UriUtils.encode(serviceInstanceId, "UTF-8")
            execution.setVariable("serviceInstanceId", serviceInstanceId)

            //subscriberInfo
            String globalSubscriberId = jsonUtil.getJsonValue(ssRequest, "requestDetails.subscriberInfo.globalSubscriberId")
            if (isBlank(globalSubscriberId)) {
                msg = "Input globalSubscriberId' is null"
                exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
            } else {
                execution.setVariable("globalSubscriberId", globalSubscriberId)
            }

            //requestInfo
            execution.setVariable("source", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.source"))
            execution.setVariable("serviceInstanceName", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.instanceName"))
            execution.setVariable("disableRollback", jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.suppressRollback"))
            String productFamilyId = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestInfo.productFamilyId")
            if (isBlank(productFamilyId)) {
                msg = "Input productFamilyId is null"
                logger.debug(msg)
                //exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
            } else {
                execution.setVariable("productFamilyId", productFamilyId)
            }

            //modelInfo
            String serviceModelInfo = jsonUtil.getJsonValue(ssRequest, "requestDetails.modelInfo")
            if (isBlank(serviceModelInfo)) {
                msg = "Input serviceModelInfo is null"
                logger.debug(msg)
                exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
            } else {
                execution.setVariable("serviceModelInfo", serviceModelInfo)
            }

            logger.debug("modelInfo: " + serviceModelInfo)

//            //requestParameters
//            String subscriptionServiceType = jsonUtil.getJsonValue(ssRequest, "requestDetails.requestParameters.subscriptionServiceType")
//            if (isBlank(subscriptionServiceType)) {
//                msg = "Input subscriptionServiceType is null"
//                logger.debug(msg)
//                exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
//            } else {
//                subscriptionServiceType = "5G"
//                execution.setVariable("subscriptionServiceType", subscriptionServiceType)
//            }
//            logger.debug("subscriptionServiceType: " + subscriptionServiceType)

            /*
            * Extracting User Parameters from incoming Request and converting into a Map
            */
            Map reqMap = jsonSlurper.parseText(ssRequest) as Map

            //InputParams
            def userParamsList = reqMap.requestDetails?.requestParameters?.userParams

            Map<String, String> inputMap = [:]
            if (userParamsList) {
                for (def i = 0; i < userParamsList.size(); i++) {
                    def userParams1 = userParamsList.get(i)
                    userParams1.each { param -> inputMap.put(param.key, param.value) }
                }
            }

            logger.debug("User Input Parameters map: " + inputMap.toString())
            String uuiRequest = inputMap.get("UUIRequest")
            Map uuiReqMap = jsonSlurper.parseText(uuiRequest) as Map
            Map<String, Object> serviceObject = (Map<String, Object>) uuiReqMap.get("service")
            Map<String, Object> parameterObject = (Map<String, Object>) serviceObject.get("parameters")
            Map<String, Object> requestInputs = (Map<String, Object>) parameterObject.get("requestInputs")

            def serviceProfile = [:]
            for(entry in requestInputs) {
                serviceProfile[entry.key] = entry.value
            }

            execution.setVariable("serviceInputParams", inputMap)
            execution.setVariable("uuiRequest", uuiRequest)
            execution.setVariable("serviceProfile", serviceProfile)
            execution.setVariable("subscriptionServiceType", serviceObject.get("serviceType"))

            //TODO
            //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams"))
            //execution.setVariable("failExists", true)

        } catch (BpmnError e) {
            throw e
        } catch (Exception ex) {
            msg = "Exception in preProcessRequest " + ex.getMessage()
            logger.debug(msg)
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
        }
        logger.debug("Finish preProcessRequest")
    }

    /**
     *
     * @param execution
     */
    public void prepareInitServiceOperationStatus(DelegateExecution execution) {
        logger.debug("Start prepareInitServiceOperationStatus")
        try{
            String serviceId = execution.getVariable("serviceInstanceId")
            String operationId = execution.getVariable("operationId")
            String operationType = "CREATE"
            String userId = execution.getVariable("globalSubscriberId")
            String result = "processing"
            String progress = "0"
            String reason = ""
            String operationContent = "Prepare service creation"
            logger.debug("Generated new operation for Service Instance serviceId:" + serviceId + " operationId:" + operationId)
            serviceId = UriUtils.encode(serviceId,"UTF-8")
            execution.setVariable("serviceInstanceId", serviceId)
            execution.setVariable("operationType", operationType)

            def dbAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.openecomp.db.endpoint",execution)
            execution.setVariable("CSSOS_dbAdapterEndpoint", dbAdapterEndpoint)
            logger.debug("DB Adapter Endpoint is: " + dbAdapterEndpoint)
            def dbAdapterAuth = UrnPropertiesReader.getVariable("mso.requestDb.auth")
            Map<String, String> CSSOS_headerMap = [:]
            CSSOS_headerMap.put("content-type", "application/soap+xml")
            CSSOS_headerMap.put("Authorization", dbAdapterAuth)
            execution.setVariable("CSSOS_headerMap", CSSOS_headerMap)
            logger.debug("DB Adapter Header is: " + CSSOS_headerMap)

            String payload =
                    """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                        xmlns:ns="http://org.onap.so/requestsdb">
                        <soapenv:Header/>
                        <soapenv:Body>
                            <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
                            <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
                            <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
                            <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
                            <userId>${MsoUtils.xmlEscape(userId)}</userId>
                            <result>${MsoUtils.xmlEscape(result)}</result>
                            <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
                            <progress>${MsoUtils.xmlEscape(progress)}</progress>
                            <reason>${MsoUtils.xmlEscape(reason)}</reason>
                        </ns:initServiceOperationStatus>
                    </soapenv:Body>
                </soapenv:Envelope>"""

            payload = utils.formatXml(payload)
            execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload)
            logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload)
        }catch(Exception e){
            logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                    "Exception Occured Processing prepareInitServiceOperationStatus.", "BPMN",
                    ErrorCode.UnknownError.getValue(), "Exception is:\n" + e)
        }
        logger.debug("Finish prepareInitServiceOperationStatus")
    }

    /**
     * prepare create OrchestrationTask
     * @param execution
     */
    public void prepareCreateOrchestrationTask(DelegateExecution execution) {
        logger.debug("Start createOrchestrationTask")
        String taskId = execution.getBusinessKey()
        execution.setVariable("orchestrationTaskId", taskId)
        logger.debug("BusinessKey: " + taskId)
        String serviceInstanceId = execution.getVariable("serviceInstanceId")
        String serviceInstanceName = execution.getVariable("serviceInstanceName")
        String taskName = "SliceServiceTask"
        String taskStatus = "Planning"
        String isManual = "false"
        String requestMethod = "POST"
        execution.setVariable("CSSOT_taskId", taskId)
        execution.setVariable("CSSOT_name", taskName)
        execution.setVariable("CSSOT_status", taskStatus)
        execution.setVariable("CSSOT_isManual", isManual)
        execution.setVariable("CSSOT_requestMethod", requestMethod)

        Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") as Map<String, Object>

        SliceTaskParamsAdapter sliceTaskParams = new SliceTaskParamsAdapter()
        sliceTaskParams.setServiceId(serviceInstanceId)
        sliceTaskParams.setServiceName(serviceInstanceName)
        sliceTaskParams.setServiceProfile(serviceProfile)

        execution.setVariable("sliceTaskParams", sliceTaskParams)

        execution.setVariable("CSSOT_paramJson", objectMapper.writeValueAsString(sliceTaskParams))

        logger.debug("Finish createOrchestrationTask")
    }

    /**
     *  send sync response to csmf
     * @param execution
     */
    public void sendSyncResponse(DelegateExecution execution) {
        logger.debug("Start sendSyncResponse")
        try {
            String operationId = execution.getVariable("operationId")
            String serviceInstanceId = execution.getVariable("serviceInstanceId")
            // RESTResponse for API Handler (APIH) Reply Task
            String createServiceRestRequest = """
                {
                   "service": {
                        "serviceId":"${serviceInstanceId}",
                        "operationId":"${operationId}"
                   }
                }
                """.trim()

            logger.debug("sendSyncResponse to APIH:" + "\n" + createServiceRestRequest)
            sendWorkflowResponse(execution, 202, createServiceRestRequest)
            execution.setVariable("sentSyncResponse", true)
        } catch (Exception e) {
            String msg = "Exceptuion in sendSyncResponse:" + e.getMessage()
            logger.debug(msg)
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
        }
        logger.debug("Finish sendSyncResponse")
    }

    public void prepareSelectNSTRequest(DelegateExecution execution) {
        logger.debug("Start prepareSelectNSTRequest")
        String requestId = execution.getVariable("msoRequestId")
        String messageType = "NSTSelectionResponse"
        execution.setVariable("nstSelectionUrl", "/api/oof/v1/selection/nst")
        execution.setVariable("nstSelection_messageType", messageType)
        execution.setVariable("nstSelection_correlator", requestId)
        String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution);
        execution.setVariable("nstSelection_timeout", timeout)

        Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") as Map<String, Object>
        serviceProfile.remove("profileId")
        String oofRequest = oofUtils.buildSelectNSTRequest(requestId, messageType, serviceProfile)
        execution.setVariable("nstSelection_oofRequest", oofRequest)
        logger.debug("Finish prepareSelectNSTRequest")

    }

    /**
     * process async response of oof, put the {@solutions} at {@nstSolution}
     * @param execution
     */
    public void processNSTSolutions(DelegateExecution execution) {
        Map<String, Object> nstSolution
        try {
            logger.debug("Start processing NSTSolutions")
            Map<String, Object> resMap =
                    objectMapper.readValue(execution.getVariable("nstSelection_oofResponse") as String,
                            Map.class)

            List<Map<String, Object>> nstSolutions = (List<Map<String, Object>>) resMap.get("solutions")
            nstSolution = nstSolutions.get(0)
            execution.setVariable("nstSolution", nstSolution)

            //set nst info into sliceTaskParams
            SliceTaskParamsAdapter sliceTaskParams =
                    execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
            TemplateInfo nstInfo = new TemplateInfo()
            nstInfo.setUUID(nstSolution.get("UUID") as String)
            nstInfo.setInvariantUUID(nstSolution.get("invariantUUID") as String)
            nstInfo.setName(nstSolution.get("NSTName") as String)

            sliceTaskParams.setNSTInfo(nstInfo)
            sliceTaskParams.setNstId(nstSolution.get("UUID") as String)
            sliceTaskParams.setNstName(nstSolution.get("NSTName") as String)

            execution.setVariable("sliceTaskParams", sliceTaskParams)

        } catch (Exception ex) {
            logger.debug( "Failed to get NST solution suggested by OOF.")
            exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Failed to get NST solution suggested by OOF.")
        }

    }

    public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
        logger.debug("Start prepareUpdateOrchestrationTask")
        String requestMethod = "PUT"
        String taskStatus = execution.getVariable("taskStatus")
        SliceTaskParamsAdapter sliceTaskParams =
                execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
        int nsstCount=execution.getVariable("nsstCount") as int
	nsstCount=nsstCount+1
        execution.setVariable("nsstCount", nsstCount)
        execution.setVariable("CSSOT_status", taskStatus)
        execution.setVariable("CSSOT_paramJson", objectMapper.writeValueAsString(sliceTaskParams))
        execution.setVariable("CSSOT_requestMethod", requestMethod)
        logger.debug("Finish prepareUpdateOrchestrationTask")
    }


    public void prepareGetUserOptions(DelegateExecution execution) {
        logger.debug("Start prepareGetUserOptions")
        String requestMethod = "GET"
        execution.setVariable("taskAction", "commit")
        String taskAction = execution.getVariable("taskAction")
        logger.debug("task action is: " + taskAction)
        if (!"commit".equals(taskAction) && !"abort".equals(taskAction)) {
            String msg = "Unknown task action: " + taskAction
            logger.debug(msg)
            exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
        }
        execution.setVariable("CSSOT_requestMethod", requestMethod)
        logger.debug("Finish prepareGetUserOptions")
    }

    public void processUserOptions(DelegateExecution execution) {
        logger.debug("Start processUserOptions")
        String response = execution.getVariable("CSSOT_dbResponse")
        OrchestrationTask orchestrationTask = objectMapper.readValue(response, OrchestrationTask.class)
        String paramJson = orchestrationTask.getParams()
        logger.debug("paramJson: " + paramJson)

        SliceTaskParamsAdapter sliceTaskParams = objectMapper.readValue(paramJson, SliceTaskParamsAdapter.class)

        execution.setVariable("sliceTaskParams", sliceTaskParams)
        logger.debug("Finish processUserOptions")
    }

    public void updateAAIOrchStatus(DelegateExecution execution) {
        logger.debug("Start updateAAIOrchStatus")
        String serviceInstanceId = execution.getVariable("serviceInstanceId")
        String orchStatus = execution.getVariable("orchestrationStatus")

        try {
            ServiceInstance si = new ServiceInstance()
            si.setOrchestrationStatus(orchStatus)

            AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId))
            client.update(uri, si)
        } catch (BpmnError e) {
            throw e
        } catch (Exception ex) {
            String msg = "Exception in CreateSliceService.updateAAIOrchStatus " + ex.getMessage()
            logger.info(msg)
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
        }

        logger.debug("Finish updateAAIOrchStatus")
    }

    public void prepareUpdateServiceOperationStatus(DelegateExecution execution) {
        logger.debug("Start preUpdateServiceOperationStatus")
        try{
            String serviceId = execution.getVariable("serviceInstanceId")
            String operationId = execution.getVariable("operationId")
            String operationType = execution.getVariable("operationType")
            String userId = execution.getVariable("globalSubscriberId")
            String result = execution.getVariable("operationResult")
            String progress = execution.getVariable("operationProgress")
            String reason = execution.getVariable("operationReason")
            String operationContent = "service: " + result + " progress: " + progress

            String payload =
                    """<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                        xmlns:ns="http://org.onap.so/requestsdb">
                        <soapenv:Header/>
                        <soapenv:Body>
                            <ns:initServiceOperationStatus xmlns:ns="http://org.onap.so/requestsdb">
                            <serviceId>${MsoUtils.xmlEscape(serviceId)}</serviceId>
                            <operationId>${MsoUtils.xmlEscape(operationId)}</operationId>
                            <operationType>${MsoUtils.xmlEscape(operationType)}</operationType>
                            <userId>${MsoUtils.xmlEscape(userId)}</userId>
                            <result>${MsoUtils.xmlEscape(result)}</result>
                            <operationContent>${MsoUtils.xmlEscape(operationContent)}</operationContent>
                            <progress>${MsoUtils.xmlEscape(progress)}</progress>
                            <reason>${MsoUtils.xmlEscape(reason)}</reason>
                        </ns:initServiceOperationStatus>
                    </soapenv:Body>
                </soapenv:Envelope>"""

            payload = utils.formatXml(payload)
            execution.setVariable("CSSOS_updateServiceOperStatusRequest", payload)
            logger.debug("Outgoing updateServiceOperStatusRequest: \n" + payload)

        }catch(Exception e){
            logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
                    "Exception Occured Processing preUpdateServiceOperationStatus.", "BPMN",
                    ErrorCode.UnknownError.getValue(), "Exception is:\n" + e.getMessage())
        }
        logger.debug("Finish preUpdateServiceOperationStatus")
    }



    public void prepareCompletionRequest (DelegateExecution execution) {
        logger.trace("Start prepareCompletionRequest")
        try {
            String requestId = execution.getVariable("msoRequestId")
            String serviceInstanceId = execution.getVariable("serviceInstanceId")
            String source = execution.getVariable("source")

            String msoCompletionRequest =
                    """<aetgt:MsoCompletionRequest xmlns:aetgt="http://org.onap/so/workflow/schema/v1"
                                xmlns:ns="http://org.onap/so/request/types/v1">
                        <request-info xmlns="http://org.onap/so/infra/vnf-request/v1">
                            <request-id>${MsoUtils.xmlEscape(requestId)}</request-id>
                            <action>CREATE</action>
                            <source>${MsoUtils.xmlEscape(source)}</source>
                        </request-info>
                        <status-message>Service Instance was created successfully.</status-message>
                        <serviceInstanceId>${MsoUtils.xmlEscape(serviceInstanceId)}</serviceInstanceId>
                        <mso-bpel-name>CreateGenericALaCarteServiceInstance</mso-bpel-name>
                    </aetgt:MsoCompletionRequest>"""

            // Format Response
            String xmlMsoCompletionRequest = utils.formatXml(msoCompletionRequest)

            execution.setVariable("completionRequest", xmlMsoCompletionRequest)
            logger.debug("Overall SUCCESS Response going to CompleteMsoProcess - " + "\n" + xmlMsoCompletionRequest)

        } catch (Exception ex) {
            String msg = " Exception in prepareCompletion:" + ex.getMessage()
            logger.debug(msg)
            exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
        }
        logger.trace("Finish prepareCompletionRequest")
    }

}