diff options
author | Dan Timoney <dtimoney@att.com> | 2020-08-19 18:53:54 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-08-19 18:53:54 +0000 |
commit | ee32e9add9e3daf0360dd12e0219f234041dfb93 (patch) | |
tree | 4f28f7f3dae0688ccc873095cc617d02c0fb90a5 /sdnr/northbound/ranSlice/provider/src | |
parent | 6e164bc0f1f6688714033e95731942a89f5f1868 (diff) | |
parent | 94bf6cb9d8a780b38b860acab89d32e50ce16391 (diff) |
Merge "RAN Slice YANG Model and Associated Feature code"
Diffstat (limited to 'sdnr/northbound/ranSlice/provider/src')
21 files changed, 1526 insertions, 0 deletions
diff --git a/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceClient.java b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceClient.java new file mode 100644 index 000000000..f3d2a7da7 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceClient.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * Modifications Copyright © 2018 IBM. + * ================================================================================ + * 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.ccsdk.features.sdnr.northbound.ranSlice; + + +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RANSliceClient { + + private static final Logger LOG = LoggerFactory.getLogger(RANSliceClient.class); + + private final SvcLogicService svcLogicService; + + private String ErrorCode = "error-code"; + + public RANSliceClient(final SvcLogicService svcLogicService) { + this.svcLogicService = svcLogicService; + } + + public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException + { + return svcLogicService.hasGraph(module, rpc, version, mode); + } + + + public Properties execute(String module, String rpc, String version, String mode, Properties parms, DOMDataBroker dataBroker) + throws SvcLogicException { + + + if (LOG.isDebugEnabled()) + { + LOG.debug("Parameters passed to SLI"); + + for (Object key : parms.keySet()) { + String parmName = (String) key; + String parmValue = parms.getProperty(parmName); + + LOG.debug(parmName+" = "+parmValue); + + } + } + + Properties respProps = svcLogicService.execute(module, rpc, version, mode, parms, dataBroker); + + if (LOG.isDebugEnabled()) + { + LOG.debug("Parameters returned by SLI"); + + for (Object key : respProps.keySet()) { + String parmName = (String) key; + String parmValue = respProps.getProperty(parmName); + + LOG.debug(parmName+" = "+parmValue); + + } + } + + if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) { + + if (!respProps.containsKey(ErrorCode)) { + respProps.setProperty(ErrorCode, "500"); + } + } else { + if (!respProps.containsKey(ErrorCode)) { + respProps.setProperty(ErrorCode, "200"); + } + } + + + return respProps; + } + +} diff --git a/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProvider.java b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProvider.java new file mode 100644 index 000000000..a88595bfb --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProvider.java @@ -0,0 +1,480 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights + * reserved. + * Modifications Copyright © 2018 IBM. + * ================================================================================ + * 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.ccsdk.features.sdnr.northbound.ranSlice; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.md.sal.binding.impl.AbstractForwardedDataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.*; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeaderBuilder; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.status.StatusBuilder; +import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; + +import org.onap.ccsdk.features.sdnr.northbound.ranSlice.RANSliceResponseCode.*; + +/** + * Defines a base implementation for your provider. This class extends from a + * helper class which provides storage for the most commonly used components of + * the MD-SAL. Additionally the base class provides some basic logging and + * initialization / clean up methods. + * + */ +public class RANSliceProvider implements AutoCloseable, RanSliceApiService { + + private class CommonRANSliceFields { + private StatusBuilder statusBuilder; + private CommonHeaderBuilder commonHeaderBuilder; + private Payload payload; + + public CommonRANSliceFields(StatusBuilder statusBuilder, CommonHeaderBuilder commonHeaderBuilder) { + this.statusBuilder = statusBuilder; + this.commonHeaderBuilder = commonHeaderBuilder; + this.payload = null; + } + + public CommonRANSliceFields(StatusBuilder statusBuilder, CommonHeaderBuilder commonHeaderBuilder, Payload payload) { + this.statusBuilder = statusBuilder; + this.commonHeaderBuilder = commonHeaderBuilder; + this.payload = payload; + } + + public StatusBuilder getStatusBuilder() { + return statusBuilder; + } + + public CommonHeaderBuilder getCommonHeaderBuilder() { + return commonHeaderBuilder; + } + + public Payload getPayload() { + return payload; + } + } + + private static final Logger LOG = LoggerFactory.getLogger(RANSliceProvider.class); + + private static final String exceptionMessage = "Caught exception"; + + private static final String APPLICATION_NAME = "RANSlice"; + + private final ExecutorService executor; + protected DataBroker dataBroker; + protected DOMDataBroker domDataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + private final RANSliceClient RANSliceClient; + + protected BindingAwareBroker.RpcRegistration<RanSliceApiService> rpcRegistration; + + public RANSliceProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService, + final RpcProviderRegistry rpcProviderRegistry, final RANSliceClient rANSliceClient) { + + LOG.info("Creating provider for {}", APPLICATION_NAME); + executor = Executors.newFixedThreadPool(1); + this.dataBroker = dataBroker; + if (dataBroker instanceof AbstractForwardedDataBroker) { + domDataBroker = ((AbstractForwardedDataBroker) dataBroker).getDelegate(); + } + notificationService = notificationPublishService; + rpcRegistry = rpcProviderRegistry; + this.RANSliceClient = rANSliceClient; + initialize(); + } + + public void initialize() { + LOG.info("Initializing {} for {}", this.getClass().getName(), APPLICATION_NAME); + + if (rpcRegistration == null) { + if (rpcRegistry != null) { + rpcRegistration = rpcRegistry.addRpcImplementation(RanSliceApiService.class, this); + LOG.info("Initialization complete for {}", APPLICATION_NAME); + } else { + LOG.warn("Error initializing {} : rpcRegistry unset", APPLICATION_NAME); + } + } + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + LOG.info("Closing provider for " + APPLICATION_NAME); + executor.shutdown(); + rpcRegistration.close(); + LOG.info("Successfully closed provider for " + APPLICATION_NAME); + } + + +//RPC configureNearRTRIC + + @Override + public ListenableFuture<RpcResult<ConfigureNearRTRICOutput>> configureNearRTRIC(ConfigureNearRTRICInput input) { + ConfigureNearRTRICInputBuilder iBuilder = new ConfigureNearRTRICInputBuilder(input); + ConfigureNearRTRICOutputBuilder oBuilder = new ConfigureNearRTRICOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("configureNearRTRIC", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<ConfigureNearRTRICOutput> rpcResult = + RpcResultBuilder.<ConfigureNearRTRICOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC instantiateRANSlice + + @Override + public ListenableFuture<RpcResult<InstantiateRANSliceOutput>> instantiateRANSlice(InstantiateRANSliceInput input) { + InstantiateRANSliceInputBuilder iBuilder = new InstantiateRANSliceInputBuilder(input); + InstantiateRANSliceOutputBuilder oBuilder = new InstantiateRANSliceOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("instantiateRANSlice", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<InstantiateRANSliceOutput> rpcResult = + RpcResultBuilder.<InstantiateRANSliceOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + + + //RPC configureRANSliceInstance + + @Override + public ListenableFuture<RpcResult<ConfigureRANSliceInstanceOutput>> configureRANSliceInstance(ConfigureRANSliceInstanceInput input) { + ConfigureRANSliceInstanceInputBuilder iBuilder = new ConfigureRANSliceInstanceInputBuilder(input); + ConfigureRANSliceInstanceOutputBuilder oBuilder = new ConfigureRANSliceInstanceOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("configureRANSliceInstance", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<ConfigureRANSliceInstanceOutput> rpcResult = + RpcResultBuilder.<ConfigureRANSliceInstanceOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC configureCU + + @Override + public ListenableFuture<RpcResult<ConfigureCUOutput>> configureCU(ConfigureCUInput input) { + ConfigureCUInputBuilder iBuilder = new ConfigureCUInputBuilder(input); + ConfigureCUOutputBuilder oBuilder = new ConfigureCUOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("configureCU", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<ConfigureCUOutput> rpcResult = + RpcResultBuilder.<ConfigureCUOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC configureDU + + @Override + public ListenableFuture<RpcResult<ConfigureDUOutput>> configureDU(ConfigureDUInput input) { + ConfigureDUInputBuilder iBuilder = new ConfigureDUInputBuilder(input); + ConfigureDUOutputBuilder oBuilder = new ConfigureDUOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("configureDU", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<ConfigureDUOutput> rpcResult = + RpcResultBuilder.<ConfigureDUOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC activateRANSliceInstance + + @Override + public ListenableFuture<RpcResult<ActivateRANSliceInstanceOutput>> activateRANSliceInstance(ActivateRANSliceInstanceInput input) { + ActivateRANSliceInstanceInputBuilder iBuilder = new ActivateRANSliceInstanceInputBuilder(input); + ActivateRANSliceInstanceOutputBuilder oBuilder = new ActivateRANSliceInstanceOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("activateRANSliceInstance", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<ActivateRANSliceInstanceOutput> rpcResult = + RpcResultBuilder.<ActivateRANSliceInstanceOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + + //RPC deactivateRANSliceInstance + + @Override + public ListenableFuture<RpcResult<DeactivateRANSliceInstanceOutput>> deactivateRANSliceInstance(DeactivateRANSliceInstanceInput input) { + DeactivateRANSliceInstanceInputBuilder iBuilder = new DeactivateRANSliceInstanceInputBuilder(input); + DeactivateRANSliceInstanceOutputBuilder oBuilder = new DeactivateRANSliceInstanceOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("deactivateRANSliceInstance", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<DeactivateRANSliceInstanceOutput> rpcResult = + RpcResultBuilder.<DeactivateRANSliceInstanceOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC terminateRANSliceInstance + + @Override + public ListenableFuture<RpcResult<TerminateRANSliceInstanceOutput>> terminateRANSliceInstance(TerminateRANSliceInstanceInput input) { + TerminateRANSliceInstanceInputBuilder iBuilder = new TerminateRANSliceInstanceInputBuilder(input); + TerminateRANSliceInstanceOutputBuilder oBuilder = new TerminateRANSliceInstanceOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("terminateRANSliceInstance", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<TerminateRANSliceInstanceOutput> rpcResult = + RpcResultBuilder.<TerminateRANSliceInstanceOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC determineRANSliceResources + + @Override + public ListenableFuture<RpcResult<DetermineRANSliceResourcesOutput>> determineRANSliceResources(DetermineRANSliceResourcesInput input) { + DetermineRANSliceResourcesInputBuilder iBuilder = new DetermineRANSliceResourcesInputBuilder(input); + DetermineRANSliceResourcesOutputBuilder oBuilder = new DetermineRANSliceResourcesOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("determineRANSliceResources", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<DetermineRANSliceResourcesOutput> rpcResult = + RpcResultBuilder.<DetermineRANSliceResourcesOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + //RPC cm-notify + + @Override + public ListenableFuture<RpcResult<ConfigNotificationOutput>> configNotification(ConfigNotificationInput input) { + + ConfigNotificationInputBuilder iBuilder = new ConfigNotificationInputBuilder(input); + ConfigNotificationOutputBuilder oBuilder = new ConfigNotificationOutputBuilder(); + + try { + CommonRANSliceFields retval = callDG("configNotification", iBuilder.build()); + oBuilder.setStatus(retval.getStatusBuilder().build()); + oBuilder.setCommonHeader(retval.getCommonHeaderBuilder().build()); + } catch (RANSliceRpcInvocationException e) { + LOG.debug(exceptionMessage, e); + oBuilder.setCommonHeader(e.getCommonHeader()); + oBuilder.setStatus(e.getStatus()); + } + + RpcResult<ConfigNotificationOutput> rpcResult = + RpcResultBuilder.<ConfigNotificationOutput> status(true).withResult(oBuilder.build()).build(); + // return error + return Futures.immediateFuture(rpcResult); + + } + + + private CommonRANSliceFields callDG(String rpcName, Object input) throws RANSliceRpcInvocationException { + + StatusBuilder statusBuilder = new StatusBuilder(); + + if (input == null) { + LOG.debug("Rejecting " +rpcName+ " because of invalid input"); + statusBuilder.setCode(RANSliceResponseCode.REJECT_INVALID_INPUT.getValue()); + statusBuilder.setMessage("REJECT - INVALID INPUT. Missing input"); + CommonHeaderBuilder hBuilder = new CommonHeaderBuilder(); + hBuilder.setApiVer("1"); + hBuilder.setOriginatorId("unknown"); + hBuilder.setRequestId("unset"); + hBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + throw new RANSliceRpcInvocationException(statusBuilder.build(), hBuilder.build()); + } + + CommonHeaderBuilder hBuilder = new CommonHeaderBuilder(((CommonHeader)input).getCommonHeader()); + + // add input to parms + LOG.info("Adding INPUT data for "+ rpcName +" input: " + input.toString()); + Properties inputProps = new Properties(); + MdsalHelper.toProperties(inputProps, input); + + LOG.info("Printing SLI parameters to be passed"); + + // iterate properties file to get key-value pairs + for (String key : inputProps.stringPropertyNames()) { + String value = inputProps.getProperty(key); + LOG.info("The SLI parameter in " + key + " is: " + value); + } + + Properties respProps = new Properties(); + + // Call SLI sync method + try + { + if (RANSliceClient.hasGraph("ran-slice-api", rpcName , null, "sync")) + { + try + { + respProps = RANSliceClient.execute("ran-slice-api", rpcName, null, "sync", inputProps, domDataBroker); + } + catch (Exception e) + { + LOG.error("Caught exception executing service logic for "+ rpcName, e); + statusBuilder.setCode(RANSliceResponseCode.FAILURE_DG_FAILURE.getValue()); + statusBuilder.setMessage("FAILURE - DG FAILURE ("+e.getMessage()+")"); + throw new RANSliceRpcInvocationException(statusBuilder.build(), hBuilder.build()); + } + } else { + LOG.error("No service logic active for RANSlice: '" + rpcName + "'"); + + statusBuilder.setCode(RANSliceResponseCode.REJECT_DG_NOT_FOUND.getValue()); + statusBuilder.setMessage("FAILURE - DG not found for action "+rpcName); + throw new RANSliceRpcInvocationException(statusBuilder.build(), hBuilder.build()); + } + } + catch (Exception e) + { + LOG.error("Caught exception looking for service logic", e); + + statusBuilder.setCode(RANSliceResponseCode.FAILURE_DG_FAILURE.getValue()); + statusBuilder.setMessage("FAILURE - Unexpected error looking for DG ("+e.getMessage()+")"); + throw new RANSliceRpcInvocationException(statusBuilder.build(), hBuilder.build()); + } + + + StatusBuilder sBuilder = new StatusBuilder(); + MdsalHelper.toBuilder(respProps, sBuilder); + MdsalHelper.toBuilder(respProps, hBuilder); + + Payload payload = null; + String payloadValue = respProps.getProperty("payload"); + if (payloadValue != null) { + payload = new Payload(payloadValue); + } + + String statusCode = sBuilder.getCode().toString(); + + if (!"400".equals(statusCode)) { + LOG.error("Returned FAILED for "+rpcName+" error code: '" + statusCode + "'"); + } else { + LOG.info("Returned SUCCESS for "+rpcName+" "); + } + + return new CommonRANSliceFields(sBuilder, hBuilder, payload); + + } + +} diff --git a/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceResponseCode.java b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceResponseCode.java new file mode 100644 index 000000000..814b27e64 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceResponseCode.java @@ -0,0 +1,51 @@ +package org.onap.ccsdk.features.sdnr.northbound.ranSlice; + +public enum RANSliceResponseCode { + + // Accepted category + ACCEPT_ACCEPTED(100), + // Error category + ERROR_UNEXPECTED_ERROR(200), + // Rejected category + REJECT_REJECTED(300), + REJECT_INVALID_INPUT(301), + REJECT_MISSING_PARAM(302), + REJECT_PARSING_FAILED(303), + REJECT_NO_TRANSITION(304), + REJECT_ACTION_NOT_SUPPORTED(305), + REJECT_VNF_NOT_FOUND(306), + REJECT_DG_NOT_FOUND(307), + REJECT_WORKFLOW_NOT_FOUND(308), + REJECT_UNSTABLE_VNF(309), + REJECT_LOCKING_FAILURE(310), + REJECT_EXPIRED_REQUEST(311), + REJECT_DUPLICATE_REQUEST(312), + REJECT_MISSING_AAI_DATA(313), + REJECT_MULTIPLE_REQUESTS_FOR_SEARCH(315), + REJECT_POLICY_VALIDATION_FAILURE(316), + // Success category + SUCCESS(400), + // Failure category + FAILURE_DG_FAILURE(401), + FAILURE_NO_TRANSITION(402), + FAILURE_AAI_FAILURE(403), + FAILURE_EXPIRED_REQUEST(404), + FAILURE_UNEXPECTED_FAILURE(405), + FAILURE_UNSTABLE_VNF(406), + FAILURE_REQUEST_NOT_SUPPORTED(450), + // Partial success + PARTIAL_SUCCESS(500); + + + + private int value; + private RANSliceResponseCode(int value) { + this.value = value; + } + + public int getValue() { + return value; + } + + +} diff --git a/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceRpcInvocationException.java b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceRpcInvocationException.java new file mode 100644 index 000000000..18b66312d --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceRpcInvocationException.java @@ -0,0 +1,25 @@ +package org.onap.ccsdk.features.sdnr.northbound.ranSlice; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeader; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.status.Status; + +public class RANSliceRpcInvocationException extends SvcLogicException { + + private Status status; + private CommonHeader commonHeader; + + public RANSliceRpcInvocationException(Status status, CommonHeader commonHeader) { + this.status = status; + this.commonHeader = commonHeader; + } + + public Status getStatus() { + return status; + } + + public CommonHeader getCommonHeader() { + return commonHeader; + } + +} diff --git a/sdnr/northbound/ranSlice/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/sdnr/northbound/ranSlice/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml new file mode 100644 index 000000000..57ebfbfcc --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ ============LICENSE_START======================================================= + ~ ONAP : ccsdk features + ~ ================================================================================ + ~ Copyright (C) 2020 AT&T Intellectual Property. 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======================================================= + ~ + --> + +<blueprint xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> + + <reference id="svcLogicService" + interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService"/> + + <bean id="client" class="org.onap.ccsdk.features.sdnr.northbound.ranSlice.RANSliceClient"> + <argument ref="svcLogicService"/> + </bean> + + <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" + odl:type="default"/> + + <reference id="notificationService" + interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService" + odl:type="default"/> + + <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" + odl:type="default"/> + + <bean id="provider" class="org.onap.ccsdk.features.sdnr.northbound.ranSlice.RANSliceProvider"> + <argument ref="dataBroker"/> + <argument ref="rpcRegistry"/> + <argument ref="notificationService"/> + <argument ref="client"/> + </bean> + + <odl:rpc-implementation ref="provider"/> + +</blueprint> diff --git a/sdnr/northbound/ranSlice/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/northbound/ranSlice/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml new file mode 100644 index 000000000..57ebfbfcc --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ ============LICENSE_START======================================================= + ~ ONAP : ccsdk features + ~ ================================================================================ + ~ Copyright (C) 2020 AT&T Intellectual Property. 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======================================================= + ~ + --> + +<blueprint xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" + xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" odl:use-default-for-reference-types="true"> + + <reference id="svcLogicService" + interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService"/> + + <bean id="client" class="org.onap.ccsdk.features.sdnr.northbound.ranSlice.RANSliceClient"> + <argument ref="svcLogicService"/> + </bean> + + <reference id="dataBroker" interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" + odl:type="default"/> + + <reference id="notificationService" + interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService" + odl:type="default"/> + + <reference id="rpcRegistry" interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" + odl:type="default"/> + + <bean id="provider" class="org.onap.ccsdk.features.sdnr.northbound.ranSlice.RANSliceProvider"> + <argument ref="dataBroker"/> + <argument ref="rpcRegistry"/> + <argument ref="notificationService"/> + <argument ref="client"/> + </bean> + + <odl:rpc-implementation ref="provider"/> + +</blueprint> diff --git a/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java new file mode 100644 index 000000000..f1e1524ec --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/RANSliceProviderTest.java @@ -0,0 +1,366 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.ccsdk.features.sdnr.northbound.ranSlice; + + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.io.InputStream; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Properties; +import java.util.concurrent.ExecutionException; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.onap.ccsdk.sli.core.sli.SvcLogicLoader; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicClassResolver; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicPropertiesProviderImpl; +import org.onap.ccsdk.sli.core.sli.provider.SvcLogicServiceImpl; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; +import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.*; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeaderBuilder; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class RANSliceProviderTest { + + Logger LOG = LoggerFactory.getLogger(RANSliceProvider.class); + private RANSliceProvider provider; + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + DataBroker dataBroker = mock(DataBroker.class); + NotificationPublishService notifyService = mock(NotificationPublishService.class); + RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class); + BindingAwareBroker.RpcRegistration<RanSliceApiService> rpcRegistration = (BindingAwareBroker.RpcRegistration<RanSliceApiService>) mock(BindingAwareBroker.RpcRegistration.class); + when(rpcRegistry.addRpcImplementation(any(Class.class), any(RanSliceApiService.class))).thenReturn(rpcRegistration); + + + // Load svclogic.properties and get a SvcLogicStore + InputStream propStr = RANSliceProviderTest.class.getResourceAsStream("/svclogic.properties"); + Properties svcprops = new Properties(); + svcprops.load(propStr); + + SvcLogicStore store = SvcLogicStoreFactory.getSvcLogicStore(svcprops); + + assertNotNull(store); + + URL graphUrl = RANSliceProviderTest.class.getClassLoader().getResource("graphs"); + LOG.info("Graph URL:" + graphUrl); + + + if (graphUrl == null) { + fail("Cannot find graphs directory"); + } + + SvcLogicLoader loader = new SvcLogicLoader(graphUrl.getPath(), store); + loader.loadAndActivate(); + + // Create a ServiceLogicService + SvcLogicServiceImpl svc = new SvcLogicServiceImpl(new SvcLogicPropertiesProviderImpl(), + new SvcLogicClassResolver()); + + // Finally ready to create sliapiProvider + RANSliceClient client = new RANSliceClient(svc); + provider = new RANSliceProvider(dataBroker, notifyService, rpcRegistry, client); + } + + /** + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + provider.close(); + } + + + @Test + public void testConfigureNearRTRIC() { + ConfigureNearRTRICInputBuilder builder = new ConfigureNearRTRICInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + ConfigureNearRTRICOutput results = provider.configureNearRTRIC(builder.build()).get().getResult(); + LOG.info("configureNearRTRIC returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("configureNearRTRIC threw exception"); + } + + } + + + @Test + public void testInstantiateRANSlice() { + InstantiateRANSliceInputBuilder builder = new InstantiateRANSliceInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + InstantiateRANSliceOutput results = provider.instantiateRANSlice(builder.build()).get().getResult(); + LOG.info("instantiateRANSlice returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("instantiateRANSlice threw exception"); + } + + } + + + @Test + public void testConfigureRANSliceInstance() { + ConfigureRANSliceInstanceInputBuilder builder = new ConfigureRANSliceInstanceInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + ConfigureRANSliceInstanceOutput results = provider.configureRANSliceInstance(builder.build()).get().getResult(); + LOG.info("configureRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("configureRANSliceInstance threw exception"); + } + + } + + @Test + public void testConfigureCU() { + ConfigureCUInputBuilder builder = new ConfigureCUInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + ConfigureCUOutput results = provider.configureCU(builder.build()).get().getResult(); + LOG.info("configureCU returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("configureCU threw exception"); + } + + } + + + @Test + public void testConfigureDU() { + ConfigureDUInputBuilder builder = new ConfigureDUInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + ConfigureDUOutput results = provider.configureDU(builder.build()).get().getResult(); + LOG.info("configureDU returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("configureDU threw exception"); + } + + } + + @Test + public void testActivateRANSliceInstance() { + ActivateRANSliceInstanceInputBuilder builder = new ActivateRANSliceInstanceInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + ActivateRANSliceInstanceOutput results = provider.activateRANSliceInstance(builder.build()).get().getResult(); + LOG.info("activateRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("activateRANSliceInstance threw exception"); + } + + } + + + @Test + public void testDeactivateRANSliceInstance() { + DeactivateRANSliceInstanceInputBuilder builder = new DeactivateRANSliceInstanceInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + DeactivateRANSliceInstanceOutput results = provider.deactivateRANSliceInstance(builder.build()).get().getResult(); + LOG.info("deactivateRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("deactivateRANSliceInstance threw exception"); + } + + } + + @Test + public void testTerminateRANSliceInstance() { + TerminateRANSliceInstanceInputBuilder builder = new TerminateRANSliceInstanceInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + TerminateRANSliceInstanceOutput results = provider.terminateRANSliceInstance(builder.build()).get().getResult(); + LOG.info("terminateRANSliceInstance returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("terminateRANSliceInstance threw exception"); + } + + } + + @Test + public void testDetermineRANSliceResources() { + DetermineRANSliceResourcesInputBuilder builder = new DetermineRANSliceResourcesInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + DetermineRANSliceResourcesOutput results = provider.determineRANSliceResources(builder.build()).get().getResult(); + LOG.info("determineRANSliceResources returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("determineRANSliceResources threw exception"); + } + + } + + + @Test + public void testConfigNotification() { + ConfigNotificationInputBuilder builder = new ConfigNotificationInputBuilder(); + + CommonHeaderBuilder hdrBuilder = new CommonHeaderBuilder(); + hdrBuilder.setApiVer("1"); + hdrBuilder.setFlags(null); + hdrBuilder.setOriginatorId("jUnit"); + hdrBuilder.setRequestId("123"); + hdrBuilder.setTimestamp(new ZULU(new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").format(new Date()))); + builder.setCommonHeader(hdrBuilder.build()); + + builder.setAction(Action.Reconfigure); + + try { + ConfigNotificationOutput results = provider.configNotification(builder.build()).get().getResult(); + LOG.info("configNotification returned status {} : {}", results.getStatus().getCode(), results.getStatus().getMessage()); + assert(results.getStatus().getCode() == 400); + } catch (InterruptedException | ExecutionException e) { + LOG.error("Caught exception", e); + fail("configNotification threw exception"); + } + + } + + + } diff --git a/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java new file mode 100644 index 000000000..4c32c22bf --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/ranSlice/TestRANSliceRpcInvocationException.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2020 Nordix Foundation. + * ================================================================================ + * 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. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + + +package org.onap.ccsdk.features.sdnr.northbound.ranSlice; + +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeader; +import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.status.Status; + + +public class TestRANSliceRpcInvocationException { + + @Test(expected = SvcLogicException.class) + public void testRANSliceRpcInvocationException() throws SvcLogicException{ + Status status = null; + CommonHeader commonHeader = null; + RANSliceRpcInvocationException exception = new RANSliceRpcInvocationException(status, commonHeader); + assert(exception.getStatus() == status); + assert(exception.getCommonHeader() == commonHeader); + throw exception; + } +} diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/graph.versions b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/graph.versions new file mode 100644 index 000000000..e9642a45f --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/graph.versions @@ -0,0 +1,10 @@ +ran-slice-api configureNearRTRIC 1.0.1 sync +ran-slice-api instantiateRANSlice 1.0.1 sync +ran-slice-api configureRANSliceInstance 1.0.1 sync +ran-slice-api configureCU 1.0.1 sync +ran-slice-api configureDU 1.0.1 sync +ran-slice-api activateRANSliceInstance 1.0.1 sync +ran-slice-api deactivateRANSliceInstance 1.0.1 sync +ran-slice-api terminateRANSliceInstance 1.0.1 sync +ran-slice-api determineRANSliceResources 1.0.1 sync +ran-slice-api configNotification 1.0.1 sync diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_activateRANSliceInstance.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_activateRANSliceInstance.xml new file mode 100644 index 000000000..b7ab247ba --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_activateRANSliceInstance.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='activateRANSliceInstance' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configNotification.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configNotification.xml new file mode 100644 index 000000000..bad05304c --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configNotification.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='configNotification' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureCU.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureCU.xml new file mode 100644 index 000000000..f1e52ea75 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureCU.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='configureCU' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureDU.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureDU.xml new file mode 100644 index 000000000..097376580 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureDU.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='configureDU' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureNearRTRIC.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureNearRTRIC.xml new file mode 100644 index 000000000..eadcf768a --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureNearRTRIC.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='configureNearRTRIC' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureRANSliceInstance.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureRANSliceInstance.xml new file mode 100644 index 000000000..08242f4b3 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_configureRANSliceInstance.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='configureRANSliceInstance' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_deactivateRANSliceInstance.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_deactivateRANSliceInstance.xml new file mode 100644 index 000000000..e7b5c00b9 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_deactivateRANSliceInstance.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='deactivateRANSliceInstance' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_determineRANSliceResources.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_determineRANSliceResources.xml new file mode 100644 index 000000000..7b7a69786 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_determineRANSliceResources.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='determineRANSliceResources' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_instantiateRANSlice.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_instantiateRANSlice.xml new file mode 100644 index 000000000..71f8655cc --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_instantiateRANSlice.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='instantiateRANSlice' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_terminateRANSliceInstance.xml b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_terminateRANSliceInstance.xml new file mode 100644 index 000000000..372f3ae0b --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/graphs/ranSlice/ran-slice-api_terminateRANSliceInstance.xml @@ -0,0 +1,30 @@ +<!-- + ============LICENSE_START======================================================= + openECOMP : SDN-C + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= + --> + +<service-logic xmlns="http://www.onap.org/sdnc/svclogic" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.onap.org/sdnc/svclogic ./svclogic.xsd" + module='ran-slice-api' version='1.0.1'> + <method rpc='terminateRANSliceInstance' mode='sync'> + <set> + <parameter name='status.code' value='400' /> + <parameter name='status.message' value='SUCCESS' /> + </set> + </method> +</service-logic> diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/simplelogger.properties b/sdnr/northbound/ranSlice/provider/src/test/resources/simplelogger.properties new file mode 100644 index 000000000..001dfd427 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/simplelogger.properties @@ -0,0 +1,22 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= +### + +org.slf4j.simpleLogger.defaultLogLevel=debug diff --git a/sdnr/northbound/ranSlice/provider/src/test/resources/svclogic.properties b/sdnr/northbound/ranSlice/provider/src/test/resources/svclogic.properties new file mode 100644 index 000000000..426960f76 --- /dev/null +++ b/sdnr/northbound/ranSlice/provider/src/test/resources/svclogic.properties @@ -0,0 +1,27 @@ +### +# ============LICENSE_START======================================================= +# ONAP : CCSDK +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. 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========================================================= +### + +org.onap.ccsdk.sli.dbtype = jdbc +org.onap.ccsdk.sli.jdbc.url=jdbc:derby:memory:sdnctl;create=true +org.onap.ccsdk.sli.jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver +org.onap.ccsdk.sli.jdbc.database = sdnctl +org.onap.ccsdk.sli.jdbc.user = test +org.onap.ccsdk.sli.jdbc.password = test |