aboutsummaryrefslogtreecommitdiffstats
path: root/bpmn/so-bpmn-infrastructure-common/src
diff options
context:
space:
mode:
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy338
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy771
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy524
3 files changed, 1633 insertions, 0 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
new file mode 100644
index 0000000000..d5b554d841
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSI.groovy
@@ -0,0 +1,338 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import com.google.common.reflect.TypeToken
+import com.google.gson.Gson
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.AllottedResource
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIEdgeLabel
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.client.RequestsDbClient
+import org.onap.so.db.request.beans.OrchestrationTask
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.UriBuilder
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSI.class);
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+ RequestsDbClient requestsDbClient = new RequestsDbClient()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+
+ void preProcessRequest (DelegateExecution execution) {
+ String msg = ""
+ logger.trace("Enter preProcessRequest()")
+ Map<String, Object> nssiMap = new HashMap<>()
+ execution.setVariable("nssiMap", nssiMap)
+ boolean isMoreNSSTtoProcess = true
+ execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
+ List<String> nsstSequence = new ArrayList<>(Arrays.asList("cn"))
+ execution.setVariable("nsstSequence", nsstSequence)
+ logger.trace("Exit preProcessRequest")
+ }
+
+ void retriveSliceOption(DelegateExecution execution) {
+ logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI")
+ String uuiRequest = execution.getVariable("uuiRequest")
+ boolean isNSIOptionAvailable = false
+ List<String> nssiAssociated = new ArrayList<>()
+ SliceTaskParams sliceParams = execution.getVariable("sliceTaskParams")
+ try
+ {
+ String modelUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_uuid")
+ String modelInvariantUuid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.nstar0_allottedresource0_providing_service_invariant_uuid")
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ //Params sliceParams = new Gson().fromJson(params, new TypeToken<Params>() {}.getType());
+ execution.setVariable("sliceParams", sliceParams)
+ }catch (Exception ex) {
+ logger.debug( "Unable to get the task information from request DB: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.")
+ }
+
+ if(isBlank(sliceParams.getSuggestNsiId()))
+ {
+ isNSIOptionAvailable=false
+ }
+ else
+ {
+ isNSIOptionAvailable=true
+ execution.setVariable('nsiServiceInstanceId',sliceParams.getSuggestNsiId())
+ execution.setVariable('nsiServiceInstanceName',sliceParams.getSuggestNsiName())
+ }
+ execution.setVariable("isNSIOptionAvailable",isNSIOptionAvailable)
+ logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI")
+ }
+
+ void updateRelationship(DelegateExecution execution) {
+ logger.trace("Enter update relationship in DoAllocateNSIandNSSI()")
+ String nsiServiceInstanceId = execution.getVariable("nsiServiceInstanceId")
+ String allottedResourceId = execution.getVariable("allottedResourceId")
+ //Need to check whether nsi exist : Begin
+ org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = new org.onap.aai.domain.yang.ServiceInstance()
+ SliceTaskParams sliceParams = execution.getVariable("sliceParams")
+
+ String nsiServiceInstanceID = sliceParams.getSuggestNsiId()
+
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID)
+ //AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.QUERY_ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceID)
+
+ try {
+ AAIResultWrapper wrapper = resourceClient.get(nsiServiceuri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ nsiServiceInstance = si.get()
+ //allottedResourceId=nsiServiceInstance.getAllottedResources().getAllottedResource().get(0).getId()
+
+// if(resourceClient.exists(nsiServiceuri)){
+// execution.setVariable("nsi_resourceLink", nsiServiceuri.build().toString())
+// }else{
+// exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "Service instance was not found in aai to " +
+// "associate for service :"+serviceInstanceId)
+// }
+ }catch(BpmnError e) {
+ throw e;
+ }catch (Exception ex){
+ String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID
+ logger.debug(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nsiServiceInstanceId, allottedResourceId)
+ getAAIClient().connect(allottedResourceUri,nsiServiceuri)
+
+ List<String> nssiAssociated = new ArrayList<>()
+ RelationshipList relationshipList = nsiServiceInstance.getRelationshipList()
+ List<Relationship> relationships = relationshipList.getRelationship()
+ for(Relationship relationship in relationships)
+ {
+ if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
+ {
+ String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
+ if(!NSSIassociated.equals(nsiServiceInstanceID))
+ nssiAssociated.add(NSSIassociated)
+ }
+ }
+ execution.setVariable("nssiAssociated",nssiAssociated)
+ execution.setVariable("nsiServiceInstanceName",nsiServiceInstance.getServiceInstanceName())
+ logger.trace("Exit update relationship in DoAllocateNSIandNSSI()")
+ }
+
+ void prepareNssiModelInfo(DelegateExecution execution){
+ logger.trace("Enter prepareNssiModelInfo in DoAllocateNSIandNSSI()")
+ List<String> nssiAssociated = new ArrayList<>()
+ Map<String, Object> nssiMap = new HashMap<>()
+ nssiAssociated=execution.getVariable("nssiAssociated")
+ for(String nssiID in nssiAssociated)
+ {
+ try {
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("serviceType"), nssiID)
+ AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+ nssiMap.put(nssi.getEnvironmentContext(),"""{
+ "serviceInstanceId":"${nssi.getServiceInstanceId()}",
+ "modelUuid":"${nssi.getModelVersionId()}"
+ }""")
+
+ }catch(NotFoundException e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }catch(Exception e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }
+ execution.setVariable("nssiMap",nssiMap)
+
+ }
+ logger.trace("Exit prepareNssiModelInfo in DoAllocateNSIandNSSI()")
+ }
+
+ void createNSIinAAI(DelegateExecution execution) {
+ logger.trace("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ org.onap.aai.domain.yang.ServiceInstance nsi = new ServiceInstance();
+ String sliceInstanceId = UUID.randomUUID().toString()
+ execution.setVariable("sliceInstanceId",sliceInstanceId)
+ nsi.setServiceInstanceId(sliceInstanceId)
+ String sliceInstanceName = "nsi_"+execution.getVariable("serviceInstanceName")
+ nsi.setServiceInstanceName(sliceInstanceName)
+ String serviceType = execution.getVariable("serviceType")
+ nsi.setServiceType(serviceType)
+ String serviceStatus = "deactivated"
+ nsi.setOrchestrationStatus(serviceStatus)
+ String modelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
+ String modelUuid = serviceDecomposition.getModelInfo().getModelUuid()
+ nsi.setModelInvariantId(modelInvariantUuid)
+ nsi.setModelVersionId(modelUuid)
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
+ nsi.setServiceInstanceLocationId(serviceInstanceLocationid)
+ //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.requestInputs.snssai")
+ //nsi.setEnvironmentContext(snssai)
+ String serviceRole = "nsi"
+ nsi.setServiceRole(serviceRole)
+ try {
+
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceInstanceId)
+ client.create(uri, nsi)
+
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ Map<String, Object> nssiMap = new HashMap<>()
+ List<ServiceProxy> serviceProxyList = serviceDecomposition.getServiceProxy()
+ List<String> nsstModelInfoList = new ArrayList<>()
+ for(ServiceProxy serviceProxy : serviceProxyList)
+ {
+ //String nsstModelUuid = serviceProxy.getModelInfo().getModelUuid()
+ String nsstModelUuid = serviceProxy.getSourceModelUuid()
+ //String nsstModelInvariantUuid = serviceProxy.getModelInfo().getModelInvariantUuid()
+ String nsstServiceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${nsstModelUuid}",
+ "modelVersion":""
+ }"""
+ nsstModelInfoList.add(nsstServiceModelInfo)
+ }
+ int currentIndex=0
+ int maxIndex=nsstModelInfoList.size()
+ if(maxIndex < 1)
+ {
+ msg = "Exception in DoAllocateNSIandNSSI. There is no NSST associated with NST "
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ execution.setVariable("nsstModelInfoList",nsstModelInfoList)
+ execution.setVariable("currentIndex",currentIndex)
+ execution.setVariable("maxIndex",maxIndex)
+ execution.setVariable('nsiServiceInstanceId',sliceInstanceId)
+ execution.setVariable("nsiServiceInstanceName",sliceInstanceName)
+ logger.trace("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()")
+ }
+
+ void getOneNsstInfo(DelegateExecution execution){
+ List<String> nsstModelInfoList = new ArrayList<>()
+ nsstModelInfoList = execution.getVariable("nsstModelInfoList")
+ int currentIndex = execution.getVariable("currentIndex")
+ int maxIndex = execution.getVariable("maxIndex")
+ boolean isMoreNSSTtoProcess = true
+ String nsstServiceModelInfo = nsstModelInfoList.get(currentIndex)
+ execution.setVariable("serviceModelInfo", nsstServiceModelInfo)
+ execution.setVariable("currentIndex", currentIndex)
+ currentIndex = currentIndex+1
+ if(currentIndex <= maxIndex )
+ isMoreNSSTtoProcess = false
+ execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess)
+ }
+
+ void createNSSTMap(DelegateExecution execution){
+ ServiceDecomposition serviceDecomposition = execution.getVariable("serviceDecomposition")
+ String modelUuid= serviceDecomposition.getModelInfo().getModelUuid()
+ String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
+ //String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
+ //String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+ //String type = jsonUtil.getJsonValue(content, "metadata.type")
+ String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
+
+ Map<String, Object> nssiMap = execution.getVariable("nssiMap")
+ String servicename = execution.getVariable("serviceInstanceName")
+ String nsiname = "nsi_"+servicename
+ nssiMap.put(domain,"""{
+ "serviceInstanceId":"",
+ "modelUuid":"${modelUuid}"
+ }""")
+ execution.setVariable("nssiMap",nssiMap)
+ }
+
+ void prepareNSSIList(DelegateExecution execution){
+ logger.trace("Enter prepareNSSIList in DoAllocateNSIandNSSI()")
+ Map<String, Object> nssiMap = new HashMap<>()
+ Boolean isMoreNSSI = false
+ nssiMap = execution.getVariable("nssiMap")
+ List<String> keys=new ArrayList<String>(nssiMap.values())
+ List<String> nsstSequence = execution.getVariable("nsstSequence")
+ Integer currentIndex=0;
+ execution.setVariable("currentNssiIndex",currentIndex)
+ Integer maxIndex=keys.size()
+ execution.setVariable("maxIndex",maxIndex)
+ if(maxIndex>0)
+ isMoreNSSI=true
+ execution.setVariable("isMoreNSSI",isMoreNSSI)
+ logger.trace("Exit prepareNSSIList in DoAllocateNSIandNSSI()")
+ }
+
+
+ void getOneNSSIInfo(DelegateExecution execution){
+ logger.trace("Enter getOneNSSIInfo in DoAllocateNSIandNSSI()")
+
+ //ServiceDecomposition serviceDecompositionObj = execution.getVariable("serviceDecompositionObj")
+ Map<String, Object> nssiMap=execution.getVariable("nssiMap")
+ List<String> nsstSequence = execution.getVariable("nsstSequence")
+ String currentNSST= nsstSequence.get(execution.getVariable("currentNssiIndex"))
+ boolean isNSSIOptionAvailable = false
+ String nsstInput=nssiMap.get(currentNSST)
+ execution.setVariable("nsstInput",nsstInput)
+ String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
+ String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
+ String nssiserviceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ Integer currentIndex = execution.getVariable("currentNssiIndex")
+ currentIndex=currentIndex+1;
+ execution.setVariable("currentNssiIndex",currentIndex)
+ execution.setVariable("nssiserviceModelInfo",nssiserviceModelInfo)
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ logger.trace("Exit getOneNSSIInfo in DoAllocateNSIandNSSI()")
+ }
+
+ void updateCurrentIndex(DelegateExecution execution){
+
+ logger.trace("Enter updateCurrentIndex in DoAllocateNSIandNSSI()")
+ Integer currentIndex = execution.getVariable("currentNssiIndex")
+ Integer maxIndex = execution.getVariable("maxIndex")
+ if(currentIndex>=maxIndex)
+ {
+ Boolean isMoreNSSI=false
+ execution.setVariable("isMoreNSSI",isMoreNSSI)
+ }
+ logger.trace("Exit updateCurrentIndex in DoAllocateNSIandNSSI()")
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
new file mode 100644
index 0000000000..d786cb0ba1
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy
@@ -0,0 +1,771 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.aai.domain.yang.SliceProfile
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.AllocateAnNssi
+import org.onap.so.beans.nsmf.AllocateCnNssi
+import org.onap.so.beans.nsmf.AllocateTnNssi
+import org.onap.so.beans.nsmf.AnSliceProfile
+import org.onap.so.beans.nsmf.CnSliceProfile
+import org.onap.so.beans.nsmf.EsrInfo
+import org.onap.so.beans.nsmf.JobStatusRequest
+import org.onap.so.beans.nsmf.NetworkType
+import org.onap.so.beans.nsmf.NsiInfo
+import org.onap.so.beans.nsmf.NssiAllocateRequest
+import org.onap.so.beans.nsmf.PerfReq
+import org.onap.so.beans.nsmf.PerfReqEmbbList
+import org.onap.so.beans.nsmf.PerfReqUrllcList
+import org.onap.so.beans.nsmf.ResourceSharingLevel
+import org.onap.so.beans.nsmf.ServiceProfile
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.beans.nsmf.TnSliceProfile
+import org.onap.so.beans.nsmf.UeMobilityLevel
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.core.RollbackData
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.ModelInfo
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIEdgeLabel
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+
+class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSI.class);
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+ void preProcessRequest (DelegateExecution execution) {
+ logger.trace("Enter preProcessRequest()")
+ String msg = ""
+ String nssmfOperation = ""
+ String msoRequestId = execution.getVariable("msoRequestId")
+ String nsstInput = execution.getVariable("nsstInput")
+ String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid")
+ //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f"
+ String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo",serviceModelInfo)
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ String nssiProfileID = UUID.randomUUID().toString()
+ execution.setVariable("nssiProfileID",nssiProfileID)
+ if(isBlank(nssiInstanceId))
+ {
+ nssmfOperation="create"
+ nssiInstanceId = UUID.randomUUID().toString()
+ }else {
+ nssmfOperation = "update"
+ }
+ execution.setVariable("nssmfOperation",nssmfOperation)
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+
+ def isDebugLogEnabled ="false"
+ def isNSSICreated = false
+ execution.setVariable("isNSSICreated",isNSSICreated)
+
+ int currentCycle = 0
+ execution.setVariable("currentCycle", currentCycle)
+
+ logger.trace("Exit preProcessRequest")
+ }
+
+
+ void getNSSTInfo(DelegateExecution execution){
+ logger.trace("Enter getNSSTInfo in DoAllocateNSSI()")
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ ModelInfo modelInfo = serviceDecomposition.getModelInfo()
+ String serviceRole = "nssi"
+ String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid()
+ String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid()
+ String nssiServiceType = serviceDecomposition.getServiceType()
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name")
+ execution.setVariable("nssiServiceName",nssiServiceName)
+ execution.setVariable("nssiServiceType",nssiServiceType)
+ execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid)
+ execution.setVariable("nssiServiceUuid",nssiServiceUuid)
+ execution.setVariable("serviceRole",serviceRole)
+
+ String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
+ String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
+ String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+ String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType")
+ String nsstType = jsonUtil.getJsonValue(content, "metadata.type")
+
+ execution.setVariable("nsstID",nsstID)
+ execution.setVariable("nsstVendor",nsstVendor)
+ execution.setVariable("nsstDomain",nsstDomain)
+ execution.setVariable("nssiServiceUuid",nssiServiceUuid)
+ execution.setVariable("nsstType",nsstType)
+
+ String nsstContentInfo = """{
+ "NsstID":"${nsstID}",
+ "Vendor":"${nsstVendor}",
+ "type":"${nsstType}"
+ }"""
+
+ logger.trace("Exit getNSSTInfo in DoAllocateNSSI()")
+ }
+
+ void timeDelay(DelegateExecution execution) {
+ logger.trace("Enter timeDelay in DoAllocateNSSI()")
+ try {
+ Thread.sleep(60000);
+ int currentCycle = execution.getVariable("currentCycle")
+ currentCycle=currentCycle+1
+ if(currentCycle>60)
+ {
+ logger.trace("Completed all the retry times... but still nssmf havent completed the creation process...")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "NSSMF creation didnt complete by time...")
+ }
+ execution.setVariable("currentCycle",currentCycle)
+ } catch(InterruptedException e) {
+ logger.info("Time Delay exception" + e)
+ }
+ logger.trace("Exit timeDelay in DoAllocateNSSI()")
+ }
+
+
+ void sendUpdateRequestNSSMF(DelegateExecution execution) {
+ logger.trace("Enter sendUpdateRequestNSSMF in DoAllocateNSSI()")
+ String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ logger.debug( "get NSSMF: " + urlString)
+
+ //Prepare auth for NSSMF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+ String domain = execution.getVariable("nsstDomain")
+ String nssmfRequest = buildUpdateNSSMFRequest(execution, domain.toUpperCase())
+
+ //send request to update NSSI option - Begin
+ URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(nssmfRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF sync response code is: " + responseCode)
+
+ if(responseCode < 199 && responseCode > 299){
+ String nssmfResponse ="NSSMF response have nobody"
+ if(httpResponse.hasEntity())
+ nssmfResponse = httpResponse.readEntity(String.class)
+ logger.trace("received error message from NSSMF : "+nssmfResponse)
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String nssmfResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("nssmfResponse", nssmfResponse)
+ String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
+ String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
+ execution.setVariable("nssiId",nssiId)
+ execution.setVariable("jobId",jobId)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+ logger.trace("Exit sendUpdateRequestNSSMF in DoAllocateNSSI()")
+ }
+
+ void sendCreateRequestNSSMF(DelegateExecution execution) {
+ logger.trace("Enter sendCreateRequestNSSMF in DoAllocateNSSI()")
+ String urlString = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ logger.debug( "get NSSMF: " + urlString)
+
+ //Prepare auth for NSSMF - Begin
+ String domain = execution.getVariable("nsstDomain")
+ String nssmfRequest = buildCreateNSSMFRequest(execution, domain.toUpperCase())
+
+ //send request to get NSI option - Begin
+ URL url = new URL(urlString+"/api/rest/provMns/v1/NSS/SliceProfiles")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(nssmfRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF sync response code is: " + responseCode)
+
+ if(responseCode < 199 || responseCode > 299 ){
+ String nssmfResponse ="NSSMF response have nobody"
+ if(httpResponse.hasEntity())
+ nssmfResponse = httpResponse.readEntity(String.class)
+ logger.trace("received error message from NSSMF : "+nssmfResponse)
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String nssmfResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("nssmfResponse", nssmfResponse)
+ String nssiId = jsonUtil.getJsonValue(nssmfResponse, "nssiId")
+ String jobId = jsonUtil.getJsonValue(nssmfResponse, "jobId")
+ execution.setVariable("nssiId",nssiId)
+ execution.setVariable("jobId",jobId)
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+
+ }
+
+ void getNSSMFProgresss(DelegateExecution execution) {
+ logger.trace("Enter getNSSMFProgresss in DoAllocateNSSI()")
+
+ String endpoint = UrnPropertiesReader.getVariable("mso.adapters.nssmf.endpoint", execution)
+ logger.debug( "get NSSMF: " + endpoint)
+
+ //Prepare auth for NSSMF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.nssmf.auth", execution)
+
+ String nssmfRequest = buildNSSMFProgressRequest(execution)
+ String strUrl="/api/rest/provMns/v1/NSS/jobs/"+execution.getVariable("jobId")
+ //send request to update NSSI option - Begin
+ URL url = new URL(endpoint+strUrl)
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.EXTERNAL)
+ Response httpResponse = httpClient.post(nssmfRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("NSSMF sync response code is: " + responseCode)
+
+ if(responseCode < 199 || responseCode > 299){
+ String nssmfResponse ="NSSMF response have nobody"
+ if(httpResponse.hasEntity())
+ nssmfResponse = httpResponse.readEntity(String.class)
+ logger.trace("received error message from NSSMF : "+nssmfResponse)
+ logger.trace("Exit sendCreateRequestNSSMF in DoAllocateNSSI()")
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String nssmfResponse = httpResponse.readEntity(String.class)
+ Boolean isNSSICreated = false
+ execution.setVariable("nssmfResponse", nssmfResponse)
+ Integer progress = java.lang.Integer.parseInt(jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.progress"))
+ String status = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.status")
+ String statusDescription = jsonUtil.getJsonValue(nssmfResponse, "responseDescriptor.statusDescription")
+ execution.setVariable("nssmfProgress",progress)
+ execution.setVariable("nssmfStatus",status)
+ execution.setVariable("nddmfStatusDescription",statusDescription)
+ if(progress>99)
+ isNSSICreated = true
+ execution.setVariable("isNSSICreated",isNSSICreated)
+
+ }else{
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from NSSMF.")
+ }
+ logger.trace("Exit getNSSMFProgresss in DoAllocateNSSI()")
+
+ }
+
+ void updateRelationship(DelegateExecution execution) {
+ logger.trace("Enter updateRelationship in DoAllocateNSSI()")
+ String nssiInstanceId = execution.getVariable("nssiInstanceId")
+ String nsiInstanceId = execution.getVariable("nsiServiceInstanceId")
+ try{
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nsiInstanceId);
+ AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
+ getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
+ }catch(Exception ex) {
+ String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ logger.trace("Exit updateRelationship in DoAllocateNSSI()")
+ }
+
+
+ void instantiateNSSIService(DelegateExecution execution) {
+ logger.trace("Enter instantiateNSSIService in DoAllocateNSSI()")
+ //String nssiInstanceId = execution.getVariable("nssiInstanceId")
+ String nssiInstanceId = execution.getVariable("nssiId")
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ String sliceInstanceId = execution.getVariable("nsiServiceInstanceId")
+ try {
+ org.onap.aai.domain.yang.ServiceInstance nssi = new ServiceInstance();
+ Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+
+ nssi.setServiceInstanceId(nssiInstanceId)
+ nssi.setServiceInstanceName(execution.getVariable("nssiServiceName"))
+ //nssi.setServiceType(execution.getVariable("nssiServiceType"))
+ nssi.setServiceType(serviceProfileMap.get("sST").toString())
+ String serviceStatus = "deactivated"
+ nssi.setOrchestrationStatus(serviceStatus)
+ String modelInvariantUuid = execution.getVariable("nssiServiceInvariantUuid")
+ String modelUuid = execution.getVariable("nssiServiceUuid")
+ nssi.setModelInvariantId(modelInvariantUuid)
+ nssi.setModelVersionId(modelUuid)
+ String uuiRequest = execution.getVariable("uuiRequest")
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList")
+ nssi.setServiceInstanceLocationId(serviceInstanceLocationid)
+ //String snssai = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.sNSSAI")
+ String envContext=execution.getVariable("nsstDomain")
+ nssi.setEnvironmentContext(envContext)
+ nssi.setServiceRole(execution.getVariable("serviceRole"))
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), nssiInstanceId)
+ client.create(uri, nssi)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ try{
+ AAIResourceUri nsiServiceuri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, sliceInstanceId);
+ AAIResourceUri nssiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, nssiInstanceId)
+ getAAIClient().connect(nsiServiceuri, nssiServiceUri, AAIEdgeLabel.COMPOSED_OF);
+ }catch(Exception ex) {
+ String msg = "Exception in DoAllocateNSSI InstantiateNSSI service while creating relationship " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+
+
+ def rollbackData = execution.getVariable("RollbackData")
+ if (rollbackData == null) {
+ rollbackData = new RollbackData();
+ }
+ //rollbackData.put("SERVICEINSTANCE", "disableRollback", idisableRollback.toStrng())
+ rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
+ rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", nssiInstanceId)
+ rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("subscriptionServiceType"))
+ rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
+ execution.setVariable("rollbackData", rollbackData)
+ execution.setVariable("RollbackData", rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
+ logger.trace("Exit instantiateNSSIService in DoAllocateNSSI()")
+ }
+
+
+ void createSliceProfile(DelegateExecution execution) {
+ logger.trace("Enter createSliceProfile in DoAllocateNSSI()")
+ String sliceserviceInstanceId = execution.getVariable("nssiInstanceId")
+ String nssiProfileID = execution.getVariable("nssiProfileID")
+ Map<String, Object> sliceProfileMap = execution.getVariable("sliceProfileCn")
+ Map<String, Object> serviceProfileMap = execution.getVariable("serviceProfile")
+ SliceProfile sliceProfile = new SliceProfile()
+ sliceProfile.setServiceAreaDimension("")
+ sliceProfile.setPayloadSize(0)
+ sliceProfile.setJitter(0)
+ sliceProfile.setSurvivalTime(0)
+ //sliceProfile.setCsAvailability()
+ //sliceProfile.setReliability()
+ sliceProfile.setExpDataRate(0)
+ sliceProfile.setTrafficDensity(0)
+ sliceProfile.setConnDensity(0)
+ sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString()))
+ sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString()))
+ sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
+ sliceProfile.setResourceSharingLevel(sliceProfileMap.get("activityFactor").toString())
+ sliceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString())
+ sliceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString())
+ sliceProfile.setMaxNumberOfUEs(Integer.parseInt(sliceProfileMap.get("activityFactor").toString()))
+ sliceProfile.setLatency(Integer.parseInt(sliceProfileMap.get("latency").toString()))
+ sliceProfile.setProfileId(nssiProfileID)
+ sliceProfile.setE2ELatency(0)
+
+ try {
+ AAIResourcesClient client = new AAIResourcesClient()
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE,
+ execution.getVariable("globalSubscriberId"), execution.getVariable("subscriptionServiceType"), sliceserviceInstanceId, nssiProfileID)
+ client.create(uri, sliceProfile)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+
+ def rollbackData = execution.getVariable("RollbackData")
+ if (rollbackData == null) {
+ rollbackData = new RollbackData();
+ }
+ //rollbackData.put("SERVICEINSTANCE", "disableRollback", disableRollback.toString())
+ rollbackData.put("SERVICEINSTANCE", "rollbackAAI", "true")
+ rollbackData.put("SERVICEINSTANCE", "serviceInstanceId", sliceserviceInstanceId)
+ rollbackData.put("SERVICEINSTANCE", "subscriptionServiceType", execution.getVariable("serviceType"))
+ rollbackData.put("SERVICEINSTANCE", "globalSubscriberId", execution.getVariable("globalSubscriberId"))
+ execution.setVariable("rollbackData", rollbackData)
+ execution.setVariable("RollbackData", rollbackData)
+ logger.debug("RollbackData:" + rollbackData)
+ logger.trace("Exit createSliceProfile in DoAllocateNSSI()")
+ }
+
+
+ String buildCreateNSSMFRequest(DelegateExecution execution, String domain) {
+
+ NssiAllocateRequest request = new NssiAllocateRequest()
+ String strRequest = ""
+ //String uuiRequest = execution.getVariable("uuiRequest")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+
+ switch (domain) {
+ case "AN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("networkType"))
+ esrInfo.setVendor(execution.getVariable("nsstVendor"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AnSliceProfile anSliceProfile = new AnSliceProfile()
+ anSliceProfile.setLatency(execution.getVariable("latency"))
+ anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
+ anSliceProfile.setQi(execution.getVariable("qi"))
+
+ AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
+ allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
+ allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateAnNssi.setNsiInfo(nsiInfo)
+ allocateAnNssi.setSliceProfile(anSliceProfile)
+ String anScriptName = sliceTaskParams.getAnScriptName()
+ allocateAnNssi.setScriptName(anScriptName)
+
+ request.setAllocateAnNssi(allocateAnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "CN":
+ Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
+ nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
+
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(NetworkType.fromString(domain))
+ esrInfo.setVendor(execution.getVariable("nsstVendor"))
+ execution.setVariable("esrInfo",esrInfo)
+
+
+ PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList()
+ perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
+ perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
+ perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
+ perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
+ perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
+
+ List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>()
+ listPerfReqEmbbList.add(perfReqEmbb)
+
+ PerfReq perfReq = new PerfReq()
+ perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
+
+ PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList()
+ perfReqUrllc.setConnDensity(0)
+ perfReqUrllc.setTrafficDensity(0)
+ perfReqUrllc.setExpDataRate(0)
+ perfReqUrllc.setReliability(0)
+ perfReqUrllc.setCsAvailability(0)
+ perfReqUrllc.setSurvivalTime(0)
+ perfReqUrllc.setJitter(0)
+ perfReqUrllc.setE2eLatency(0)
+ perfReqUrllc.setPayloadSize("0")
+ perfReqUrllc.setServiceAreaDimension("")
+
+ List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>()
+ perfReqUrllcList.add(perfReqUrllc)
+ perfReq.setPerfReqUrllcList(perfReqUrllcList)
+
+ CnSliceProfile cnSliceProfile = new CnSliceProfile()
+ cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
+ String plmnStr = serviceProfile.get("plmnIdList")
+ List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
+ cnSliceProfile.setPlmnIdList(plmnIdList)
+
+ String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
+ cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
+
+ String coverageArea = serviceProfile.get("coverageAreaTAList")
+ List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
+ cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
+
+ String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
+ cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
+
+ int latency = serviceProfile.get("latency")
+ cnSliceProfile.setLatency(latency)
+
+ int maxUE = serviceProfile.get("maxNumberofUEs")
+ cnSliceProfile.setMaxNumberofUEs(maxUE)
+
+ String snssai = serviceProfile.get("sNSSAI")
+ List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
+ cnSliceProfile.setSnssaiList(snssaiList)
+
+ cnSliceProfile.setPerfReq(perfReq)
+
+ AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
+ allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
+ allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateCnNssi.setSliceProfile(cnSliceProfile)
+ allocateCnNssi.setNsiInfo(nsiInfo)
+ String cnScriptName = sliceTaskParams.getCnScriptName()
+ allocateCnNssi.setScriptName(cnScriptName)
+ request.setAllocateCnNssi(allocateCnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "TN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("networkType"))
+ esrInfo.setVendor(execution.getVariable("vendor"))
+
+ TnSliceProfile tnSliceProfile = new TnSliceProfile()
+ tnSliceProfile.setLatency(execution.getVariable("latency"))
+ tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
+ allocateTnNssi.setSliceProfile(tnSliceProfile)
+ allocateTnNssi.setNsiInfo(nsiInfo)
+ allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
+ String tnScriptName = sliceTaskParams.getTnScriptName()
+ allocateTnNssi.setScriptName(tnScriptName)
+
+ request.setAllocateTnNssi(allocateTnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ default:
+ break;
+ }
+ try {
+ strRequest = MAPPER.writeValueAsString(request);
+ } catch (IOException e) {
+ logger.error("Invalid get progress request bean to convert as string");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
+ }
+ return strRequest
+ }
+
+
+ String buildUpdateNSSMFRequest(DelegateExecution execution, String domain) {
+ NssiAllocateRequest request = new NssiAllocateRequest()
+ String nsstInput = execution.getVariable("nsstInput")
+ String nssiId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId")
+ String strRequest = ""
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ switch (domain) {
+ case "AN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("nsstType"))
+ esrInfo.setVendor(execution.getVariable("vendor"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AnSliceProfile anSliceProfile = new AnSliceProfile()
+ anSliceProfile.setLatency(execution.getVariable("latency"))
+ anSliceProfile.setCoverageAreaTAList(execution.getVariable("coverageAreaList"))
+ anSliceProfile.setQi(execution.getVariable("qi"))
+
+ AllocateAnNssi allocateAnNssi = new AllocateAnNssi()
+ allocateAnNssi.setNsstId(execution.getVariable("nsstId"))
+ allocateAnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateAnNssi.setNsiInfo(nsiInfo)
+ allocateAnNssi.setSliceProfile(anSliceProfile)
+ String anScriptName = sliceTaskParams.getAnScriptName()
+ allocateAnNssi.setScriptName(anScriptName)
+ request.setAllocateAnNssi(allocateAnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "CN":
+ Map<String, Object> sliceProfileCn =execution.getVariable("sliceProfileCn")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiServiceInstanceId"))
+ nsiInfo.setNsiName(execution.getVariable("nsiServiceInstanceName"))
+
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(NetworkType.fromString(domain))
+ esrInfo.setVendor(execution.getVariable("nsstVendor"))
+ execution.setVariable("esrInfo",esrInfo)
+
+
+ PerfReqEmbbList perfReqEmbb = new PerfReqEmbbList()
+ perfReqEmbb.setActivityFactor(sliceProfileCn.get("activityFactor"))
+ perfReqEmbb.setAreaTrafficCapDL(sliceProfileCn.get("areaTrafficCapDL"))
+ perfReqEmbb.setAreaTrafficCapUL(sliceProfileCn.get("areaTrafficCapUL"))
+ perfReqEmbb.setExpDataRateDL(sliceProfileCn.get("expDataRateDL"))
+ perfReqEmbb.setExpDataRateUL(sliceProfileCn.get("expDataRateUL"))
+
+ List<PerfReqEmbbList> listPerfReqEmbbList = new ArrayList<>()
+ listPerfReqEmbbList.add(perfReqEmbb)
+
+ PerfReq perfReq = new PerfReq()
+ perfReq.setPerfReqEmbbList(listPerfReqEmbbList)
+
+ PerfReqUrllcList perfReqUrllc = new PerfReqUrllcList()
+ perfReqUrllc.setConnDensity(0)
+ perfReqUrllc.setTrafficDensity(0)
+ perfReqUrllc.setExpDataRate(0)
+ perfReqUrllc.setReliability(0)
+ perfReqUrllc.setCsAvailability(0)
+ perfReqUrllc.setSurvivalTime(0)
+ perfReqUrllc.setJitter(0)
+ perfReqUrllc.setE2eLatency(0)
+ perfReqUrllc.setPayloadSize("0")
+ perfReqUrllc.setServiceAreaDimension("")
+
+ List<PerfReqUrllcList> perfReqUrllcList = new ArrayList<>()
+ perfReqUrllcList.add(perfReqUrllc)
+ perfReq.setPerfReqUrllcList(perfReqUrllcList)
+
+ CnSliceProfile cnSliceProfile = new CnSliceProfile()
+ cnSliceProfile.setSliceProfileId(execution.getVariable("nssiProfileID"))
+ String plmnStr = serviceProfile.get("plmnIdList")
+ List<String> plmnIdList=Arrays.asList(plmnStr.split("\\|"))
+ cnSliceProfile.setPlmnIdList(plmnIdList)
+
+ String resourceSharingLevel = serviceProfile.get("resourceSharingLevel").toString()
+ cnSliceProfile.setResourceSharingLevel(ResourceSharingLevel.fromString(resourceSharingLevel))
+
+ String coverageArea = serviceProfile.get("coverageAreaTAList")
+ List<String> coverageAreaList=Arrays.asList(coverageArea.split("\\|"))
+ cnSliceProfile.setCoverageAreaTAList(coverageAreaList)
+
+ String ueMobilityLevel = serviceProfile.get("uEMobilityLevel").toString()
+ cnSliceProfile.setUeMobilityLevel(UeMobilityLevel.fromString(ueMobilityLevel))
+
+ int latency = serviceProfile.get("latency")
+ cnSliceProfile.setLatency(latency)
+
+ int maxUE = serviceProfile.get("maxNumberofUEs")
+ cnSliceProfile.setMaxNumberofUEs(maxUE)
+
+ String snssai = serviceProfile.get("sNSSAI")
+ List<String> snssaiList = Arrays.asList(snssai.split("\\|"))
+ cnSliceProfile.setSnssaiList(snssaiList)
+
+ cnSliceProfile.setPerfReq(perfReq)
+
+ AllocateCnNssi allocateCnNssi = new AllocateCnNssi()
+ allocateCnNssi.setNsstId(execution.getVariable("nsstid"))
+ allocateCnNssi.setNssiName(execution.getVariable("nssiName"))
+ allocateCnNssi.setSliceProfile(cnSliceProfile)
+ allocateCnNssi.setNsiInfo(nsiInfo)
+ allocateCnNssi.setNssiId(nssiId) // need to check this
+ String cnScriptName = sliceTaskParams.getCnScriptName()
+ allocateCnNssi.setScriptName(cnScriptName)
+ request.setAllocateCnNssi(allocateCnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ case "TN":
+ EsrInfo esrInfo = new EsrInfo()
+ esrInfo.setNetworkType(execution.getVariable("networkType"))
+ esrInfo.setVendor(execution.getVariable("vendor"))
+
+ TnSliceProfile tnSliceProfile = new TnSliceProfile()
+ tnSliceProfile.setLatency(execution.getVariable("latency"))
+ tnSliceProfile.setBandwidth(execution.getVariable("bandWidth"))
+
+ NsiInfo nsiInfo = new NsiInfo()
+ nsiInfo.setNsiId(execution.getVariable("nsiInstanceID"))
+ nsiInfo.setNsiName(execution.getVariable("nsiInstanceName"))
+
+ AllocateTnNssi allocateTnNssi = new AllocateTnNssi()
+ allocateTnNssi.setSliceProfile(tnSliceProfile)
+ allocateTnNssi.setNsiInfo(nsiInfo)
+ allocateTnNssi.setNsstId(execution.getVariable("nsstid"))
+ String tnScriptName = sliceTaskParams.getTnScriptName()
+ allocateTnNssi.setScriptName(tnScriptName)
+ request.setAllocateTnNssi(allocateTnNssi)
+ request.setEsrInfo(esrInfo)
+ break;
+ default:
+ break;
+ }
+ try {
+ strRequest = MAPPER.writeValueAsString(request);
+ } catch (IOException e) {
+ logger.error("Invalid get progress request bean to convert as string");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
+ }
+ return strRequest
+ }
+
+ String buildNSSMFProgressRequest(DelegateExecution execution){
+ JobStatusRequest request = new JobStatusRequest()
+ String strRequest = ""
+ EsrInfo esrInfo = execution.getVariable("esrInfo")
+ request.setNsiId(execution.getVariable("nsiServiceInstanceId"))
+ request.setNssiId(execution.getVariable("nssiId"))
+ request.setEsrInfo(esrInfo)
+
+ try {
+ strRequest = MAPPER.writeValueAsString(request);
+ } catch (IOException e) {
+ logger.error("Invalid get progress request bean to convert as string");
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Invalid get progress request bean to convert as string")
+ }
+ return strRequest
+ }
+
+ public void prepareUpdateOrchestrationTask(DelegateExecution execution) {
+ logger.debug("Start prepareUpdateOrchestrationTask progress")
+ String requestMethod = "PUT"
+ String progress = execution.getVariable("nssmfProgress")
+ String status = execution.getVariable("nssmfStatus")
+ String statusDescription=execution.getVariable("nddmfStatusDescription")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ String domain = execution.getVariable("nsstDomain")
+ switch (domain.toUpperCase()) {
+ case "AN":
+ sliceTaskParams.setAnProgress(progress)
+ sliceTaskParams.setAnStatus(status)
+ sliceTaskParams.setAnStatusDescription(statusDescription)
+ break;
+ case "CN":
+ sliceTaskParams.setCnProgress(progress)
+ sliceTaskParams.setCnStatus(status)
+ sliceTaskParams.setCnStatusDescription(statusDescription)
+ break;
+ case "TN":
+ sliceTaskParams.setTnProgress(progress)
+ sliceTaskParams.setTnStatus(status)
+ sliceTaskParams.setTnStatusDescription(statusDescription)
+ break;
+ default:
+ break;
+ }
+ String paramJson = sliceTaskParams.convertToJson()
+ execution.setVariable("CSSOT_paramJson", paramJson)
+ execution.setVariable("CSSOT_requestMethod", requestMethod)
+ logger.debug("Finish prepareUpdateOrchestrationTask progress")
+ }
+
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
new file mode 100644
index 0000000000..c66a89b9c6
--- /dev/null
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy
@@ -0,0 +1,524 @@
+package org.onap.so.bpmn.infrastructure.scripts
+
+import com.fasterxml.jackson.core.type.TypeReference
+import groovy.json.JsonBuilder
+import groovy.json.JsonSlurper
+import org.camunda.bpm.engine.delegate.BpmnError
+import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.Relationship
+import org.onap.aai.domain.yang.RelationshipList
+import org.onap.aai.domain.yang.ServiceInstance
+import org.onap.logging.filter.base.ONAPComponents
+import org.onap.so.beans.nsmf.SliceTaskParams
+import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor
+import org.onap.so.bpmn.common.scripts.ExceptionUtil
+import org.onap.so.bpmn.common.scripts.OofUtils
+import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.so.bpmn.core.domain.ServiceDecomposition
+import org.onap.so.bpmn.core.domain.ServiceProxy
+import org.onap.so.bpmn.core.json.JsonUtils
+import org.onap.so.client.HttpClient
+import org.onap.so.client.HttpClientFactory
+import org.onap.so.client.aai.AAIObjectType
+import org.onap.so.client.aai.AAIResourcesClient
+import org.onap.so.client.aai.entities.AAIResultWrapper
+import org.onap.so.client.aai.entities.uri.AAIResourceUri
+import org.onap.so.client.aai.entities.uri.AAIUriFactory
+import org.onap.so.db.request.client.RequestsDbClient
+import org.onap.so.db.request.beans.OrchestrationTask
+import org.slf4j.Logger
+import org.slf4j.LoggerFactory
+import javax.ws.rs.NotFoundException
+import javax.ws.rs.core.Response
+
+import static org.apache.commons.lang3.StringUtils.isBlank
+
+public class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{
+
+ private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOption.class)
+
+
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+
+ JsonUtils jsonUtil = new JsonUtils()
+
+ RequestsDbClient requestsDbClient = new RequestsDbClient()
+
+ OofUtils oofUtils = new OofUtils()
+
+ /**
+ * Pre Process the BPMN Flow Request
+ * Inclouds:
+ * generate the nsOperationKey
+ * generate the nsParameters
+ */
+ void preProcessRequest (DelegateExecution execution) {
+ String msg = ""
+ logger.trace("Enter preProcessRequest()")
+ String taskID = execution.getVariable("taskID")
+ Boolean isSharable = true
+ String resourceSharingLevel = execution.getVariable("resourceSharingLevel")
+ if (resourceSharingLevel.equals("shared"))
+ isSharable = true
+ execution.setVariable("isSharable",isSharable)
+ logger.trace("Exit preProcessRequest")
+
+ }
+
+
+ void getNSIOptionfromOOF(DelegateExecution execution) {
+
+ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+ logger.debug( "get NSI option OOF Url: " + urlString)
+ boolean isNSISuggested = true
+ execution.setVariable("isNSISuggested",isNSISuggested)
+ String nsiInstanceId = ""
+ String nsiName = ""
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ //Prepare auth for OOF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
+ String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+
+ String basicAuthValue = utils.encrypt(basicAuth, msokey)
+ if (basicAuthValue != null) {
+ logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+ try {
+ authHeader = utils.getBasicAuth(basicAuthValue, msokey)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+ } catch (Exception ex) {
+ logger.debug( "Unable to encode username and password string: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
+ "encode username and password string")
+ }
+ } else {
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
+ "value null")
+ }
+ //Prepare auth for OOF - End
+
+ String requestId = execution.getVariable("msoRequestId")
+ Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
+ String nstModelUuid = execution.getVariable("nstModelUuid")
+ String nstModelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
+ String nstInfo = """"NSTInfo" : {
+ "invariantUUID":"${nstModelInvariantUuid}",
+ "UUID":"${nstModelUuid}"
+ }"""
+
+ String oofRequest = oofUtils.buildSelectNSIRequest(execution, requestId, nstInfo, profileInfo)
+
+ //send request to get NSI option - Begin
+ URL url = new URL(urlString+"/api/oof/v1/selectnsi")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+
+ if(responseCode != 200){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ logger.debug("Info: No NSI suggested by OOF" )
+ }
+
+ if(httpResponse.hasEntity()){
+ String OOFResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("OOFResponse", OOFResponse)
+ int index = 0 //This needs to be changed to derive a value when we add policy to decide the solution options.
+ Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse)
+ if(execution.getVariable("isSharable" ) == true && OOFResponseObject.get("solutions").containsKey("sharedNSIsolutions")) {
+ nsiInstanceId = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIId
+ nsiName = OOFResponseObject.get("solutions").get("sharedNSIsolutions").get(0).get("NSISolution").NSIName
+ sliceTaskParams.setNstId(nsiInstanceId)
+ sliceTaskParams.setSuggestNsiName(nsiName)
+ execution.setVariable("nsiInstanceId",nsiInstanceId)
+ execution.setVariable("nsiName",nsiName)
+ }else {
+ if(OOFResponseObject.get("solutions").containsKey("newNSISolutions")) {
+ List NSSImap = OOFResponseObject.get("solutions").get("newNSISolutions").get(index).get("NSSISolutions")
+ for(Map nssi : NSSImap) {
+ String nssiName = nssi.get("NSSISolution").NSSIName
+ String nssiId = nssi.get("NSSISolution").NSSIId
+ String domain = nssi.get("NSSISolution").domain.toUpperCase()
+ switch (domain) {
+ case "AN":
+ sliceTaskParams.setAnSuggestNssiId(nssiId)
+ sliceTaskParams.setAnSuggestNssiName(nssiName)
+ break;
+ case "CN":
+ sliceTaskParams.setCnSuggestNssiId(nssiId)
+ sliceTaskParams.setCnSuggestNssiName(nssiName)
+ break;
+ case "TN":
+ sliceTaskParams.setTnSuggestNssiId(nssiId)
+ sliceTaskParams.setTnSuggestNssiName(nssiName)
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ }
+ execution.setVariable("sliceTaskParams", sliceTaskParams)
+ logger.debug("Info: No NSI suggested by OOF" )
+ }
+ //send request to get NSI option - Begin
+
+
+ //send request to get NSI service Info - Begin
+
+ /***
+ * Need to check whether its needed.
+ */
+// logger.debug("Begin to query OOF suggetsed NSI from AAI ")
+// if(isBlank(nsiInstanceId)){
+// isNSISuggested = false
+// execution.setVariable("isNSISuggested",isNSISuggested)
+// }else
+// {
+// try {
+// String globalSubscriberId = execution.getVariable('globalSubscriberId')
+// String serviceType = execution.getVariable('subscriptionServiceType')
+// AAIResourcesClient resourceClient = new AAIResourcesClient()
+// AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nsiInstanceId)
+// AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+// Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+// org.onap.aai.domain.yang.ServiceInstance nsiServiceInstance = si.get()
+// execution.setVariable("nsiServiceInstance",nsiServiceInstance)
+// isNSISuggested = true
+// execution.setVariable("isNSISuggested",isNSISuggested)
+// SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+// sliceTaskParams.setSuggestNsiId(nsiInstanceId)
+// sliceTaskParams.setSuggestNsiName(si.get().getServiceInstanceName())
+// execution.setVariable("sliceTaskParams", sliceTaskParams)
+// logger.debug("Info: NSI suggested by OOF exist in AAI ")
+// }catch(BpmnError e) {
+// throw e
+// }catch(Exception ex) {
+// String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
+// //exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+// logger.debug("Info: NSI suggested by OOF doesnt exist in AAI " + nsiInstanceId)
+// }
+// }
+ //send request to get NSI service Info - End
+ //${OrchestrationTaskHandler.createOrchestrationTask(execution.getVariable("OrchestrationTask"))}
+ logger.debug( "*** Completed options Call to OOF ***")
+
+ }
+
+
+ public void parseServiceProfile(DelegateExecution execution) {
+ logger.debug("Start parseServiceProfile")
+ String serviceType = execution.getVariable("serviceType")
+ Map<String, Object> serviceProfile = execution.getVariable("serviceProfile")
+
+ // set sliceProfile for three domains
+ Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile)
+ Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile)
+ Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile)
+
+ execution.setVariable("sliceProfileTn", sliceProfileTn)
+ execution.setVariable("sliceProfileCn", sliceProfileCn)
+ execution.setVariable("sliceProfileAn", sliceProfileAn)
+ logger.debug("sliceProfileTn: " + sliceProfileTn)
+ logger.debug("sliceProfileCn: " + sliceProfileCn)
+ logger.debug("sliceProfileAn: " + sliceProfileAn)
+
+ logger.debug("Finish parseServiceProfile")
+ }
+
+ public Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) {
+ String variablePath = "nsmf." + serviceType + ".profileMap" + domain
+ String profileMapStr = UrnPropertiesReader.getVariable(variablePath)
+ logger.debug("Profile map for " + domain + " : " + profileMapStr)
+ Map<String, String> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){})
+ Map<String, Object> sliceProfileTn = [:]
+ for (Map.Entry<String, String> profileMap : profileMaps) {
+ sliceProfileTn.put(profileMap.key, serviceProfile.get(profileMap.value))
+ }
+
+ return sliceProfileTn
+ }
+
+
+ void prepareNSSIList(DelegateExecution execution)
+ {
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ List<String> nssiAssociated = new ArrayList<>()
+ Map<String, String> nssimap = new HashMap<>()
+ String nsiInstanceId=execution.getVariable("nsiInstanceId")
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("subscriptionServiceType")
+
+ try {
+
+ ServiceInstance si = execution.getVariable("nsiServiceInstance")
+ //List<Relationship> relationships = si.getRelationshipList().getRelationship().stream().filter(relation ->
+ // relation.getRelatedTo().equalsIgnoreCase("service-instance"))
+ RelationshipList relationshipList = si.getRelationshipList()
+ List<Relationship> relationships = relationshipList.getRelationship()
+ for(Relationship relationship in relationships)
+ {
+ if(relationship.getRelatedTo().equalsIgnoreCase("service-instance"))
+ {
+ String NSSIassociated = relationship.getRelatedLink().substring(relationship.getRelatedLink().lastIndexOf("/") + 1);
+ if(!NSSIassociated.equals(nsiInstanceId))
+ nssiAssociated.add(NSSIassociated)
+ }
+ }
+ }catch(BpmnError e) {
+ throw e
+ }catch(Exception ex) {
+ String msg = "Internal Error in getServiceInstance: " + ex.getMessage()
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ Map<String, Object> params = execution.getVariable("params")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ for(String nssiID in nssiAssociated)
+ {
+ try {
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiID)
+ AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+
+ String domain = nssi.getEnvironmentContext().toString().toUpperCase()
+ switch (domain) {
+ case "AN":
+ sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "CN":
+ sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "TN":
+ sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ default:
+ break;
+ }
+ }catch(NotFoundException e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }catch(Exception e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiID)
+ }
+
+ }
+ String nstName = serviceDecomposition.getModelInfo().getModelName()
+ sliceTaskParams.setNstName(nstName)
+ String nstId = serviceDecomposition.getModelInfo().getModelUuid()
+ sliceTaskParams.setNstId(nstId)
+ execution.setVariable("sliceTaskParams",sliceTaskParams)
+
+ }
+
+
+ void updateOptionsInDB(DelegateExecution execution) {
+ logger.debug("Updating options with default value since not sharable : Begin ")
+ String taskID = execution.getVariable("taskID")
+ String params = execution.getVariable("params")
+ logger.debug("Updating options with default value since not sharable : End ")
+
+ }
+
+ void prepareNSTDecompose(DelegateExecution execution) {
+
+ String modelUuid = execution.getVariable("nstModelUuid")
+ String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid")
+
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"${modelInvariantUuid}",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ }
+
+ void prepareNSSTDecompose(DelegateExecution execution) {
+ Boolean isMoreNSSTtoProcess = false
+ Integer maxNSST = execution.getVariable("maxNSST")
+ Integer currentNSST=execution.getVariable("currentNSST")
+ List<String> nsstModelUUIDList = new ArrayList<>()
+ nsstModelUUIDList = execution.getVariable("nsstModelUUIDList")
+ String modelUuid = nsstModelUUIDList.get(currentNSST)
+ String serviceModelInfo = """{
+ "modelInvariantUuid":"",
+ "modelUuid":"${modelUuid}",
+ "modelVersion":""
+ }"""
+ execution.setVariable("serviceModelInfo", serviceModelInfo)
+ currentNSST=currentNSST+1
+ if(currentNSST<maxNSST)
+ isMoreNSSTtoProcess=true
+ execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
+ execution.setVariable("maxNSST",maxNSST)
+ execution.setVariable("currentNSST",currentNSST)
+ }
+
+
+ void updateStatusInDB(DelegateExecution execution) {
+
+ String taskID = execution.getVariable("taskID")
+ //OrchestrationTask orchestrationTask = requestsDbClient.getNetworkSliceOption(taskID);
+ //orchestrationTask.setTaskStage("wait to confirm")
+ //requestsDbClient.updateNetworkSliceOption(orchestrationTask)
+ }
+
+ void prepareNSSTlistfromNST(DelegateExecution execution) {
+ //Need to update this part from decomposition.
+ logger.trace("Enter prepareNSSTlistfromNST()")
+ Boolean isMoreNSSTtoProcess = false
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ String nstName = serviceDecomposition.getModelInfo().getModelName()
+ sliceTaskParams.setNstName(nstName)
+ String nstId = serviceDecomposition.getModelInfo().getModelUuid()
+ sliceTaskParams.setNstId(nstId)
+ execution.setVariable("sliceTaskParams",sliceTaskParams)
+
+ List<ServiceProxy> proxyList = serviceDecomposition.getServiceProxy()
+ List<String> nsstModelUUIDList = new ArrayList<>()
+ for(ServiceProxy serviceProxy:proxyList)
+ nsstModelUUIDList.add(serviceProxy.getSourceModelUuid())
+ execution.setVariable("nsstModelUUIDList",nsstModelUUIDList)
+ Integer maxNSST = nsstModelUUIDList.size()
+ Integer currentNSST=0
+ execution.setVariable("maxNSST",maxNSST)
+ execution.setVariable("currentNSST",currentNSST)
+ if(currentNSST<maxNSST)
+ isMoreNSSTtoProcess=true
+ execution.setVariable("isMoreNSSTtoProcess",isMoreNSSTtoProcess)
+ logger.trace("Exit prepareNSSTlistfromNST()")
+
+ }
+
+
+ void getNSSTOption(DelegateExecution execution) {
+ ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition")
+ String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution)
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String serviceType = execution.getVariable("subscriptionServiceType")
+ String nssiInstanceId =""
+ String nssiName =""
+ SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams")
+ logger.debug( "get NSI option OOF Url: " + urlString)
+ boolean isNSISuggested = false
+ execution.setVariable("isNSISuggested",isNSISuggested)
+
+ //Prepare auth for OOF - Begin
+ def authHeader = ""
+ String basicAuth = UrnPropertiesReader.getVariable("mso.oof.auth", execution)
+ String msokey = UrnPropertiesReader.getVariable("mso.msoKey", execution)
+
+ String basicAuthValue = utils.encrypt(basicAuth, msokey)
+ if (basicAuthValue != null) {
+ logger.debug( "Obtained BasicAuth username and password for OOF: " + basicAuthValue)
+ try {
+ authHeader = utils.getBasicAuth(basicAuthValue, msokey)
+ execution.setVariable("BasicAuthHeaderValue", authHeader)
+ } catch (Exception ex) {
+ logger.debug( "Unable to encode username and password string: " + ex)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - Unable to " +
+ "encode username and password string")
+ }
+ } else {
+ logger.debug( "Unable to obtain BasicAuth - BasicAuth value null")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Internal Error - BasicAuth " +
+ "value null")
+ }
+ //Prepare auth for OOF - End
+ //Prepare send request to OOF - Begin
+ String requestId = execution.getVariable("msoRequestId")
+ Map<String, Object> profileInfo = execution.getVariable("serviceProfile")
+ String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid()
+ String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid()
+ String nsstInfo = """"NSSTInfo": {
+ "invariantUUID":"${nsstModelInvariantUuid}",
+ "UUID":"${nsstModelUuid}"
+ }"""
+ String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo)
+
+
+ URL url = new URL(urlString+"/api/oof/v1/selectnssi")
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF)
+ httpClient.addAdditionalHeader("Authorization", authHeader)
+ Response httpResponse = httpClient.post(oofRequest)
+
+ int responseCode = httpResponse.getStatus()
+ logger.debug("OOF sync response code is: " + responseCode)
+
+ if(responseCode != 200){
+ exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.")
+ }
+
+ if(httpResponse.hasEntity()){
+ String OOFResponse = httpResponse.readEntity(String.class)
+ execution.setVariable("OOFResponse", OOFResponse)
+ nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID")
+ nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName")
+ execution.setVariable("nssiInstanceId",nssiInstanceId)
+ execution.setVariable("nssiName",nssiName)
+ }
+ if(isBlank(nssiInstanceId)){
+ logger.debug( "There is no valid NSST suggested by OOF.")
+ }else
+ {
+ try {
+ AAIResourcesClient resourceClient = new AAIResourcesClient()
+ AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId)
+ AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class)
+ Optional<org.onap.aai.domain.yang.ServiceInstance> si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class)
+ org.onap.aai.domain.yang.ServiceInstance nssi = si.get()
+
+ String domain = nssi.getEnvironmentContext().toString().toUpperCase()
+ switch (domain) {
+ case "AN":
+ sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "CN":
+ sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ case "TN":
+ sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId())
+ sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName())
+ break;
+ default:
+ break;
+ }
+ }catch(NotFoundException e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
+ }catch(Exception e)
+ {
+ logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId)
+ }
+ }
+
+
+ //Prepare send request to OOF - End
+
+// String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent()
+// String nsstID = jsonUtil.getJsonValue(content, "metadata.id")
+// String vendor = jsonUtil.getJsonValue(content, "metadata.vendor")
+// String domain = jsonUtil.getJsonValue(content, "metadata.domainType")
+// String type = jsonUtil.getJsonValue(content, "metadata.type")
+// String nsstContentInfo = """{
+// "NsstID":"${nsstID}",
+// "Vendor":"${vendor}",
+// "type":"${type}"
+// }"""
+
+ logger.debug("Prepare NSSI option completed ")
+ }
+}
+