summaryrefslogtreecommitdiffstats
path: root/nsh/impl/src/main/java/io
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-09-10 13:50:26 +0200
committerMarek Gradzki <mgradzki@cisco.com>2016-09-14 08:52:07 +0200
commitf03ebfd9dcc6762d47f648b1590079ac8145109c (patch)
treebaa02bbefdfe973f408558f251a35ce67b4065d0 /nsh/impl/src/main/java/io
parent0b419f853ec86e4c89ed44db99bc438e9eb3a9e7 (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/io')
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/VppNshModule.java43
-rw-r--r--nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/cfgattrs/vppnsh.json3
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"
-}
'>339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436