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 --- .../onap/so/bpmn/common/scripts/OofUtils.groovy | 31 +++ .../scripts/DoAllocateNSIandNSSI.groovy | 83 ++++++- .../infrastructure/scripts/DoAllocateNSSI.groovy | 83 +++++-- .../scripts/DoCreateSliceServiceOption.groovy | 182 ++++++++++---- .../main/resources/process/CreateSliceService.bpmn | 3 + .../resources/subprocess/DoAllocateNSIandNSSI.bpmn | 32 +-- .../main/resources/subprocess/DoAllocateNSSI.bpmn | 4 +- .../subprocess/DoCreateSliceServiceInstance.bpmn | 2 +- .../subprocess/DoCreateSliceServiceOption.bpmn | 261 ++++++++++----------- .../onap/so/beans/nsmf/SliceTaskParamsAdapter.java | 12 +- .../org/onap/so/beans/nsmf/oof/NssiReqBody.java | 12 +- 11 files changed, 468 insertions(+), 237 deletions(-) diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy index 44188b462b..bd70ee79b7 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy @@ -23,6 +23,7 @@ package org.onap.so.bpmn.common.scripts import org.onap.so.beans.nsmf.oof.NsiReqBody +import org.onap.so.beans.nsmf.oof.NssiReqBody import org.onap.so.beans.nsmf.oof.RequestInfo import org.onap.so.beans.nsmf.oof.SubnetCapability import org.onap.so.beans.nsmf.oof.TemplateInfo @@ -661,6 +662,7 @@ return json.toString() List subnetCapabilities, Integer timeOut){ def transactionId = requestId + String correlator = requestId logger.debug( "transactionId is: " + transactionId) String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator @@ -686,4 +688,33 @@ return json.toString() return objectMapper.writeValueAsString(nsiReqBody) } + + public String buildSelectNSSIRequest(String requestId, TemplateInfo nsstInfo, String messageType, + T sliceProfile, Integer timeOut){ + + def transactionId = requestId + String correlator = requestId + logger.debug( "transactionId is: " + transactionId) + + String callbackUrl = UrnPropertiesReader.getVariable("mso.adapters.oof.callback.endpoint") + "/" + messageType + "/" + correlator + + NssiReqBody nssiReqBody = new NssiReqBody() + + RequestInfo requestInfo = new RequestInfo() + requestInfo.setRequestId(requestId) + requestInfo.setTransactionId(transactionId) + requestInfo.setCallbackUrl(callbackUrl) + requestInfo.setSourceId("so") + requestInfo.setTimeout(timeOut) + //requestInfo.setNumSolutions() + + nssiReqBody.setRequestInfo(requestInfo) + nssiReqBody.setSliceProfile(sliceProfile) + nssiReqBody.setNSSTInfo(nsstInfo) + + + ObjectMapper objectMapper = new ObjectMapper() + + return objectMapper.writeValueAsString(nssiReqBody) + } } 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 + } + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn index 60d7355a9c..9656c86ae5 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/CreateSliceService.bpmn @@ -42,6 +42,8 @@ css.processUserOptions(execution) + + SequenceFlow_1dfon41 SequenceFlow_0jhqtls @@ -278,6 +280,7 @@ css.prepareUpdateOrchestrationTask(execution) + SequenceFlow_1bevt3a SequenceFlow_0mlrlbv diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn index e42f001012..9090bf2fab 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSI.bpmn @@ -58,19 +58,11 @@ dcnsio.createNSIinAAI(execution) - - - - - - - - @@ -80,6 +72,8 @@ dcnsio.createNSIinAAI(execution) + + SequenceFlow_0npsyye SequenceFlow_1xb5nx1 @@ -88,19 +82,11 @@ dcnsio.createNSIinAAI(execution) - - - - - - - - @@ -111,6 +97,8 @@ dcnsio.createNSIinAAI(execution) + + SequenceFlow_0cwbtmr SequenceFlow_1l74seh @@ -185,19 +173,11 @@ dcnsio.createTnBHSliceProfile(execution) - - - - - - - - @@ -207,6 +187,8 @@ dcnsio.createTnBHSliceProfile(execution) + + SequenceFlow_01isn2q SequenceFlow_1omynpt @@ -279,7 +261,7 @@ dcnsio.prepareAllocateTnBHNssi(execution) - + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn index 6e94538775..58795056d4 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSI.bpmn @@ -76,7 +76,7 @@ dcnssi.timeDelay(execution) - + @@ -155,4 +155,4 @@ dcnssi.timeDelay(execution) - + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn index 0345ea7a9f..9d47888b14 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceInstance.bpmn @@ -135,4 +135,4 @@ dcsi.prepareDecomposeService(execution) - + \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn index 045d88daa9..b16ceee0d3 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOption.bpmn @@ -29,43 +29,19 @@ dcso.processDecompositionNST(execution) - - SequenceFlow_1h3kdce - SequenceFlow_05250mp - SequenceFlow_0euwvgf - SequenceFlow_0il5j01 - - - SequenceFlow_14rhmx9 - SequenceFlow_103oxyw - SequenceFlow_0aasemn - SequenceFlow_1tr3i9d - - + - - - - + + + + - - + + SequenceFlow_0abqxa1 SequenceFlow_1tqg26p - - - - - - - - - - - SequenceFlow_1nrfy6i - SequenceFlow_1fuwy35 @@ -107,29 +83,10 @@ dcso.preNSSIRequest(execution) SequenceFlow_1tqg26p - SequenceFlow_1i3j8c3 + SequenceFlow_1ezi1oi import org.onap.so.bpmn.infrastructure.scripts.* def dcso = new DoCreateSliceServiceOption() dcso.processNSSIResp(execution) - - - SequenceFlow_1tey3hz - SequenceFlow_126j77n - SequenceFlow_1nrfy6i - - - #{(execution.getVariable("nssmfOperation" ) == "update")} - - - - - - SequenceFlow_1tr3i9d - SequenceFlow_1i3j8c3 - SequenceFlow_1tey3hz - import org.onap.so.bpmn.infrastructure.scripts.* -def dcso = new DoCreateSliceServiceOption() -dcso.handleNssiSelect(execution) SequenceFlow_0zglfyw @@ -215,10 +172,53 @@ dcso.preNSIRequest(execution) + + SequenceFlow_1tr3i9d + SequenceFlow_1tey3hz + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.handleNssiSelect(execution) + + + SequenceFlow_0aasemn + SequenceFlow_103oxyw + SequenceFlow_14rhmx9 + SequenceFlow_1tr3i9d + + + + + + + SequenceFlow_1h3kdce + SequenceFlow_0il5j01 + SequenceFlow_0euwvgf + SequenceFlow_05250mp + + + + + + + + + SequenceFlow_1tey3hz + SequenceFlow_1ezi1oi + SequenceFlow_126j77n + SequenceFlow_1nrfy6i + + + #{(execution.getVariable("needSelectNssi" ) == true)} + + + SequenceFlow_1nrfy6i + + + - + @@ -236,58 +236,9 @@ dcso.preNSIRequest(execution) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -314,36 +265,7 @@ dcso.preNSIRequest(execution) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -420,10 +342,87 @@ dcso.preNSIRequest(execution) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java index 87de04a6ee..6ad752f047 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java @@ -19,12 +19,16 @@ */ package org.onap.so.beans.nsmf; -import lombok.Data; +import lombok.*; import org.onap.so.beans.nsmf.oof.TemplateInfo; import java.util.Map; @Data +@NoArgsConstructor +@AllArgsConstructor +@ToString +@Builder public class SliceTaskParamsAdapter { private static final long serialVersionUID = -7785578865170503301L; @@ -53,4 +57,10 @@ public class SliceTaskParamsAdapter { private SliceTaskInfo cnSliceTaskInfo; private SliceTaskInfo anSliceTaskInfo; + + public String convertToJson() { + SliceTaskParams sliceTaskParams = new SliceTaskParams(); + sliceTaskParams.setServiceId(serviceId); + return sliceTaskParams.convertToJson(); + } } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java index 7cfb60c113..96c5b343fd 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java @@ -19,17 +19,19 @@ */ package org.onap.so.beans.nsmf.oof; -import lombok.Data; -import org.onap.so.beans.nsmf.ServiceProfile; +import lombok.*; import java.io.Serializable; -import java.util.Map; @Data -public class NssiReqBody implements Serializable { +@NoArgsConstructor +@AllArgsConstructor +@ToString +@Builder +public class NssiReqBody implements Serializable { private static final long serialVersionUID = -76327522074333341L; - private Map serviceProfile; + private T sliceProfile; private RequestInfo requestInfo; -- cgit 1.2.3-korg