summaryrefslogtreecommitdiffstats
path: root/infra/northbound/bgp/src/main
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2017-07-06 12:55:17 +0200
committerMarek Gradzki <mgradzki@cisco.com>2017-07-06 13:27:18 +0200
commit76ec4e831b2653426d8bc434dabe145d97efcc2a (patch)
tree77ed1404294299f666f65fb17bdab4bd8575da14 /infra/northbound/bgp/src/main
parent299296e6ff842a1c275a67a07f2f3e09852c1959 (diff)
HONEYCOMB-377: remove enabled flag for bgp
Use module configuration to enable/disabe BGP. Also hides BgpExtensionModule module to the user (until HONEYCOMB-363 is fixed). Change-Id: I8294d080138a0bcf640420484b76c089aa332d93 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'infra/northbound/bgp/src/main')
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java7
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java2
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java15
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java17
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java12
-rw-r--r--infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java12
-rw-r--r--infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp.json1
7 files changed, 15 insertions, 51 deletions
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java
index 9182dd3a0..6cc245af7 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfiguration.java
@@ -31,16 +31,10 @@ import net.jmob.guice.conf.core.Syntax;
@BindConfig(value = "bgp", syntax = Syntax.JSON)
public class BgpConfiguration {
- public boolean isBgpEnabled() {
- return Boolean.valueOf(bgpEnabled);
- }
-
public boolean isBgpMultiplePathsEnabled() {
return Boolean.valueOf(bgpMultiplePaths.get());
}
- @InjectConfig("bgp-enabled")
- public String bgpEnabled;
@InjectConfig("bgp-binding-address")
public Optional<String> bgpBindingAddress;
@InjectConfig("bgp-port")
@@ -56,7 +50,6 @@ public class BgpConfiguration {
@Override
public String toString() {
return MoreObjects.toStringHelper(this)
- .add("bgpEnabled", bgpEnabled)
.add("bgpBindingAddress", bgpBindingAddress)
.add("bgpPort", bgpPort)
.add("bgp-as-number", bgpAsNumber)
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java
index a1c2e765b..0efe7a12a 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpConfigurationModule.java
@@ -22,7 +22,7 @@ import net.jmob.guice.conf.core.ConfigurationModule;
/**
* Load the configuration from json into HoneycombConfiguration and make it available.
*/
-public class BgpConfigurationModule extends AbstractModule {
+final class BgpConfigurationModule extends AbstractModule {
protected void configure() {
install(ConfigurationModule.create());
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java
index d744065fb..b096e3dbd 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpExtensionsModule.java
@@ -16,9 +16,9 @@
package io.fd.honeycomb.infra.bgp;
+import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
-import io.fd.honeycomb.northbound.NorthboundAbstractModule;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionConsumerContext;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderActivator;
import org.opendaylight.protocol.bgp.rib.spi.RIBExtensionConsumerContext;
@@ -28,20 +28,13 @@ import org.slf4j.LoggerFactory;
/**
* Registers BGP extensions provided by ODL implementation.
- * TODO add support for flowspec (requires some special initialization)
+ * TODO(HONEYCOMB-363): create module per BGP extension
+ * TODO(HONEYCOMB-378): add support for flowspec (requires some special initialization)
*/
-public final class BgpExtensionsModule extends NorthboundAbstractModule<BgpConfiguration> {
+final class BgpExtensionsModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(BgpExtensionsModule.class);
- public BgpExtensionsModule() {
- super(new BgpConfigurationModule(), BgpConfiguration.class);
- }
-
protected void configure() {
- if (!getConfiguration().isBgpEnabled()) {
- LOG.debug("BGP disabled. Skipping initialization");
- return;
- }
LOG.debug("Initializing BgpExtensionsModule");
// This should be part of BgpModule, but that one is Private and Multibinders + private BASE_MODULES
// do not work together, that's why there's a dedicated module here
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
index 32c4440e0..dd6449d0d 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpModule.java
@@ -19,12 +19,12 @@ package io.fd.honeycomb.infra.bgp;
import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.CONFIG;
import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.OPERATIONAL;
+import com.google.inject.PrivateModule;
import com.google.inject.Singleton;
import com.google.inject.name.Names;
import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider;
import io.fd.honeycomb.infra.distro.data.DataStoreProvider;
import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider;
-import io.fd.honeycomb.northbound.NorthboundPrivateModule;
import io.fd.honeycomb.translate.bgp.RibWriter;
import io.netty.channel.EventLoopGroup;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -41,22 +41,13 @@ import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.BgpNe
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class BgpModule extends NorthboundPrivateModule<BgpConfiguration> {
+public final class BgpModule extends PrivateModule {
private static final Logger LOG = LoggerFactory.getLogger(BgpModule.class);
static final String HONEYCOMB_BGP = "honeycomb-bgp";
- public BgpModule() {
- super(new BgpConfigurationModule(), BgpConfiguration.class);
- }
-
protected void configure() {
- if (!getConfiguration().isBgpEnabled()) {
- LOG.debug("BGP disabled. Skipping initialization");
- return;
- }
LOG.debug("Initializing BgpModule");
- install(getConfigurationModule());
// Create BGPDispatcher BGPDispatcher for creating BGP clients
bind(EventLoopGroup.class).toProvider(BgpNettyThreadGroupProvider.class).in(Singleton.class);
bind(BGPDispatcher.class).toProvider(BGPDispatcherImplProvider.class).in(Singleton.class);
@@ -77,6 +68,10 @@ public final class BgpModule extends NorthboundPrivateModule<BgpConfiguration> {
// (initialize eagerly to configure RouteWriters)
bind(RibWriter.class).toProvider(LocRibWriterProvider.class).asEagerSingleton();
expose(RibWriter.class);
+
+ // install other BGP modules (hidden from HC user):
+ install(new BgpConfigurationModule());
+ install(new BgpExtensionsModule());
}
private void configureRIB() {
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java
index 9f819614e..1dc1359c7 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpReadersModule.java
@@ -16,25 +16,17 @@
package io.fd.honeycomb.infra.bgp;
+import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
-import io.fd.honeycomb.northbound.NorthboundAbstractModule;
import io.fd.honeycomb.translate.read.ReaderFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class BgpReadersModule extends NorthboundAbstractModule<BgpConfiguration> {
+public final class BgpReadersModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(BgpReadersModule.class);
- public BgpReadersModule() {
- super(new BgpConfigurationModule(), BgpConfiguration.class);
- }
-
protected void configure() {
- if (!getConfiguration().isBgpEnabled()) {
- LOG.debug("BGP disabled. Skipping initialization");
- return;
- }
LOG.debug("Initializing BgpReadersModule");
// This should be part of BgpModule, but that one is Private and Multibinders + private BASE_MODULES
// do not work together, that's why there's a dedicated module here
diff --git a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java
index 690a7feb2..b16702968 100644
--- a/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java
+++ b/infra/northbound/bgp/src/main/java/io/fd/honeycomb/infra/bgp/BgpWritersModule.java
@@ -16,25 +16,17 @@
package io.fd.honeycomb.infra.bgp;
+import com.google.inject.AbstractModule;
import com.google.inject.Singleton;
import com.google.inject.multibindings.Multibinder;
-import io.fd.honeycomb.northbound.NorthboundAbstractModule;
import io.fd.honeycomb.translate.write.WriterFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class BgpWritersModule extends NorthboundAbstractModule<BgpConfiguration> {
+public final class BgpWritersModule extends AbstractModule {
private static final Logger LOG = LoggerFactory.getLogger(BgpWritersModule.class);
- public BgpWritersModule() {
- super(new BgpConfigurationModule(), BgpConfiguration.class);
- }
-
protected void configure() {
- if (!getConfiguration().isBgpEnabled()) {
- LOG.debug("BGP disabled. Skipping initialization");
- return;
- }
LOG.debug("Initializing BgpReadersModule");
// This should be part of BgpModule, but that one is Private and Multibinders + private BASE_MODULES
// do not work together, that's why there's a dedicated module here
diff --git a/infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp.json b/infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp.json
index c0981429f..2efe55ee3 100644
--- a/infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp.json
+++ b/infra/northbound/bgp/src/main/resources/honeycomb-minimal-resources/config/bgp.json
@@ -1,5 +1,4 @@
{
- "bgp-enabled": "false",
"bgp-binding-address": "127.0.0.1",
"bgp-port": 1790,
"bgp-as-number": 65000,