a22819f2e98ecaead2788f01b00b043b461e7049
[so.git] / bpmn / so-bpmn-infrastructure-common / src / main / groovy / org / onap / so / bpmn / infrastructure / scripts / DoAllocateNSIandNSSI.groovy
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  # Copyright (c) 2020, CMCC Technologies Co., Ltd.
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 org.onap.aai.domain.yang.NetworkRoute
24 import org.onap.so.beans.nsmf.ConnectionLink
25 import org.onap.so.beans.nsmf.EndPoint
26 import org.onap.so.beans.nsmf.NsiInfo
27 import org.onap.so.beans.nsmf.SliceProfileAdapter
28 import org.onap.so.beans.nsmf.TransportSliceNetwork
29 import org.onap.so.beans.nsmf.oof.SubnetType
30 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
31 import javax.ws.rs.NotFoundException
32 import org.camunda.bpm.engine.delegate.BpmnError
33 import org.camunda.bpm.engine.delegate.DelegateExecution
34 import org.onap.aai.domain.yang.Relationship
35 import org.onap.aai.domain.yang.ServiceInstance
36 import org.onap.aai.domain.yang.SliceProfile
37 import org.onap.aaiclient.client.aai.AAINamespaceConstants
38 import org.onap.aaiclient.client.aai.AAIResourcesClient
39 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
40 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
41 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
42 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
43 import org.onap.so.beans.nsmf.AllocateAnNssi
44 import org.onap.so.beans.nsmf.AllocateCnNssi
45 import org.onap.so.beans.nsmf.AllocateTnNssi
46 import org.onap.so.beans.nsmf.EsrInfo
47 import org.onap.so.beans.nsmf.NssiResponse
48 import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest
49 import org.onap.so.beans.nsmf.ServiceInfo
50 import org.onap.so.beans.nsmf.SliceTaskInfo
51 import org.onap.so.beans.nsmf.SliceTaskParamsAdapter
52 import org.onap.so.bpmn.common.scripts.ExceptionUtil
53 import org.onap.so.bpmn.core.json.JsonUtils
54 import org.slf4j.Logger
55 import org.slf4j.LoggerFactory
56 import static org.apache.commons.lang3.StringUtils.isBlank
57 import org.onap.aaiclient.client.aai.AAIObjectType
58
59 class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{
60
61     private static final Logger logger = LoggerFactory.getLogger(DoAllocateNSIandNSSI.class);
62
63     ExceptionUtil exceptionUtil = new ExceptionUtil()
64
65     JsonUtils jsonUtil = new JsonUtils()
66
67     AnNssmfUtils anNssmfUtils = new AnNssmfUtils()
68
69     AAIResourcesClient client = getAAIClient()
70
71     /**
72      * Pre Process the BPMN Flow Request
73      * Inclouds:
74      * generate the nsOperationKey
75      * generate the nsParameters
76      */
77
78     void preProcessRequest (DelegateExecution execution) {
79         String msg = ""
80         logger.trace("Enter preProcessRequest()")
81         Map<String, Object> nssiMap = new HashMap<>()
82         int nsstCount=execution.getVariable("nsstCount") as int
83         if(nsstCount==5){
84             execution.setVariable("processFHandMH", true)
85         }
86         else{
87             execution.setVariable("processFHandMH", false)
88         }
89         execution.setVariable("nssiMap", nssiMap)
90         boolean isMoreNSSTtoProcess = true
91         execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
92         List<String> nsstSequence = new ArrayList<>(Arrays.asList("cn"))
93         execution.setVariable("nsstSequence", nsstSequence)
94         logger.trace("Exit preProcessRequest")
95     }
96
97     /**
98      * Process NSI options
99      * @param execution
100      */
101     void retriveSliceOption(DelegateExecution execution) {
102         logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI")
103
104         boolean isNSIOptionAvailable
105
106         SliceTaskParamsAdapter sliceParams =
107                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
108
109         if(isBlank(sliceParams.getSuggestNsiId())) {
110             isNSIOptionAvailable = false
111         }
112         else {
113             isNSIOptionAvailable = true
114             execution.setVariable('nsiServiceInstanceId', sliceParams.getSuggestNsiId())
115             execution.setVariable('nsiServiceInstanceName', sliceParams.getSuggestNsiName())
116         }
117         execution.setVariable("isNSIOptionAvailable", isNSIOptionAvailable)
118         logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI")
119     }
120
121
122     /**
123      * create nsi instance in aai
124      * @param execution
125      */
126     void createNSIinAAI(DelegateExecution execution) {
127         logger.debug("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()")
128
129         String sliceInstanceId = UUID.randomUUID().toString()
130         SliceTaskParamsAdapter sliceParams =
131                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
132
133         //set new nsiId to sliceParams suggestNsiId
134         ServiceInstance nsi = new ServiceInstance()
135
136         String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName")
137         String serviceType = sliceParams.serviceProfile.get("sST")
138         String serviceStatus = "deactivated"
139         String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID
140         String modelUuid = sliceParams.getNSTInfo().UUID
141         String serviceFunction = sliceParams.serviceProfile.get("resourceSharingLevel")
142
143         sliceParams.setSuggestNsiId(sliceInstanceId)
144         sliceParams.setSuggestNsiName(sliceInstanceName)
145
146         String uuiRequest = execution.getVariable("uuiRequest")
147         String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
148         String serviceRole = "nsi"
149
150         execution.setVariable("sliceInstanceId", sliceInstanceId)
151         nsi.setServiceInstanceId(sliceInstanceId)
152         nsi.setServiceInstanceName(sliceInstanceName)
153         nsi.setServiceType(serviceType)
154         nsi.setOrchestrationStatus(serviceStatus)
155         nsi.setModelInvariantId(modelInvariantUuid)
156         nsi.setModelVersionId(modelUuid)
157         nsi.setServiceInstanceLocationId(serviceInstanceLocationid)
158         nsi.setServiceRole(serviceRole)
159         nsi.setServiceFunction(serviceFunction)
160         String msg
161         try {
162
163             AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
164                     .customer(execution.getVariable("globalSubscriberId"))
165                     .serviceSubscription(execution.getVariable("subscriptionServiceType"))
166                     .serviceInstance(sliceInstanceId))
167             client.create(nsiServiceUri, nsi)
168
169             execution.setVariable("nsiServiceUri", nsiServiceUri)
170
171         } catch (BpmnError e) {
172             throw e
173         } catch (Exception ex) {
174             msg = "Exception in DoAllocateNSIandNSSI.createNSIinAAI: " + ex.getMessage()
175             logger.info(msg)
176             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
177         }
178         execution.setVariable("sliceTaskParams", sliceParams)
179
180         logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
181     }
182
183
184     /**
185      * create relationship between nsi and service profile instance
186      * @param execution
187      */
188     void createRelationship(DelegateExecution execution) {
189         //relation ship
190         logger.debug("Enter createRelationship in DoAllocateNSIandNSSI")
191         //String allottedResourceId = execution.getVariable("allottedResourceId")
192         //SliceTaskParamsAdapter sliceParams =
193         //        execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
194         String msg
195         try {
196
197             AAIResourceUri nsiServiceUri = execution.getVariable("nsiServiceUri") as AAIResourceUri
198             logger.debug("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri.toString())
199
200             //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId))
201
202             AAIResourceUri allottedResourceUri = execution.getVariable("allottedResourceUri") as AAIResourceUri
203             logger.debug("Creating Allotted resource relationship, allottedResourceUri: " + allottedResourceUri.toString())
204
205             client.connect(allottedResourceUri, nsiServiceUri)
206         } catch (BpmnError e) {
207             throw e
208         } catch (Exception ex) {
209             msg = "Exception in DoAllocateNSIandNSSI.createRelationship. " + ex.getMessage()
210             logger.info(msg)
211             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
212         }
213         logger.debug("Exit createRelationship in DoAllocateNSIandNSSI")
214     }
215
216     /**
217      *
218      * @param execution
219      */
220     void updateRelationship(DelegateExecution execution) {
221         logger.debug("Enter update relationship in DoAllocateNSIandNSSI()")
222         //todo: allottedResourceId
223         String allottedResourceId = execution.getVariable("allottedResourceId")
224         //Need to check whether nsi exist : Begin
225
226         SliceTaskParamsAdapter sliceParams =
227                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
228
229         String nsiServiceInstanceID = sliceParams.getSuggestNsiId()
230         //sliceParams.setServiceId(nsiServiceInstanceID)
231
232         AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
233                 .customer(execution.getVariable("globalSubscriberId"))
234                 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
235                 .serviceInstance(nsiServiceInstanceID))
236
237         try {
238             AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class)
239             Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
240             if (!si.isPresent()) {
241                 String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
242                 logger.debug(msg)
243                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
244             }
245
246             //AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")).serviceSubscription(execution.getVariable("subscriptionServiceType")).serviceInstance(sliceParams.suggestNsiId).allottedResource(allottedResourceId))
247             AAIResourceUri allottedResourceUri = execution.getVariable("allottedResourceUri") as AAIResourceUri
248             logger.debug("updateRelationship Allotted resource relationship, allottedResourceUri: " + allottedResourceUri.toString())
249             client.connect(allottedResourceUri, nsiServiceUri)
250
251             execution.setVariable("sliceTaskParams", sliceParams)
252         }catch(BpmnError e) {
253             throw e
254         }catch (Exception ex){
255             String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
256             logger.debug(msg)
257             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
258         }
259         logger.debug("Exit update relationship in DoAllocateNSIandNSSI()")
260     }
261
262     /**
263      * create RAN Slice Profile Instance
264      * @param execution
265      */
266     void createAnSliceProfileInstance(DelegateExecution execution) {
267
268         String globalSubscriberId = execution.getVariable("globalSubscriberId")
269         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
270         String serviceInstanceId = UUID.randomUUID().toString()
271         execution.setVariable("ranSliceProfileInstanceId", serviceInstanceId) //todo:
272
273         String oStatus = "deactivated"
274
275         SliceTaskParamsAdapter sliceParams =
276                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
277         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo
278         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
279         String sliceProfileName = "sliceprofile_an_" + sliceParams.serviceName
280
281         // create slice profile
282         ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, sliceProfileName, oStatus)
283
284         //timestamp format YYYY-MM-DD hh:mm:ss
285         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
286
287         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
288                 .customer(globalSubscriberId)
289                 .serviceSubscription(subscriptionServiceType)
290                 .serviceInstance(serviceInstanceId))
291         client.create(uri, rspi)
292
293         execution.setVariable("sliceTaskParams", sliceParams)
294     }
295
296     /**
297      * create An Slice Profile
298      * @param execution
299      */
300     void createAnSliceProfile(DelegateExecution execution) {
301
302         String globalSubscriberId = execution.getVariable("globalSubscriberId")
303         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
304         //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
305
306         SliceTaskParamsAdapter sliceParams =
307                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
308         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo
309         SliceProfileAdapter anSliceProfile = sliceTaskInfo.sliceProfile
310
311         String profileId = UUID.randomUUID().toString()
312         anSliceProfile.setSliceProfileId(profileId)
313
314         SliceProfile sliceProfile = new SliceProfile()
315         sliceProfile.setProfileId(profileId)
316         sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList)
317         sliceProfile.setMaxNumberOfUEs(anSliceProfile.maxNumberOfUEs)
318         sliceProfile.setLatency(anSliceProfile.latency)
319         sliceProfile.setMaxNumberOfPDUSession(anSliceProfile.maxNumberOfPDUSession)
320         sliceProfile.setExpDataRateDL(anSliceProfile.expDataRateDL)
321         sliceProfile.setExpDataRateUL(anSliceProfile.expDataRateUL)
322         sliceProfile.setAreaTrafficCapDL(anSliceProfile.areaTrafficCapDL)
323         sliceProfile.setAreaTrafficCapUL(anSliceProfile.areaTrafficCapUL)
324         sliceProfile.setOverallUserDensity(anSliceProfile.overallUserDensity)
325         sliceProfile.setActivityFactor(anSliceProfile.activityFactor)
326         sliceProfile.setUeMobilityLevel(anSliceProfile.ueMobilityLevel)
327         sliceProfile.setResourceSharingLevel(anSliceProfile.resourceSharingLevel)
328         sliceProfile.setCsAvailabilityTarget(anSliceProfile.csAvailabilityTarget)
329         sliceProfile.setCsReliabilityMeanTime(anSliceProfile.csReliabilityMeanTime)
330         sliceProfile.setExpDataRate(anSliceProfile.expDataRate)
331         sliceProfile.setMsgSizeByte(anSliceProfile.msgSizeByte)
332         sliceProfile.setTransferIntervalTarget(anSliceProfile.transferIntervalTarget)
333         sliceProfile.setSurvivalTime(anSliceProfile.survivalTime)
334
335         AAIResourceUri uri = AAIUriFactory.createResourceUri(
336             AAIFluentTypeBuilder.business().customer(globalSubscriberId)
337             .serviceSubscription(subscriptionServiceType)
338             .serviceInstance(sliceTaskInfo.sliceInstanceId)
339             .sliceProfile(profileId)
340         )
341         client.create(uri, sliceProfile)
342         execution.setVariable("sliceTaskParams", sliceParams)
343     }
344
345     void createANEndpoint(DelegateExecution execution){
346         logger.debug("Enter createANEndpoint in DoAllocateNSIandNSSI()")
347         SliceTaskParamsAdapter sliceParams =
348                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
349         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.anSliceTaskInfo
350
351         NetworkRoute route = new NetworkRoute()
352         String routeId = UUID.randomUUID().toString()
353         route.setRouteId(routeId)
354         route.setType("endpoint")
355         route.setRole("AN")
356         route.setFunction("3gppTransportEP")
357         route.setIpAddress( sliceTaskInfo.sliceProfile.ipAddress)
358         route.setNextHop(sliceTaskInfo.sliceProfile.nextHopInfo)
359         route.setLogicalInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId)
360         route.setAddressFamily("ipv4")
361         route.setPrefixLength(24)
362         sliceTaskInfo.setEndPointId(routeId)
363
364         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(routeId))
365         client.create(uri, route)
366         execution.setVariable("sliceTaskParams", sliceParams)
367         logger.info("an endpointId:" + sliceParams.anSliceTaskInfo.endPointId)
368     }
369
370
371     void createCNEndpoint(DelegateExecution execution){
372         logger.debug("Enter createCNNetworkRoute in DoAllocateNSIandNSSI()")
373         SliceTaskParamsAdapter sliceParams =
374                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
375         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
376
377         NetworkRoute route = new NetworkRoute()
378         String routeId = UUID.randomUUID().toString()
379         route.setRouteId(routeId)
380         route.setType("endpoint")
381         route.setRole("CN")
382         route.setFunction("3gppTransportEP")
383         route.setIpAddress( sliceTaskInfo.sliceProfile.ipAddress)
384         route.setNextHop(sliceTaskInfo.sliceProfile.nextHopInfo)
385         route.setLogicalInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId)
386         route.setAddressFamily("ipv4")
387         route.setPrefixLength(24)
388
389         sliceTaskInfo.setEndPointId(routeId)
390         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(routeId))
391         client.create(uri, route)
392
393         execution.setVariable("cnEndpointId", routeId)
394         execution.setVariable("sliceTaskParams", sliceParams)
395         logger.info("cn endpointId:" + sliceParams.cnSliceTaskInfo.endPointId)
396     }
397
398     /**
399      * prepare AllocateAnNssi
400      * @param execution
401      */
402     void prepareAllocateAnNssi(DelegateExecution execution) {
403
404         //todo:
405         SliceTaskParamsAdapter sliceParams =
406                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
407         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.getAnSliceTaskInfo()
408
409         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
410
411         AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
412         allocateAnNssi.setSliceProfile(sliceTaskInfo.getSliceProfile().trans2AnProfile())
413         allocateAnNssi.getSliceProfile().setSliceProfileId(sliceTaskInfo.getSliceInstanceId())
414         allocateAnNssi.setNsstId(sliceTaskInfo.getNSSTInfo().getUUID())
415         allocateAnNssi.setNssiId(sliceTaskInfo.getSuggestNssiId())
416         allocateAnNssi.setNssiName("nssi_an" + execution.getVariable("sliceServiceInstanceName") as String)
417         allocateAnNssi.setScriptName(sliceTaskInfo.getScriptName())
418         NsiInfo nsiInfo = new NsiInfo()
419         nsiInfo.setNsiId(sliceParams.getSuggestNsiId())
420         nsiInfo.setNsiName(sliceParams.getSuggestNsiName())
421         allocateAnNssi.setNsiInfo(nsiInfo)
422         //endPoint
423         EndPoint endPoint = new EndPoint()
424         endPoint.setIpAddress(sliceTaskInfo.getSliceProfile().getIpAddress())
425         endPoint.setLogicInterfaceId(sliceTaskInfo.getSliceProfile().getLogicInterfaceId())
426         endPoint.setNextHopInfo(sliceTaskInfo.getSliceProfile().getNextHopInfo())
427         allocateAnNssi.setEndPoint(endPoint)
428
429         EsrInfo esrInfo = new EsrInfo()
430         //todo: vendor and network
431         esrInfo.setVendor(sliceTaskInfo.getVendor())
432         esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
433
434         String globalSubscriberId = execution.getVariable("globalSubscriberId") as String
435         String subscriptionServiceType = execution.getVariable("subscriptionServiceType") as String
436
437         //todo: service info
438         ServiceInfo serviceInfo = ServiceInfo.builder()
439                 .globalSubscriberId(globalSubscriberId)
440                 .subscriptionServiceType(subscriptionServiceType)
441                 .nsiId(sliceParams.getSuggestNsiId())
442                 .serviceInvariantUuid(sliceTaskInfo.getNSSTInfo().getInvariantUUID())
443                 .serviceUuid(sliceTaskInfo.getNSSTInfo().getUUID())
444                 .sST(sliceTaskInfo.getSliceProfile().getSST() ?: sliceParams.getServiceProfile().get("sST") as String)
445                 .nssiName(sliceTaskInfo.getSuggestNssiId() ? sliceTaskInfo.getNSSTInfo().getName() : allocateAnNssi.getNssiName())
446                 .nssiId(sliceTaskInfo.getSuggestNssiId())
447                 .resourceSharingLevel(sliceParams.serviceProfile.get("resourceSharingLevel") as String)
448                 .build()
449
450         nbiRequest.setServiceInfo(serviceInfo)
451         nbiRequest.setEsrInfo(esrInfo)
452         nbiRequest.setAllocateAnNssi(allocateAnNssi)
453
454         execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest)
455         execution.setVariable("anSliceTaskInfo", sliceTaskInfo)
456         execution.setVariable("anSubnetType", SubnetType.AN)
457     }
458
459
460     /**
461      * create RAN Slice Profile Instance
462      * @param execution
463      */
464     void createCnSliceProfileInstance(DelegateExecution execution) {
465
466         String globalSubscriberId = execution.getVariable("globalSubscriberId")
467         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
468         String serviceInstanceId = UUID.randomUUID().toString()
469         execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
470
471         String oStatus = "deactivated"
472
473         SliceTaskParamsAdapter sliceParams =
474                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
475         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
476         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
477         String sliceProfileName = "sliceprofile_cn_"+sliceParams.serviceName
478
479         // create slice profile
480         ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, sliceProfileName, oStatus)
481
482         //timestamp format YYYY-MM-DD hh:mm:ss
483         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
484
485         execution.setVariable("communicationServiceInstance", rspi)
486
487         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
488                 .customer(globalSubscriberId)
489                 .serviceSubscription(subscriptionServiceType)
490                 .serviceInstance(serviceInstanceId))
491         client.create(uri, rspi)
492         execution.setVariable("sliceTaskParams", sliceParams)
493     }
494
495     /**
496      * create Cn Slice Profile
497      * @param execution
498      */
499     void createCnSliceProfile(DelegateExecution execution) {
500
501         String globalSubscriberId = execution.getVariable("globalSubscriberId")
502         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
503         //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId")
504
505         SliceTaskParamsAdapter sliceParams =
506                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
507
508         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
509         SliceProfileAdapter cnSliceProfile = sliceTaskInfo.sliceProfile
510
511         String profileId = UUID.randomUUID().toString()
512         cnSliceProfile.setSliceProfileId(profileId)
513
514         SliceProfile sliceProfile = new SliceProfile()
515         sliceProfile.setProfileId(profileId)
516         sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String)
517         sliceProfile.setMaxNumberOfUEs(cnSliceProfile.maxNumberOfUEs)
518         sliceProfile.setLatency(cnSliceProfile.latency)
519         sliceProfile.setMaxNumberOfPDUSession(cnSliceProfile.maxNumberOfPDUSession)
520         sliceProfile.setExpDataRateDL(cnSliceProfile.expDataRateDL)
521         sliceProfile.setExpDataRateUL(cnSliceProfile.expDataRateUL)
522         sliceProfile.setAreaTrafficCapDL(cnSliceProfile.areaTrafficCapDL)
523         sliceProfile.setAreaTrafficCapUL(cnSliceProfile.areaTrafficCapUL)
524         sliceProfile.setOverallUserDensity(cnSliceProfile.overallUserDensity)
525         sliceProfile.setActivityFactor(cnSliceProfile.activityFactor)
526         sliceProfile.setUeMobilityLevel(cnSliceProfile.ueMobilityLevel)
527         sliceProfile.setResourceSharingLevel(cnSliceProfile.resourceSharingLevel)
528         sliceProfile.setCsAvailabilityTarget(cnSliceProfile.csAvailabilityTarget)
529         sliceProfile.setCsReliabilityMeanTime(cnSliceProfile.csReliabilityMeanTime)
530         sliceProfile.setExpDataRate(cnSliceProfile.expDataRate)
531         sliceProfile.setMsgSizeByte(cnSliceProfile.msgSizeByte)
532         sliceProfile.setTransferIntervalTarget(cnSliceProfile.transferIntervalTarget)
533         sliceProfile.setSurvivalTime(cnSliceProfile.survivalTime)
534
535         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
536                 .customer(globalSubscriberId)
537                 .serviceSubscription(subscriptionServiceType)
538                 .serviceInstance(sliceTaskInfo.sliceInstanceId)
539                 .sliceProfile(profileId))
540         client.create(uri, sliceProfile)
541         execution.setVariable("sliceTaskParams", sliceParams)
542     }
543
544     /**
545      * prepare AllocateCnNssi
546      * @param execution
547      */
548     void prepareAllocateCnNssi(DelegateExecution execution) {
549
550         //todo:
551         SliceTaskParamsAdapter sliceParams =
552                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
553         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.cnSliceTaskInfo
554
555         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
556
557         AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
558         allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID
559         allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId
560         allocateCnNssi.nssiName = "nssi_cn" + execution.getVariable("sliceServiceInstanceName")
561         allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile.trans2CnProfile()
562         allocateCnNssi.sliceProfile.sliceProfileId = sliceTaskInfo.sliceInstanceId
563         allocateCnNssi.scriptName = sliceTaskInfo.getScriptName()
564
565         NsiInfo nsiInfo = new NsiInfo()
566         nsiInfo.nsiId = sliceParams.suggestNsiId
567         nsiInfo.nsiName = sliceParams.suggestNsiName
568         allocateCnNssi.nsiInfo = nsiInfo
569         // endPoint
570         EndPoint endPoint = new EndPoint()
571         endPoint.setIpAddress(sliceTaskInfo.sliceProfile.ipAddress)
572         endPoint.setLogicInterfaceId(sliceTaskInfo.sliceProfile.logicInterfaceId)
573         endPoint.setNextHopInfo(sliceTaskInfo.sliceProfile.nextHopInfo)
574         allocateCnNssi.setEndPoint(endPoint)
575
576         EsrInfo esrInfo = new EsrInfo()
577         //todo: vendor and network
578         esrInfo.setVendor(sliceTaskInfo.getVendor())
579         esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
580
581         String globalSubscriberId = execution.getVariable("globalSubscriberId")
582         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
583
584         //todo: service info
585         ServiceInfo serviceInfo = new ServiceInfo()
586         serviceInfo.globalSubscriberId = globalSubscriberId
587         serviceInfo.subscriptionServiceType = subscriptionServiceType
588         serviceInfo.nsiId = sliceParams.suggestNsiId
589         serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
590         serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
591         serviceInfo.nssiId = sliceTaskInfo.suggestNssiId //if shared
592         serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST")
593         serviceInfo.nssiName = allocateCnNssi.nssiName
594         serviceInfo.resourceSharingLevel = sliceParams.serviceProfile.get("resourceSharingLevel")
595
596         nbiRequest.setServiceInfo(serviceInfo)
597         nbiRequest.setEsrInfo(esrInfo)
598         nbiRequest.setAllocateCnNssi(allocateCnNssi)
599
600         execution.setVariable("CnAllocateNssiNbiRequest", nbiRequest)
601         execution.setVariable("cnSliceTaskInfo", sliceTaskInfo)
602         execution.setVariable("cnSubnetType", SubnetType.CN)
603     }
604
605
606     /**
607      * create TN Slice Profile Instance
608      * @param execution
609      */
610     void createTnBHSliceProfileInstance(DelegateExecution execution) {
611         String globalSubscriberId = execution.getVariable("globalSubscriberId")
612         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
613
614         String oStatus = "deactivated"
615
616         SliceTaskParamsAdapter sliceParams =
617                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
618
619         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
620         String serviceInstanceId = UUID.randomUUID().toString()
621
622         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
623         String sliceProfileName = "sliceprofile_tn_" + sliceParams.serviceName
624         //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
625
626         // create slice profile
627         ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, sliceProfileName, oStatus)
628
629         //timestamp format YYYY-MM-DD hh:mm:ss
630         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
631
632         execution.setVariable("communicationServiceInstance", rspi)
633
634         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
635                 .customer(globalSubscriberId)
636                 .serviceSubscription(subscriptionServiceType)
637                 .serviceInstance(serviceInstanceId))
638         client.create(uri, rspi)
639
640         execution.setVariable("sliceTaskParams", sliceParams)
641     }
642
643     /**
644      * create Tn Slice Profile
645      * @param execution
646      */
647     void createTnBHSliceProfile(DelegateExecution execution) {
648
649         String globalSubscriberId = execution.getVariable("globalSubscriberId")
650         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
651
652         SliceTaskParamsAdapter sliceParams =
653                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
654
655         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
656
657         SliceProfileAdapter tnSliceProfile = sliceTaskInfo.sliceProfile
658         String profileId = UUID.randomUUID().toString()
659         tnSliceProfile.setSliceProfileId(profileId)
660
661         SliceProfile sliceProfile = new SliceProfile()
662         sliceProfile.setProfileId(profileId)
663         sliceProfile.setLatency(tnSliceProfile.latency)
664         sliceProfile.setMaxBandwidth(tnSliceProfile.maxBandwidth)
665         sliceProfile.setJitter(tnSliceProfile.jitter)
666
667         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
668                 .customer(globalSubscriberId)
669                 .serviceSubscription(subscriptionServiceType)
670                 .serviceInstance(sliceTaskInfo.sliceInstanceId)
671                 .sliceProfile(profileId))
672         client.create(uri, sliceProfile)
673
674         execution.setVariable("sliceTaskParams", sliceParams)
675     }
676
677     /**
678      * prepare AllocateCnNssi
679      * @param execution
680      */
681     void prepareAllocateTnBHNssi(DelegateExecution execution) {
682
683         //todo:
684         SliceTaskParamsAdapter sliceParams =
685                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
686         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnBHSliceTaskInfo
687
688         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
689
690         AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
691         allocateTnNssi.setNssiId(sliceTaskInfo.suggestNssiId)
692         allocateTnNssi.scriptName = sliceTaskInfo.getScriptName()
693         //todo: AllocateTnNssi
694         //todo: endPointId -> set into tn
695         List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>()
696         TransportSliceNetwork transportSliceNetwork = new TransportSliceNetwork()
697         List<ConnectionLink> connectionLinks = new ArrayList<>()
698         ConnectionLink connectionLink = new ConnectionLink()
699         connectionLink.setTransportEndpointA(sliceParams.anSliceTaskInfo.endPointId)
700         connectionLink.setTransportEndpointB(sliceParams.cnSliceTaskInfo.endPointId)
701         connectionLinks.add(connectionLink)
702         transportSliceNetwork.setConnectionLinks(connectionLinks)
703         transportSliceNetworks.add(transportSliceNetwork)
704         allocateTnNssi.setTransportSliceNetworks(transportSliceNetworks)
705
706         allocateTnNssi.setNetworkSliceInfos()
707         allocateTnNssi.setSliceProfile(sliceTaskInfo.sliceProfile.trans2TnProfile())
708         allocateTnNssi.getSliceProfile().setDomainType(sliceTaskInfo.subnetType.subnetType)
709         NsiInfo nsiInfo = new NsiInfo()
710         nsiInfo.setNsiId(sliceParams.suggestNsiId)
711         nsiInfo.setNsiName(sliceParams.suggestNsiName)
712         allocateTnNssi.setNsiInfo(nsiInfo)
713
714         //allocateTnNssi.networkSliceInfos
715
716         EsrInfo esrInfo = new EsrInfo()
717         esrInfo.setVendor(sliceTaskInfo.getVendor())
718         esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
719
720         String globalSubscriberId = execution.getVariable("globalSubscriberId")
721         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
722
723         ServiceInfo serviceInfo = new ServiceInfo()
724         serviceInfo.globalSubscriberId = globalSubscriberId
725         serviceInfo.subscriptionServiceType = subscriptionServiceType
726         serviceInfo.nsiId = sliceParams.suggestNsiId
727         serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID
728         serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID
729         serviceInfo.nssiId = sliceTaskInfo.suggestNssiId
730         serviceInfo.sST = sliceTaskInfo.sliceProfile.sST ?: sliceParams.serviceProfile.get("sST")
731         serviceInfo.nssiName = "nssi_tn" + execution.getVariable("sliceServiceInstanceName")
732         serviceInfo.resourceSharingLevel = sliceParams.serviceProfile.get("resourceSharingLevel")
733
734         nbiRequest.setServiceInfo(serviceInfo)
735         nbiRequest.setEsrInfo(esrInfo)
736         nbiRequest.setAllocateTnNssi(allocateTnNssi)
737
738         execution.setVariable("TnBHAllocateNssiNbiRequest", nbiRequest)
739         execution.setVariable("tnBHSliceTaskInfo", sliceTaskInfo)
740         execution.setVariable("tnBHSubnetType", SubnetType.TN_BH)
741     }
742
743     /**
744      * Update relationship between
745      * 1. NSI and NSSI
746      * 2. Slice Profile and Service Profile
747      * 3. SliceProfile and NSSI
748      * 4. sliceProfile and endpoint
749      *
750      * @param execution
751      */
752     public void updateAnRelationship(DelegateExecution execution) {
753         //todo:
754         SliceTaskParamsAdapter sliceParams =
755                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
756
757         NssiResponse result = execution.getVariable("anNssiAllocateResult") as NssiResponse
758         String nssiId = result.getNssiId()
759         String nsiId = sliceParams.getSuggestNsiId()
760         String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId
761         String serviceProfileInstanceId = sliceParams.serviceId
762         String epId = sliceParams.anSliceTaskInfo.endPointId
763         //nsi id
764         //todo: aai -> nssi -> relationship -> endPointId -> set into tn
765         //String endPointId = getEndpointIdFromAAI(execution, nssiId)
766         //execution.setVariable("endPointIdAn", endPointId)
767         updateRelationship(execution, nsiId, nssiId)
768
769         updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
770
771         updateRelationship(execution, sliceProfileInstanceId, nssiId)
772
773         updateEPRelationship(execution, nssiId, epId)
774
775         updateEPRelationship(execution, sliceProfileInstanceId, epId)
776
777         sliceParams.anSliceTaskInfo.suggestNssiId = nssiId
778         execution.setVariable("sliceTaskParams", sliceParams)
779     }
780
781
782     /**
783      * Update relationship between
784      * 1. NSI and NSSI
785      * 2. Slice Profile and Service Profile
786      * 3. SliceProfile and NSSI
787      *
788      * @param execution
789      */
790     public void updateCnRelationship(DelegateExecution execution) {
791         //todo:
792         SliceTaskParamsAdapter sliceParams =
793                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
794
795         NssiResponse result = execution.getVariable("cnNssiAllocateResult") as NssiResponse
796         String nssiId = result.getNssiId()
797         String nsiId = sliceParams.getSuggestNsiId()
798         String sliceProfileInstanceId = sliceParams.cnSliceTaskInfo.sliceInstanceId
799         String serviceProfileInstanceId = sliceParams.serviceId
800         String epId = sliceParams.cnSliceTaskInfo.endPointId
801         //nsi id
802         //todo: aai -> nssi -> relationship -> endPointId -> set into tn
803 //        String endPointId = getEndpointIdFromAAI(execution, nssiId)
804 //        execution.setVariable("endPointIdCn", endPointId)
805
806         updateRelationship(execution, nsiId, nssiId)
807
808         updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
809
810         updateRelationship(execution, sliceProfileInstanceId, nssiId)
811
812         updateEPRelationship(execution, nssiId, epId)
813
814         updateEPRelationship(execution, sliceProfileInstanceId, epId)
815
816         sliceParams.cnSliceTaskInfo.suggestNssiId = nssiId
817         execution.setVariable("sliceTaskParams", sliceParams)
818     }
819
820     /**
821      * get endpoint Id from AAI by nssi id
822      * @param execution
823      * @param nssiId
824      * @return
825      */
826     private String getEndpointIdFromAAI(DelegateExecution execution, String nssiId) {
827         logger.debug("Enter update relationship in DoAllocateNSIandNSSI()")
828         //todo: allottedResourceId
829
830         SliceTaskParamsAdapter sliceParams =
831                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
832
833         //sliceParams.setServiceId(nsiServiceInstanceID)
834         AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
835                 .customer(execution.getVariable("globalSubscriberId"))
836                 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
837                 .serviceInstance(nssiId))
838
839         String endpointId = null
840
841         try {
842             AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class)
843             Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class)
844             if (!si.isPresent()) {
845                 String msg = "NSSI in the option doesn't exist. " + nssiId
846                 logger.debug(msg)
847                 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
848             } else {
849                 ServiceInstance nssiInstance = si.get()
850                 //todo: handle relationship and return endPointId
851                 if (nssiInstance.relationshipList == null) {
852                     String msg = "relationshipList of " + nssiId + " is null"
853                     logger.debug(msg)
854                     return null
855                 }
856                 for (Relationship relationship : nssiInstance.relationshipList.getRelationship()) {
857                     if (relationship.relationshipLabel){
858                         endpointId = relationship //todo
859                     }
860                 }
861
862                 return endpointId
863             }
864
865         }catch(BpmnError e) {
866             throw e
867         }catch (Exception ex){
868             String msg = "Exception: " + ex
869             logger.debug(msg)
870             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
871         }
872         logger.debug("Exit update relationship in DoAllocateNSIandNSSI()")
873     }
874
875     /**
876      * Update relationship between
877      * 1. NSI and NSSI
878      * 2. Slice Profile and Service Profile
879      * 3. SliceProfile and NSSI
880      *
881      * @param execution
882      */
883     public void updateTnBHRelationship(DelegateExecution execution) {
884         SliceTaskParamsAdapter sliceParams =
885                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
886
887         NssiResponse result = execution.getVariable("tnBHNssiAllocateResult") as NssiResponse
888         String nssiId = result.getNssiId()
889         String nsiId = sliceParams.getSuggestNsiId()
890         String sliceProfileInstanceId = sliceParams.tnBHSliceTaskInfo.sliceInstanceId
891         String serviceProfileInstanceId = sliceParams.serviceId
892         //nsi id
893
894         updateRelationship(execution, nsiId, nssiId)
895
896         updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
897
898         updateRelationship(execution,sliceProfileInstanceId, nssiId)
899
900         sliceParams.tnBHSliceTaskInfo.suggestNssiId = nssiId
901         execution.setVariable("sliceTaskParams", sliceParams)
902     }
903
904     /**
905      * sourceId -> targetId
906      * @param execution
907      * @param sourceId
908      * @param targetId
909      */
910     void updateRelationship(DelegateExecution execution, String sourceId, String targetId) {
911         //relation ship
912         Relationship relationship = new Relationship()
913
914         AAIResourceUri targetInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
915                 .customer(execution.getVariable("globalSubscriberId"))
916                 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
917                 .serviceInstance(targetId))
918
919         logger.debug("Creating relationship, targetInstanceUri: " + targetInstanceUri)
920
921         relationship.setRelatedLink(targetInstanceUri.build().toString())
922
923         AAIResourceUri sourceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
924                 .customer(execution.getVariable("globalSubscriberId"))
925                 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
926                 .serviceInstance(sourceId))
927                 .relationshipAPI()
928         client.create(sourceInstanceUri, relationship)
929     }
930
931     /**
932      * update endpoint relationship
933      * @param execution
934      * @param sourceId
935      * @param targetId
936      */
937     void updateEPRelationship(DelegateExecution execution, String sourceId, String endpointId) {
938         //relation ship
939         Relationship relationship = new Relationship()
940
941         AAIResourceUri endpointUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(endpointId))
942
943         logger.debug("Creating relationship, endpoint Uri: " + endpointUri + ",endpointId: " + endpointId)
944
945         relationship.setRelatedLink(endpointUri.build().toString())
946
947         AAIResourceUri sourceInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
948                 .customer(execution.getVariable("globalSubscriberId"))
949                 .serviceSubscription(execution.getVariable("subscriptionServiceType"))
950                 .serviceInstance(sourceId))
951                 .relationshipAPI()
952         client.create(sourceInstanceUri, relationship)
953     }
954
955     static def createSliceProfileInstance(SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo, String sliceProfileName, String oStatus) {
956         // create slice profile
957         ServiceInstance rspi = new ServiceInstance()
958         rspi.setServiceInstanceName(sliceProfileName)
959         rspi.setServiceType(sliceTaskInfo.sliceProfile.getSST())
960         rspi.setServiceRole("slice-profile")
961         rspi.setOrchestrationStatus(oStatus)
962         rspi.setServiceInstanceLocationId(sliceTaskInfo.sliceProfile.getPLMNIdList())
963         rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID)
964         rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID)
965         rspi.setWorkloadContext(sliceTaskInfo.subnetType.subnetType)
966         rspi.setEnvironmentContext(sliceTaskInfo.sliceProfile.getSNSSAIList())
967         rspi.setServiceFunction(sliceTaskInfo.sliceProfile.getResourceSharingLevel())
968
969         //timestamp format YYYY-MM-DD hh:mm:ss
970         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
971         return rspi
972     }
973
974     public void createTNEndPoints(DelegateExecution execution) {
975         String type = "endpoint"
976         String function = "transport_EP"
977         int prefixLength = 24
978         String addressFamily = "ipv4"
979         //BH RAN end point update
980         //set BH end point
981         String sliceParams = execution.getVariable("sliceParams")
982         List<String> BH_endPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
983         logger.debug("BH end points list : "+BH_endPoints)
984         if(BH_endPoints.empty) {
985             String msg = "End point info is empty"
986             logger.debug(msg)
987             exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
988         }
989         String bh_routeId = UUID.randomUUID().toString()
990         execution.setVariable("tranportEp_ID_bh", bh_routeId)
991         String role = "CU"
992         String CU_IpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
993         String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
994         String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
995         NetworkRoute bh_ep = new NetworkRoute()
996         bh_ep.setRouteId(bh_routeId)
997         bh_ep.setFunction(function)
998         bh_ep.setRole(role)
999         bh_ep.setType(type)
1000         bh_ep.setIpAddress(CU_IpAddress)
1001         bh_ep.setLogicalInterfaceId(LogicalLinkId)
1002         bh_ep.setNextHop(nextHopInfo)
1003         bh_ep.setPrefixLength(prefixLength)
1004         bh_ep.setAddressFamily(addressFamily)
1005         //FH RAN end points update
1006         //RU
1007         String RU_routeId = UUID.randomUUID().toString()
1008         execution.setVariable("tranportEp_ID_RU", RU_routeId)
1009         role = "RU"
1010         NetworkRoute RU_ep = new NetworkRoute()
1011         RU_ep.setRouteId(RU_routeId)
1012         RU_ep.setFunction(function)
1013         RU_ep.setRole(role)
1014         RU_ep.setType(type)
1015         RU_ep.setIpAddress("192.168.100.4")
1016         RU_ep.setLogicalInterfaceId("1234")
1017         RU_ep.setNextHop("Host1")
1018         RU_ep.setPrefixLength(prefixLength)
1019         RU_ep.setAddressFamily(addressFamily)
1020         //DU Ingress
1021         String DUIN_routeId = UUID.randomUUID().toString()
1022         execution.setVariable("tranportEp_ID_DUIN", DUIN_routeId)
1023         role = "DU"
1024         NetworkRoute DU_ep = new NetworkRoute()
1025         DU_ep.setRouteId(DUIN_routeId)
1026         DU_ep.setFunction(function)
1027         DU_ep.setRole(role)
1028         DU_ep.setType(type)
1029         DU_ep.setIpAddress("192.168.100.5")
1030         DU_ep.setLogicalInterfaceId("1234")
1031         DU_ep.setNextHop("Host2")
1032         DU_ep.setPrefixLength(prefixLength)
1033         DU_ep.setAddressFamily(addressFamily)
1034         //MH RAN end point update
1035         //DUEG
1036         String DUEG_routeId = UUID.randomUUID().toString()
1037         execution.setVariable("tranportEp_ID_DUEG", DUEG_routeId)
1038         NetworkRoute DUEG_ep = new NetworkRoute()
1039         DUEG_ep.setRouteId(DUEG_routeId)
1040         DUEG_ep.setFunction(function)
1041         DUEG_ep.setRole(role)
1042         DUEG_ep.setType(type)
1043         DUEG_ep.setIpAddress("192.168.100.5")
1044         DUEG_ep.setLogicalInterfaceId("1234")
1045         DUEG_ep.setPrefixLength(prefixLength)
1046         DUEG_ep.setAddressFamily(addressFamily)
1047         DUEG_ep.setNextHop("Host3")
1048         //CUIN
1049         String CUIN_routeId = UUID.randomUUID().toString()
1050         execution.setVariable("tranportEp_ID_CUIN", CUIN_routeId)
1051         NetworkRoute CUIN_ep = new NetworkRoute()
1052         CUIN_ep.setRouteId(CUIN_routeId)
1053         CUIN_ep.setFunction(function)
1054         CUIN_ep.setRole(role)
1055         CUIN_ep.setType(type)
1056         CUIN_ep.setIpAddress("192.168.100.6")
1057         CUIN_ep.setLogicalInterfaceId("1234")
1058         CUIN_ep.setNextHop("Host4")
1059         CUIN_ep.setPrefixLength(prefixLength)
1060         CUIN_ep.setAddressFamily(addressFamily)
1061         try {
1062             AAIResourcesClient client = new AAIResourcesClient()
1063             logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
1064             AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(bh_routeId))
1065             client.create(networkRouteUri, bh_ep)
1066             logger.debug("creating RU endpoint . ID : "+RU_routeId+" node details : "+RU_ep.toString())
1067             networkRouteUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(RU_routeId))
1068             client.create(networkRouteUri, RU_ep)
1069             logger.debug("creating DUIN endpoint . ID : "+DUIN_routeId+" node details : "+DU_ep.toString())
1070             networkRouteUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(DUIN_routeId))
1071             client.create(networkRouteUri, DU_ep)
1072             logger.debug("creating DUEG endpoint . ID : "+DUEG_routeId+" node details : "+DUEG_ep.toString())
1073             networkRouteUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(DUEG_routeId))
1074             client.create(networkRouteUri, DUEG_ep)
1075             logger.debug("creating CUIN endpoint . ID : "+CUIN_routeId+" node details : "+CUIN_ep.toString())
1076             networkRouteUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().networkRoute(CUIN_routeId))
1077             client.create(networkRouteUri, CUIN_ep)
1078             //relationship b/w bh_ep and RAN NSSI
1079             def AN_NSSI = execution.getVariable("RANServiceInstanceId")
1080             Relationship relationship = new Relationship()
1081             String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
1082             relationship.setRelatedLink(relatedLink)
1083             relationship.setRelatedTo("network-route")
1084             relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
1085             anNssmfUtils.createRelationShipInAAI(execution, relationship, AN_NSSI)
1086             def ANNF_serviceInstanceId = execution.getVariable("RANNFServiceInstanceId")
1087             relatedLink = "aai/v21/network/network-routes/network-route/${RU_routeId}"
1088             relationship.setRelatedLink(relatedLink)
1089             anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1090             relatedLink = "aai/v21/network/network-routes/network-route/${DUIN_routeId}"
1091             relationship.setRelatedLink(relatedLink)
1092             anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1093             relatedLink = "aai/v21/network/network-routes/network-route/${DUEG_routeId}"
1094             relationship.setRelatedLink(relatedLink)
1095             anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1096             relatedLink = "aai/v21/network/network-routes/network-route/${CUIN_routeId}"
1097             relationship.setRelatedLink(relatedLink)
1098             anNssmfUtils.createRelationShipInAAI(execution, relationship, ANNF_serviceInstanceId)
1099         } catch (BpmnError e) {
1100             throw e
1101         } catch (Exception ex) {
1102             String msg = "Exception in createEndPointsInAai " + ex.getMessage()
1103             logger.info(msg)
1104             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
1105         }
1106     }
1107
1108     /**
1109      * create TN Slice Profile Instance
1110      * @param execution
1111      */
1112     void createTnFHSliceProfileInstance(DelegateExecution execution) {
1113         String globalSubscriberId = execution.getVariable("globalSubscriberId")
1114         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
1115
1116         String oStatus = "deactivated"
1117
1118         SliceTaskParamsAdapter sliceParams =
1119                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1120
1121         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnFHSliceTaskInfo
1122         String serviceInstanceId = UUID.randomUUID().toString()
1123
1124         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
1125         String sliceProfileName = "tn_fh" + sliceParams.serviceName
1126         //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo:
1127
1128         // create slice profile
1129         ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, sliceProfileName, oStatus)
1130
1131         //timestamp format YYYY-MM-DD hh:mm:ss
1132         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
1133
1134         execution.setVariable("communicationServiceInstance", rspi)
1135
1136         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
1137                 .customer(globalSubscriberId)
1138                 .serviceSubscription(subscriptionServiceType)
1139                 .serviceInstance(serviceInstanceId))
1140         client.create(uri, rspi)
1141
1142         execution.setVariable("sliceTaskParams", sliceParams)
1143     }
1144
1145     /**
1146      * create Tn Slice Profile
1147      * @param execution
1148      */
1149     void createTnFHSliceProfile(DelegateExecution execution) {
1150
1151         String globalSubscriberId = execution.getVariable("globalSubscriberId")
1152         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
1153
1154         SliceTaskParamsAdapter sliceParams =
1155                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1156
1157         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnFHSliceTaskInfo
1158
1159         SliceProfileAdapter tnSliceProfile = sliceTaskInfo.sliceProfile
1160         String profileId = UUID.randomUUID().toString()
1161         tnSliceProfile.setSliceProfileId(profileId)
1162
1163         SliceProfile sliceProfile = new SliceProfile()
1164         sliceProfile.setProfileId(profileId)
1165         sliceProfile.setLatency(tnSliceProfile.latency)
1166         sliceProfile.setMaxBandwidth(tnSliceProfile.maxBandwidth)
1167         sliceProfile.setJitter(tnSliceProfile.jitter)
1168
1169         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
1170                 .customer(globalSubscriberId)
1171                 .serviceSubscription(subscriptionServiceType)
1172                 .serviceInstance(sliceTaskInfo.sliceInstanceId)
1173                 .sliceProfile(profileId))
1174         client.create(uri, sliceProfile)
1175
1176         execution.setVariable("sliceTaskParams", sliceParams)
1177     }
1178
1179     /**
1180      * prepare AllocateCnNssi
1181      * @param execution
1182      */
1183     void prepareAllocateTnFHNssi(DelegateExecution execution) {
1184
1185         //todo:
1186         SliceTaskParamsAdapter sliceParams =
1187                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1188         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.getTnFHSliceTaskInfo()
1189
1190         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
1191
1192         AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
1193         allocateTnNssi.setNssiId(sliceTaskInfo.getSuggestNssiId())
1194         //todo: AllocateTnNssi
1195         //todo: endPointId -> set into tn
1196         List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>()
1197         TransportSliceNetwork transportSliceNetwork = new TransportSliceNetwork()
1198         List<ConnectionLink> connectionLinks = new ArrayList<>()
1199         ConnectionLink connectionLink = new ConnectionLink()
1200         connectionLink.setTransportEndpointA(execution.getVariable("tranportEp_ID_RU") as String)
1201         connectionLink.setTransportEndpointB(execution.getVariable("tranportEp_ID_DUIN") as String)
1202         connectionLinks.add(connectionLink)
1203         transportSliceNetwork.setConnectionLinks(connectionLinks)
1204         transportSliceNetworks.add(transportSliceNetwork)
1205         allocateTnNssi.setTransportSliceNetworks(transportSliceNetworks)
1206
1207         allocateTnNssi.setSliceProfile(sliceTaskInfo.getSliceProfile().trans2TnProfile())
1208         NsiInfo nsiInfo = new NsiInfo()
1209         nsiInfo.setNsiId(sliceParams.getSuggestNsiId())
1210         nsiInfo.setNsiName(sliceParams.getSuggestNsiName())
1211         allocateTnNssi.setNsiInfo(nsiInfo)
1212
1213         EsrInfo esrInfo = new EsrInfo()
1214         esrInfo.setVendor(sliceTaskInfo.getVendor())
1215         esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
1216
1217         String globalSubscriberId = execution.getVariable("globalSubscriberId") as String
1218         String subscriptionServiceType = execution.getVariable("subscriptionServiceType") as String
1219
1220         ServiceInfo serviceInfo = ServiceInfo.builder()
1221                 .globalSubscriberId(globalSubscriberId)
1222                 .subscriptionServiceType(subscriptionServiceType)
1223                 .nsiId(sliceParams.getSuggestNsiId())
1224                 .serviceInvariantUuid(sliceTaskInfo.getNSSTInfo().getInvariantUUID())
1225                 .setServiceUuid(sliceTaskInfo.getNSSTInfo().getUUID())
1226                 .nssiId(sliceTaskInfo.getSuggestNssiId())
1227                 .sST(sliceTaskInfo.getSliceProfile().getSST() ?: sliceParams.getServiceProfile().get("sST"))
1228                 .nssiName("nssi_tn_fh_" + execution.getVariable("sliceServiceInstanceName") as String)
1229                 .build()
1230
1231         nbiRequest.setServiceInfo(serviceInfo)
1232         nbiRequest.setEsrInfo(esrInfo)
1233         nbiRequest.setAllocateTnNssi(allocateTnNssi)
1234
1235         execution.setVariable("TnFHAllocateNssiNbiRequest", nbiRequest)
1236         execution.setVariable("tnFHSliceTaskInfo", sliceTaskInfo)
1237         execution.setVariable("tnFHSubnetType", SubnetType.TN_BH)
1238     }
1239
1240     /**
1241      * Update relationship between
1242      * 1. NSI and NSSI
1243      * 2. Slice Profile and Service Profile
1244      * 3. SliceProfile and NSSI
1245      *
1246      * @param execution
1247      */
1248     public void updateTnFHRelationship(DelegateExecution execution) {
1249         SliceTaskParamsAdapter sliceParams =
1250                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1251
1252         NssiResponse result = execution.getVariable("tnFHNssiAllocateResult") as NssiResponse
1253         String nssiId = result.getNssiId()
1254         String nsiId = sliceParams.getSuggestNsiId()
1255         String sliceProfileInstanceId = sliceParams.tnFHSliceTaskInfo.sliceInstanceId
1256         String serviceProfileInstanceId = sliceParams.serviceId
1257
1258         updateRelationship(execution, nsiId, nssiId)
1259
1260         updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
1261
1262         updateRelationship(execution,sliceProfileInstanceId, nssiId)
1263
1264         sliceParams.tnFHSliceTaskInfo.suggestNssiId = nssiId
1265         execution.setVariable("sliceTaskParams", sliceParams)
1266     }
1267
1268     /**
1269      * create TN Slice Profile Instance
1270      * @param execution
1271      */
1272     void createTnMHSliceProfileInstance(DelegateExecution execution) {
1273         String globalSubscriberId = execution.getVariable("globalSubscriberId")
1274         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
1275
1276         String oStatus = "deactivated"
1277
1278         SliceTaskParamsAdapter sliceParams =
1279                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1280
1281         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnMHSliceTaskInfo
1282         String serviceInstanceId = UUID.randomUUID().toString()
1283
1284         sliceTaskInfo.setSliceInstanceId(serviceInstanceId)
1285         String sliceProfileName = "tn_mh_" + sliceParams.serviceName
1286         ServiceInstance rspi = createSliceProfileInstance(sliceTaskInfo, sliceProfileName, oStatus)
1287
1288         rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault()))
1289
1290         execution.setVariable("communicationServiceInstance", rspi)
1291
1292         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
1293                 .customer(globalSubscriberId)
1294                 .serviceSubscription(subscriptionServiceType)
1295                 .serviceInstance(serviceInstanceId))
1296         client.create(uri, rspi)
1297
1298         execution.setVariable("sliceTaskParams", sliceParams)
1299     }
1300
1301     /**
1302      * create Tn Slice Profile
1303      * @param execution
1304      */
1305     void createTnMHSliceProfile(DelegateExecution execution) {
1306
1307         String globalSubscriberId = execution.getVariable("globalSubscriberId")
1308         String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
1309
1310         SliceTaskParamsAdapter sliceParams =
1311                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1312
1313         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.tnMHSliceTaskInfo
1314
1315         SliceProfileAdapter tnSliceProfile = sliceTaskInfo.sliceProfile
1316         String profileId = UUID.randomUUID().toString()
1317         tnSliceProfile.setSliceProfileId(profileId)
1318
1319         SliceProfile sliceProfile = new SliceProfile()
1320         sliceProfile.setProfileId(profileId)
1321         sliceProfile.setLatency(tnSliceProfile.latency)
1322         sliceProfile.setMaxBandwidth(tnSliceProfile.maxBandwidth)
1323         sliceProfile.setJitter(tnSliceProfile.jitter)
1324
1325         AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business()
1326                 .customer(globalSubscriberId)
1327                 .serviceSubscription(subscriptionServiceType)
1328                 .serviceInstance(sliceTaskInfo.sliceInstanceId)
1329                 .sliceProfile(profileId))
1330         client.create(uri, sliceProfile)
1331
1332         execution.setVariable("sliceTaskParams", sliceParams)
1333     }
1334
1335     /**
1336      * prepare AllocateCnNssi
1337      * @param execution
1338      */
1339     void prepareAllocateTnMHNssi(DelegateExecution execution) {
1340
1341         SliceTaskParamsAdapter sliceParams =
1342                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1343         SliceTaskInfo<SliceProfileAdapter> sliceTaskInfo = sliceParams.getTnMHSliceTaskInfo()
1344
1345         NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest()
1346
1347         AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
1348         allocateTnNssi.setNssiId(sliceTaskInfo.getSuggestNssiId())
1349         List<TransportSliceNetwork> transportSliceNetworks = new ArrayList<>()
1350         TransportSliceNetwork transportSliceNetwork = new TransportSliceNetwork()
1351         List<ConnectionLink> connectionLinks = new ArrayList<>()
1352         ConnectionLink connectionLink = new ConnectionLink()
1353         connectionLink.setTransportEndpointA(execution.getVariable("tranportEp_ID_DUEG") as String)
1354         connectionLink.setTransportEndpointB(execution.getVariable("tranportEp_ID_CUIN") as String)
1355         connectionLinks.add(connectionLink)
1356         transportSliceNetwork.setConnectionLinks(connectionLinks)
1357         transportSliceNetworks.add(transportSliceNetwork)
1358         allocateTnNssi.setTransportSliceNetworks(transportSliceNetworks)
1359
1360         allocateTnNssi.setSliceProfile(sliceTaskInfo.getSliceProfile().trans2TnProfile())
1361         NsiInfo nsiInfo = new NsiInfo()
1362         nsiInfo.setNsiId(sliceParams.getSuggestNsiId())
1363         nsiInfo.setNsiName(sliceParams.getSuggestNsiName())
1364         allocateTnNssi.setNsiInfo(nsiInfo)
1365
1366         EsrInfo esrInfo = new EsrInfo()
1367         esrInfo.setVendor(sliceTaskInfo.getVendor())
1368         esrInfo.setNetworkType(sliceTaskInfo.getNetworkType())
1369
1370         String globalSubscriberId = execution.getVariable("globalSubscriberId") as String
1371         String subscriptionServiceType = execution.getVariable("subscriptionServiceType") as String
1372
1373         ServiceInfo serviceInfo = ServiceInfo.builder()
1374                 .globalSubscriberId(globalSubscriberId)
1375                 .subscriptionServiceType(subscriptionServiceType)
1376                 .nsiId(sliceParams.getSuggestNsiId())
1377                 .serviceInvariantUuid(sliceTaskInfo.getNSSTInfo().getInvariantUUID())
1378                 .serviceUuid(sliceTaskInfo.getNSSTInfo().getUUID())
1379                 .nssiId(sliceTaskInfo.getSuggestNssiId())
1380                 .sST(sliceTaskInfo.getSliceProfile().getSST() ?: sliceParams.getServiceProfile().get("sST"))
1381                 .nssiName("nssi_tn_bh_" + execution.getVariable("sliceServiceInstanceName") as String)
1382                 .build()
1383
1384         nbiRequest.setServiceInfo(serviceInfo)
1385         nbiRequest.setEsrInfo(esrInfo)
1386         nbiRequest.setAllocateTnNssi(allocateTnNssi)
1387
1388         execution.setVariable("TnMHAllocateNssiNbiRequest", nbiRequest)
1389         execution.setVariable("tnMHSliceTaskInfo", sliceTaskInfo)
1390         execution.setVariable("tnMHSubnetType", SubnetType.TN_BH)
1391     }
1392
1393     /**
1394      * Update relationship between
1395      * 1. NSI and NSSI
1396      * 2. Slice Profile and Service Profile
1397      * 3. SliceProfile and NSSI
1398      *
1399      * @param execution
1400      */
1401     public void updateTnMHRelationship(DelegateExecution execution) {
1402         SliceTaskParamsAdapter sliceParams =
1403                 execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter
1404
1405         NssiResponse result = execution.getVariable("tnMHNssiAllocateResult") as NssiResponse
1406         String nssiId = result.getNssiId()
1407         String nsiId = sliceParams.getSuggestNsiId()
1408         String sliceProfileInstanceId = sliceParams.tnMHSliceTaskInfo.sliceInstanceId
1409         String serviceProfileInstanceId = sliceParams.serviceId
1410
1411         updateRelationship(execution, nsiId, nssiId)
1412
1413         updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId)
1414
1415         updateRelationship(execution,sliceProfileInstanceId, nssiId)
1416
1417         sliceParams.tnMHSliceTaskInfo.suggestNssiId = nssiId
1418         execution.setVariable("sliceTaskParams", sliceParams)
1419     }
1420 }