summaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src/main/groovy
diff options
context:
space:
mode:
authoralexanb <alexander.borovitzky@guest.telecomitalia.it>2020-09-30 21:02:44 +0300
committeralexanb <alexander.borovitzky@guest.telecomitalia.it>2020-10-01 12:22:55 +0300
commit289aa8a1de4c0b0c32bfbe13c4da48dc5da64795 (patch)
tree9a09c523b8c22e280ab29e8ffa223f862542dbb8 /bpmn/so-bpmn-infrastructure-common/src/main/groovy
parentf2f9bec9aee2de5135226b24c70708a5df5ca525 (diff)
Use Allotted Resources in Deallocate and Modify flows
Issue-ID: SO-3280 Change-Id: I5c325cb45e3230fc7d7e2190233c6ee91b7175b6 Signed-off-by: alexanb <alexander.borovitzky@guest.telecomitalia.it>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src/main/groovy')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy32
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy176
3 files changed, 280 insertions, 57 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
index 567725246e..646861a6a0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
@@ -246,11 +246,61 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
void getNSSIAssociatedProfiles(DelegateExecution execution) {
LOGGER.trace("${getPrefix()} Start getNSSIAssociatedProfiles")
+ List<SliceProfile> associatedProfiles = new ArrayList<>()
+
+ AAIResourcesClient client = getAAIClient()
+
def currentNSSI = execution.getVariable("currentNSSI")
ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ String nssiId = currentNSSI['nssiId']
+
+ // NSSI
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResultWrapper nssiWrapper = client.get(nssiUri)
+ Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships()
+
+ if (nssiRelationships.isPresent()) {
+ // Allotted Resource
+ for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) {
+ AAIResultWrapper arWrapper = client.get(allottedResourceUri)
+ Optional<Relationships> arRelationships = arWrapper.getRelationships()
+
+ boolean isFound = false
+ if(arRelationships.isPresent()) {
+ // Slice Profile Instance
+ for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) {
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+ if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance
+ associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri
+
+ isFound = true
+ break // Should be only one
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found")
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource")
+ }
+
+ if(isFound) {
+ break
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId)
+ }
if(associatedProfiles.isEmpty()) {
String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId())
@@ -587,13 +637,13 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param constituteVnf
* @return List<VfModules>
*/
- List<VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
+ List<org.onap.so.serviceinstancebeans.VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
AAIResourcesClient client = getAAIClient()
- List<VfModules> vfModuless = new ArrayList<>()
+ List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>()
for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) {
- VfModules vfmodules = new VfModules()
+ org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules()
ModelInfo vfModuleModelInfo = new ModelInfo()
vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
@@ -703,7 +753,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
Vnfs vnf = new Vnfs()
// Line of Business
- LineOfBusiness lob = new LineOfBusiness()
+ org.onap.so.serviceinstancebeans.LineOfBusiness lob = new org.onap.so.serviceinstancebeans.LineOfBusiness()
lob.setLineOfBusinessName("VNF")
vnf.setLineOfBusiness(lob)
@@ -739,8 +789,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* Prepare Service
* @return Service
*/
- Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
- Service service = new Service()
+ org.onap.so.serviceinstancebeans.Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ org.onap.so.serviceinstancebeans.Service service = new org.onap.so.serviceinstancebeans.Service()
// Model Info
service.setModelInfo(prepareServiceModelInfo(networkServiceInstance, modelInfo))
@@ -793,21 +843,21 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return OwningEntity
*/
- OwningEntity prepareOwningEntity(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.OwningEntity prepareOwningEntity(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri']
- OwningEntity owningEntity = new OwningEntity()
+ org.onap.so.serviceinstancebeans.OwningEntity owningEntity = new org.onap.so.serviceinstancebeans.OwningEntity()
AAIResultWrapper wrapper = client.get(networkServiceInstanceUri)
Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships()
if (owningEntityRelationshipsOps.isPresent()) {
List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedUris(Types.OWNING_ENTITY)
if (!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
+ Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.v19.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
if (owningEntityOpt.isPresent()) {
owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId())
owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName())
@@ -825,12 +875,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return Project
*/
- Project prepareProject(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.Project prepareProject(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
- Project project = new Project()
+ org.onap.so.serviceinstancebeans.Project project = new org.onap.so.serviceinstancebeans.Project()
AAIResourceUri cloudRegionRelatedAAIUri = (AAIResourceUri)currentNSSI['cloudRegionRelatedAAIUri']
@@ -840,7 +890,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
if (cloudRegionOps.isPresent()) {
List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedUris(Types.PROJECT)
if (!(projectAAIUris == null || projectAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0))
+ Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.v19.Project.class, projectAAIUris.get(0))
if (projectOpt.isPresent()) {
project.setProjectName(projectOpt.get().getProjectName())
}
@@ -950,23 +1000,49 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
-
String nssiId = currentNSSI['nssiId']
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ AAIResourceUri sliceProfileInstanceUri = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
- String currentSNSSAI = currentNSSI['S-NSSAI']
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ List<SliceProfile> associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ String currentSNSSAI = currentNSSI['S-NSSAI']
+
+ if(!(associatedProfiles == null || associatedProfiles.isEmpty())) {
+ // Removes slice profile which contains given S-NSSAI and updates Slice Profile Instance
+ associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+
+ try {
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ currentNSSI['sliceProfileInstance'] = sliceProfileInstance
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profiles found")
+ }
- associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found")
+ }
+ // Removes SLice Profile Instance association with NSSI
try {
- getAAIClient().update(nssiUri, nssi)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ client.disconnect(nssiUri, sliceProfileInstanceUri)
+ }
+ catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage())
}
+
LOGGER.trace("${getPrefix()} Exit removeSPAssociationWithNSSI")
}
@@ -982,17 +1058,10 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
- // global-customer-id, service-type, service-instance-id, profile-id
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
+ AAIResourceUri sliceProfileInstanceURI = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
try {
- client.delete(sliceProfileUri)
+ client.delete(sliceProfileInstanceURI)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
index 055cbfc9cc..fe881eb888 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
@@ -22,10 +22,14 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.Relationships
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder
import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -299,12 +303,38 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
String nssiId = currentNSSI['nssiId']
String nsiId = currentNSSI['nsiId']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ // NSSI
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ ServiceInstance nssi = currentNSSI['nssi']
+
+ String allottedResourceId = null
+
+ // Removes Allotted resource
+ List<AllottedResource> allottedResources = nssi.getAllottedResources()?.getAllottedResource()
+ if(allottedResources != null && allottedResources.size() == 1) { // Shouldn contain one allotted resource
+ allottedResourceId = allottedResources.get(0).getId()
+ allottedResources.remove(0)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No allotted resource found for NSSI id = " + nssiId)
+ }
+
+ try {
+ client.update(nssiUri, nssi)
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
+ }
+
+
+ // Remove association between NSI and Allotted Resource
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResourceId))
try {
- client.disconnect(nssiUri, nsiUri)
+ client.disconnect(nsiUri, allottedResourceUri)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
index 4ccea61ed4..ff16184f02 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
@@ -22,8 +22,11 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
+import org.onap.aai.domain.yang.v19.AllottedResources
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
+import org.onap.aai.domain.yang.v19.SliceProfiles
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
@@ -37,6 +40,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import static org.apache.commons.lang3.StringUtils.isAllLowerCase
import static org.apache.commons.lang3.StringUtils.isBlank
class DoModifyCoreNSSI extends DoCommonCoreNSSI {
@@ -51,22 +55,18 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
+
/**
- * Creates Slice Profile Instance
+ * Prepares Slice Profile
* @param execution
+ * @return SLice Profile
*/
- void createSliceProfileInstance(DelegateExecution execution) {
- LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
-
+ SliceProfile prepareSliceProfile(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
String sliceProfileID = currentNSSI['sliceProfileId']
Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setServiceAreaDimension("")
sliceProfile.setPayloadSize(0)
@@ -112,14 +112,80 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
sliceProfile.setProfileId(sliceProfileID)
sliceProfile.setE2ELatency(0)
+ return sliceProfile
+ }
+
+
+ /**
+ * Prepares Slice Profile Instance
+ * @param execution
+ * @return Slice Profile Instance
+ */
+ ServiceInstance prepareSliceProfileInstance(DelegateExecution execution) {
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ String sliceProfileInstanceId = UUID.randomUUID().toString()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+
+
+ String sliceInstanceName = "sliceprofile_" + sliceProfileInstanceId
+ sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
+
+ String serviceType = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "sST")
+ sliceProfileInstance.setServiceType(serviceType)
+
+ String serviceStatus = "deactivated"
+ sliceProfileInstance.setOrchestrationStatus(serviceStatus)
+
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "plmnIdList")
+ sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
+
+ String serviceRole = "slice-profile-instance"
+ sliceProfileInstance.setServiceRole(serviceRole)
+ List<String> snssaiList = (List<String>)currentNSSI['S-NSSAIs']
+ String snssai = snssaiList.get(0)
+
+ sliceProfileInstance.setEnvironmentContext(snssai)
+ sliceProfileInstance.setWorkloadContext("CN-NF")
+
+ // TO DO: Model info
+
+ return sliceProfileInstance
+ }
+
+
+
+ /**
+ * Creates Slice Profile Instance
+ * @param execution
+ */
+ void createSliceProfileInstance(DelegateExecution execution) {
+ LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ SliceProfile sliceProfile = prepareSliceProfile(execution)
+
+ ServiceInstance sliceProfileInstance = prepareSliceProfileInstance(execution)
+
+ SliceProfiles sliceProfiles = new SliceProfiles()
+ sliceProfiles.getSliceProfile().add(sliceProfile)
+ sliceProfileInstance.setSliceProfiles(sliceProfiles)
+
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
- client.create(uri, sliceProfile)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
+ client.create(uri, sliceProfileInstance)
- currentNSSI['createdSliceProfile'] = sliceProfile
+ currentNSSI['createdSliceProfileInstanceId'] = sliceProfileInstance.getServiceInstanceId()
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Slice Profile create call:" + ex.getMessage())
}
LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
@@ -127,6 +193,42 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
/**
+ * Creates Allotted Resource
+ * @param execution
+ * @return AllottedResource
+ */
+ AllottedResource createAllottedResource(DelegateExecution execution) {
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ // TO DO: No other info
+
+ try {
+ AAIResourcesClient client = getAAIClient()
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+
+ client.create(allottedResourceUri, allottedResource)
+
+ currentNSSI['allottedResourceUri'] = allottedResourceUri
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Allotted Resource create call:" + ex.getMessage())
+ }
+
+ return allottedResource
+ }
+
+
+
+ /**
* Creates Slice Profile association with NSSI
* @param execution
*/
@@ -135,26 +237,48 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
def currentNSSI = execution.getVariable("currentNSSI")
- String sliceProfileID = currentNSSI['sliceProfileId']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+ AAIResourcesClient client = getAAIClient()
+
+ // Creates Allotted Resource
+ AllottedResource allottedResource = createAllottedResource(execution)
+ AAIResourceUri allottedResourceUri = (AAIResourceUri)currentNSSI['allottedResourceUri']
+
+ // Updates Slice Profile Instance with Allotted Resource
try {
- SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
- associatedProfiles.add(createdSliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ AllottedResources allottedResources = sliceProfileInstance.getAllottedResources()
+ if(allottedResources == null) {
+ allottedResources = new AllottedResources()
+ }
+
+ allottedResources.getAllottedResource().add(allottedResource)
+ sliceProfileInstance.setAllottedResources(allottedResources)
+
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found with id = " + sliceProfileInstanceId)
+ }
+
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance update call: " + e.getMessage())
+ }
- getAAIClient().update(nssiUri, nssi)
- getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
+ // Associates NSSI with Allotted Resource
+ try {
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ client.connect(nssiUri, allottedResourceUri, AAIEdgeLabel.USES)
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI with Allotted Resource connect call: " + e.getMessage())
}
LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")