From 3e4d7035ff7fc105465840bfaec14da47f64b3aa Mon Sep 17 00:00:00 2001 From: hetengjiao Date: Fri, 25 Sep 2020 16:17:33 +0800 Subject: Update NSMF workflow of allocate Issue-ID: SO-2963 Signed-off-by: hetengjiao Change-Id: I4ab9272501a76c93e1c56d4bf0ed646699363ecb --- .../scripts/DoAllocateNSIandNSSI.groovy | 83 +++++++++- .../infrastructure/scripts/DoAllocateNSSI.groovy | 83 ++++++++-- .../scripts/DoCreateSliceServiceOption.groovy | 182 +++++++++++++++------ 3 files changed, 276 insertions(+), 72 deletions(-) (limited to 'bpmn/so-bpmn-infrastructure-common/src') 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 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/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index 161b92080b..079a31be94 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) } @@ -511,82 +497,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 nssiNeedHandlerInfos = new ArrayList<>() + Map nssiNeedHandlerMap = new HashMap() + + //List nssiNeedHandlers = new ArrayList<>() + //List 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 nssiNeedHandlerInfos = + execution.getVariable("nssiNeedHandlerInfos") as List + + 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" - - Map profileInfo = execution.getVariable("serviceProfile") as Map - Map 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}" - }""" + String messageType = "NSSISelectionResponse" - 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 nssiNeedHandlerInfos = + execution.getVariable("nssiNeedHandlerInfos") as List + + 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 resMap = objectMapper.readValue(OOFResponse, Map.class) List> nsiSolutions = (List>) resMap.get("solutions") - Map solutions = nsiSolutions.get(0) + Map 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 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 + } + } } -- cgit 1.2.3-korg