diff options
author | Marek Gradzki <mgradzki@cisco.com> | 2016-09-10 13:50:26 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-09-14 08:52:07 +0200 |
commit | f03ebfd9dcc6762d47f648b1590079ac8145109c (patch) | |
tree | baa02bbefdfe973f408558f251a35ce67b4065d0 /nsh/impl/src/main/java | |
parent | 0b419f853ec86e4c89ed44db99bc438e9eb3a9e7 (diff) |
Allow HC user to enable/disable NSH module
Because NSH plugin is optional in VPP,
it is disabled by default in HC.
Change-Id: I6842c68b94144b7ba7e9f6f87a2395e0d692a70c
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'nsh/impl/src/main/java')
-rwxr-xr-x | nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/VppNshModule.java | 43 | ||||
-rw-r--r-- | nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/cfgattrs/vppnsh.json | 3 |
2 files changed, 32 insertions, 14 deletions
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/VppNshModule.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/VppNshModule.java index 48f323394..ec1be5bab 100755 --- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/VppNshModule.java +++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/VppNshModule.java @@ -16,36 +16,41 @@ package io.fd.honeycomb.vppnsh.impl; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; - import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; import com.google.inject.Singleton; import com.google.inject.multibindings.Multibinder; import com.google.inject.name.Names; import io.fd.honeycomb.data.init.DataTreeInitializer; -import io.fd.honeycomb.notification.ManagedNotificationProducer; +import io.fd.honeycomb.translate.read.ReaderFactory; +import io.fd.honeycomb.translate.v3po.util.NamingContext; +import io.fd.honeycomb.translate.write.WriterFactory; import io.fd.honeycomb.vppnsh.impl.cfgattrs.VppNshConfiguration; import io.fd.honeycomb.vppnsh.impl.config.VppNshWriterFactory; -import io.fd.honeycomb.vppnsh.impl.oper.VppNshReaderFactory; import io.fd.honeycomb.vppnsh.impl.init.VppNshInitializer; +import io.fd.honeycomb.vppnsh.impl.oper.VppNshReaderFactory; import io.fd.honeycomb.vppnsh.impl.util.JVppNshProvider; -import io.fd.honeycomb.translate.read.ReaderFactory; -import io.fd.honeycomb.translate.v3po.util.NamingContext; -import io.fd.honeycomb.translate.write.WriterFactory; import net.jmob.guice.conf.core.ConfigurationModule; import org.openvpp.jvpp.nsh.future.FutureJVppNsh; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This is some glue code necessary for Honeycomb distribution to pick up the plugin classes */ public final class VppNshModule extends AbstractModule { + private static final Logger LOG = LoggerFactory.getLogger(VppNshModule.class); + @Override protected void configure() { - // These are plugin specific config attributes - install(ConfigurationModule.create()); - requestInjection(VppNshConfiguration.class); + // TODO HONEYCOMB-207 workaround: + if (!isEnabled()) { + LOG.info("VppNshModule is disabled. Skipping module configuration."); + return; + } + LOG.info("Configuring VppNsh module"); // Naming contexts bind(NamingContext.class) @@ -63,5 +68,21 @@ public final class VppNshModule extends AbstractModule { Multibinder.newSetBinder(binder(), WriterFactory.class).addBinding().to(VppNshWriterFactory.class); Multibinder.newSetBinder(binder(), ReaderFactory.class).addBinding().to(VppNshReaderFactory.class); Multibinder.newSetBinder(binder(), DataTreeInitializer.class).addBinding().to(VppNshInitializer.class); + LOG.info("NSH module successfully configured"); + } + + private static boolean isEnabled() { + final Injector injector = Guice.createInjector(new AbstractModule() { + @Override + protected void configure() { + // These are plugin specific config attributes + install(ConfigurationModule.create()); + requestInjection(VppNshConfiguration.class); + } + }); + + final VppNshConfiguration cfgAttributes = injector.getInstance(VppNshConfiguration.class); + LOG.debug("Configuration for VppNsh module: {}", cfgAttributes); + return cfgAttributes.isNshEnabled(); } } diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/cfgattrs/vppnsh.json b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/cfgattrs/vppnsh.json deleted file mode 100644 index f2fe985b9..000000000 --- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/cfgattrs/vppnsh.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "nsh-enabled" : "false" -} |