From 2f9e781a7c3e22bf25df83dcc3ff44b885a80957 Mon Sep 17 00:00:00 2001 From: Ravi Pendurty Date: Wed, 3 Feb 2021 14:09:25 +0100 Subject: Adapt SDNR northbound to Aluminium Adapt SDNR northbound to Aluminium Issue-ID: CCSDK-3128 Signed-off-by: Ravi Pendurty Change-Id: Id2dc38d4f2573d5c6aeedfb42349433f22aa86f5 Signed-off-by: Ravi Pendurty --- sdnr/northbound/ranSlice/provider/pom.xml | 33 ++--------- .../sdnr/northbound/ranSlice/RANSliceClient.java | 2 +- .../sdnr/northbound/ranSlice/RANSliceProvider.java | 69 ++++++++++++---------- .../northbound/ranSlice/RANSliceResponseCode.java | 21 +++++++ .../ranSlice/RANSliceRpcInvocationException.java | 21 +++++++ .../OSGI-INF/blueprint/impl-blueprint.xml | 52 ---------------- .../org/opendaylight/blueprint/impl-blueprint.xml | 34 ++++++----- .../northbound/ranSlice/RANSliceProviderTest.java | 49 +++++++++------ 8 files changed, 138 insertions(+), 143 deletions(-) delete mode 100644 sdnr/northbound/ranSlice/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml (limited to 'sdnr/northbound/ranSlice/provider') diff --git a/sdnr/northbound/ranSlice/provider/pom.xml b/sdnr/northbound/ranSlice/provider/pom.xml index 03563b9cc..a4e068015 100644 --- a/sdnr/northbound/ranSlice/provider/pom.xml +++ b/sdnr/northbound/ranSlice/provider/pom.xml @@ -26,7 +26,7 @@ org.onap.ccsdk.parent binding-parent - 2.1.0 + 2.1.1-SNAPSHOT @@ -39,14 +39,7 @@ - - org.opendaylight.controller - mdsal-artifacts - 1.6.1 - pom - import - - + org.onap.ccsdk.sli.core sli-core-artifacts ${ccsdk.sli.core.version} @@ -61,27 +54,13 @@ ranSlice-model ${project.version} - - - org.opendaylight.controller - sal-binding-api - - - org.opendaylight.controller - sal-common-util - - org.opendaylight.controller - sal-core-api + org.opendaylight.mdsal + mdsal-binding-api - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.mdsal + mdsal-dom-api org.opendaylight.yangtools 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 index f3d2a7da7..0b1d8c512 100644 --- 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 @@ -27,7 +27,7 @@ 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.opendaylight.mdsal.dom.api.DOMDataBroker; import org.slf4j.Logger; import org.slf4j.LoggerFactory; 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 index a88595bfb..fbaab938c 100644 --- 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 @@ -27,17 +27,15 @@ 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.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; 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.concepts.ObjectRegistration; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -46,8 +44,6 @@ 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 @@ -97,43 +93,56 @@ public class RANSliceProvider implements AutoCloseable, RanSliceApiService { protected DataBroker dataBroker; protected DOMDataBroker domDataBroker; protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - private final RANSliceClient RANSliceClient; + protected RpcProviderService rpcProviderRegistry; + private RANSliceClient RANSliceClient; - protected BindingAwareBroker.RpcRegistration rpcRegistration; + private ObjectRegistration rpcRegistration; - public RANSliceProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService, - final RpcProviderRegistry rpcProviderRegistry, final RANSliceClient rANSliceClient) { + public RANSliceProvider() { LOG.info("Creating provider for {}", APPLICATION_NAME); executor = Executors.newFixedThreadPool(1); + this.dataBroker = null; + this.domDataBroker = null; + this.notificationService = null; + this.rpcProviderRegistry = null; + this.rpcRegistration = null; + this.RANSliceClient = null; + } + + public void setDataBroker(DataBroker dataBroker) { 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); + public void setDomDataBroker(DOMDataBroker domDataBroker) { + this.domDataBroker = domDataBroker; + } + + public void setRpcProviderRegistry(RpcProviderService rpcProviderRegistry) { + this.rpcProviderRegistry = rpcProviderRegistry; + } + public void setNotificationPublishService(NotificationPublishService notificationPublishService) { + this.notificationService = notificationPublishService; + } + + public void setClient(RANSliceClient client) { + this.RANSliceClient = client; + } + + public void init() { + LOG.info("Initializing {} for {}", this.getClass().getName(), APPLICATION_NAME); + if (rpcRegistration == null) { - if (rpcRegistry != null) { - rpcRegistration = rpcRegistry.addRpcImplementation(RanSliceApiService.class, this); + if (rpcProviderRegistry != null) { + rpcRegistration = rpcProviderRegistry.registerRpcImplementation(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); 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 index 814b27e64..77c09d172 100644 --- 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 @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * 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========================================================= + */ + package org.onap.ccsdk.features.sdnr.northbound.ranSlice; public enum RANSliceResponseCode { 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 index 18b66312d..3e6fcb4ce 100644 --- 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 @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * openECOMP : SDN-C + * ================================================================================ + * 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========================================================= + */ + package org.onap.ccsdk.features.sdnr.northbound.ranSlice; import org.onap.ccsdk.sli.core.sli.SvcLogicException; 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 deleted file mode 100644 index 57ebfbfcc..000000000 --- a/sdnr/northbound/ranSlice/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - 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 index 57ebfbfcc..896c0575a 100644 --- 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 @@ -30,21 +30,25 @@ - - - - - - - - - - - + + + + + + + + + + + + + + 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 index f1e1524ec..4bd3e5049 100644 --- 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 @@ -42,13 +42,17 @@ 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.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; +import org.opendaylight.mdsal.dom.api.DOMDataBroker; +/*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.*; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev200806.common.header.CommonHeaderBuilder; - +import org.opendaylight.yangtools.concepts.ObjectRegistration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -63,10 +67,12 @@ public class RANSliceProviderTest { @Before public void setUp() throws Exception { DataBroker dataBroker = mock(DataBroker.class); + DOMDataBroker domDataBroker = mock(DOMDataBroker.class); NotificationPublishService notifyService = mock(NotificationPublishService.class); - RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class); - BindingAwareBroker.RpcRegistration rpcRegistration = (BindingAwareBroker.RpcRegistration) mock(BindingAwareBroker.RpcRegistration.class); - when(rpcRegistry.addRpcImplementation(any(Class.class), any(RanSliceApiService.class))).thenReturn(rpcRegistration); + //RpcProviderRegistry rpcRegistry = mock(RpcProviderRegistry.class); + RpcProviderService rpcRegistry = mock(RpcProviderService.class); + ObjectRegistration rpcRegistration = mock(ObjectRegistration.class); + when(rpcRegistry.registerRpcImplementation(any(Class.class), any(RanSliceApiService.class))).thenReturn(rpcRegistration); // Load svclogic.properties and get a SvcLogicStore @@ -95,7 +101,14 @@ public class RANSliceProviderTest { // Finally ready to create sliapiProvider RANSliceClient client = new RANSliceClient(svc); - provider = new RANSliceProvider(dataBroker, notifyService, rpcRegistry, client); + provider = new RANSliceProvider(); + provider.setDataBroker(dataBroker); + provider.setDomDataBroker(domDataBroker); + provider.setNotificationPublishService(notifyService); + provider.setClient(client); + provider.init(); + + } /** @@ -103,7 +116,7 @@ public class RANSliceProviderTest { */ @After public void tearDown() throws Exception { - provider.close(); + //provider.close(); } @@ -124,7 +137,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("configureNearRTRIC threw exception"); @@ -150,7 +163,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("instantiateRANSlice threw exception"); @@ -176,7 +189,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("configureRANSliceInstance threw exception"); @@ -201,7 +214,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("configureCU threw exception"); @@ -227,7 +240,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("configureDU threw exception"); @@ -252,7 +265,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("activateRANSliceInstance threw exception"); @@ -278,7 +291,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("deactivateRANSliceInstance threw exception"); @@ -303,7 +316,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("terminateRANSliceInstance threw exception"); @@ -328,7 +341,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("determineRANSliceResources threw exception"); @@ -354,7 +367,7 @@ public class RANSliceProviderTest { 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); + assert(results.getStatus().getCode().intValue() == 400); } catch (InterruptedException | ExecutionException e) { LOG.error("Caught exception", e); fail("configNotification threw exception"); -- cgit 1.2.3-korg