From 8398451b410b4657c42e17e30422feb2091c58f5 Mon Sep 17 00:00:00 2001 From: hetengjiao Date: Fri, 11 Sep 2020 08:38:55 +0800 Subject: Update NSMF workflow to implement the E2E Network Slicing requirements for Guilin release Issue-ID: SO-2963 Signed-off-by: hetengjiao Change-Id: I20c6b880cc26b0e0dbd096f4de6f39fd936b4bc0 --- .../scripts/DoAllocateNSIandNSSIV2.groovy | 613 ++++++++++++++ .../infrastructure/scripts/DoAllocateNSSIV2.groovy | 117 +++ .../scripts/DoCreateSliceServiceOptionV2.groovy | 907 +++++++++++++++++++++ .../subprocess/DoAllocateNSIandNSSIV2.bpmn | 598 ++++++++++++++ .../resources/subprocess/DoAllocateNSSIV2.bpmn | 233 ++++++ .../subprocess/DoCreateSliceServiceOptionV2.bpmn | 563 +++++++++++++ .../java/org/onap/so/beans/nsmf/SliceTaskInfo.java | 33 + .../onap/so/beans/nsmf/SliceTaskParamsAdapter.java | 36 + .../org/onap/so/beans/nsmf/TnSliceProfile.java | 10 + .../org/onap/so/beans/nsmf/oof/DomainType.java | 27 + .../org/onap/so/beans/nsmf/oof/NsiReqBody.java | 23 + .../org/onap/so/beans/nsmf/oof/NssiReqBody.java | 17 + .../org/onap/so/beans/nsmf/oof/RequestInfo.java | 27 + .../onap/so/beans/nsmf/oof/SubnetCapability.java | 15 + .../org/onap/so/beans/nsmf/oof/TemplateInfo.java | 17 + 15 files changed, 3236 insertions(+) create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn create mode 100644 bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java create mode 100644 common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy new file mode 100644 index 0000000000..924b42fe9f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSIandNSSIV2.groovy @@ -0,0 +1,613 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.BpmnError +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.Relationship +import org.onap.aai.domain.yang.ServiceInstance +import org.onap.aai.domain.yang.SliceProfile +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.so.beans.nsmf.* +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.json.JsonUtils +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.NotFoundException + +class DoAllocateNSIandNSSIV2 extends AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSIandNSSIV2.class); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + AAIResourcesClient client = getAAIClient() + + /** + * Pre Process the BPMN Flow Request + * Inclouds: + * generate the nsOperationKey + * generate the nsParameters + */ + + void preProcessRequest (DelegateExecution execution) { + String msg = "" + logger.trace("Enter preProcessRequest()") + Map nssiMap = new HashMap<>() + execution.setVariable("nssiMap", nssiMap) + boolean isMoreNSSTtoProcess = true + execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess) + List nsstSequence = new ArrayList<>(Arrays.asList("cn")) + execution.setVariable("nsstSequence", nsstSequence) + logger.trace("Exit preProcessRequest") + } + + /** + * Process NSI options + * @param execution + */ + void retriveSliceOption(DelegateExecution execution) { + logger.trace("Enter retriveSliceOption() of DoAllocateNSIandNSSI") + + boolean isNSIOptionAvailable + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter +// try +// { +// Map nstSolution = execution.getVariable("nstSolution") as Map +// String modelUuid = nstSolution.get("UUID") +// String modelInvariantUuid = nstSolution.get("invariantUUID") +// String serviceModelInfo = """{ +// "modelInvariantUuid":"${modelInvariantUuid}", +// "modelUuid":"${modelUuid}", +// "modelVersion":"" +// }""" +// execution.setVariable("serviceModelInfo", serviceModelInfo) +// +// execution.setVariable("sliceParams", sliceParams) +// }catch (Exception ex) { +// logger.debug( "Unable to get the task information from request DB: " + ex) +// exceptionUtil.buildAndThrowWorkflowException(execution, 401, "Unable to get task information from request DB.") +// } + + if(StringUtils.isBlank(sliceParams.getSuggestNsiId())) { + isNSIOptionAvailable = false + } + else { + isNSIOptionAvailable = true + execution.setVariable('nsiServiceInstanceId', sliceParams.getSuggestNsiId()) + execution.setVariable('nsiServiceInstanceName', sliceParams.getSuggestNsiName()) + } + execution.setVariable("isNSIOptionAvailable", isNSIOptionAvailable) + logger.trace("Exit retriveSliceOption() of DoAllocateNSIandNSSI") + } + + + /** + * create nsi instance in aai + * @param execution + */ + void createNSIinAAI(DelegateExecution execution) { + logger.debug("Enter CreateNSIinAAI in DoAllocateNSIandNSSI()") + + String sliceInstanceId = UUID.randomUUID().toString() + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + sliceParams.setServiceId(sliceInstanceId) + + ServiceInstance nsi = new ServiceInstance() + + + String sliceInstanceName = "nsi_"+execution.getVariable("sliceServiceInstanceName") + String serviceType = execution.getVariable("serviceType") + String serviceStatus = "deactivated" + String modelInvariantUuid = sliceParams.getNSTInfo().invariantUUID + String modelUuid = sliceParams.getNSTInfo().UUID + + String uuiRequest = execution.getVariable("uuiRequest") + String serviceInstanceLocationid = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.plmnIdList") + String serviceRole = "nsi" + + execution.setVariable("sliceInstanceId", sliceInstanceId) + nsi.setServiceInstanceId(sliceInstanceId) + nsi.setServiceInstanceName(sliceInstanceName) + nsi.setServiceType(serviceType) + nsi.setOrchestrationStatus(serviceStatus) + nsi.setModelInvariantId(modelInvariantUuid) + nsi.setModelVersionId(modelUuid) + nsi.setServiceInstanceLocationId(serviceInstanceLocationid) + nsi.setServiceRole(serviceRole) + String msg + try { + + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + sliceInstanceId) + client.create(nsiServiceUri, nsi) + + execution.setVariable("nsiServiceUri", nsiServiceUri.build().toString()) + + } catch (BpmnError e) { + throw e + } catch (Exception ex) { + msg = "Exception in DoCreateSliceServiceInstance.instantiateSliceService. " + ex.getMessage() + logger.info(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + logger.debug("Exit CreateNSIinAAI in DoAllocateNSIandNSSI()") + } + + + /** + * create relationship between nsi and service profile instance + * @param execution + */ + void createRelationship(DelegateExecution execution) { + //relation ship + Relationship relationship = new Relationship() + String nsiServiceUri = execution.getVariable("nsiServiceUri") as String + logger.info("Creating Allotted resource relationship, nsiServiceUri: " + nsiServiceUri) + + relationship.setRelatedLink(nsiServiceUri) + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri( + AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceServiceInstanceId"), + execution.getVariable("allottedResourceId")) + .relationshipAPI() + client.create(allottedResourceUri, relationship) + } + + /** + * + * @param execution + */ + void updateRelationship(DelegateExecution execution) { + logger.debug("Enter update relationship in DoAllocateNSIandNSSI()") + String allottedResourceId = execution.getVariable("allottedResourceId") + //Need to check whether nsi exist : Begin + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + String nsiServiceInstanceID = sliceParams.getSuggestNsiId() + sliceParams.setServiceId(nsiServiceInstanceID) + + AAIResourceUri nsiServiceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + nsiServiceInstanceID) + + try { + AAIResultWrapper wrapper = client.get(nsiServiceUri, NotFoundException.class) + Optional si = wrapper.asBean(ServiceInstance.class) + //todo: if exists + if (!si.ifPresent()) { + String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + + AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIObjectType.ALLOTTED_RESOURCE, + execution.getVariable("globalSubscriberId"), + execution.getVariable("subscriptionServiceType"), + execution.getVariable("sliceServiceInstanceId"), + allottedResourceId) + + client.connect(allottedResourceUri, nsiServiceUri) + + execution.setVariable("sliceParams", sliceParams) + }catch(BpmnError e) { + throw e + }catch (Exception ex){ + String msg = "NSI suggested in the option doesn't exist. " + nsiServiceInstanceID + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug("Exit update relationship in DoAllocateNSIandNSSI()") + } + + /** + * create RAN Slice Profile Instance + * @param execution + */ + void createAnSliceProfileInstance(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = UUID.randomUUID().toString() + execution.setVariable("ranSliceProfileInstanceId", serviceInstanceId) //todo: + + String serviceType = "" + String serviceRole = "slice-profile" + String oStatus = "deactivated" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo sliceTaskInfo = sliceParams.anSliceTaskInfo + sliceTaskInfo.setServiceInstanceId(serviceInstanceId) + + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(serviceType) + rspi.setServiceRole(serviceRole) + rspi.setOrchestrationStatus(oStatus) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setInputParameters(uuiRequest) + rspi.setWorkloadContext(useInterval) + rspi.setEnvironmentContext(sNSSAI_id) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + + execution.setVariable("communicationServiceInstance", rspi) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId) + client.create(uri, rspi) + + execution.setVariable("sliceParams", sliceParams) + } + + /** + * create An Slice Profile + * @param execution + */ + void createAnSliceProfile(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId") + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo sliceTaskInfo = sliceParams.anSliceTaskInfo + AnSliceProfile anSliceProfile = sliceTaskInfo.sliceProfile + + String profileId = UUID.randomUUID().toString() + anSliceProfile.setSliceProfileId(profileId) + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setProfileId(profileId) + sliceProfile.setCoverageAreaTAList(anSliceProfile.coverageAreaTAList as String) + //todo:... + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + globalSubscriberId, + subscriptionServiceType, + sliceTaskInfo.serviceInstanceId, + profileId + ) + client.create(uri, sliceProfile) + execution.setVariable("sliceParams", sliceParams) + } + + /** + * prepare AllocateAnNssi + * @param execution + */ + void prepareAllocateAnNssi(DelegateExecution execution) { + + //todo: + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo sliceTaskInfo = sliceParams.anSliceTaskInfo + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + AllocateAnNssi allocateAnNssi = new AllocateAnNssi() + allocateAnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID + allocateAnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID + allocateAnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + allocateAnNssi.sliceProfile = sliceTaskInfo.sliceProfile + allocateAnNssi.nsiInfo.nsiId = sliceParams + + EsrInfo esrInfo = new EsrInfo() + //todo: vendor and network + esrInfo.setVendor(sliceTaskInfo.getVendor()) + esrInfo.setNetworkType(sliceTaskInfo.getNetworkType()) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //todo: service info + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.globalSubscriberId = globalSubscriberId + serviceInfo.subscriptionServiceType = subscriptionServiceType + serviceInfo.nsiId = sliceParams.serviceId + serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID + serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setAllocateAnNssi(allocateAnNssi) + + execution.setVariable("AnAllocateNssiNbiRequest", nbiRequest) + execution.setVariable("anBHSliceTaskInfo", sliceTaskInfo) + } + + + /** + * create RAN Slice Profile Instance + * @param execution + */ + void createCnSliceProfileInstance(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = UUID.randomUUID().toString() + execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo: + + String serviceType = "" + String serviceRole = "slice-profile" + String oStatus = "deactivated" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo sliceTaskInfo = sliceParams.cnSliceTaskInfo + sliceTaskInfo.setServiceInstanceId(serviceInstanceId) + + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(serviceType) + rspi.setServiceRole(serviceRole) + rspi.setOrchestrationStatus(oStatus) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setInputParameters(uuiRequest) + rspi.setWorkloadContext(useInterval) + rspi.setEnvironmentContext(sNSSAI_id) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + + execution.setVariable("communicationServiceInstance", rspi) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId) + client.create(uri, rspi) + execution.setVariable("sliceParams", sliceParams) + } + + /** + * create An Slice Profile + * @param execution + */ + void createCnSliceProfile(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + //String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId") + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + SliceTaskInfo sliceTaskInfo = sliceParams.cnSliceTaskInfo + CnSliceProfile cnSliceProfile = sliceTaskInfo.sliceProfile + + String profileId = UUID.randomUUID().toString() + cnSliceProfile.setSliceProfileId(profileId) + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setProfileId(profileId) + sliceProfile.setCoverageAreaTAList(cnSliceProfile.coverageAreaTAList as String) + //todo:... + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + globalSubscriberId, + subscriptionServiceType, + sliceTaskInfo.serviceInstanceId, + profileId + ) + client.create(uri, sliceProfile) + execution.setVariable("sliceParams", sliceParams) + } + + /** + * prepare AllocateCnNssi + * @param execution + */ + void prepareAllocateCnNssi(DelegateExecution execution) { + + //todo: + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo sliceTaskInfo = sliceParams.cnSliceTaskInfo + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + AllocateCnNssi allocateCnNssi = new AllocateCnNssi() + allocateCnNssi.nsstId = sliceTaskInfo.NSSTInfo.UUID + allocateCnNssi.nssiId = sliceTaskInfo.NSSTInfo.UUID + allocateCnNssi.nssiName = sliceTaskInfo.NSSTInfo.name + allocateCnNssi.sliceProfile = sliceTaskInfo.sliceProfile + allocateCnNssi.nsiInfo.nsiId = sliceParams + + EsrInfo esrInfo = new EsrInfo() + //todo: vendor and network + esrInfo.setVendor(sliceTaskInfo.getVendor()) + esrInfo.setNetworkType(sliceTaskInfo.getNetworkType()) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //todo: service info + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.globalSubscriberId = globalSubscriberId + serviceInfo.subscriptionServiceType = subscriptionServiceType + serviceInfo.nsiId = sliceParams.serviceId + serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID + serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setAllocateCnNssi(allocateCnNssi) + + execution.setVariable("CnAllocateNssiNbiRequest", nbiRequest) + execution.setVariable("cnSliceTaskInfo", sliceTaskInfo) + } + + + /** + * create TN Slice Profile Instance + * @param execution + */ + void createTnBHSliceProfileInstance(DelegateExecution execution) { + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + String serviceType = "" + String serviceRole = "slice-profile" + String oStatus = "deactivated" + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + SliceTaskInfo sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + String serviceInstanceId = UUID.randomUUID().toString() + + sliceTaskInfo.setServiceInstanceId(serviceInstanceId) + //execution.setVariable("cnSliceProfileInstanceId", serviceInstanceId) //todo: + + // create slice profile + ServiceInstance rspi = new ServiceInstance() + rspi.setServiceInstanceName(sliceTaskInfo.NSSTInfo.name) + rspi.setServiceType(serviceType) + rspi.setServiceRole(serviceRole) + rspi.setOrchestrationStatus(oStatus) + rspi.setModelInvariantId(sliceTaskInfo.NSSTInfo.invariantUUID) + rspi.setModelVersionId(sliceTaskInfo.NSSTInfo.UUID) + rspi.setInputParameters(uuiRequest) + rspi.setWorkloadContext(useInterval) + rspi.setEnvironmentContext(sNSSAI_id) + + //timestamp format YYYY-MM-DD hh:mm:ss + rspi.setCreatedAt(new Date(System.currentTimeMillis()).format("yyyy-MM-dd HH:mm:ss", TimeZone.getDefault())) + + execution.setVariable("communicationServiceInstance", rspi) + + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId) + client.create(uri, rspi) + + execution.setVariable("sliceParams", sliceParams) + } + + /** + * create An Slice Profile + * @param execution + */ + void createTnBHSliceProfile(DelegateExecution execution) { + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + String serviceInstanceId = execution.getVariable("ranSliceProfileInstanceId") + + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + + SliceTaskInfo sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + + TnSliceProfile tnSliceProfile = sliceTaskInfo.sliceProfile + String profileId = UUID.randomUUID().toString() + tnSliceProfile.setSliceProfileId(profileId) + + SliceProfile sliceProfile = new SliceProfile() + sliceProfile.setProfileId(profileId) + //todo:... + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SLICE_PROFILE, + globalSubscriberId, + subscriptionServiceType, + serviceInstanceId, + profileId + ) + client.create(uri, sliceProfile) + + execution.setVariable("sliceParams", sliceParams) + } + + /** + * prepare AllocateCnNssi + * @param execution + */ + void prepareAllocateTnBHNssi(DelegateExecution execution) { + + //todo: + SliceTaskParamsAdapter sliceParams = + execution.getVariable("sliceParams") as SliceTaskParamsAdapter + SliceTaskInfo sliceTaskInfo = sliceParams.tnBHSliceTaskInfo + + NssmfAdapterNBIRequest nbiRequest = new NssmfAdapterNBIRequest() + + AllocateTnNssi allocateTnNssi = new AllocateTnNssi() + //todo: AllocateTnNssi + //allocateTnNssi.networkSliceInfos + + EsrInfo esrInfo = new EsrInfo() + //todo: vendor and network + esrInfo.setVendor(sliceTaskInfo.getVendor()) + esrInfo.setNetworkType(sliceTaskInfo.getNetworkType()) + + String globalSubscriberId = execution.getVariable("globalSubscriberId") + String subscriptionServiceType = execution.getVariable("subscriptionServiceType") + + //todo: service info + ServiceInfo serviceInfo = new ServiceInfo() + serviceInfo.globalSubscriberId = globalSubscriberId + serviceInfo.subscriptionServiceType = subscriptionServiceType + serviceInfo.nsiId = sliceParams.serviceId + serviceInfo.serviceInvariantUuid = sliceTaskInfo.NSSTInfo.invariantUUID + serviceInfo.serviceUuid = sliceTaskInfo.NSSTInfo.UUID + + nbiRequest.setServiceInfo(serviceInfo) + nbiRequest.setEsrInfo(esrInfo) + nbiRequest.setAllocateTnNssi(allocateTnNssi) + + execution.setVariable("TnBHAllocateNssiNbiRequest", nbiRequest) + execution.setVariable("tnBHSliceTaskInfo", sliceTaskInfo) + } + +} \ No newline at end of file diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy new file mode 100644 index 0000000000..05bb53a61e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSIV2.groovy @@ -0,0 +1,117 @@ +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.SliceTaskInfo +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.slf4j.Logger +import org.slf4j.LoggerFactory + +class DoAllocateNSSIV2 extends AbstractServiceTaskProcessor { + + private static final Logger logger = LoggerFactory.getLogger( DoAllocateNSSIV2.class); + private static final ObjectMapper MAPPER = new ObjectMapper(); + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.trace("Enter preProcessRequest()") + +// String nssmfOperation +// +// String nsstInput = execution.getVariable("nsstInput") +// String modelUuid = jsonUtil.getJsonValue(nsstInput, "modelUuid") +// //modelUuid="2763777c-27bd-4df7-93b8-c690e23f4d3f" +// String nssiInstanceId = jsonUtil.getJsonValue(nsstInput, "serviceInstanceId") +// String serviceModelInfo = """{ +// "modelInvariantUuid":"", +// "modelUuid":"${modelUuid}", +// "modelVersion":"" +// }""" +// execution.setVariable("serviceModelInfo", serviceModelInfo) +// execution.setVariable("nssiInstanceId", nssiInstanceId) +// String nssiProfileID = UUID.randomUUID().toString() +// execution.setVariable("nssiProfileID", nssiProfileID) +// if(isBlank(nssiInstanceId)) +// { +// nssmfOperation="create" +// nssiInstanceId = UUID.randomUUID().toString() +// }else { +// nssmfOperation = "update" +// } +// execution.setVariable("nssmfOperation",nssmfOperation) +// execution.setVariable("nssiInstanceId",nssiInstanceId) +// +// def isNSSICreated = false +// execution.setVariable("isNSSICreated",isNSSICreated) +// +// int currentCycle = 0 +// execution.setVariable("currentCycle", currentCycle) + + + SliceTaskInfo sliceTaskInfo = execution.getVariable("sliceTaskInfo") as SliceTaskInfo + if (StringUtils.isBlank(sliceTaskInfo.suggestNssiId)) { + execution.setVariable("nssmfOperation", "create") + } else { + execution.setVariable("nssmfOperation", "update") + } + logger.trace("Exit preProcessRequest") + } + + /** + * prepare nssi request + * @param execution + */ + void prepareNSSIReq(DelegateExecution execution) { + + } + + void getNSSTInfo(DelegateExecution execution){ + logger.trace("Enter getNSSTInfo in DoAllocateNSSI()") + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + ModelInfo modelInfo = serviceDecomposition.getModelInfo() + String serviceRole = "nssi" + String nssiServiceInvariantUuid = serviceDecomposition.modelInfo.getModelInvariantUuid() + String nssiServiceUuid = serviceDecomposition.modelInfo.getModelUuid() + String nssiServiceType = serviceDecomposition.getServiceType() + String uuiRequest = execution.getVariable("uuiRequest") + String nssiServiceName = "nssi_"+jsonUtil.getJsonValue(uuiRequest, "service.name") + execution.setVariable("nssiServiceName",nssiServiceName) + execution.setVariable("nssiServiceType",nssiServiceType) + execution.setVariable("nssiServiceInvariantUuid",nssiServiceInvariantUuid) + execution.setVariable("nssiServiceUuid",nssiServiceUuid) + execution.setVariable("serviceRole",serviceRole) + + String content = serviceDecomposition.getServiceInfo().getServiceArtifact().get(0).getContent() + String nsstID = jsonUtil.getJsonValue(content, "metadata.id") + String nsstVendor = jsonUtil.getJsonValue(content, "metadata.vendor") + String nsstDomain = jsonUtil.getJsonValue(content, "metadata.domainType") + String nsstType = jsonUtil.getJsonValue(content, "metadata.type") + + execution.setVariable("nsstID",nsstID) + execution.setVariable("nsstVendor",nsstVendor) + execution.setVariable("nsstDomain",nsstDomain) + execution.setVariable("nssiServiceUuid",nssiServiceUuid) + execution.setVariable("nsstType",nsstType) + + String nsstContentInfo = """{ + "NsstID":"${nsstID}", + "Vendor":"${nsstVendor}", + "type":"${nsstType}" + }""" + + logger.trace("Exit getNSSTInfo in DoAllocateNSSI()") + } + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy new file mode 100644 index 0000000000..ca262172d0 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOptionV2.groovy @@ -0,0 +1,907 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + # Copyright (c) 2019, CMCC Technologies Co., Ltd. + # + # Licensed under the Apache License, Version 2.0 (the "License") + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.infrastructure.scripts + +import com.fasterxml.jackson.core.type.TypeReference +import com.fasterxml.jackson.databind.ObjectMapper +import org.apache.commons.lang3.StringUtils +import org.camunda.bpm.engine.delegate.DelegateExecution +import org.onap.aai.domain.yang.ServiceInstance +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.logging.filter.base.ONAPComponents +import org.onap.so.beans.nsmf.* +import org.onap.so.beans.nsmf.oof.SubnetCapability +import org.onap.so.beans.nsmf.oof.TemplateInfo +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.common.scripts.OofUtils +import org.onap.so.bpmn.core.UrnPropertiesReader +import org.onap.so.bpmn.core.domain.ServiceDecomposition +import org.onap.so.bpmn.core.domain.ServiceProxy +import org.onap.so.bpmn.core.json.JsonUtils +import org.onap.so.client.HttpClient +import org.onap.so.client.HttpClientFactory +import org.slf4j.Logger +import org.slf4j.LoggerFactory + +import javax.ws.rs.NotFoundException +import javax.ws.rs.core.Response + +class DoCreateSliceServiceOptionV2 extends AbstractServiceTaskProcessor{ + + private static final Logger logger = LoggerFactory.getLogger( DoCreateSliceServiceOptionV2.class) + + ExceptionUtil exceptionUtil = new ExceptionUtil() + + JsonUtils jsonUtil = new JsonUtils() + + OofUtils oofUtils = new OofUtils() + + ObjectMapper objectMapper = new ObjectMapper() + + void preProcessRequest (DelegateExecution execution) { + } + + + /** + * prepare select nsi request + * @param execution + */ + void prepareSelectNSIRequest(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + + boolean isNSISuggested = true + execution.setVariable("isNSISuggested",isNSISuggested) + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + + Map profileInfo = execution.getVariable("serviceProfile") + Map nstSolution = execution.getVariable("nstSolution") + 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) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution); + execution.setVariable("nsiSelection_timeout",timeout) + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo,messageType, profileInfo) + execution.setVariable("nsiSelection_oofRequest",oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /** + * process select nsi response + * @param execution + */ + void processOOFResponse(DelegateExecution execution) { + + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams + 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 resMap = objectMapper.readValue(OOFResponse, Map.class) + List> nsiSolutions = (List>) resMap.get("solutions") + Map solutions = nsiSolutions.get(0) + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel == "shared" + + if (solutions != null) { + if (isSharable && solutions.get("existingNSI")) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolution")) { + processNewNSISolutions(solutions, execution) + } + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) + logger.debug("*** Completed options Call to OOF ***") + + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + + private void processNewNSISolutions(Map solutions, DelegateExecution execution) { + int index = 0 + List newNSISolutions = solutions.get("newNSISolution") + List NSSImap = new ArrayList<>() + if (newNSISolutions != null && newNSISolutions.size() > 0) { + NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List + for (Map nssi : NSSImap) { + Map oofSliceProfile = nssi.get("sliceProfile") + String domain = oofSliceProfile.getOrDefault("domainType","") + logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}") + if(null != domain){ + //TODO +// def nssiSolution = nssi.get("NSSISolution") as Map +// String nssiName = nssiSolution.getOrDefault("NSSIName", "") +// String nssiId = nssiSolution.getOrDefault("NSSIId", "") +// saveNSSIId(nssi, sliceTaskParams) + Map sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + + } + } + } + } + + private void processSharedNSISolutions(Map solutions, DelegateExecution execution) { + String nsiName, nsiInstanceId, nssiId, nssiName + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + + Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0) + nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "") + nsiName = sharedNSIsolution.getOrDefault("NSIName", "") + sliceTaskParams.setSuggestNsiId(nsiInstanceId) + sliceTaskParams.setSuggestNsiName(nsiName) + + //Temporary modification + List NSSIs = sharedNSIsolution.get("NSSIs") + for(Map nssi : NSSIs){ + Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) + String domain = oofSliceProfile.getOrDefault("domainType","") + nssiId = nssi.getOrDefault("NSSIId","") + nssiName = nssi.getOrDefault("NSSIName","") + saveNSSIId(domain, nssiId, nssiName,execution) + Map sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}") + logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}") + } + } + + private void parseServiceProfile(DelegateExecution execution) { + logger.debug("Start parseServiceProfile") + String serviceType = execution.getVariable("serviceType") + Map serviceProfile = execution.getVariable("serviceProfile") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + // set sliceProfile for three domains + if(!sliceTaskParams.getSliceProfileAn()){ + Map sliceProfileAn = getSliceProfile( "AN", execution,null) + saveSliceProfile(execution,"AN",sliceProfileAn) + } + + if(!sliceTaskParams.getSliceProfileTn()){ + Map sliceProfileTn = getSliceProfile( "TN", execution,null) + saveSliceProfile(execution,"TN",sliceProfileTn) + } + + if(!sliceTaskParams.getSliceProfileCn()){ + Map sliceProfileCn = getSliceProfile( "CN", execution,null, ) + saveSliceProfile(execution,"CN",sliceProfileCn) + } + + logger.debug("Finish parseServiceProfile") + } + + private void saveSliceProfile(DelegateExecution execution, String domain, Map sliceProfile){ + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + execution.setVariable("sliceProfileAn", sliceProfile) + sliceTaskParams.setSliceProfileAn(sliceProfile) + logger.debug("sliceProfileAn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("TN")){ + execution.setVariable("sliceProfileTn", sliceProfile) + sliceTaskParams.setSliceProfileTn(sliceProfile) + logger.debug("sliceProfileTn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("CN")){ + execution.setVariable("sliceProfileCn", sliceProfile) + sliceTaskParams.setSliceProfileCn(sliceProfile) + logger.debug("sliceProfileCn: " + sliceProfile) + } + } + + private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) { + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + sliceTaskParams.setAnSuggestNssiId(nssiId) + sliceTaskParams.setAnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("CN")){ + sliceTaskParams.setCnSuggestNssiId(nssiId) + sliceTaskParams.setCnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("TN")){ + sliceTaskParams.setTnSuggestNssiId(nssiId) + sliceTaskParams.setTnSuggestNssiName(nssiName) + } + } + + private Map getSliceProfile(String domain, DelegateExecution execution, Map oofSliceProfile) { + String profileMapStr + Map serviceProfile = execution.getVariable("serviceProfile") + Integer domainLatency = (Integer) serviceProfile.get("latency")/3 + + if(domain.equalsIgnoreCase("AN")){ + profileMapStr = """ { + "latency": ${domainLatency}, + "sNSSAI": "sNSSAI", + "uEMobilityLevel": "uEMobilityLevel", + "coverageAreaTAList": "coverageAreaTAList", + "5QI": 100 + }""" + } + else if(domain.equalsIgnoreCase("TN")){ + profileMapStr =""" { + "latency":${domainLatency}, + "sNSSAI":"sNSSAI", + "e2eLatency":"latency", + "bandwidth": 100 + }""" + } + else if(domain.equalsIgnoreCase("CN")){ + profileMapStr = """ { + "areaTrafficCapDL":"areaTrafficCapDL", + "maxNumberofUEs":"maxNumberofUEs", + "latency":${domainLatency}, + "expDataRateUL":"expDataRateUL", + "sNSSAI":"sNSSAI", + "areaTrafficCapUL":"areaTrafficCapUL", + "uEMobilityLevel":"uEMobilityLevel", + "expDataRateDL":"expDataRateDL", + "activityFactor":"activityFactor", + "resourceSharingLevel":"resourceSharingLevel" + }""" + } + + logger.debug("Profile map for " + domain + " : " + profileMapStr) + Map profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference>(){}) + Map sliceProfile = [:] + for (Map.Entry profileMap : profileMaps) { + String key = profileMap.key + String value = profileMaps.get(key) + if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){ + sliceProfile.put(key, oofSliceProfile.get(key)) + logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}") + } + else if(serviceProfile.keySet().contains(value)){ + sliceProfile.put(key, serviceProfile.get(value)) + } + else{ + sliceProfile.put(key, profileMaps.get(key)) + } + } + return sliceProfile + } + + void processDecomposition(DelegateExecution execution){ + logger.debug("Start processDecomposition") + + ServiceDecomposition serviceDecomposition= execution.getVariable("serviceDecomposition") + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + String nstName = serviceDecomposition.getModelInfo().getModelName() + String nstId = serviceDecomposition.getModelInfo().getModelUuid() + sliceTaskParams.setNstName(nstName) + sliceTaskParams.setNstId(nstId) + + logger.debug("End processDecomposition") + } + + + void prepareNSTDecompose(DelegateExecution execution) { + + String modelUuid = execution.getVariable("nstModelUuid") + String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + } + + void prepareNSSTDecompose(DelegateExecution execution) { + Boolean isMoreNSSTtoProcess = false + Integer maxNSST = execution.getVariable("maxNSST") + Integer currentNSST=execution.getVariable("currentNSST") + List nsstModelUUIDList = new ArrayList<>() + nsstModelUUIDList = execution.getVariable("nsstModelUUIDList") + String modelUuid = nsstModelUUIDList.get(currentNSST) + String serviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("serviceModelInfo", serviceModelInfo) + currentNSST=currentNSST+1 + if(currentNSST proxyList = serviceDecomposition.getServiceProxy() + List nsstModelUUIDList = new ArrayList<>() + for(ServiceProxy serviceProxy:proxyList) + nsstModelUUIDList.add(serviceProxy.getSourceModelUuid()) + execution.setVariable("nsstModelUUIDList",nsstModelUUIDList) + Integer maxNSST = nsstModelUUIDList.size() + Integer currentNSST=0 + execution.setVariable("maxNSST",maxNSST) + execution.setVariable("currentNSST",currentNSST) + if(currentNSST profileInfo = execution.getVariable("serviceProfile") + String nsstModelInvariantUuid = serviceDecomposition.getModelInfo().getModelInvariantUuid() + String nsstModelUuid = serviceDecomposition.getModelInfo().getModelUuid() + String nsstInfo = """"NSSTInfo": { + "invariantUUID":"${nsstModelInvariantUuid}", + "UUID":"${nsstModelUuid}" + }""" + String oofRequest = oofUtils.buildSelectNSSIRequest(execution, requestId, nsstInfo ,profileInfo) + + + URL url = new URL(urlString+"/api/oof/v1/selectnssi") + HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.OOF) + httpClient.addAdditionalHeader("Authorization", authHeader) + Response httpResponse = httpClient.post(oofRequest) + + int responseCode = httpResponse.getStatus() + logger.debug("OOF sync response code is: " + responseCode) + + if(responseCode != 200){ + exceptionUtil.buildAndThrowWorkflowException(execution, responseCode, "Received a Bad Sync Response from OOF.") + } + + if(httpResponse.hasEntity()){ + String OOFResponse = httpResponse.readEntity(String.class) + execution.setVariable("OOFResponse", OOFResponse) + nssiInstanceId = jsonUtil.getJsonValue(OOFResponse, "NSSIIInfo.NSSIID") + nssiName = jsonUtil.getJsonValue(OOFResponse, "NSSIInfo.NSSIName") + execution.setVariable("nssiInstanceId",nssiInstanceId) + execution.setVariable("nssiName",nssiName) + } + if(StringUtils.isBlank(nssiInstanceId)){ + logger.debug( "There is no valid NSST suggested by OOF.") + }else + { + try { + AAIResourcesClient resourceClient = new AAIResourcesClient() + AAIResourceUri serviceInstanceUri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalSubscriberId, serviceType, nssiInstanceId) + AAIResultWrapper wrapper = resourceClient.get(serviceInstanceUri, NotFoundException.class) + Optional si = wrapper.asBean(org.onap.aai.domain.yang.ServiceInstance.class) + org.onap.aai.domain.yang.ServiceInstance nssi = si.get() + + String domain = nssi.getEnvironmentContext().toString().toUpperCase() + switch (domain) { + case "AN": + sliceTaskParams.setAnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setAnSuggestNssiName(nssi.getServiceInstanceName()) + break + case "CN": + sliceTaskParams.setCnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setCnSuggestNssiName(nssi.getServiceInstanceName()) + break + case "TN": + sliceTaskParams.setTnSuggestNssiId(nssi.getServiceInstanceId()) + sliceTaskParams.setTnSuggestNssiName(nssi.getServiceInstanceName()) + break + default: + break + } + }catch(NotFoundException e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) + }catch(Exception e) + { + logger.debug("NSSI Service Instance not found in AAI: " + nssiInstanceId) + } + } + logger.debug("Prepare NSSI option completed ") + } + + + /** + * new + */ + + private static final ObjectMapper MAPPER = new ObjectMapper() + + private NssmfAdapterUtils nssmfAdapterUtils = new NssmfAdapterUtils(httpClientFactory, jsonUtil) + + private static final String QUERY_SUB_NET_CAPABILITY = "/api/rest/provMns/v1/NSS/subnetCapabilityQuery" + + private static final String QUERY_NSSI_SELECTION_CAPABILITY = "/api/rest/provMns/v1/NSS/NSSISelectionCapability" + + /** + * query Subnet Capability of TN + * @param execution + */ + public void queryTNSubnetCapability(DelegateExecution execution) { + + String vendor = execution.getVariable("vendor") + + List subnetTypes = new ArrayList<>() + subnetTypes.add("TN_FH") + subnetTypes.add("TN_MH") + subnetTypes.add("TN_BH") + + String strRequest = MAPPER.writeValueAsString( + buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.TRANSPORT)) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest) + execution.setVariable("subnetCapabilityOfTN", response) + } + + /** + * query Subnet Capability of CN + * @param execution + */ + public void queryCNSubnetCapability(DelegateExecution execution) { + + String vendor = execution.getVariable("vendor") + + List subnetTypes = new ArrayList<>() + subnetTypes.add("CN") + + String strRequest = MAPPER.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.CORE)) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest) + + execution.setVariable("subnetCapabilityOfCN", response) + } + + /** + * query Subnet Capability of AN + * @param execution + */ + public void queryANSubnetCapability(DelegateExecution execution) { + + String vendor = execution.getVariable("vendor") + + List subnetTypes = new ArrayList<>() + subnetTypes.add("AN-NF") + + String strRequest = MAPPER.writeValueAsString(buildQuerySubnetCapRequest(vendor, subnetTypes, NetworkType.ACCESS)) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_SUB_NET_CAPABILITY, strRequest) + + execution.setVariable("subnetCapabilityOfAN", response) + } + + /** + * build request body for querying Subnet Capability + * @param vendor + * @param subnetTypes + * @param networkType + * @return + */ + private static String buildQuerySubnetCapRequest(String vendor, List subnetTypes, NetworkType networkType) { + NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() + + Map paramMap = new HashMap() + paramMap.put("subnetTypes", subnetTypes) + + request.setSubnetCapabilityQuery(MAPPER.writeValueAsString(paramMap)) + + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor(vendor) + esrInfo.setNetworkType(networkType) + + request.setEsrInfo(esrInfo) + + String strRequest = MAPPER.writeValueAsString(request) + + return strRequest + } + + /** + * handle response of Subnet Capability, generate SubnetCapabilities Info for request to oof + * @param execution + */ + public void generateSubnetCapabilities(DelegateExecution execution) { + //todo: + execution.setVariable("subnetCapabilities", []) + } + + /** + * prepare the params for decompose nst + * @param execution + */ + public void prepareDecomposeNST(DelegateExecution execution) { + + String modelUuid = execution.getVariable("nstModelUuid") + String modelInvariantUuid = execution.getVariable("nstModelInvariantUuid") + + String serviceModelInfo = """{ + "modelInvariantUuid":"${modelInvariantUuid}", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("nstServiceModelInfo", serviceModelInfo) + } + + /** + * process the result of NST Decomposition + * @param execution + */ + public void processDecompositionNST(DelegateExecution execution) { + + ServiceDecomposition nstServiceDecomposition = execution.getVariable("nstServiceDecomposition") + //todo: + + } + + + /** + * prepare the params for decompose nsst + * @param execution + */ + public void prepareDecomposeNSST(DelegateExecution execution) { + Boolean isMoreNSSTtoProcess = false + def maxNSST = execution.getVariable("maxNSST") as Integer + def currentNSST = execution.getVariable("currentNSST") as Integer + def nsstModelUUIDList = execution.getVariable("nsstModelUUIDList") as List + String modelUuid = nsstModelUUIDList.get(currentNSST) + String serviceModelInfo = """{ + "modelInvariantUuid":"", + "modelUuid":"${modelUuid}", + "modelVersion":"" + }""" + execution.setVariable("nsstServiceModelInfo", serviceModelInfo) + currentNSST = currentNSST + 1 + + if(currentNSST < maxNSST) { + isMoreNSSTtoProcess = true + } + + execution.setVariable("isMoreNSSTtoProcess", isMoreNSSTtoProcess) + execution.setVariable("maxNSST", maxNSST) + execution.setVariable("currentNSST", currentNSST) + + //todo: + } + + /** + * process the result of NSST Decomposition + * @param execution + */ + public void processDecompositionNSST(DelegateExecution execution) { + ServiceDecomposition nsstServiceDecomposition = execution.getVariable("nsstServiceDecomposition") + //todo: + } + + /** + * todo: need rewrite + * prepare select nsi request + * @param execution + */ + public void preNSIRequest(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + + boolean isNSISuggested = true + execution.setVariable("isNSISuggested", isNSISuggested) + String requestId = execution.getVariable("msoRequestId") + String messageType = "NSISelectionResponse" + + ServiceProfile profileInfo = execution.getVariable("serviceProfile") as ServiceProfile + Map nstSolution = execution.getVariable("nstSolution") as Map + logger.debug("Get NST selection from OOF: " + nstSolution.toString()) + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType", messageType) + execution.setVariable("nsiSelection_correlator", requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution) + execution.setVariable("nsiSelection_timeout", timeout) + + + TemplateInfo nstInfo = new TemplateInfo() + nstInfo.setInvariantUUID(nstSolution.get("invariantUUID") as String) + nstInfo.setUUID(nstSolution.get("UUID") as String) + nstInfo.setName(nstSolution.get("NSTName") as String) + + execution.setVariable("NSTInfo", nstInfo) + + List nsstInfos = execution.getVariable("NSSTInfos") as List + + List subnetCapabilities = execution.getVariable("subnetCapabilities") as List + + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, nsstInfos, + messageType, profileInfo, subnetCapabilities, timeout as Integer) + + execution.setVariable("nsiSelection_oofRequest", oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /** + * todo: need rewrite + * process select nsi response + * @param execution + */ + public void processNSIResp(DelegateExecution execution) { + + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams + 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 resMap = objectMapper.readValue(OOFResponse, Map.class) + List> nsiSolutions = (List>) resMap.get("solutions") + Map solutions = nsiSolutions.get(0) + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel == "shared" + + if (solutions != null) { + if (isSharable && solutions.get("existingNSI")) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolution")) { + processNewNSISolutions(solutions, execution) + } + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("sliceTaskParams: " + sliceTaskParams.convertToJson()) + logger.debug("*** Completed options Call to OOF ***") + + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + /** + * get NSSI Selection Capability for AN + * @param execution + */ + public void getNSSISelectionCap4AN(DelegateExecution execution) { + + def vendor = execution.getVariable("vendor") as String + + String strRequest = buildNSSISelectionReq(vendor, NetworkType.ACCESS) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest) + + Map resMap = objectMapper.readValue(response, Map.class) + + String selection = resMap.get("selection") + + + if ("NSMF".equalsIgnoreCase(selection)) { + execution.setVariable("NEED_AN_NSSI_SELECTION", true) + } + } + + /** + * get NSSI Selection Capability for TN + * @param execution + */ + public void getNSSISelectionCap4TN(DelegateExecution execution) { + + def vendor = execution.getVariable("vendor") as String + + String strRequest = buildNSSISelectionReq(vendor, NetworkType.TRANSPORT) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest) + + Map resMap = objectMapper.readValue(response, Map.class) + + String selection = resMap.get("selection") + + if ("NSMF".equalsIgnoreCase(selection)) { + execution.setVariable("NEED_TN_NSSI_SELECTION", true) + } + } + + /** + * get NSSI Selection Capability for CN + * @param execution + */ + public void getNSSISelectionCap4CN(DelegateExecution execution) { + + def vendor = execution.getVariable("vendor") as String + + String strRequest = buildNSSISelectionReq(vendor, NetworkType.CORE) + + String response = nssmfAdapterUtils.sendPostRequestNSSMF(execution, QUERY_NSSI_SELECTION_CAPABILITY, strRequest) + + Map resMap = objectMapper.readValue(response, Map.class) + + String selection = resMap.get("selection") + + if ("NSMF".equalsIgnoreCase(selection)) { + execution.setVariable("NEED_CN_NSSI_SELECTION", true) + } + } + + /** + * build NSSI Selection Capability Request body to nssmf adapter + * @param vendor + * @param networkType + * @return + */ + private static String buildNSSISelectionReq(String vendor, NetworkType networkType) { + NssmfAdapterNBIRequest request = new NssmfAdapterNBIRequest() + EsrInfo esrInfo = new EsrInfo() + esrInfo.setVendor(vendor) + esrInfo.setNetworkType(networkType) + request.setEsrInfo(esrInfo) + + return MAPPER.writeValueAsString(request) + } + + /** + * if exist nssi need to select? + * @param execution + */ + public void handleNssiSelect(DelegateExecution execution) { + + SliceTaskParamsAdapter sliceTaskParams = + execution.getVariable("sliceTaskParams") as SliceTaskParamsAdapter + + execution.setVariable() + } + + /** + * todo: need rewrite + * prepare select nssi request + * @param execution + */ + public void preNSSIRequest(DelegateExecution execution) { + + String urlString = UrnPropertiesReader.getVariable("mso.oof.endpoint", execution) + logger.debug( "get NSI option OOF Url: " + urlString) + + boolean isNSISuggested = true + execution.setVariable("isNSISuggested", isNSISuggested) + String 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}" + }""" + + execution.setVariable("nsiSelectionUrl", "/api/oof/selection/nsi/v1") + execution.setVariable("nsiSelection_messageType", messageType) + execution.setVariable("nsiSelection_correlator", requestId) + String timeout = UrnPropertiesReader.getVariable("mso.adapters.oof.timeout", execution) + execution.setVariable("nsiSelection_timeout", timeout) + + //todo + String oofRequest = oofUtils.buildSelectNSIRequest(requestId, nstInfo, messageType, profileInfo) + + execution.setVariable("nsiSelection_oofRequest", oofRequest) + logger.debug("Sending request to OOF: " + oofRequest) + } + + /** + * process select nssi response + * @param execution + */ + public void processNSSIResp(DelegateExecution execution) { + + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") as SliceTaskParams + 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 resMap = objectMapper.readValue(OOFResponse, Map.class) + List> nsiSolutions = (List>) resMap.get("solutions") + Map solutions = nsiSolutions.get(0) + + String resourceSharingLevel = execution.getVariable("resourceSharingLevel") + Boolean isSharable = resourceSharingLevel == "shared" + + if (solutions != null) { + if (isSharable && solutions.get("existingNSI")) { + //sharedNSISolution + processSharedNSISolutions(solutions, execution) + } + else if(solutions.containsKey("newNSISolution")) { + processNewNSISolutions(solutions, execution) + } + } + execution.setVariable("sliceTaskParams", sliceTaskParams) + logger.debug("sliceTaskParams: "+sliceTaskParams.convertToJson()) + logger.debug("*** Completed options Call to OOF ***") + + logger.debug("start parseServiceProfile") + parseServiceProfile(execution) + logger.debug("end parseServiceProfile") + } + + +} diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn new file mode 100644 index 0000000000..071960a972 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSIandNSSIV2.bpmn @@ -0,0 +1,598 @@ + + + + + SequenceFlow_0xgfj7z + + + + SequenceFlow_0xgfj7z + SequenceFlow_00aukg6 + import org.onap.so.bpmn.infrastructure.scripts.* +def dansi = new DoAllocateNSIandNSSI() +dansi.preProcessRequest(execution) + + + SequenceFlow_00aukg6 + SequenceFlow_1ggo6s5 + import org.onap.so.bpmn.infrastructure.scripts.* +def dansi = new DoAllocateNSIandNSSI() +dansi.retriveSliceOption(execution) + + + + SequenceFlow_1ggo6s5 + SequenceFlow_0c986i9 + SequenceFlow_03ye8m4 + + + + + SequenceFlow_0c986i9 + SequenceFlow_1k3cspv + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createNSIinAAI(execution) + + + + #{(execution.getVariable("isNSIOptionAvailable" ) == true)} + + + SequenceFlow_0t0wddg + SequenceFlow_05ovikm + + + + SequenceFlow_0ct8yh4 + + + + + SequenceFlow_0ct8yh4 + SequenceFlow_1m68yca + SequenceFlow_0k5iu2n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0npsyye + SequenceFlow_1xb5nx1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_0cwbtmr + SequenceFlow_1l74seh + + + + + SequenceFlow_1gkb7iy + SequenceFlow_03zglrh + SequenceFlow_0ax2c4p + + + SequenceFlow_03ye8m4 + SequenceFlow_0t0wddg + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.updateRelationship(execution) + + + + SequenceFlow_1k3cspv + SequenceFlow_05ovikm + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createRelationship(execution) + + + + SequenceFlow_1m68yca + SequenceFlow_1hfjn79 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createAnSliceProfileInstance(execution) + + + SequenceFlow_1hfjn79 + SequenceFlow_0zbd2tq + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createAnSliceProfile(execution) + + + + SequenceFlow_0k5iu2n + SequenceFlow_0f36cu2 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createCnSliceProfileInstance(execution) + + + SequenceFlow_0f36cu2 + SequenceFlow_1wffel4 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createCnSliceProfile(execution) + + + + SequenceFlow_0paqrtx + SequenceFlow_1d48cil + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createTnBHSliceProfileInstance(execution) + + + SequenceFlow_1d48cil + SequenceFlow_00dexhy + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.createTnBHSliceProfile(execution) + + + + + + + + + + + + + + + + + + + + + + + + + + + + SequenceFlow_01isn2q + SequenceFlow_1omynpt + + + + + SequenceFlow_0paqrtx + + + + + SequenceFlow_1omynpt + SequenceFlow_150xio1 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + SequenceFlow_150xio1 + SequenceFlow_040fu80 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + SequenceFlow_040fu80 + SequenceFlow_1uti8ls + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + + + SequenceFlow_1xb5nx1 + SequenceFlow_0xx5bwa + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + + SequenceFlow_0xx5bwa + SequenceFlow_1sckufj + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + + SequenceFlow_1sckufj + SequenceFlow_1gkb7iy + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + + SequenceFlow_1l74seh + SequenceFlow_0jqxxjq + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + SequenceFlow_0jqxxjq + SequenceFlow_02qun80 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + SequenceFlow_02qun80 + SequenceFlow_03zglrh + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + + + + + + SequenceFlow_1uti8ls + + + + SequenceFlow_0ax2c4p + + + + SequenceFlow_0zbd2tq + SequenceFlow_0npsyye + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateAnNssi(execution) + + + + SequenceFlow_1wffel4 + SequenceFlow_0cwbtmr + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateCnNssi(execution) + + + + + SequenceFlow_00dexhy + SequenceFlow_01isn2q + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnsio = new DoAllocateNSIandNSSI() +dcnsio.prepareAllocateTnBHNssi(execution) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn new file mode 100644 index 0000000000..bcb48a60e6 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoAllocateNSSIV2.bpmn @@ -0,0 +1,233 @@ + + + + + SequenceFlow_07xkshs + + + SequenceFlow_07xkshs + SequenceFlow_0h6mn7j + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.preProcessRequest(execution) + + + + SequenceFlow_1iw5oad + SequenceFlow_1wclf50 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.sendCreateRequestNSSMF(execution) + + + SequenceFlow_0ib27f2 + SequenceFlow_1iw5oad + SequenceFlow_0haiyzv + + + SequenceFlow_0haiyzv + SequenceFlow_1ellzst + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.sendUpdateRequestNSSMF(execution) + + + SequenceFlow_1wclf50 + SequenceFlow_1ellzst + SequenceFlow_0ejdefw + + + #{(execution.getVariable("nssmfOperation" ) == "create")} + + + + #{(execution.getVariable("nssmfOperation" ) == "update")} + + + + + SequenceFlow_0h6mn7j + SequenceFlow_0ib27f2 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.getNSSTInfo(execution) + + + + + SequenceFlow_0ejdefw + SequenceFlow_0gpgxw4 + SequenceFlow_0p9gd2n + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.queryNSSIStatus(execution) + + + SequenceFlow_0p9gd2n + SequenceFlow_1ozi7ed + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.prepareUpdateOrchestrationTask(execution) + + + + + + + + + + + + + + SequenceFlow_1ozi7ed + SequenceFlow_0hgv9c5 + + + + + SequenceFlow_0hgv9c5 + SequenceFlow_0y5jr25 + SequenceFlow_170frn3 + + + + SequenceFlow_0y5jr25 + SequenceFlow_0gpgxw4 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcnssi = new DoAllocateNSSI() +dcnssi.timeDelay(execution) + + + + + #{(execution.getVariable("nssmfOperation" ) == "update")} + + + SequenceFlow_170frn3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn new file mode 100644 index 0000000000..5d9e53ac18 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/subprocess/DoCreateSliceServiceOptionV2.bpmn @@ -0,0 +1,563 @@ + + + + + SequenceFlow_17otbuu + SequenceFlow_00t0340 + SequenceFlow_06uu0eh + SequenceFlow_09see8v + SequenceFlow_14s7fck + SequenceFlow_1c374y2 + + + SequenceFlow_04avf98 + SequenceFlow_00xa5wa + SequenceFlow_064p1n6 + SequenceFlow_1a699ly + + + SequenceFlow_16qt6r2 + SequenceFlow_175xozh + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preNSIRequest(execution) + + + SequenceFlow_09see8v + SequenceFlow_04avf98 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.queryTNSubnetCapability(execution) + + + SequenceFlow_14s7fck + SequenceFlow_00xa5wa + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.queryCNSubnetCapability(execution) + + + SequenceFlow_1c374y2 + SequenceFlow_064p1n6 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.queryANSubnetCapability(execution) + + + + + + + SequenceFlow_00t0340 + SequenceFlow_1kzy63m + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareDecomposeNST(execution) + + + + + + + + + + + SequenceFlow_1kzy63m + SequenceFlow_1t317y2 + + + SequenceFlow_1t317y2 + SequenceFlow_1rwl882 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processDecomposition(execution) + + + SequenceFlow_06uu0eh + SequenceFlow_1dtfpqp + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.prepareNSTDecompose(execution) + + + + + + + + + + + SequenceFlow_1dtfpqp + SequenceFlow_0fdqj9b + + + SequenceFlow_0fdqj9b + SequenceFlow_0d2lpv3 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processDecomposition(execution) + + + + + + + + + + + + + + + + + + SequenceFlow_175xozh + SequenceFlow_188g03z + + + + SequenceFlow_188g03z + SequenceFlow_17emrud + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.processNSIResp(execution) + + + + + SequenceFlow_1sg6mqd + + + + SequenceFlow_1sg6mqd + SequenceFlow_05250mp + SequenceFlow_0euwvgf + SequenceFlow_0il5j01 + + + SequenceFlow_14rhmx9 + SequenceFlow_103oxyw + SequenceFlow_0aasemn + SequenceFlow_1tr3i9d + + + + + + + + + + + + SequenceFlow_0abqxa1 + SequenceFlow_1tqg26p + + + + + + + + + + + + + SequenceFlow_17emrud + + + + SequenceFlow_1nrfy6i + + + SequenceFlow_1rwl882 + SequenceFlow_0d2lpv3 + SequenceFlow_06t1dq5 + SequenceFlow_16qt6r2 + + + + SequenceFlow_1fuwy35 + + + SequenceFlow_1fuwy35 + SequenceFlow_17otbuu + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preProcessRequest(execution) + + + + + + + + + + SequenceFlow_05250mp + SequenceFlow_14rhmx9 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSISelectionCap4TN(execution) + + + SequenceFlow_0euwvgf + SequenceFlow_103oxyw + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSISelectionCap4CN(execution) + + + SequenceFlow_0il5j01 + SequenceFlow_0aasemn + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.getNSSISelectionCap4AN(execution) + + + + SequenceFlow_1a699ly + SequenceFlow_06t1dq5 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.handleSubnetCapabilityResp(execution) + + + SequenceFlow_126j77n + SequenceFlow_0abqxa1 + import org.onap.so.bpmn.infrastructure.scripts.* +def dcso = new DoCreateSliceServiceOption() +dcso.preNSSIRequest(execution) + + + SequenceFlow_1tqg26p + SequenceFlow_1i3j8c3 + 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) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java new file mode 100644 index 0000000000..dd1292e7e5 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskInfo.java @@ -0,0 +1,33 @@ +package org.onap.so.beans.nsmf; + +import lombok.Data; +import org.onap.so.beans.nsmf.oof.TemplateInfo; +import java.io.Serializable; + +@Data +public class SliceTaskInfo implements Serializable { + private static final long serialVersionUID = 7580056468353975320L; + + private String suggestNssiId; + + private String suggestNssiName; + + private String progress; + + private String status; + + private String statusDescription; + + private T sliceProfile; + + private TemplateInfo NSSTInfo; + + private String serviceInstanceId; + + private String scriptName; + + private String vendor; + + private NetworkType networkType; + +} 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 new file mode 100644 index 0000000000..cab209ebd1 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/SliceTaskParamsAdapter.java @@ -0,0 +1,36 @@ +package org.onap.so.beans.nsmf; + +import lombok.Data; +import org.onap.so.beans.nsmf.oof.TemplateInfo; + + +@Data +public class SliceTaskParamsAdapter { + private static final long serialVersionUID = -7785578865170503301L; + + private String serviceId; + + private String serviceName; + + private String nstId; + + private String nstName; + + private ServiceProfile serviceProfile; + + private String suggestNsiId; + + private String suggestNsiName; + + private TemplateInfo NSTInfo; + + private SliceTaskInfo tnBHSliceTaskInfo; + + private SliceTaskInfo tnMHSliceTaskInfo; + + private SliceTaskInfo tnFHSliceTaskInfo; + + private SliceTaskInfo cnSliceTaskInfo; + + private SliceTaskInfo anSliceTaskInfo; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java index c3548f15af..be530bfb9c 100644 --- a/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java +++ b/common/src/main/java/org/onap/so/beans/nsmf/TnSliceProfile.java @@ -25,11 +25,21 @@ import com.fasterxml.jackson.annotation.JsonInclude; @JsonInclude(JsonInclude.Include.NON_NULL) public class TnSliceProfile { + private String sliceProfileId; + private String bandwidth; @JsonInclude(JsonInclude.Include.NON_DEFAULT) private int latency; + public String getSliceProfileId() { + return sliceProfileId; + } + + public void setSliceProfileId(String sliceProfileId) { + this.sliceProfileId = sliceProfileId; + } + public String getBandwidth() { return bandwidth; } diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java new file mode 100644 index 0000000000..4af60cf492 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/DomainType.java @@ -0,0 +1,27 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Getter; +import org.onap.so.beans.nsmf.NetworkType; + +@Getter +public enum DomainType { + + AN_NF("AN-NF", NetworkType.ACCESS), + + CN("CN", NetworkType.CORE), + + TN_FH("TN-FH", NetworkType.TRANSPORT), + + TN_MH("TN-MH", NetworkType.TRANSPORT), + + TN_BH("TN-BH", NetworkType.TRANSPORT),; + + private NetworkType networkType; + + private String domainType; + + DomainType(String domainType, NetworkType networkType) { + this.domainType = domainType; + this.networkType = networkType; + } +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java new file mode 100644 index 0000000000..e1829eb2c3 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/NsiReqBody.java @@ -0,0 +1,23 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import org.onap.so.beans.nsmf.ServiceProfile; +import java.io.Serializable; +import java.util.List; + +@Data +public class NsiReqBody implements Serializable { + private static final long serialVersionUID = -1383112063216226985L; + + private ServiceProfile serviceProfile; + + private RequestInfo requestInfo; + + private TemplateInfo NSTInfo; + + private List NSSTInfo; + + private Boolean preferReuse; + + private List subnetCapabilities; +} 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 new file mode 100644 index 0000000000..0632ab78e9 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/NssiReqBody.java @@ -0,0 +1,17 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import org.onap.so.beans.nsmf.ServiceProfile; +import java.io.Serializable; + +@Data +public class NssiReqBody implements Serializable { + + private static final long serialVersionUID = -76327522074333341L; + + private ServiceProfile serviceProfile; + + private RequestInfo requestInfo; + + private TemplateInfo NSSTInfo; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java new file mode 100644 index 0000000000..f900c3599d --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/RequestInfo.java @@ -0,0 +1,27 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@Data +public class RequestInfo implements Serializable { + + private static final long serialVersionUID = -875589918188540922L; + + private String transactionId; + + private String requestId; + + private String callbackUrl; + + private Map callbackHeader; + + private String sourceId; + + private Integer numSolutions; + + private Integer timeout; + + private Map addtnlArgs; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java new file mode 100644 index 0000000000..f21c1c379e --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/SubnetCapability.java @@ -0,0 +1,15 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import java.io.Serializable; +import java.util.Map; + +@Data +public class SubnetCapability implements Serializable { + + private static final long serialVersionUID = -7671021271451538821L; + + private String domainType; + + private Map capabilityDetails; +} diff --git a/common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java b/common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java new file mode 100644 index 0000000000..3713bc7186 --- /dev/null +++ b/common/src/main/java/org/onap/so/beans/nsmf/oof/TemplateInfo.java @@ -0,0 +1,17 @@ +package org.onap.so.beans.nsmf.oof; + +import lombok.Data; +import java.io.Serializable; + + +@Data +public class TemplateInfo implements Serializable { + + private static final long serialVersionUID = 4237411651259839093L; + + private String UUID; + + private String invariantUUID; + + private String name; +} -- cgit 1.2.3-korg