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 --- .../northbound/oofpcipoc/OofpcipocProvider.java | 720 ++++++++++----------- .../OSGI-INF/blueprint/impl-blueprint.xml | 50 -- .../org/opendaylight/blueprint/impl-blueprint.xml | 90 ++- .../sdnr/northbound/oofpcipoc/TestOofpcipoc.java | 27 +- 4 files changed, 398 insertions(+), 489 deletions(-) delete mode 100644 sdnr/northbound/oofpcipoc/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml (limited to 'sdnr/northbound/oofpcipoc/provider/src') diff --git a/sdnr/northbound/oofpcipoc/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/OofpcipocProvider.java b/sdnr/northbound/oofpcipoc/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/OofpcipocProvider.java index f0749fbee..6bfa74eea 100644 --- a/sdnr/northbound/oofpcipoc/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/OofpcipocProvider.java +++ b/sdnr/northbound/oofpcipoc/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/OofpcipocProvider.java @@ -19,131 +19,127 @@ * ============LICENSE_END========================================================= */ - package org.onap.ccsdk.features.sdnr.northbound.oofpcipoc; +package org.onap.ccsdk.features.sdnr.northbound.oofpcipoc; import java.util.Properties; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; 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.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.NotificationProviderService; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.*; - -import com.google.common.base.Preconditions; +import org.opendaylight.yangtools.concepts.ObjectRegistration; 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.base.Preconditions; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; /** - * 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. + * 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 OofpcipocProvider implements AutoCloseable, OofpcipocApiService { - private static final Logger LOG = LoggerFactory.getLogger(OofpcipocProvider.class); + private static final Logger LOG = LoggerFactory.getLogger(OofpcipocProvider.class); + + private static final String APPLICATION_NAME = "oofpcipoc-api"; - private static final String APPLICATION_NAME = "oofpcipoc-api"; + private final ExecutorService executor; - private final ExecutorService executor; + private DataBroker dataBroker; + private NotificationPublishService notificationService; + private RpcProviderService rpcProviderService; + private ObjectRegistration rpcRegistration; + private OofpcipocClient OofpcipocClient; - protected DataBroker dataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - protected BindingAwareBroker.RpcRegistration rpcRegistration; - private final OofpcipocClient OofpcipocClient; + public OofpcipocProvider() { + LOG.info("Creating provider for {}", APPLICATION_NAME); + executor = Executors.newFixedThreadPool(1); + this.dataBroker = null; + this.notificationService = null; + this.rpcProviderService = null; + this.OofpcipocClient = null; + } + + public void setDataBroker(DataBroker dataBroker) { + this.dataBroker = dataBroker; + } - public OofpcipocProvider(final DataBroker dataBroker, - final NotificationPublishService notificationPublishService, - final RpcProviderRegistry rpcProviderRegistry, - final OofpcipocClient OofpcipocClient) { + public void setRpcProviderService(RpcProviderService rpcProviderRegistry) { + this.rpcProviderService = rpcProviderRegistry; + } - this.LOG.info( "Creating provider for {}", APPLICATION_NAME); - executor = Executors.newFixedThreadPool(1); - this.dataBroker = dataBroker; - this.notificationService = notificationPublishService; - this.rpcRegistry = rpcProviderRegistry; - this.OofpcipocClient = OofpcipocClient; - initialize(); - } + public void setNotificationPublishService(NotificationPublishService notificationPublishService) { + this.notificationService = notificationPublishService; + } - public void initialize(){ - LOG.info( "Initializing provider for {}", APPLICATION_NAME); - rpcRegistration = rpcRegistry.addRpcImplementation(OofpcipocApiService.class, this); - LOG.info( "Initialization complete for {}", APPLICATION_NAME); - } + public void setClient(OofpcipocClient client) { + this.OofpcipocClient = client; + } - protected void initializeChild() { - //Override if you have custom initialization intelligence - } + public void init() { + LOG.info("Initializing provider for {}", APPLICATION_NAME); + rpcRegistration = rpcProviderService.registerRpcImplementation(OofpcipocApiService.class, this); + LOG.info("Initialization complete for {}", APPLICATION_NAME); + } - @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); - } + @Override + public void close() throws Exception { + LOG.info("Closing provider for {}", APPLICATION_NAME); + executor.shutdown(); + if (rpcRegistration != null) + rpcRegistration.close(); + LOG.info("Successfully closed provider for {}", APPLICATION_NAME); + } @Override - public ListenableFuture> greeting( - GreetingInput input) { + public ListenableFuture> greeting(GreetingInput input) { final String svcOperation = "greeting"; Properties parms = new Properties(); GreetingOutputBuilder serviceDataBuilder = new GreetingOutputBuilder(); - LOG.info( "Reached RPC greeting"); + LOG.info("Reached RPC greeting"); - LOG.info( svcOperation +" called." ); + LOG.info(svcOperation + " called."); - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); serviceDataBuilder.setResponse("Input is null"); - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // add input to parms - LOG.info("Adding INPUT data for "+svcOperation+" input: " + input); + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); GreetingInputBuilder inputBuilder = new GreetingInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); // Call SLI sync method - try - { - if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation , null, "sync")) - { - LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); - try - { - OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); + try { + if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation, null, "sync")) { + LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); + try { + OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); serviceDataBuilder.setResponse("500"); } } else { LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); serviceDataBuilder.setResponse("503"); } - } - catch (Exception e) - { + } catch (Exception e) { LOG.error("Caught exception looking for service logic", e); serviceDataBuilder.setResponse("500"); } @@ -151,22 +147,22 @@ public class OofpcipocProvider implements AutoCloseable, OofpcipocApiService { String errorCode = serviceDataBuilder.getResponse(); if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'"); + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); } else { - LOG.info("Returned SUCCESS for "+svcOperation+" "); - serviceDataBuilder.setResponse("Welcome OOF POC " + input.getSalutation()); + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder.setResponse("Welcome OOF POC " + input.getSalutation()); } - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); - LOG.info("Successful exit from greeting "); + LOG.info("Successful exit from greeting "); return Futures.immediateFuture(rpcResult); } // RPC configuration-phy-cell-id - @Override + @Override public ListenableFuture> configurationPhyCellId( ConfigurationPhyCellIdInput input) { final String svcOperation = "configuration-phy-cell-id"; @@ -174,47 +170,164 @@ public class OofpcipocProvider implements AutoCloseable, OofpcipocApiService { Properties parms = new Properties(); ConfigurationPhyCellIdOutputBuilder serviceDataBuilder = new ConfigurationPhyCellIdOutputBuilder(); - LOG.info( "Reached RPC configurationPhyCellId"); + LOG.info("Reached RPC configurationPhyCellId"); - LOG.info( svcOperation +" called." ); + LOG.info(svcOperation + " called."); - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); serviceDataBuilder.setResponseCode("Input is null"); - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); + RpcResult rpcResult = RpcResultBuilder + .status(true).withResult(serviceDataBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // add input to parms - LOG.info("Adding INPUT data for "+svcOperation+" input: " + input); + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); ConfigurationPhyCellIdInputBuilder inputBuilder = new ConfigurationPhyCellIdInputBuilder(input); MdsalHelper.toProperties(parms, inputBuilder.build()); // Call SLI sync method - try - { + try { - if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation , null, "sync")) - { - LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); + if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation, null, "sync")) { + LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); - try - { + try { OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); + serviceDataBuilder.setResponseCode("500"); } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); + } else { + LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); + serviceDataBuilder.setResponseCode("503"); + } + } catch (Exception e) { + LOG.error("Caught exception looking for service logic", e); + serviceDataBuilder.setResponseCode("500"); + } + + String errorCode = serviceDataBuilder.getResponseCode(); + + if (!("0".equals(errorCode) || "200".equals(errorCode))) { + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); + } else { + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder + .setResponseCode("Welcome OOF POC. Number of FAP entries " + input.getFapServiceNumberOfEntries()); + } + + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // RPC add-neighbor + @Override + public ListenableFuture> addNeighbor(AddNeighborInput input) { + final String svcOperation = "add-neighbor"; + + Properties parms = new Properties(); + AddNeighborOutputBuilder serviceDataBuilder = new AddNeighborOutputBuilder(); + + LOG.info("Reached RPC addNeighbor"); + + LOG.info(svcOperation + " called."); + + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); + serviceDataBuilder.setResponseCode("Input is null"); + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // add input to parms + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); + AddNeighborInputBuilder inputBuilder = new AddNeighborInputBuilder(input); + MdsalHelper.toProperties(parms, inputBuilder.build()); + + // Call SLI sync method + try { + + if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation, null, "sync")) { + LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); + + try { + OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); serviceDataBuilder.setResponseCode("500"); } } else { LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); serviceDataBuilder.setResponseCode("503"); } + } catch (Exception e) { + LOG.error("Caught exception looking for service logic", e); + serviceDataBuilder.setResponseCode("500"); + } + + String errorCode = serviceDataBuilder.getResponseCode(); + + if (!("0".equals(errorCode) || "200".equals(errorCode))) { + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); + } else { + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder.setResponseCode( + "Welcome OOF POC. Number of Neighbor entries to be added " + input.getLteCellNumberOfEntries()); + } + + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // RPC delete-neighbor + @Override + public ListenableFuture> deleteNeighbor(DeleteNeighborInput input) { + final String svcOperation = "delete-neighbor"; + + Properties parms = new Properties(); + DeleteNeighborOutputBuilder serviceDataBuilder = new DeleteNeighborOutputBuilder(); + + LOG.info("Reached RPC deleteNeighbor"); + + LOG.info(svcOperation + " called."); + + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); + serviceDataBuilder.setResponseCode("Input is null"); + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); } - catch (Exception e) - { + + // add input to parms + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); + DeleteNeighborInputBuilder inputBuilder = new DeleteNeighborInputBuilder(input); + MdsalHelper.toProperties(parms, inputBuilder.build()); + + // Call SLI sync method + try { + + if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation, null, "sync")) { + LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); + + try { + OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); + serviceDataBuilder.setResponseCode("500"); + } + } else { + LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); + serviceDataBuilder.setResponseCode("503"); + } + } catch (Exception e) { LOG.error("Caught exception looking for service logic", e); serviceDataBuilder.setResponseCode("500"); } @@ -222,292 +335,143 @@ public class OofpcipocProvider implements AutoCloseable, OofpcipocApiService { String errorCode = serviceDataBuilder.getResponseCode(); if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'"); + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); } else { - LOG.info("Returned SUCCESS for "+svcOperation+" "); - serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of FAP entries " + input.getFapServiceNumberOfEntries()); + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder.setResponseCode( + "Welcome OOF POC. Number of Neighbor entries to be deleted " + input.getLteCellNumberOfEntries()); } - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); + RpcResult rpcResult = RpcResultBuilder.status(true) + .withResult(serviceDataBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - // RPC add-neighbor - @Override - public ListenableFuture> addNeighbor( - AddNeighborInput input) { - final String svcOperation = "add-neighbor"; - - Properties parms = new Properties(); - AddNeighborOutputBuilder serviceDataBuilder = new AddNeighborOutputBuilder(); - - LOG.info( "Reached RPC addNeighbor"); - - LOG.info( svcOperation +" called." ); - - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); - serviceDataBuilder.setResponseCode("Input is null"); - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // add input to parms - LOG.info("Adding INPUT data for "+svcOperation+" input: " + input); - AddNeighborInputBuilder inputBuilder = new AddNeighborInputBuilder(input); - MdsalHelper.toProperties(parms, inputBuilder.build()); - - // Call SLI sync method - try - { - - if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation , null, "sync")) - { - LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); - - try - { - OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); - serviceDataBuilder.setResponseCode("500"); - } - } else { - LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); - serviceDataBuilder.setResponseCode("503"); - } - } - catch (Exception e) - { - LOG.error("Caught exception looking for service logic", e); - serviceDataBuilder.setResponseCode("500"); - } - - String errorCode = serviceDataBuilder.getResponseCode(); - - if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'"); - } else { - LOG.info("Returned SUCCESS for "+svcOperation+" "); - serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of Neighbor entries to be added " + input.getLteCellNumberOfEntries()); - } - - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - - return Futures.immediateFuture(rpcResult); - } - - // RPC delete-neighbor - @Override - public ListenableFuture> deleteNeighbor( - DeleteNeighborInput input) { - final String svcOperation = "delete-neighbor"; - - Properties parms = new Properties(); - DeleteNeighborOutputBuilder serviceDataBuilder = new DeleteNeighborOutputBuilder(); - - LOG.info( "Reached RPC deleteNeighbor"); - - LOG.info( svcOperation +" called." ); - - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); - serviceDataBuilder.setResponseCode("Input is null"); - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // add input to parms - LOG.info("Adding INPUT data for "+svcOperation+" input: " + input); - DeleteNeighborInputBuilder inputBuilder = new DeleteNeighborInputBuilder(input); - MdsalHelper.toProperties(parms, inputBuilder.build()); - - // Call SLI sync method - try - { - - if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation , null, "sync")) - { - LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); - - try - { - OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); - serviceDataBuilder.setResponseCode("500"); - } - } else { - LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); - serviceDataBuilder.setResponseCode("503"); - } - } - catch (Exception e) - { - LOG.error("Caught exception looking for service logic", e); - serviceDataBuilder.setResponseCode("500"); - } - - String errorCode = serviceDataBuilder.getResponseCode(); - - if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'"); - } else { - LOG.info("Returned SUCCESS for "+svcOperation+" "); - serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of Neighbor entries to be deleted " + input.getLteCellNumberOfEntries()); - } - - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - - return Futures.immediateFuture(rpcResult); - } - - // RPC generic-neighbor-configuration - @Override - public ListenableFuture> genericNeighborConfiguration( - GenericNeighborConfigurationInput input) { - final String svcOperation = "generic-neighbor-configuration"; - - Properties parms = new Properties(); - GenericNeighborConfigurationOutputBuilder serviceDataBuilder = new GenericNeighborConfigurationOutputBuilder(); - - LOG.info( "Reached RPC genericNeighborConfiguration"); - - LOG.info( svcOperation +" called." ); - - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); - serviceDataBuilder.setResponseCode("Input is null"); - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // add input to parms - LOG.info("Adding INPUT data for "+svcOperation+" input: " + input); - GenericNeighborConfigurationInputBuilder inputBuilder = new GenericNeighborConfigurationInputBuilder(input); - MdsalHelper.toProperties(parms, inputBuilder.build()); - - // Call SLI sync method - try - { - - if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation , null, "sync")) - { - LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); - - try - { - OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); - serviceDataBuilder.setResponseCode("500"); - } - } else { - LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); - serviceDataBuilder.setResponseCode("503"); - } - } - catch (Exception e) - { - LOG.error("Caught exception looking for service logic", e); - serviceDataBuilder.setResponseCode("500"); - } - - String errorCode = serviceDataBuilder.getResponseCode(); - - if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'"); - } else { - LOG.info("Returned SUCCESS for "+svcOperation+" "); - serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of Neighbor entries to be configured " + input.getLteCellNumberOfEntries()); - } - - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - - return Futures.immediateFuture(rpcResult); - } - - // RPC handle-nbrlist-change-notif - @Override - public ListenableFuture> handleNbrlistChangeNotif( - HandleNbrlistChangeNotifInput input) { - final String svcOperation = "handle-nbrlist-change-notif"; - - Properties parms = new Properties(); - HandleNbrlistChangeNotifOutputBuilder serviceDataBuilder = new HandleNbrlistChangeNotifOutputBuilder(); - - LOG.info( "Reached RPC handle-nbrlist-change-notif"); - - LOG.info( svcOperation +" called." ); - - if(input == null ) { - LOG.debug("exiting " +svcOperation+ " because of invalid input"); - serviceDataBuilder.setResponseCode("Input is null"); - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // add input to parms - LOG.info("Adding INPUT data for "+svcOperation+" input: " + input); - HandleNbrlistChangeNotifInputBuilder inputBuilder = new HandleNbrlistChangeNotifInputBuilder(input); - MdsalHelper.toProperties(parms, inputBuilder.build()); - - // Call SLI sync method - try - { - if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation , null, "sync")) - { - LOG.info( "OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); - try - { - OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { - LOG.error("Caught exception executing service logic for "+ svcOperation, e); - serviceDataBuilder.setResponseCode("500"); - } - } else { - LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); - serviceDataBuilder.setResponseCode("503"); - } - } - catch (Exception e) - { - LOG.error("Caught exception looking for service logic", e); - serviceDataBuilder.setResponseCode("500"); - } - - String errorCode = serviceDataBuilder.getResponseCode(); - - if (!("0".equals(errorCode) || "200".equals(errorCode))) { - LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'"); - } else { - LOG.info("Returned SUCCESS for "+svcOperation+" "); - serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of FAP services changed = " + input.getFapServiceNumberOfEntriesChanged()); - } - - RpcResult rpcResult = - RpcResultBuilder. status(true).withResult(serviceDataBuilder.build()).build(); - - LOG.info("Successful exit from handle-nbrlist-change-notif "); - - return Futures.immediateFuture(rpcResult); - } + // RPC generic-neighbor-configuration + @Override + public ListenableFuture> genericNeighborConfiguration( + GenericNeighborConfigurationInput input) { + final String svcOperation = "generic-neighbor-configuration"; + + Properties parms = new Properties(); + GenericNeighborConfigurationOutputBuilder serviceDataBuilder = new GenericNeighborConfigurationOutputBuilder(); + + LOG.info("Reached RPC genericNeighborConfiguration"); + + LOG.info(svcOperation + " called."); + + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); + serviceDataBuilder.setResponseCode("Input is null"); + RpcResult rpcResult = RpcResultBuilder + .status(true).withResult(serviceDataBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // add input to parms + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); + GenericNeighborConfigurationInputBuilder inputBuilder = new GenericNeighborConfigurationInputBuilder(input); + MdsalHelper.toProperties(parms, inputBuilder.build()); + + // Call SLI sync method + try { + + if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation, null, "sync")) { + LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); + + try { + OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); + serviceDataBuilder.setResponseCode("500"); + } + } else { + LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); + serviceDataBuilder.setResponseCode("503"); + } + } catch (Exception e) { + LOG.error("Caught exception looking for service logic", e); + serviceDataBuilder.setResponseCode("500"); + } + + String errorCode = serviceDataBuilder.getResponseCode(); + + if (!("0".equals(errorCode) || "200".equals(errorCode))) { + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); + } else { + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder.setResponseCode("Welcome OOF POC. Number of Neighbor entries to be configured " + + input.getLteCellNumberOfEntries()); + } + + RpcResult rpcResult = RpcResultBuilder + .status(true).withResult(serviceDataBuilder.build()).build(); + + return Futures.immediateFuture(rpcResult); + } + + // RPC handle-nbrlist-change-notif + @Override + public ListenableFuture> handleNbrlistChangeNotif( + HandleNbrlistChangeNotifInput input) { + final String svcOperation = "handle-nbrlist-change-notif"; + + Properties parms = new Properties(); + HandleNbrlistChangeNotifOutputBuilder serviceDataBuilder = new HandleNbrlistChangeNotifOutputBuilder(); + + LOG.info("Reached RPC handle-nbrlist-change-notif"); + + LOG.info(svcOperation + " called."); + + if (input == null) { + LOG.debug("exiting " + svcOperation + " because of invalid input"); + serviceDataBuilder.setResponseCode("Input is null"); + RpcResult rpcResult = RpcResultBuilder + .status(true).withResult(serviceDataBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // add input to parms + LOG.info("Adding INPUT data for " + svcOperation + " input: " + input); + HandleNbrlistChangeNotifInputBuilder inputBuilder = new HandleNbrlistChangeNotifInputBuilder(input); + MdsalHelper.toProperties(parms, inputBuilder.build()); + + // Call SLI sync method + try { + if (OofpcipocClient.hasGraph("oofpcipoc-api", svcOperation, null, "sync")) { + LOG.info("OofpcipocClient has a Directed Graph for '" + svcOperation + "'"); + try { + OofpcipocClient.execute("oofpcipoc-api", svcOperation, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + LOG.error("Caught exception executing service logic for " + svcOperation, e); + serviceDataBuilder.setResponseCode("500"); + } + } else { + LOG.error("No service logic active for Oofpcipoc: '" + svcOperation + "'"); + serviceDataBuilder.setResponseCode("503"); + } + } catch (Exception e) { + LOG.error("Caught exception looking for service logic", e); + serviceDataBuilder.setResponseCode("500"); + } + + String errorCode = serviceDataBuilder.getResponseCode(); + + if (!("0".equals(errorCode) || "200".equals(errorCode))) { + LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'"); + } else { + LOG.info("Returned SUCCESS for " + svcOperation + " "); + serviceDataBuilder.setResponseCode( + "Welcome OOF POC. Number of FAP services changed = " + input.getFapServiceNumberOfEntriesChanged()); + } + + RpcResult rpcResult = RpcResultBuilder + .status(true).withResult(serviceDataBuilder.build()).build(); + + LOG.info("Successful exit from handle-nbrlist-change-notif "); + + return Futures.immediateFuture(rpcResult); + } } diff --git a/sdnr/northbound/oofpcipoc/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml b/sdnr/northbound/oofpcipoc/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml deleted file mode 100644 index d62c2f797..000000000 --- a/sdnr/northbound/oofpcipoc/provider/src/main/resources/OSGI-INF/blueprint/impl-blueprint.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/sdnr/northbound/oofpcipoc/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml b/sdnr/northbound/oofpcipoc/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml index d62c2f797..a02e4a4cd 100644 --- a/sdnr/northbound/oofpcipoc/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml +++ b/sdnr/northbound/oofpcipoc/provider/src/main/resources/org/opendaylight/blueprint/impl-blueprint.xml @@ -1,50 +1,46 @@ - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/sdnr/northbound/oofpcipoc/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/TestOofpcipoc.java b/sdnr/northbound/oofpcipoc/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/TestOofpcipoc.java index daa210e4b..597c75cef 100644 --- a/sdnr/northbound/oofpcipoc/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/TestOofpcipoc.java +++ b/sdnr/northbound/oofpcipoc/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/oofpcipoc/TestOofpcipoc.java @@ -24,14 +24,6 @@ package org.onap.ccsdk.features.sdnr.northbound.oofpcipoc; import org.junit.Before; import org.junit.Test; -import org.onap.ccsdk.features.sdnr.northbound.oofpcipoc.OofpcipocClient; -import org.onap.ccsdk.features.sdnr.northbound.oofpcipoc.OofpcipocProvider; - -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.test.AbstractConcurrentDataBrokerTest; -import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry; - import org.opendaylight.yangtools.yang.common.RpcResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,15 +33,18 @@ import static org.mockito.Mockito.mock; import java.math.*; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdInput; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.RpcProviderService; + import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdInputBuilder; import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdOutput; -import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev190308.ConfigurationPhyCellIdOutputBuilder; + import com.google.common.util.concurrent.ListenableFuture; -public class TestOofpcipoc extends AbstractConcurrentDataBrokerTest { +public class TestOofpcipoc { private OofpcipocProvider oofpcipocProvider; private static final Logger LOG = LoggerFactory.getLogger(OofpcipocProvider.class); @@ -57,11 +52,15 @@ public class TestOofpcipoc extends AbstractConcurrentDataBrokerTest { @Before public void setUp() throws Exception { if (null == oofpcipocProvider) { - DataBroker dataBroker = getDataBroker(); + DataBroker dataBroker = mock(DataBroker.class); NotificationPublishService mockNotification = mock(NotificationPublishService.class); - RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); + RpcProviderService mockRpcRegistry = mock(RpcProviderService.class); OofpcipocClient mockSliClient = mock(OofpcipocClient.class); - oofpcipocProvider = new OofpcipocProvider(dataBroker, mockNotification, mockRpcRegistry, mockSliClient); + oofpcipocProvider = new OofpcipocProvider(); + oofpcipocProvider.setDataBroker(dataBroker); + oofpcipocProvider.setNotificationPublishService(mockNotification); + oofpcipocProvider.setRpcProviderService(mockRpcRegistry); + oofpcipocProvider.setClient(mockSliClient); } } -- cgit 1.2.3-korg