1 package org.onap.so.bpmn.infrastructure.scripts
3 import com.fasterxml.jackson.databind.ObjectMapper
4 import org.camunda.bpm.engine.delegate.BpmnError
5 import org.camunda.bpm.engine.delegate.DelegateExecution
6 import org.onap.aai.domain.yang.CloudRegion
7 import org.onap.aai.domain.yang.Customer
8 import org.onap.aai.domain.yang.GenericVnf
9 import org.onap.aai.domain.yang.ModelVer
10 import org.onap.aai.domain.yang.ServiceInstance
11 import org.onap.aai.domain.yang.ServiceSubscription
12 import org.onap.aai.domain.yang.SliceProfile
13 import org.onap.aai.domain.yang.Tenant
14 import org.onap.aai.domain.yang.VfModule
15 import org.onap.aaiclient.client.aai.AAIObjectType
16 import org.onap.aaiclient.client.aai.AAIResourcesClient
17 import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
18 import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
19 import org.onap.aaiclient.client.aai.entities.Relationships
20 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
21 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
22 import org.onap.logging.filter.base.ONAPComponents
23 import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
24 import org.onap.so.bpmn.common.scripts.ExceptionUtil
25 import org.onap.so.bpmn.common.scripts.MsoUtils
26 import org.onap.so.bpmn.common.scripts.RequestDBUtil
27 import org.onap.so.bpmn.core.UrnPropertiesReader
28 import org.onap.so.bpmn.core.json.JsonUtils
29 import org.onap.so.client.HttpClient
30 import org.onap.so.db.request.beans.OperationStatus
31 import org.onap.so.requestsdb.RequestsDbConstant
32 import org.onap.so.serviceinstancebeans.CloudConfiguration
33 import org.onap.so.serviceinstancebeans.ModelInfo
34 import org.onap.so.serviceinstancebeans.ModelType
35 import org.onap.so.serviceinstancebeans.OwningEntity
36 import org.onap.so.serviceinstancebeans.Project
37 import org.onap.so.serviceinstancebeans.RequestDetails
38 import org.onap.so.serviceinstancebeans.RequestInfo
39 import org.onap.so.serviceinstancebeans.RequestParameters
40 import org.onap.so.serviceinstancebeans.Resources
41 import org.onap.so.serviceinstancebeans.Service
42 import org.onap.so.serviceinstancebeans.SubscriberInfo
43 import org.onap.so.serviceinstancebeans.VfModules
44 import org.onap.so.serviceinstancebeans.Vnfs
45 import org.slf4j.Logger
46 import org.slf4j.LoggerFactory
48 import javax.ws.rs.core.Response
50 class DoModifyCoreNSSI extends AbstractServiceTaskProcessor {
52 private final String PREFIX ="DoModifyCoreNSSI"
54 private ExceptionUtil exceptionUtil = new ExceptionUtil()
55 private RequestDBUtil requestDBUtil = new RequestDBUtil()
56 private MsoUtils utils = new MsoUtils()
57 private JsonUtils jsonUtil = new JsonUtils()
59 private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
62 void preProcessRequest(DelegateExecution execution) {
63 LOGGER.trace("${PREFIX} Start preProcessRequest")
65 def currentNSSI = execution.getVariable("currentNSSI")
67 String msg = "currentNSSI is null"
69 exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg)
72 LOGGER.trace("***** ${PREFIX} Exit preProcessRequest")
77 * Queries Network Service Instance in AAI
80 void getNetworkServiceInstance(DelegateExecution execution) {
81 LOGGER.trace("${PREFIX} Start getNetworkServiceInstance")
83 AAIResourcesClient client = getAAIClient()
85 def currentNSSI = execution.getVariable("currentNSSI")
87 String globalSubscriberId = currentNSSI['globalSubscriberId']
88 String serviceType = currentNSSI['serviceType']
89 String nssiId = currentNSSI['nssiServiceInstanceId']
91 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId) //AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiId)
92 Optional<ServiceInstance> nssiOpt = client.get(ServiceInstance.class, nssiUri)
94 if (nssiOpt.isPresent()) {
95 ServiceInstance nssi = nssiOpt.get()
96 execution.setVariable("nssi", nssi)
98 execution.setVariable("nssiUri", nssiUrl)
100 // Network Service Instance
101 AAIResultWrapper wrapper = client.get(nssiUri);
102 Optional<Relationships> relationships = wrapper.getRelationships()
103 if (relationships.isPresent()) {
104 for(AAIResourceUri networkServiceInstanceUri: relationships.get().getRelatedAAIUris(AAIObjectType.SERVICE_INSTANCE)){ // ???
105 Optional<ServiceInstance> networkServiceInstanceOpt = client.get(ServiceInstance.class, networkServiceInstanceUri)
106 if(networkServiceInstanceOpt.isPresent()) {
107 ServiceInstance networkServiceInstance = networkServiceInstanceOpt.get()
109 if(networkServiceInstance.getServiceRole().equals("Network Service")) { // Network Service
110 execution.setVariable("networkServiceInstance", networkServiceInstance)
112 execution.setVariable("networkServiceInstanceUri", networkServiceInstanceUri)
113 break // Should be only one Network Service Instance
117 String msg = String.format("No Network Service Instance found for NSSI %s in AAI", nssiId)
119 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
125 String msg = String.format("No relationship presented for NSSI %s in AAI", nssiId)
127 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
131 String msg = String.format("NSSI %s not found in AAI", nssiId)
133 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
137 LOGGER.trace("***** ${PREFIX} Exit getNetworkServiceInstance")
142 * Queries constitute VNF from Network Service Instance
145 void getConstituteVNFFromNetworkServiceInst(DelegateExecution execution) {
146 LOGGER.trace("${PREFIX} Start getConstituteVNFFromNetworkServiceInst")
148 AAIResourcesClient client = getAAIClient()
150 AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)execution.getVariable("networkServiceInstanceUri")
151 AAIResultWrapper wrapper = client.get(networkServiceInstanceUri);
152 Optional<Relationships> relationships = wrapper.getRelationships()
153 if (relationships.isPresent()) {
154 for (AAIResourceUri constituteVnfUri : relationships.get().getRelatedAAIUris(AAIObjectType.GENERIC_VNF)) { // ???
155 execution.setVariable("constituteVnfUri", constituteVnfUri)
156 Optional<GenericVnf> constituteVnfOpt = client.get(GenericVnf.class, constituteVnfUri)
157 if(constituteVnfOpt.isPresent()) {
158 GenericVnf constituteVnf = constituteVnfOpt.get()
159 execution.setVariable("constituteVnf", constituteVnf)
162 String msg = String.format("No constitute VNF found for Network Service Instance %s in AAI", ((ServiceInstance)execution.getVariable("networkServiceInstance")).getServiceInstanceId())
164 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
167 execution.setVariable("networkServiceInstanceUri", networkServiceInstanceUri)
168 break // Should be only one constitute VNF
172 String msg = String.format("No relationship presented for Network Service Instance %s in AAI", ((ServiceInstance)execution.getVariable("networkServiceInstance")).getServiceInstanceId())
174 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
177 LOGGER.trace("${PREFIX} Exit getConstituteVNFFromNetworkServiceInst")
183 * Retrieves NSSI associated profiles from AAI
186 void getNSSIAssociatedProfiles(DelegateExecution execution) {
187 LOGGER.trace("${PREFIX} Start getNSSIAssociatedProfiles")
189 AAIResourcesClient client = getAAIClient()
191 ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi")
193 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
195 if(associatedProfiles.isEmpty()) {
196 String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId())
198 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, msg)
201 execution.setVariable("associatedProfiles", associatedProfiles)
204 LOGGER.trace("${PREFIX} Exit getNSSIAssociatedProfiles")
209 * Calculates a final list of S-NSSAI
212 void calculateSNSSAI(DelegateExecution execution) {
213 LOGGER.trace("${PREFIX} Start calculateSNSSAI")
215 List<SliceProfile> associatedProfiles = (List<SliceProfile>)execution.getVariable("associatedProfiles")
217 def currentNSSI = execution.getVariable("currentNSSI")
219 String currentSNSSAI = currentNSSI['S-NSSAI']
221 List<String> snssais = new ArrayList<>()
223 if((Boolean)execution.getVariable("isCreateSliceProfileInstance" ).equals(Boolean.TRUE)) { // Slice Profile Instance has to be created
224 for (SliceProfile associatedProfile : associatedProfiles) {
225 snssais.add(associatedProfile.getSNssai())
228 snssais.add(currentSNSSAI)
230 else { // Slice profile instance has to be deleted
231 for (SliceProfile associatedProfile : associatedProfiles) {
232 if (!associatedProfile.getSNssai().equals(currentNSSI)) { // not current S-NSSAI
233 snssais.add(associatedProfile.getSNssai())
238 execution.setVariable("S-NSSAIs", snssais)
240 LOGGER.trace("${PREFIX} Exit calculateSNSSAI")
245 * Invoke PUT Service Instance API
248 void invokePUTServiceInstance(DelegateExecution execution) {
249 LOGGER.trace("${PREFIX} Start invokePUTServiceInstance")
252 //url:/onap/so/infra/serviceInstantiation/v7/serviceInstances/{serviceInstanceId}/vnfs/{vnfId}"
253 def nsmfЕndpoint = UrnPropertiesReader.getVariable("mso.infra.endpoint.url", execution) // ???
255 ServiceInstance networkServiceInstance = (ServiceInstance)execution.getVariable("networkServiceInstance")
257 GenericVnf constituteVnf = (GenericVnf)execution.getVariable("constituteVnf")
259 String url = String.format("${nsmfЕndpoint}/serviceInstantiation/v7/serviceInstances/%s/vnfs/%s", networkServiceInstance.getServiceInstanceId(), constituteVnf.getVnfId()) // ???
261 String msoKey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
262 String basicAuth = UrnPropertiesReader.getVariable("mso.infra.endpoint.auth", execution)
263 String basicAuthValue = utils.encrypt(basicAuth, msoKey)
264 String encodeString = utils.getBasicAuth(basicAuthValue, msoKey)
266 HttpClient httpClient = getHttpClientFactory().newJsonClient(new URL(url), ONAPComponents.EXTERNAL)
267 httpClient.addAdditionalHeader("Authorization", encodeString)
268 httpClient.addAdditionalHeader("Accept", "application/json")
270 RequestDetails requestDetails = prepareRequestDetails(execution)
271 ObjectMapper mapper = new ObjectMapper()
272 String requestDetailsStr = mapper.writeValueAsString(requestDetails)
274 Response httpResponse = httpClient.put(requestDetailsStr) // check http code ???
276 String msg = "Exception in DoDeallocateCoreNSSI.deleteServiceOrder. " + any.getCause()
278 exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
281 LOGGER.trace("${PREFIX} Exit invokePUTServiceInstance")
288 * @param requestDetails
291 private ModelInfo prepareModelInfo(DelegateExecution execution) {
292 ModelInfo modelInfo = new ModelInfo()
294 modelInfo.setModelType(ModelType.service)
295 modelInfo.setModelInvariantId(networkServiceInstance.getModelInvariantId())
297 AAIResourceUri modelVerUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, networkServiceInstance.getModelInvariantId()) // model of Network Service Instance ???
298 Optional<ModelVer> modelVerOpt = client.get(ModelVer.class, modelVerUrl)
300 if (modelVerOpt.isPresent()) {
301 modelInfo.setModelVersionId(modelVerOpt.get().getModelVersionId())
302 modelInfo.setModelName(modelVerOpt.get().getModelName())
303 modelInfo.setModelVersion(modelVerOpt.get().getModelVersion())
312 * Prepares RequestDetails object
316 private RequestDetails prepareRequestDetails(DelegateExecution execution) {
317 RequestDetails requestDetails = new RequestDetails()
319 def currentNSSI = execution.getVariable("currentNSSI")
321 String globalSubscriberId = currentNSSI['globalSubscriberId']
323 ServiceInstance networkServiceInstance = (ServiceInstance)execution.getVariable("networkServiceInstance")
326 AAIResourcesClient client = getAAIClient()
329 requestDetails.setModelInfo(prepareModelInfo(execution))
332 SubscriberInfo subscriberInfo = new SubscriberInfo()
333 subscriberInfo.setGlobalSubscriberId(globalSubscriberId)
335 Customer customer = null
336 ServiceSubscription serviceSubscription = null
338 AAIResourceUri networkServiceInstanceUri = execution.getVariable("networkServiceInstanceUri")
339 AAIResultWrapper wrapper = client.get(networkServiceInstanceUri)
340 Optional<Relationships> serviceSubscriptionRelationshipsOps = wrapper.getRelationships()
341 if(serviceSubscriptionRelationshipsOps.isPresent()) {
342 List<AAIResourceUri> serviceSubscriptionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.SERVICE_SUBSCRIPTION)
343 if(!(serviceSubscriptionRelatedAAIUris == null || serviceSubscriptionRelatedAAIUris.isEmpty())) {
344 AAIResourceUri serviceSubscriptionUri = serviceSubscriptionRelatedAAIUris.get(0) // Many-To-One relation
345 Optional<ServiceSubscription> serviceSubscriptionOpt = client.get(ServiceSubscription.class, serviceSubscriptionUri)
346 if(serviceSubscriptionOpt.isPresent()) {
347 serviceSubscription = serviceSubscriptionOpt.get()
350 wrapper = client.get(serviceSubscriptionUri)
351 Optional<Relationships> customerRelationshipsOps = wrapper.getRelationships()
352 if(customerRelationshipsOps.isPresent()) {
353 List<AAIResourceUri> customerRelatedAAIUris = customerRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CUSTOMER)
354 if(!(customerRelatedAAIUris == null || customerRelatedAAIUris.isEmpty())) {
355 Optional<Customer> customerOpt = client.get(Customer.class, customerRelatedAAIUris.get(0)) // Many-To-One relation
356 if(customerOpt.isPresent()) {
357 customer = customerOpt.get()
358 subscriberInfo.setSubscriberName(customer.getSubscriberName())
365 requestDetails.setSubscriberInfo(subscriberInfo)
368 RequestInfo requestInfo = new RequestInfo()
369 requestInfo.setInstanceName(networkServiceInstance.getServiceInstanceName())
371 /* No found data to provide ???
372 requestInfo.setSource()
373 requestInfo.setSuppressRollback()
374 requestInfo.setRequestorId()
375 requestInfo.setProductFamilyId()
378 requestDetails.setRequestInfo(requestInfo)
381 // Request Parameters
382 RequestParameters requestParameters = new RequestParameters()
384 // No found data to provide ??? requestParameters.setaLaCarte()
385 requestParameters.setSubscriptionServiceType(serviceSubscription.getServiceType())
388 List<Map<String, Object>> userParams = new ArrayList<>()
390 Service service = new Service()
392 ModelInfo serviceModelInfo = new ModelInfo()
393 serviceModelInfo.setModelType(ModelType.service)
394 serviceModelInfo.setModelInvariantId(networkServiceInstance.getModelInvariantId())
396 serviceModelInfo.setModelVersionId(modelInfo.get().getModelVersionId())
397 serviceModelInfo.setModelName(modelInfo.get().getModelName())
398 serviceModelInfo.setModelVersion(modelInfo.get().getModelVersion())
400 service.setModelInfo(serviceModelInfo)
403 Resources resources = new Resources()
405 CloudRegion cloudRegion = null
406 AAIResourceUri cloudRegionRelatedAAIUri = null
408 List<Vnfs> vnfs = new ArrayList<>()
410 Vnfs vnf = new Vnfs()
412 // Cloud configuration
413 CloudConfiguration cloudConfiguration = new CloudConfiguration()
415 AAIResourceUri constituteVnfUri = (AAIResourceUri)execution.getVariable("constituteVnfUri")
416 wrapper = client.get(constituteVnfUri)
417 Optional<Relationships> constituteVnfOps = wrapper.getRelationships()
418 if(constituteVnfOps.isPresent()) {
419 List<AAIResourceUri> cloudRegionRelatedAAIUris = serviceSubscriptionRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.CLOUD_REGION)
420 if(!(cloudRegionRelatedAAIUris == null || cloudRegionRelatedAAIUris.isEmpty())) {
421 cloudRegionRelatedAAIUri = cloudRegionRelatedAAIUris.get(0)
422 Optional<CloudRegion> cloudRegionrOpt = client.get(CloudRegion.class, cloudRegionRelatedAAIUris.get(0))
423 if(cloudRegionrOpt.isPresent()) {
424 cloudRegion = cloudRegionrOpt.get()
425 cloudConfiguration.setLcpCloudRegionId(cloudRegion.getCloudRegionId())
426 for(Tenant tenant:cloudRegion.getTenants()) {
427 cloudConfiguration.setTenantId(tenant.getTenantId())
428 break // only one is required
431 cloudConfiguration.setCloudOwner(cloudRegion.getCloudOwner())
436 vnf.setCloudConfiguration(cloudConfiguration)
439 GenericVnf constituteVnf = execution.getVariable("constituteVnf")
440 List<VfModules> vfModuless = new ArrayList<>()
441 for(VfModule vfModule:constituteVnf.getVfModules()) {
442 VfModules vfmodules = new VfModules()
444 ModelInfo vfModuleModelInfo = new ModelInfo()
445 vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
447 AAIResourceUri vfModuleUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, vfModule.getModelInvariantId()) // ???
448 Optional<ModelVer> vfModuleModelVerOpt = client.get(ModelVer.class, vfModuleUrl)
450 if (vfModuleModelVerOpt.isPresent()) {
451 vfModuleModelInfo.setModelVersionId(vfModuleModelVerOpt.get().getModelVersionId())
452 vfModuleModelInfo.setModelName(vfModuleModelVerOpt.get().getModelName())
453 vfModuleModelInfo.setModelVersion(vfModuleModelVerOpt.get().getModelVersion())
455 // No model customization ID
457 vfmodules.setModelInfo(vfModuleModelInfo)
459 vfmodules.setInstanceName(vfModule.getVfModuleName()) // ???
461 vfModuless.add(vfmodules)
463 vnf.setVfModules(vfModuless)
466 ModelInfo vnfModelInfo = new ModelInfo()
467 vnfModelInfo.setModelInvariantUuid(constituteVnf.getModelInvariantId())
468 AAIResourceUri vnfModelUrl = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, constituteVnf.getModelInvariantId()) // ???
469 Optional<ModelVer> vnfModelVerOpt = client.get(ModelVer.class, vnfModelUrl)
471 if (vnfModelVerOpt.isPresent()) {
472 vnfModelInfo.setModelVersionId(vnfModelVerOpt.get().getModelVersionId())
473 vnfModelInfo.setModelName(vnfModelVerOpt.get().getModelName())
474 vnfModelInfo.setModelVersion(vnfModelVerOpt.get().getModelVersion())
476 // No model customization ID
477 // No model instance name
480 vnf.setModelInfo(vnfModelInfo)
483 vnf.setInstanceName(constituteVnf.getVnfInstanceId())
486 List<Map<String, Object>> instanceParams = new ArrayList<>()
487 Map<String, Object> supporrtedNSSAIMap = new HashMap<>()
490 List<String> snssais = ( List<String>)execution.getVariable("S-NSSAIs")
491 supporrtedNSSAIMap.put("supporrtedNSSAI", snssais) // remaining S-NSSAIs ??? there is no status for each s-nssai
492 instanceParams.add(supporrtedNSSAIMap)
494 // No other instance params, e.g. config-type
496 vnf.setInstanceParams(instanceParams)
501 resources.setVnfs(vnfs)
503 service.setResources(resources)
505 Map<String, Object> serviceMap = new HashMap<>()
506 serviceMap.put("service", service)
507 userParams.add(serviceMap)
508 requestParameters.setUserParams(userParams)
510 // No other user params
512 requestDetails.setRequestParameters(requestParameters)
514 // No other request params
516 // Cloud configuration
517 requestDetails.setCloudConfiguration(cloudConfiguration)
520 OwningEntity owningEntity = new OwningEntity()
521 wrapper = client.get(networkServiceInstanceUri)
522 Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships()
523 if(owningEntityRelationshipsOps.isPresent()) {
524 List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedAAIUris(AAIObjectType.OWNING_ENTITY)
526 if(!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) {
527 Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
528 if(owningEntityOpt.isPresent()) {
529 owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId())
530 owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName())
531 requestDetails.setOwningEntity(owningEntity)
537 Project project = new Project()
538 if(cloudRegionRelatedAAIUri != null) {
539 wrapper = client.get(cloudRegionRelatedAAIUri)
540 Optional<Relationships> cloudRegionOps = wrapper.getRelationships()
541 if(cloudRegionOps.isPresent()) {
542 List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedAAIUris(AAIObjectType.PROJECT)
543 if (!(projectAAIUris == null || projectAAIUris.isEmpty())) {
544 Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0))
545 if(projectOpt.isPresent()) {
546 project.setProjectName(projectOpt.get().getProjectName())
551 requestDetails.setProject(project)
553 return requestDetails
558 * Creates Slice Profile Instance
561 void createSliceProfileInstance(DelegateExecution execution) {
562 LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
564 String sliceProfileID = execution.getVariable("sliceProfileID")
565 Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
566 Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
568 SliceProfile sliceProfile = new SliceProfile()
569 sliceProfile.setServiceAreaDimension("")
570 sliceProfile.setPayloadSize(0)
571 sliceProfile.setJitter(0)
572 sliceProfile.setSurvivalTime(0)
573 sliceProfile.setExpDataRate(0)
574 sliceProfile.setTrafficDensity(0)
575 sliceProfile.setConnDensity(0)
576 sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString())
577 sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
578 sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
579 sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
580 sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
581 sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
582 sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
583 sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
584 sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
585 sliceProfile.setProfileId(sliceProfileID)
586 sliceProfile.setE2ELatency(0)
589 AAIResourcesClient client = getAAIClient()
590 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, sliceProfileID)
591 client.create(uri, sliceProfile)
593 execution.setVariable("createdSliceProfile", sliceProfile)
594 } catch (Exception ex) {
595 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
598 LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
603 * Creates Slice Profile association with NSSI
606 void associateSliceProfileInstanceWithNSSI(DelegateExecution execution) {
607 LOGGER.trace("${PREFIX} Start associateSliceProfileInstanceWithNSSI")
609 String sliceProfileID = execution.getVariable("sliceProfileID")
611 def currentNSSI = execution.getVariable("currentNSSI")
613 String nssiId = currentNSSI['nssiServiceInstanceId']
615 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
616 AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, sliceProfileID)
619 SliceProfile createdSliceProfile = (SliceProfile)execution.getVariable("createdSliceProfile")
620 ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi")
621 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
622 associatedProfiles.add(createdSliceProfile)
624 getAAIClient().update(nssiUri, nssi)
626 getAAIClient().connect(sliceProfileUri, nsiUri, AAIEdgeLabel.BELONGS_TO)
628 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
631 LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")
636 * Removes Slice Profile association with NSSI
639 void removeSPAssociationWithNSSI(DelegateExecution execution) {
640 LOGGER.trace("${PREFIX} Start removeSPAssociationWithNSSI")
642 AAIResourcesClient client = getAAIClient()
644 def currentNSSI = execution.getVariable("currentNSSI")
646 ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi")
648 String nssiId = currentNSSI['nssiServiceInstanceId']
649 AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiId)
651 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
653 String currentSNSSAI = currentNSSI['S-NSSAI']
655 associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
658 getAAIClient().update(nssiUri, nssi)
660 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
663 LOGGER.trace("${PREFIX} Exit removeSPAssociationWithNSSI")
668 * Deletes Slice Profile Instance
671 void deleteSliceProfileInstance(DelegateExecution execution) {
672 LOGGER.trace("${PREFIX} Start deleteSliceProfileInstance")
674 AAIResourcesClient client = getAAIClient()
676 def currentNSSI = execution.getVariable("currentNSSI")
678 ServiceInstance nssi = (ServiceInstance)execution.getVariable("nssi")
680 List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
682 String currentSNSSAI = currentNSSI['S-NSSAI']
684 AAIResourceUri sliceProfileUri = null
686 for(SliceProfile associatedProfile:associatedProfiles) {
687 if(!associatedProfile.getSNssai().equals(currentNSSI)) { // not current S-NSSAI
688 sliceProfileUri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, associatedProfile.getProfileId())
694 getAAIClient().delete(sliceProfileUri)
696 exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
699 LOGGER.trace("${PREFIX} Exit deleteSliceProfileInstance")
704 * Updates operation status
707 void updateServiceOperationStatus(DelegateExecution execution) {
708 LOGGER.trace("${PREFIX} Start updateServiceOperationStatus")
710 def currentNSSI = execution.getVariable("currentNSSI")
712 OperationStatus operationStatus = new OperationStatus()
713 operationStatus.setServiceId(currentNSSI['e2eServiceInstanceId'] as String)
714 operationStatus.setOperationId(currentNSSI['operationId'] as String)
715 operationStatus.setOperation(currentNSSI['operationType'] as String)
716 operationStatus.setResult(RequestsDbConstant.Status.FINISHED)
718 requestDBUtil.prepareUpdateOperationStatus(execution, operationStatus)
720 LOGGER.trace("${PREFIX} Exit updateServiceOperationStatus")
728 AAIResourcesClient getAAIClient() {
729 return new AAIResourcesClient()