diff options
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
6 files changed, 357 insertions, 118 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index e253855ab3..67845910eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -20,7 +20,7 @@ package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.isBlank +import groovy.json.JsonSlurper import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution import org.json.JSONObject @@ -44,7 +44,8 @@ import org.onap.so.db.request.beans.OperationStatus import org.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.web.util.UriUtils -import groovy.json.JsonSlurper + +import static org.apache.commons.lang3.StringUtils.isBlank /** * This groovy class supports the <class>DoCreateCommunicationService.bpmn</class> process. @@ -349,7 +350,7 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { /** * get E2EST id through CST id and change communication profile to E2E service profile * 1. get E2EST id from cst - * 1.1 查source service id + * 1.1 source service id * 1.2 source service * 1.3 source service input, init e2e profile */ @@ -383,9 +384,29 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { } } - //TODO + //TODO temp solution e2eInputMap.put("sNSSAI", execution.getVariable("sNSSAI_id")) e2eInputMap.put("sST", execution.getVariable("csServiceType")) + + Integer activityFactor = 60 + Integer random = new Random().nextInt(5) + 2 + Integer dLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateDL").toString()) + Integer uLThptPerUE = Integer.parseInt(csInputMap.get("expDataRateUL").toString()) + Integer maxNumberofUEs = Integer.parseInt(csInputMap.get("maxNumberofUEs").toString()) + Integer dLThptPerSlice = dLThptPerUE * maxNumberofUEs * activityFactor * random + Integer uLThptPerSlice = uLThptPerUE * maxNumberofUEs * activityFactor * random + Integer maxNumberofConns = maxNumberofUEs * activityFactor * 3 + + e2eInputMap.put("jitter", 10) + e2eInputMap.put("activityFactor", activityFactor) + e2eInputMap.put("maxNumberofUEs", maxNumberofUEs) + e2eInputMap.put("dLThptPerUE", dLThptPerUE) + e2eInputMap.put("uLThptPerUE", uLThptPerUE) + e2eInputMap.put("dLThptPerSlice", dLThptPerSlice) + e2eInputMap.put("uLThptPerSlice", uLThptPerSlice) + e2eInputMap.put("maxNumberofConns", maxNumberofConns) + e2eInputMap.put("coverageAreaTAList", csInputMap.get("coverageAreaList")) + execution.setVariable("e2eInputMap", e2eInputMap) execution.setVariable("e2eServiceType", e2eServiceDecomposition.getServiceType()) execution.setVariable("e2eModelInvariantUuid", e2eServiceDecomposition.getModelInfo().getModelInvariantUuid()) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy index 65398eb658..72fd052f31 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateSliceService.groovy @@ -20,6 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder + import static org.apache.commons.lang3.StringUtils.* import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -52,11 +54,15 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { String Prefix = "CRESS_" ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + JsonSlurper jsonSlurper = new JsonSlurper() + ObjectMapper objectMapper = new ObjectMapper() + OofUtils oofUtils = new OofUtils() - NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + AAIResourcesClient client = getAAIClient() private static final Logger logger = LoggerFactory.getLogger(CreateSliceService.class) @@ -161,8 +167,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { execution.setVariable("serviceInputParams", inputMap) execution.setVariable("uuiRequest", uuiRequest) - execution.setVariable("se" + - "rviceProfile", serviceProfile) + execution.setVariable("serviceProfile", serviceProfile) //TODO //execution.setVariable("serviceInputParams", jsonUtil.getJsonValue(siRequest, "requestDetails.requestParameters.userParams")) @@ -267,10 +272,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { execution.setVariable("sliceTaskParams", sliceTaskParams) - //todo:---------------------------------------- -// String paramJson = sliceTaskParams.convertToJson() -// execution.setVariable("CSSOT_paramJson", paramJson) - /*-------------------------------------------*/ + String paramJson = sliceTaskParams.convertToJson() + execution.setVariable("CSSOT_paramJson", paramJson) logger.debug("Finish createOrchestrationTask") } @@ -360,7 +363,8 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { logger.debug("Start prepareUpdateOrchestrationTask") String requestMethod = "PUT" String taskStatus = execution.getVariable("taskStatus") - SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + SliceTaskParamsAdapter sliceTaskParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter String paramJson = sliceTaskParams.convertToJson() execution.setVariable("CSSOT_status", taskStatus) execution.setVariable("CSSOT_paramJson", paramJson) @@ -390,7 +394,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { OrchestrationTask orchestrationTask = objectMapper.readValue(response, OrchestrationTask.class) String paramJson = orchestrationTask.getParams() logger.debug("paramJson: " + paramJson) - SliceTaskParams sliceTaskParams = new SliceTaskParams() + SliceTaskParamsAdapter sliceTaskParams = new SliceTaskParamsAdapter() sliceTaskParams.convertFromJson(paramJson) execution.setVariable("sliceTaskParams", sliceTaskParams) logger.debug("Finish processUserOptions") @@ -404,7 +408,7 @@ public class CreateSliceService extends AbstractServiceTaskProcessor { try { ServiceInstance si = new ServiceInstance() si.setOrchestrationStatus(orchStatus) - AAIResourcesClient client = new AAIResourcesClient() + AAIResourceUri uri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(serviceInstanceId)) client.update(uri, si) } catch (BpmnError e) { 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 index c497fc4517..d0c189cb04 100644 --- 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 @@ -20,7 +20,8 @@ package org.onap.so.bpmn.infrastructure.scripts -import static org.apache.commons.lang3.StringUtils.isBlank +import org.onap.so.beans.nsmf.oof.SubnetType +import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import javax.ws.rs.NotFoundException import org.camunda.bpm.engine.delegate.BpmnError import org.camunda.bpm.engine.delegate.DelegateExecution @@ -49,8 +50,9 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.core.json.JsonUtils import org.slf4j.Logger import org.slf4j.LoggerFactory +import static org.apache.commons.lang3.StringUtils.isBlank -class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor{ +class DoAllocateNSIandNSSI extends AbstractServiceTaskProcessor{ private static final Logger logger = LoggerFactory.getLogger(DoAllocateNSIandNSSI.class); @@ -338,6 +340,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest) execution.setVariable("anBHSliceTaskInfo", sliceTaskInfo) + execution.setVariable("anSubnetType", SubnetType.AN_NF) } @@ -384,7 +387,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } /** - * create An Slice Profile + * create Cn Slice Profile * @param execution */ void createCnSliceProfile(DelegateExecution execution) { @@ -426,7 +429,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi AllocateCnNssi allocateCnNssi = new AllocateCnNssi() allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID - allocateCnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID + allocateCnNssi.nssiId = sliceTaskInfo.suggestNssiId allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile allocateCnNssi.nsiInfo.nsiId = sliceParams.suggestNsiId @@ -446,6 +449,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi serviceInfo.nsiId = sliceParams.suggestNsiId serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + serviceInfo.nssiId = sliceTaskInfo.suggestNssiId //if shared nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) @@ -453,6 +457,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi execution.setVariable("CnAllocateNssiNbiRequest", nbiRequest) execution.setVariable("cnSliceTaskInfo", sliceTaskInfo) + execution.setVariable("cnSubnetType", SubnetType.CN) } @@ -501,7 +506,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi } /** - * create An Slice Profile + * create Tn Slice Profile * @param execution */ void createTnBHSliceProfile(DelegateExecution execution) { @@ -542,6 +547,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi AllocateTnNssi allocateTnNssi = new AllocateTnNssi() //todo: AllocateTnNssi + //todo: endpointId -> set into tn allocateTnNssi.setTransportSliceNetworks() allocateTnNssi.setNetworkSliceInfos() @@ -561,6 +567,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi serviceInfo.nsiId = sliceParams.suggestNsiId serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + serviceInfo.nssiId = sliceTaskInfo.suggestNssiId nbiRequest.setServiceInfo(serviceInfo) nbiRequest.setEsrInfo(esrInfo) @@ -568,6 +575,7 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi execution.setVariable("TnBHAllocateNssiNbiRequest", nbiRequest) execution.setVariable("tnBHSliceTaskInfo", sliceTaskInfo) + execution.setVariable("tnBHSubnetType", SubnetType.TN_BH) } /** @@ -586,11 +594,13 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi ResponseDescriptor result = execution.getVariable("anNssiAllocateResult") as ResponseDescriptor String nssiId = result.getNssiId() - String endPointId = result.getEndPointId() String nsiId = sliceParams.getSuggestNsiId() String sliceProfileInstanceId = sliceParams.anSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId //nsi id + //todo: aai -> nssi -> relationship -> endpointId -> set into tn + String endPointId = getEndpointIdFromAAI(execution, nssiId) + execution.setVariable("endPointIdAn", endPointId) updateRelationship(execution, nsiId, nssiId) @@ -598,8 +608,8 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi updateRelationship(execution, sliceProfileInstanceId, nssiId) - updateRelationship(execution, sliceProfileInstanceId, endPointId) - + sliceParams.anSliceTaskInfo.suggestNssiId = nssiId + execution.setVariable("sliceTaskParams", sliceParams) } @@ -622,6 +632,9 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi String sliceProfileInstanceId = sliceParams.cnSliceTaskInfo.sliceInstanceId String serviceProfileInstanceId = sliceParams.serviceId //nsi id + //todo: aai -> nssi -> relationship -> endpointId -> set into tn + String endPointId = getEndpointIdFromAAI(execution, nssiId) + execution.setVariable("endPointIdCn", endPointId) updateRelationship(execution, nsiId, nssiId) @@ -629,7 +642,58 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi updateRelationship(execution,sliceProfileInstanceId, nssiId) + sliceParams.cnSliceTaskInfo.suggestNssiId = nssiId + execution.setVariable("sliceTaskParams", sliceParams) + } + /** + * get endpoint Id from AAI by nssi id + * @param execution + * @param nssiId + * @return + */ + private String getEndpointIdFromAAI(DelegateExecution execution, String nssiId) { + logger.debug("Enter update relationship in DoAllocateNSIandNSSI()") + //todo: allottedResourceId + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + //sliceParams.setServiceId(nsiServiceInstanceID) + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId)) + + String endpointId = null + + try { + AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class) + Optional<ServiceInstance> si = wrapper.asBean(ServiceInstance.class) + //todo: if exists + if (!si.ifPresent()) { + String msg = "NSSI in the option doesn't exist. " + nssiId + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + if (si.ifPresent()) { + ServiceInstance nssiInstance = si.get() + //todo: handle relationship and return endpointId + for (Relationship relationship : nssiInstance.relationshipList.getRelationship()) { + if (relationship.relationshipLabel){ + endpointId = relationship //todo + } + } + + return endpointId + } + + }catch(BpmnError e) { + throw e + }catch (Exception ex){ + String msg = "NSSI suggested in the option doesn't exist. " + nssiId + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Exit update relationship in DoAllocateNSIandNSSI()") } /** @@ -656,6 +720,9 @@ class DoAllocateNSIandNSSI extends org.onap.so.bpmn.common.scripts.AbstractServi updateRelationship(execution, serviceProfileInstanceId, sliceProfileInstanceId) updateRelationship(execution,sliceProfileInstanceId, nssiId) + + sliceParams.tnBHSliceTaskInfo.suggestNssiId = nssiId + execution.setVariable("sliceTaskParams", sliceParams) } /** 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 index 35f725738d..88014e7b54 100644 --- 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 @@ -1,6 +1,7 @@ package org.onap.so.bpmn.infrastructure.scripts import com.fasterxml.jackson.databind.ObjectMapper +import org.apache.commons.lang3.StringUtils import org.camunda.bpm.engine.delegate.DelegateExecution import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.NssiResponse @@ -8,24 +9,16 @@ import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest import org.onap.so.beans.nsmf.ResponseDescriptor import org.onap.so.beans.nsmf.ServiceInfo import org.onap.so.beans.nsmf.SliceTaskInfo +import org.onap.so.beans.nsmf.SliceTaskParamsAdapter +import org.onap.so.beans.nsmf.oof.SubnetType import org.onap.so.bpmn.common.scripts.AbstractServiceTaskProcessor import org.onap.so.bpmn.common.scripts.ExceptionUtil import org.onap.so.bpmn.common.scripts.NssmfAdapterUtils -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.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel -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.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.ResponseEntity -import static org.apache.commons.lang3.StringUtils.isBlank class DoAllocateNSSI extends AbstractServiceTaskProcessor { @@ -49,13 +42,15 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { NssmfAdapterNBIRequest nbiRequest = execution.getVariable("nbiRequest") as NssmfAdapterNBIRequest - //SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo + execution.setVariable("currentCycle", 0) boolean isNSIOptionAvailable = execution.getVariable("isNSIOptionAvailable") as Boolean - if (isNSIOptionAvailable) { - nbiRequest.serviceInfo.setActionType("modify") - } else { + if (!isNSIOptionAvailable) { nbiRequest.serviceInfo.setActionType("allocate") + } else if (StringUtils.isBlank(nbiRequest.serviceInfo.nssiId)){ + nbiRequest.serviceInfo.setActionType("allocate") + } else { + nbiRequest.serviceInfo.setActionType("modify") } execution.setVariable("nbiRequest", nbiRequest) logger.trace("Exit preProcessRequest") @@ -111,11 +106,67 @@ class DoAllocateNSSI extends AbstractServiceTaskProcessor { } void prepareUpdateOrchestrationTask(DelegateExecution execution) { - //todo;update orchestration task + logger.debug("Start prepareUpdateOrchestrationTask progress") + String requestMethod = "PUT" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + ResponseDescriptor response = execution.getVariable("nssiAllocateResult") as ResponseDescriptor + SubnetType subnetType = execution.getVariable("subnetType") as SubnetType + + + SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo + sliceTaskInfo.progress = response.getProgress() + sliceTaskInfo.status = response.getStatus() + sliceTaskInfo.statusDescription = response.getStatusDescription() + updateNssiResult(sliceParams, subnetType, sliceTaskInfo) + + String paramJson = sliceParams.convertToJson() + execution.setVariable("CSSOT_paramJson", paramJson) + execution.setVariable("CSSOT_requestMethod", requestMethod) + + execution.setVariable("sliceTaskParams", sliceParams) + execution.setVariable("sliceTaskInfo", sliceTaskInfo) + logger.debug("Finish prepareUpdateOrchestrationTask progress") + } + + private void updateNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType, + SliceTaskInfo sliceTaskInfo) { + switch (subnetType) { + case SubnetType.CN: + sliceTaskParams.cnSliceTaskInfo = sliceTaskInfo + break + case SubnetType.AN_NF: + sliceTaskParams.anSliceTaskInfo = sliceTaskInfo + break + case SubnetType.TN_BH: + sliceTaskParams.tnBHSliceTaskInfo = sliceTaskInfo + break + case SubnetType.TN_FH: + sliceTaskParams.tnFHSliceTaskInfo = sliceTaskInfo + break + case SubnetType.TN_MH: + sliceTaskParams.tnMHSliceTaskInfo = sliceTaskInfo + break + } } void timeDelay(DelegateExecution execution) { - //todo: time delay + logger.trace("Enter timeDelay in DoAllocateNSSI()") + try { + Thread.sleep(60000) + int currentCycle = execution.getVariable("currentCycle") as Integer + 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()") } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy index f64f5e8ebf..48e1acd523 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceInstance.groovy @@ -132,7 +132,7 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ } - def rollbackData = execution.getVariable("RollbackData") + RollbackData rollbackData = execution.getVariable("RollbackData") if (rollbackData == null) { rollbackData = new RollbackData() } @@ -171,19 +171,15 @@ class DoCreateSliceServiceInstance extends AbstractServiceTaskProcessor{ serviceProfile.setCoverageAreaTAList(serviceProfileMap.get("coverageAreaTAList").toString()) serviceProfile.setUeMobilityLevel(serviceProfileMap.get("uEMobilityLevel").toString()) serviceProfile.setResourceSharingLevel(serviceProfileMap.get("resourceSharingLevel").toString()) - serviceProfile.setExpDataRateUL(Integer.parseInt(serviceProfileMap.get("expDataRateUL").toString())) - serviceProfile.setExpDataRateDL(Integer.parseInt(serviceProfileMap.get("expDataRateDL").toString())) - serviceProfile.setAreaTrafficCapUL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapUL").toString())) - serviceProfile.setAreaTrafficCapDL(Integer.parseInt(serviceProfileMap.get("areaTrafficCapDL").toString())) + serviceProfile.setDlThptPerSlice(Integer.parseInt(serviceProfileMap.get("dLThptPerSlice").toString())) + serviceProfile.setDlThptPerUE(Integer.parseInt(serviceProfileMap.get("dLThptPerUE").toString())) + serviceProfile.setUlThptPerSlice(Integer.parseInt(serviceProfileMap.get("uLThptPerSlice").toString())) + serviceProfile.setUlThptPerUE(Integer.parseInt(serviceProfileMap.get("uLThptPerUE").toString())) serviceProfile.setActivityFactor(Integer.parseInt(serviceProfileMap.get("activityFactor").toString())) - serviceProfile.setJitter(0) + serviceProfile.setJitter(Integer.parseInt(serviceProfileMap.get("jitter").toString())) serviceProfile.setSurvivalTime("0") - serviceProfile.setCsAvailability(new Object()) serviceProfile.setReliability("") - serviceProfile.setExpDataRate(0) - serviceProfile.setTrafficDensity(0) - serviceProfile.setConnDensity(0) try { AAIResourceUri uri = AAIUriFactory.createResourceUri( AAIFluentTypeBuilder.business().customer(execution.getVariable("globalSubscriberId")) 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 index 161b92080b..8993127dbc 100644 --- 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 @@ -27,7 +27,6 @@ import org.onap.so.beans.nsmf.CnSliceProfile import org.onap.so.beans.nsmf.EsrInfo import org.onap.so.beans.nsmf.NetworkType import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest -import org.onap.so.beans.nsmf.SliceTaskParams import org.onap.so.beans.nsmf.SliceTaskParamsAdapter import org.onap.so.beans.nsmf.TnSliceProfile import org.onap.so.beans.nsmf.oof.SubnetCapability @@ -42,15 +41,6 @@ import org.onap.so.bpmn.core.domain.AllottedResource 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.aaiclient.client.aai.AAIObjectType -import org.onap.aaiclient.client.aai.AAIResourcesClient -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper -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.slf4j.Logger import org.slf4j.LoggerFactory import org.springframework.http.ResponseEntity @@ -181,7 +171,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ * @param execution */ public void handleNsstByType(DelegateExecution execution) { - //todo: set to sliceTaskParams by type SliceTaskParamsAdapter sliceParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter @@ -194,11 +183,8 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ for (ServiceDecomposition serviceDecomposition : nsstServiceDecompositions) { - //todo: SubnetCapability subnetCapability = new SubnetCapability() - handleByType(execution, serviceDecomposition, sliceParams, subnetCapability) - subnetCapabilities.add(subnetCapability) } @@ -208,15 +194,12 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ private void handleByType(DelegateExecution execution, ServiceDecomposition serviceDecomposition, SliceTaskParamsAdapter sliceParams, SubnetCapability subnetCapability) { - //todo: - String domainType = "" ModelInfo modelInfo = serviceDecomposition.getModelInfo() String vendor = serviceDecomposition.getServiceRole() - SubnetType subnetType + SubnetType subnetType = convertServiceCategory(serviceDecomposition.getServiceCategory()) - switch (domainType) { - case "tn_bh": - subnetType = SubnetType.TN_BH + switch (subnetType) { + case SubnetType.TN_BH: sliceParams.tnBHSliceTaskInfo.vendor = vendor sliceParams.tnBHSliceTaskInfo.subnetType = subnetType sliceParams.tnBHSliceTaskInfo.networkType = subnetType.networkType @@ -225,8 +208,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.tnBHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() break - case "tn_mh": - subnetType = SubnetType.TN_MH + case SubnetType.TN_MH: sliceParams.tnMHSliceTaskInfo.vendor = vendor sliceParams.tnMHSliceTaskInfo.subnetType = subnetType sliceParams.tnMHSliceTaskInfo.networkType = subnetType.networkType @@ -235,8 +217,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.tnMHSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() break - case "an_nf": - subnetType = SubnetType.AN_NF + case SubnetType.AN_NF: sliceParams.anSliceTaskInfo.vendor = vendor sliceParams.anSliceTaskInfo.subnetType = subnetType sliceParams.anSliceTaskInfo.networkType = subnetType.networkType @@ -244,8 +225,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ sliceParams.anSliceTaskInfo.NSSTInfo.invariantUUID = modelInfo.getModelInvariantUuid() sliceParams.anSliceTaskInfo.NSSTInfo.name = modelInfo.getModelName() break - case "cn": - subnetType = SubnetType.CN + case SubnetType.CN: sliceParams.cnSliceTaskInfo.vendor = vendor sliceParams.cnSliceTaskInfo.subnetType = subnetType sliceParams.cnSliceTaskInfo.networkType = subnetType.networkType @@ -260,9 +240,10 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ //todo } - if (subnetType == null) { - //todo: throw error - return + if (null == subnetType) { + def msg = "Get subnetType failed, modelUUId=" + modelInfo.getModelUuid() + logger.error(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) } String response = querySubnetCapability(execution, vendor, subnetType) ResponseEntity responseEntity = objectMapper.readValue(response, ResponseEntity.class) @@ -275,6 +256,26 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ } /** + * get subnetType from serviceCategory + * @return + */ + private SubnetType convertServiceCategory(String serviceCategory){ + if(serviceCategory ==~ /CN.*/){ + return SubnetType.CN + } + if (serviceCategory ==~ /AN.*NF.*/){ + return SubnetType.AN_NF + } + if (serviceCategory ==~ /TN.*BH.*/){ + return SubnetType.TN_BH + } + if(serviceCategory ==~ /TN.*MH.*/){ + return SubnetType.TN_MH + } + return null + } + + /** * query Subnet Capability of TN AN CN * @param execution */ @@ -319,12 +320,11 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ * prepare select nsi request * @param execution */ - public void preNSIRequest(DelegateExecution execution) { + public void preNSIRequest(DelegateExecution execution, boolean preferReuse) { String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) - String requestId = execution.getVariable("msoRequestId") String messageType = "NSISelectionResponse" @@ -346,7 +346,7 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ execution.getVariable("subnetCapabilities") as List<SubnetCapability> String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos, - messageType, profileInfo, subnetCapabilities, timeout as Integer) + messageType, profileInfo, subnetCapabilities, timeout as Integer, preferReuse) execution.setVariable("nsiSelection_oofRequest", oofRequest) logger.debug("Sending request to OOF: " + oofRequest) @@ -362,12 +362,12 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ SliceTaskParamsAdapter sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter - String OOFResponse = execution.getVariable("nsiSelection_oofResponse") - logger.debug("NSI OOFResponse is: " + OOFResponse) - execution.setVariable("OOFResponse", OOFResponse) + String oofResponse = execution.getVariable("nsiSelection_oofResponse") + logger.debug("NSI oofResponse is: " + oofResponse) + execution.setVariable("oofResponse", oofResponse) //This needs to be changed to derive a value when we add policy to decide the solution options. - Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class) + Map<String, Object> resMap = objectMapper.readValue(oofResponse, Map.class) List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions") Map<String, Object> solution = nsiSolutions.get(0) @@ -511,82 +511,182 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter //todo + boolean needCnNssiSelection = execution.getVariable("NEED_CN_NSSI_SELECTION") as Boolean + boolean needAnNssiSelection = execution.getVariable("NEED_AN_NSSI_SELECTION") as Boolean + boolean needTnNssiSelection = execution.getVariable("NEED_TN_NSSI_SELECTION") as Boolean + + /** + * [ + * { + * "subType": subtype, + * "nsstInfo": object, + * "sliceProfile": object + * }, + * { + * "subType": subtype, + * "nsstInfo": object, + * "sliceProfile": object + * } + * ] + */ + List<Map> nssiNeedHandlerInfos = new ArrayList<>() + Map<String, Object> nssiNeedHandlerMap = new HashMap() + + //List<TemplateInfo> nssiNeedHandlers = new ArrayList<>() + //List<Object> nssiProfileNeedHandlers = new ArrayList<>() + if (needCnNssiSelection) { + nssiNeedHandlerMap.put("subnetType", sliceTaskParams.cnSliceTaskInfo.subnetType) + nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.cnSliceTaskInfo.NSSTInfo) + nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.cnSliceTaskInfo.sliceProfile) + nssiNeedHandlerInfos.add(nssiNeedHandlerMap) + } + if (needAnNssiSelection) { + nssiNeedHandlerMap.clear() + nssiNeedHandlerMap.put("subnetType", sliceTaskParams.anSliceTaskInfo.subnetType) + nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.anSliceTaskInfo.NSSTInfo) + nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.anSliceTaskInfo.sliceProfile) + nssiNeedHandlerInfos.add(nssiNeedHandlerMap) + } + if (needTnNssiSelection) { + nssiNeedHandlerMap.clear() + nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnBHSliceTaskInfo.subnetType) + nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnBHSliceTaskInfo.NSSTInfo) + nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnBHSliceTaskInfo.sliceProfile) + nssiNeedHandlerInfos.add(nssiNeedHandlerMap) + + nssiNeedHandlerMap.clear() + nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnMHSliceTaskInfo.subnetType) + nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnMHSliceTaskInfo.NSSTInfo) + nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnMHSliceTaskInfo.sliceProfile) + nssiNeedHandlerInfos.add(nssiNeedHandlerMap) + + nssiNeedHandlerMap.clear() + nssiNeedHandlerMap.put("subnetType", sliceTaskParams.tnFHSliceTaskInfo.subnetType) + nssiNeedHandlerMap.put("nsstInfo", sliceTaskParams.tnFHSliceTaskInfo.NSSTInfo) + nssiNeedHandlerMap.put("sliceProfile", sliceTaskParams.tnFHSliceTaskInfo.sliceProfile) + nssiNeedHandlerInfos.add(nssiNeedHandlerMap) + + } + + if (nssiNeedHandlerInfos.size() > 0) { + execution.setVariable("needSelectNssi", true) + execution.setVariable("currNssiIndex", 0) + execution.setVariable("nssiNeedHandlerInfos", nssiNeedHandlerInfos) + } else { + execution.setVariable("needSelectNssi", false) + } + + execution.setVariable("sliceTaskParams", sliceTaskParams) } /** - * todo: need rewrite * prepare select nssi request * @param execution */ public void preNSSIRequest(DelegateExecution execution) { + List<Map> nssiNeedHandlerInfos = + execution.getVariable("nssiNeedHandlerInfos") as List<Map> + + int currNssiIndex = execution.getVariable("currNssiIndex") as Integer + Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map + + TemplateInfo nsstInfo = nssiNeedHandlerInfo.get("nsstInfo") as TemplateInfo + Object profileInfo = nssiNeedHandlerInfo.get("sliceProfile") + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) logger.debug( "get NSI option OOF Url: " + urlString) - boolean isNSISuggested = true - execution.setVariable("isNSISuggested", isNSISuggested) String requestId = execution.getVariable("msoRequestId") - String messageType = "NSISelectionResponse" + String messageType = "NSSISelectionResponse" - Map<String, Object> profileInfo = execution.getVariable("serviceProfile") as Map - Map<String, Object> nstSolution = execution.getVariable("nstSolution") as Map - logger.debug("Get NST selection from OOF: " + nstSolution.toString()) - String nstInfo = """{ - "modelInvariantId":"${nstSolution.invariantUUID}", - "modelVersionId":"${nstSolution.UUID}", - "modelName":"${nstSolution.NSTName}" - }""" - - execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") - execution.setVariable("nsiSelection_messageType", messageType) - execution.setVariable("nsiSelection_correlator", requestId) + execution.setVariable("nssiSelectionUrl", "/api/oof/selection/nssi/v1") + execution.setVariable("nssiSelection_messageType", messageType) + execution.setVariable("nssiSelection_correlator", requestId) String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution) - execution.setVariable("nsiSelection_timeout", timeout) + execution.setVariable("nssiSelection_timeout", timeout) - //todo - String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, messageType, profileInfo) + String oofRequest = oofUtils.buildSelectNSSIRequest(requestId, nsstInfo, messageType, + profileInfo, timeout as Integer) - execution.setVariable("nsiSelection_oofRequest", oofRequest) + execution.setVariable("nssiSelection_oofRequest", oofRequest) logger.debug("Sending request to OOF: " + oofRequest) } /** * process select nssi response - * todo: unfinished * @param execution */ public void processNSSIResp(DelegateExecution execution) { - SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams - String OOFResponse = execution.getVariable("nsiSelection_oofResponse") + List<Map> nssiNeedHandlerInfos = + execution.getVariable("nssiNeedHandlerInfos") as List<Map> + + int currNssiIndex = execution.getVariable("currNssiIndex") as Integer + Map nssiNeedHandlerInfo = nssiNeedHandlerInfos.get(currNssiIndex) as Map + SubnetType subnetType = nssiNeedHandlerInfo.get("subnetType") as SubnetType + + SliceTaskParamsAdapter sliceTaskParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + + String OOFResponse = execution.getVariable("nssiSelection_oofResponse") logger.debug("NSI OOFResponse is: " + OOFResponse) execution.setVariable("OOFResponse", OOFResponse) //This needs to be changed to derive a value when we add policy to decide the solution options. Map<String, Object> resMap = objectMapper.readValue(OOFResponse, Map.class) List<Map<String, Object>> nsiSolutions = (List<Map<String, Object>>) resMap.get("solutions") - Map<String, Object> solutions = nsiSolutions.get(0) + Map<String, Object> solution = nsiSolutions.get(0) String resourceSharingLevel = execution.getVariable("resourceSharingLevel") - Boolean isSharable = resourceSharingLevel == "shared" + Boolean isSharable = resourceSharingLevel == "shared" //todo - if (solutions != null) { - if (isSharable && solutions.get("existingNSI")) { - //sharedNSISolution - //processSharedNSISolutions(solutions, execution) - } - else if(solutions.containsKey("newNSISolution")) { - //processNewNSISolutions(solutions, execution) - } + if (isSharable && solution != null) { + processNssiResult(sliceTaskParams, subnetType, solution) } + execution.setVariable("sliceTaskParams", sliceTaskParams) - logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) + //logger.debug("sliceTaskParams: "+ sliceTaskParams.convertToJson()) logger.debug("*** Completed options Call to OOF ***") logger.debug("start parseServiceProfile") //parseServiceProfile(execution) logger.debug("end parseServiceProfile") + + if (currNssiIndex >= nssiNeedHandlerInfos.size() - 1) { + execution.setVariable("needSelectNssi", false) + } else { + execution.setVariable("currNssiIndex", currNssiIndex + 1) + execution.setVariable("needSelectNssi", true) + } + } + private void processNssiResult(SliceTaskParamsAdapter sliceTaskParams, SubnetType subnetType, + Map<String, Object> solution) { + switch (subnetType) { + case SubnetType.CN: + sliceTaskParams.cnSliceTaskInfo.suggestNssiId = solution.get("NSSIId") + sliceTaskParams.cnSliceTaskInfo.suggestNssiName = solution.get("NSSIName") + break + case SubnetType.AN_NF: + sliceTaskParams.anSliceTaskInfo.suggestNssiId = solution.get("NSSIId") + sliceTaskParams.anSliceTaskInfo.suggestNssiName = solution.get("NSSIName") + break + case SubnetType.TN_BH: + sliceTaskParams.tnBHSliceTaskInfo.suggestNssiId = solution.get("NSSIId") + sliceTaskParams.tnBHSliceTaskInfo.suggestNssiName = solution.get("NSSIName") + break + case SubnetType.TN_FH: + sliceTaskParams.tnFHSliceTaskInfo.suggestNssiId = solution.get("NSSIId") + sliceTaskParams.tnFHSliceTaskInfo.suggestNssiName = solution.get("NSSIName") + break + case SubnetType.TN_MH: + sliceTaskParams.tnMHSliceTaskInfo.suggestNssiId = solution.get("NSSIId") + sliceTaskParams.tnMHSliceTaskInfo.suggestNssiName = solution.get("NSSIName") + break + } + } } |