From 31f01fcfadf8707aefe6bf3a09daf570ce248fc5 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Fri, 19 Aug 2016 12:20:33 +0200 Subject: HONEYCOMB-18 Fixing comments from reviews Change-Id: Ic0565d601d13b5f50ec3c714a43600e32a7e456b Signed-off-by: Maros Marsalek --- .../java/io/fd/honeycomb/infra/distro/Main.java | 25 ++++++------ .../infra/distro/cfgattrs/CfgAttrsModule.groovy | 3 ++ .../distro/cfgattrs/HoneycombConfiguration.groovy | 33 +++++++++++++-- .../data/ConfigAndOperationalPipelineModule.groovy | 32 +++++++++------ .../distro/data/HoneycombDOMBrokerProvider.groovy | 1 - .../HoneycombNotificationManagerProvider.groovy | 4 +- .../data/InmemoryDOMDataBrokerProvider.groovy | 4 +- .../distro/data/ModifiableDTDelegProvider.groovy | 5 ++- .../distro/data/PersistingDataTreeProvider.groovy | 5 ++- .../data/context/ContextPipelineModule.groovy | 35 ++++++++-------- .../context/RealtimeMappingContextProvider.groovy | 2 +- .../data/oper/ReadableDTDelegProvider.groovy | 3 +- .../initializer/InitializerPipelineModule.groovy | 15 +++++-- .../initializer/InitializerRegistryProvider.groovy | 6 ++- .../ModifiableDTDelegInitProvider.groovy | 9 ++--- .../PersistedFileInitializerProvider.groovy | 8 ++-- .../HoneycombNotification2NetconfProvider.groovy | 20 ++++----- .../netconf/NetconfBindingBrokerProvider.groovy | 5 +-- .../netconf/NetconfMdsalMapperProvider.groovy | 4 +- .../infra/distro/netconf/NetconfModule.groovy | 45 ++++++++++++++------- .../netconf/NetconfMonitoringMapperProvider.groovy | 6 +-- .../NetconfMonitoringReaderFactoryProvider.groovy | 2 +- .../NetconfMonitoringServiceProvider.groovy | 6 +-- .../NetconfNotificationMapperProvider.groovy | 8 ++-- ...etconfNotificationsReaderFactoryProvider.groovy | 3 +- .../distro/netconf/NetconfReadersModule.groovy | 1 + .../netconf/NetconfServerDispatcherProvider.groovy | 6 +-- .../distro/netconf/NetconfSshServerProvider.groovy | 5 +-- .../distro/netconf/NetconfTcpServerProvider.groovy | 4 +- .../distro/netconf/NettyThreadGroupProvider.groovy | 4 +- .../infra/distro/netconf/NettyTimerProvider.groovy | 4 +- .../distro/restconf/HttpsConnectorProvider.groovy | 15 ++++--- .../distro/restconf/JettyServerProvider.groovy | 1 - .../infra/distro/restconf/RestconfModule.groovy | 7 +++- .../distro/schema/YangBindingProviderModule.groovy | 1 + .../cert/honeycomb.pkcs12 | Bin 2549 -> 0 bytes .../config/honeycomb.json | 11 +++-- 37 files changed, 194 insertions(+), 154 deletions(-) delete mode 100644 infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/cert/honeycomb.pkcs12 (limited to 'infra/minimal-distribution/src') diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java index 278f0b104..d74906244 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/Main.java @@ -98,10 +98,10 @@ public final class Main { final RestConnector instance = injector.getInstance(RestConnector.class); if (cfgAttributes.isRestconfHttpEnabled()) { - injector.getInstance(Key.get(ServerConnector.class, Names.named("restconf-http"))); + injector.getInstance(Key.get(ServerConnector.class, Names.named(RestconfModule.RESTCONF_HTTP))); } if (cfgAttributes.isRestconfHttpsEnabled()) { - injector.getInstance(Key.get(ServerConnector.class, Names.named("restconf-https"))); + injector.getInstance(Key.get(ServerConnector.class, Names.named(RestconfModule.RESTCONF_HTTPS))); } try { @@ -113,21 +113,21 @@ public final class Main { } if (cfgAttributes.isNetconfEnabled()) { - LOG.info("Starting NETCONF"); - injector.getInstance( - Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-honeycomb"))); - injector.getInstance( - Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-notification"))); - injector.getInstance( - Key.get(NetconfOperationServiceFactory.class, Names.named("netconf-mapper-monitoring"))); + LOG.info("Starting HONEYCOMB_NETCONF"); + injector.getInstance(Key.get(NetconfOperationServiceFactory.class, + Names.named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_CORE))); + injector.getInstance(Key.get(NetconfOperationServiceFactory.class, + Names.named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_NOTIF))); + injector.getInstance(Key.get(NetconfOperationServiceFactory.class, + Names.named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_OPER))); if (cfgAttributes.isNetconfTcpEnabled()) { - LOG.info("Starting NETCONF TCP"); + LOG.info("Starting HONEYCOMB_NETCONF TCP"); injector.getInstance(NetconfTcpServerProvider.NetconfTcpServer.class); } if (cfgAttributes.isNetconfSshEnabled()) { - LOG.info("Starting NETCONF SSH"); + LOG.info("Starting HONEYCOMB_NETCONF SSH"); injector.getInstance(NetconfSshServerProvider.NetconfSshServer.class); } injector.getInstance(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class); @@ -137,7 +137,8 @@ public final class Main { try { LOG.info("Initializing configuration"); - injector.getInstance(Key.get(InitializerRegistry.class, Names.named("honeycomb-initializer"))).initialize(); + injector.getInstance(Key.get(InitializerRegistry.class, + Names.named(InitializerPipelineModule.HONEYCOMB_INITIALIZER))).initialize(); LOG.info("Configuration initialized successfully"); } catch (DataTreeInitializer.InitializeException e) { LOG.error("Unable to initialize configuration", e); diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/CfgAttrsModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/CfgAttrsModule.groovy index 6c9b0a50a..b20f3cd32 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/CfgAttrsModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/CfgAttrsModule.groovy @@ -20,6 +20,9 @@ import com.google.inject.AbstractModule import groovy.util.logging.Slf4j import net.jmob.guice.conf.core.ConfigurationModule +/** + * Load the configuration from json into HoneycombConfiguration and make it available. + */ @Slf4j class CfgAttrsModule extends AbstractModule { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.groovy index 85708f11e..15f907f4b 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.groovy @@ -21,6 +21,12 @@ import net.jmob.guice.conf.core.BindConfig import net.jmob.guice.conf.core.InjectConfig import net.jmob.guice.conf.core.Syntax +/** + * This is the Java equivalent for honeyconb.json file. + * We use guice-config library to load all the config attributes into this class instance. + * + * The BindConfig annotation tells that honeycomb.json file should be looked up on classpath root. + */ @ToString(includeNames = true) @BindConfig(value = "honeycomb", syntax = Syntax.JSON) class HoneycombConfiguration { @@ -56,7 +62,26 @@ class HoneycombConfiguration { Optional restconfHttpsBindingAddress @InjectConfig("restconf-https-port") Optional restconfHttpsPort - + /** + * Restconf keystore file name. + * It will be loaded from the classpath so must be present in one of the folders packaged with the distribution e.g. cert/ + */ + @InjectConfig("restconf-keystore") + Optional restconfKeystore = Optional.of("/honeycomb-keystore") + @InjectConfig("restconf-keystore-password") + Optional keystorePassword + @InjectConfig("restconf-keystore-manager-password") + Optional keystoreManagerPassword + /** + * Restconf truststore file name. + * It will be loaded from the classpath so must be present in one of the folders packaged with the distribution e.g. cert/ + */ + @InjectConfig("restconf-truststore") + Optional restconfTruststore + @InjectConfig("restconf-truststore-password") + Optional truststorePassword + + // This is the way for optional attributes with default values to work @InjectConfig("restconf-websocket-port") Optional restconfWebsocketPort = Optional.of(7779) @@ -81,11 +106,11 @@ class HoneycombConfiguration { boolean isRestconfHttpsEnabled() { Boolean.valueOf(restconfHttps) } boolean isRestconfEnabled() { isRestconfHttpEnabled() || isRestconfHttpsEnabled() } - // NETCONF + // HONEYCOMB_NETCONF @InjectConfig("netconf-netty-threads") Integer netconfNettyThreads - // NETCONF TCP + // HONEYCOMB_NETCONF TCP @InjectConfig("netconf-tcp-enabled") String netconfTcp @InjectConfig("netconf-tcp-binding-address") @@ -93,7 +118,7 @@ class HoneycombConfiguration { @InjectConfig("netconf-tcp-binding-port") Optional netconfTcpBindingPort - // NETCONF SSH + // HONEYCOMB_NETCONF SSH @InjectConfig("netconf-ssh-enabled") String netconfSsh @InjectConfig("netconf-ssh-binding-address") diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy index ede905d06..eb17cf36a 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ConfigAndOperationalPipelineModule.groovy @@ -38,6 +38,9 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree @Slf4j class ConfigAndOperationalPipelineModule extends PrivateModule { + public static final String HONEYCOMB_CONFIG_NONPERSIST = "honeycomb-config-nopersist" + public static final String HONEYCOMB_CONFIG = "honeycomb-config" + protected void configure() { // Expose registries for plugin reader/writer factories bind(ModifiableWriterRegistryBuilder).toProvider(WriterRegistryProvider).in(Singleton) @@ -45,43 +48,48 @@ class ConfigAndOperationalPipelineModule extends PrivateModule { bind(ModifiableReaderRegistryBuilder).toProvider(ReaderRegistryProvider).in(Singleton) expose(ModifiableReaderRegistryBuilder) - // Non persisting data tree + // Non persisting data tree for config bind(DataTree) - .annotatedWith(Names.named("honeycomb-config-nopersist")) + .annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) .toProvider(DataTreeProvider.ConfigDataTreeProvider) .in(Singleton) - expose(DataTree).annotatedWith(Names.named("honeycomb-config-nopersist")) - // Persisting data tree wrapper + expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONFIG_NONPERSIST)) + // Persisting data tree wrapper for config bind(DataTree) - .annotatedWith(Names.named("honeycomb-config")) + .annotatedWith(Names.named(HONEYCOMB_CONFIG)) .toProvider(PersistingDataTreeProvider.ConfigPersistingDataTreeProvider) .in(Singleton) - expose(DataTree).annotatedWith(Names.named("honeycomb-config")) + expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONFIG)) + // Config Data Tree manager working on top of config data tree + writer registry bind(ModifiableDataManager).toProvider(ModifiableDTDelegProvider).in(Singleton) + // Operational Data Tree manager working on top of reader registry bind(ReadableDataManager).toProvider(ReadableDTDelegProvider).in(Singleton) expose(ReadableDataManager) + // DOMDataBroker wrapper on top of data tree managers def domBrokerProvider = new HoneycombDOMDataBrokerProvider() -// bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(domBrokerProvider).in(Singleton) - // Bind also without annotation for easy private injection bind(DOMDataBroker).toProvider(domBrokerProvider).in(Singleton) - bind(DataBroker).annotatedWith(Names.named("honeycomb-config")).toProvider(BindingDataBrokerProvider).in(Singleton) - expose(DataBroker).annotatedWith(Names.named("honeycomb-config")) + // BA version of data broker + bind(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONFIG)).toProvider(BindingDataBrokerProvider).in(Singleton) + expose(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONFIG)) + // Create initializer to init persisted config data bind(DataTreeInitializer) - .annotatedWith(Names.named("honeycomb-config")) + .annotatedWith(Names.named(HONEYCOMB_CONFIG)) .toProvider(PersistedFileInitializerProvider.PersistedConfigInitializerProvider) .in(Singleton) - expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-config")) + expose(DataTreeInitializer).annotatedWith(Names.named(HONEYCOMB_CONFIG)) configureNotifications() } protected void configureNotifications() { + // Create notification service bind(DOMNotificationRouter).toProvider(DOMNotificationServiceProvider).in(Singleton) expose(DOMNotificationRouter) + // Wrap notification service, data broker and schema service in a Broker MD-SAL API bind(Broker).toProvider(HoneycombDOMBrokerProvider).in(Singleton) expose(Broker) } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy index 5dc98cded..dc620b445 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombDOMBrokerProvider.groovy @@ -31,7 +31,6 @@ import org.opendaylight.controller.sal.core.api.model.SchemaService class HoneycombDOMBrokerProvider extends ProviderTrait { @Inject -// @Named("honeycomb-config") DOMDataBroker domDataBroker @Inject SchemaService schemaService diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy index 473112341..b81a8d784 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/HoneycombNotificationManagerProvider.groovy @@ -28,9 +28,7 @@ import io.fd.honeycomb.notification.impl.NotificationProducerTracker import org.opendaylight.controller.md.sal.binding.impl.BindingDOMNotificationPublishServiceAdapter import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter -/** - * Mirror of org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.notification.impl.rev160601.HoneycombNotificationManagerModule - */ + @Slf4j @ToString class HoneycombNotificationManagerProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy index 6462baa71..a04f1a81c 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/InmemoryDOMDataBrokerProvider.groovy @@ -28,9 +28,7 @@ import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroke import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService import org.opendaylight.yangtools.util.concurrent.SpecialExecutors -/** - * Mirror of org.opendaylight.controller.config.yang.md.sal.dom.impl.DomInmemoryDataBrokerModule - */ + @Slf4j @ToString class InmemoryDOMDataBrokerProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy index f7ec4cc12..cd4d9c624 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/ModifiableDTDelegProvider.groovy @@ -23,6 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.ModifiableDataManager import io.fd.honeycomb.data.impl.ModifiableDataTreeDelegator import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec @@ -35,12 +36,12 @@ class ModifiableDTDelegProvider extends ProviderTrait { @Inject BindingToNormalizedNodeCodec serializer @Inject - @Named("honeycomb-config") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) DataTree dataTree @Inject ModifiableWriterRegistryBuilder registry @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy index 753963309..6c41ad69f 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/PersistingDataTreeProvider.groovy @@ -23,6 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.impl.PersistingDataTreeAdapter import io.fd.honeycomb.infra.distro.ProviderTrait import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import org.opendaylight.controller.sal.core.api.model.SchemaService import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType @@ -49,7 +50,7 @@ abstract class PersistingDataTreeProvider extends ProviderTrait { static class ConfigPersistingDataTreeProvider extends PersistingDataTreeProvider { @Inject - @Named("honeycomb-config-nopersist") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG_NONPERSIST) DataTree delegate String getPath() { config.peristConfigPath } @@ -60,7 +61,7 @@ abstract class PersistingDataTreeProvider extends ProviderTrait { static class ContextPersistingDataTreeProvider extends PersistingDataTreeProvider { @Inject - @Named("honeycomb-context-nopersist") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT_NOPERSIST) DataTree delegate String getPath() { config.peristContextPath } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy index 25244cb2f..a4cf73162 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/ContextPipelineModule.groovy @@ -32,44 +32,45 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree class ContextPipelineModule extends PrivateModule { - protected void configure() { - // Bind also without annotation for easy private injection + public static final String HONEYCOMB_CONTEXT_NOPERSIST = "honeycomb-context-nopersist" + public static final String HONEYCOMB_CONTEXT = "honeycomb-context" - // Non persisting data tree + protected void configure() { + // Non persisting data tree for context def noPersistDataTreeProvider = new DataTreeProvider.ContextDataTreeProvider() bind(DataTree) - .annotatedWith(Names.named("honeycomb-context-nopersist")) + .annotatedWith(Names.named(HONEYCOMB_CONTEXT_NOPERSIST)) .toProvider(noPersistDataTreeProvider) .in(Singleton) - expose(DataTree).annotatedWith(Names.named("honeycomb-context-nopersist")) - // Persisting data tree wrapper + expose(DataTree).annotatedWith(Names.named(HONEYCOMB_CONTEXT_NOPERSIST)) + // Persisting data tree wrapper for context def dataTreeProvider = new PersistingDataTreeProvider.ContextPersistingDataTreeProvider() bind(DataTree).toProvider(dataTreeProvider).in(Singleton) -// bind(DataTree).annotatedWith(Names.named("honeycomb-context")).toProvider(dataTreeProvider).in(Singleton) -// expose(DataTree).annotatedWith(Names.named("honeycomb-context")) + // Data Tree manager (without any delegation) on top of context data tree bind(ModifiableDataManager).toProvider(ModifiableDTMgrProvider).in(Singleton) + // DOMDataBroker interface on top of data tree manager def domBrokerProvider = new HoneycombContextDOMDataBrokerProvider() -// bind(DOMDataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(domBrokerProvider).in(Singleton) - // Bind also without annotation for easy private injection bind(DOMDataBroker).toProvider(domBrokerProvider).in(Singleton) -// expose(DOMDataBroker).annotatedWith(Names.named("honeycomb-context")) - bind(DataBroker).annotatedWith(Names.named("honeycomb-context")).toProvider(BindingDataBrokerProvider).in(Singleton) - expose(DataBroker).annotatedWith(Names.named("honeycomb-context")) + // BA version of data broker for context + bind(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONTEXT)).toProvider(BindingDataBrokerProvider).in(Singleton) + expose(DataBroker).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) + // Create initializer to init persisted config data bind(DataTreeInitializer) - .annotatedWith(Names.named("honeycomb-context")) + .annotatedWith(Names.named(HONEYCOMB_CONTEXT)) .toProvider(PersistedFileInitializerProvider.PersistedContextInitializerProvider) .in(Singleton) - expose(DataTreeInitializer).annotatedWith(Names.named("honeycomb-context")) + expose(DataTreeInitializer).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) + // Mapping context is just a small adapter on top of BA data broker to simplify CRUD of context data bind(MappingContext) - .annotatedWith(Names.named("honeycomb-context")) + .annotatedWith(Names.named(HONEYCOMB_CONTEXT)) .toProvider(RealtimeMappingContextProvider) .in(Singleton.class) - expose(MappingContext).annotatedWith(Names.named("honeycomb-context")) + expose(MappingContext).annotatedWith(Names.named(HONEYCOMB_CONTEXT)) } } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy index 3c7eebb3d..c6afd92fc 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/context/RealtimeMappingContextProvider.groovy @@ -30,7 +30,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker class RealtimeMappingContextProvider extends ProviderTrait { @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextDataBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy index 384278793..11eaf49a4 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/data/oper/ReadableDTDelegProvider.groovy @@ -23,6 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.ReadableDataManager import io.fd.honeycomb.data.impl.ReadableDataTreeDelegator import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec @@ -39,7 +40,7 @@ class ReadableDTDelegProvider extends ProviderTrait { @Inject ModifiableReaderRegistryBuilder registry @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextBroker def create() { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy index 10757c1a5..4bd197385 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerPipelineModule.groovy @@ -30,17 +30,24 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker @Slf4j class InitializerPipelineModule extends PrivateModule { + + public static final String HONEYCOMB_INITIALIZER = "honeycomb-initializer" + protected void configure() { + // Create data tree manager on top of non-persisting config data tree bind(ModifiableDataManager).toProvider(ModifiableDTDelegInitProvider).in(Singleton) + // Wrap as DOMDataBroker bind(DOMDataBroker).toProvider(HoneycombDOMDataBrokerProvider).in(Singleton) - bind(DataBroker).annotatedWith(Names.named("honeycomb-initializer")).toProvider(BindingDataBrokerProvider).in(Singleton) - expose(DataBroker).annotatedWith(Names.named("honeycomb-initializer")) + // Wrap as BA data broker + bind(DataBroker).annotatedWith(Names.named(HONEYCOMB_INITIALIZER)).toProvider(BindingDataBrokerProvider).in(Singleton) + expose(DataBroker).annotatedWith(Names.named(HONEYCOMB_INITIALIZER)) + // Create initializer registry so that plugins can provide their initializers bind(InitializerRegistry) - .annotatedWith(Names.named("honeycomb-initializer")) + .annotatedWith(Names.named(HONEYCOMB_INITIALIZER)) .toProvider(InitializerRegistryProvider) .in(Singleton) expose(InitializerRegistry) - .annotatedWith(Names.named("honeycomb-initializer")) + .annotatedWith(Names.named(HONEYCOMB_INITIALIZER)) } } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.groovy index 5f75fc026..6c90291b9 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/InitializerRegistryProvider.groovy @@ -24,16 +24,18 @@ import io.fd.honeycomb.data.init.DataTreeInitializer import io.fd.honeycomb.data.init.InitializerRegistry import io.fd.honeycomb.data.init.InitializerRegistryImpl import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule @Slf4j @ToString class InitializerRegistryProvider extends ProviderTrait { @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataTreeInitializer contextInitializer @Inject - @Named("honeycomb-config") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) DataTreeInitializer configInitializer @Inject(optional = true) Set pluginInitializers = [] diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy index 2a1422dae..4c132756e 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/ModifiableDTDelegInitProvider.groovy @@ -23,14 +23,13 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.data.ModifiableDataManager import io.fd.honeycomb.data.impl.ModifiableDataTreeDelegator import io.fd.honeycomb.infra.distro.ProviderTrait +import io.fd.honeycomb.infra.distro.data.ConfigAndOperationalPipelineModule +import io.fd.honeycomb.infra.distro.data.context.ContextPipelineModule import io.fd.honeycomb.translate.util.write.NoopWriterRegistry import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.md.sal.binding.impl.BindingToNormalizedNodeCodec import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree -/** - * Similar to ModifiableDTDelegProvider, but uses noop writer registry - */ @Slf4j @ToString class ModifiableDTDelegInitProvider extends ProviderTrait { @@ -38,10 +37,10 @@ class ModifiableDTDelegInitProvider extends ProviderTrait @Inject BindingToNormalizedNodeCodec serializer @Inject - @Named("honeycomb-config-nopersist") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG_NONPERSIST) DataTree dataTree @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataBroker contextBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy index 8979272be..bb7015e01 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/initializer/PersistedFileInitializerProvider.groovy @@ -19,7 +19,7 @@ package io.fd.honeycomb.infra.distro.initializer import com.google.inject.Inject import groovy.transform.ToString import groovy.util.logging.Slf4j -import io.fd.honeycomb.data.init.RestorationType + import io.fd.honeycomb.data.init.RestoringInitializer import io.fd.honeycomb.infra.distro.ProviderTrait import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration @@ -28,9 +28,7 @@ import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker import org.opendaylight.controller.sal.core.api.model.SchemaService import java.nio.file.Paths -/** - * Mirror of org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.data.initializer.rev160407.PersistedFileInitializerModule - */ + @Slf4j @ToString abstract class PersistedFileInitializerProvider extends ProviderTrait { @@ -46,7 +44,7 @@ abstract class PersistedFileInitializerProvider extends ProviderTrait { @@ -48,39 +46,37 @@ class HoneycombNotification2NetconfProvider extends ProviderTrait - log.debug "Propagating notification: {} into NETCONF", notif.type + log.debug "Propagating notification: {} into HONEYCOMB_NETCONF", notif.type netconfNotifReg.onNotification(streamType, TranslationUtil.notificationToXml(notif, schemaService.globalContext)) } // NotificationManager is used to provide list of available notifications (which are all of the notifications registered) - // TODO make available notifications configurable here so that any number of notification streams for NETCONF + // TODO make available notifications configurable here so that any number of notification streams for HONEYCOMB_NETCONF // can be configured on top of a single notification manager - log.debug "Current notifications to be exposed over NETCONF: {}", hcNotificationCollector.notificationTypes + log.debug "Current notifications to be exposed over HONEYCOMB_NETCONF: {}", hcNotificationCollector.notificationTypes def currentNotificationSchemaPaths = hcNotificationCollector.notificationTypes .collect {SchemaPath.create(true, NotificationProducerRegistry.getQName(it))} // Register as listener to HC'OPERATIONAL DOM notification service - // TODO This should only be triggered when NETCONF notifications are activated + // TODO This should only be triggered when HONEYCOMB_NETCONF notifications are activated // Because this way we actually start all notification producers // final Collection notificationQNames = def domNotifListenerReg = notificationRouter .registerNotificationListener(domNotificationListener, currentNotificationSchemaPaths); - log.info "Exposing NETCONF notification stream: {}", streamType.value + log.info "Exposing HONEYCOMB_NETCONF notification stream: {}", streamType.value new HoneycombNotification2Netconf(domNotifListenerReg: domNotifListenerReg, netconfNotifReg: netconfNotifReg) } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy index ebf6782c1..f1f49700e 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.groovy @@ -25,15 +25,12 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker import org.opendaylight.controller.sal.binding.api.BindingAwareBroker import io.fd.honeycomb.impl.FakeBindingAwareBroker -/** - * Mirror of {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.honeycomb.impl.rev141210.NetconfBindingBrokerModule} - */ @Slf4j @ToString class NetconfBindingBrokerProvider extends ProviderTrait { @Inject - @Named("netconf") + @Named(NetconfModule.HONEYCOMB_NETCONF) DataBroker dataBroker @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy index 491eedcef..dff5319b4 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.groovy @@ -26,9 +26,7 @@ import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener import org.opendaylight.netconf.mdsal.connector.MdsalNetconfOperationServiceFactory import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext -/** - * Mirror of org.opendaylight.controller.config.yang.netconf.mdsal.mapper.NetconfMdsalMapperModule - */ + @Slf4j @ToString class NetconfMdsalMapperProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy index e1f8901c7..29eeae301 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.groovy @@ -46,63 +46,77 @@ import static InmemoryDOMDataBrokerProvider.OPERATIONAL class NetconfModule extends PrivateModule { + + public static final String HONEYCOMB_NETCONF = "honeycomb-netconf" + public static final String HONEYCOMB_NETCONF_MAPPER_AGGR = "netconf-mapper-aggregator" + public static final String HONEYCOMB_NETCONF_MAPPER_NOTIF = "netconf-mapper-notification" + public static final String HONEYCOMB_NETCONF_MAPPER_CORE = "netconf-mapper-honeycomb" + public static final String HONEYCOMB_NETCONF_MAPPER_OPER = "netconf-mapper-monitoring" + @Override protected void configure() { + // Create inmemory data store for HONEYCOMB_NETCONF config metadata bind(InMemoryDOMDataStore) .annotatedWith(Names.named(CONFIG)) .toProvider(new DataStoreProvider(type: LogicalDatastoreType.CONFIGURATION, name: CONFIG)) .in(Singleton) + // Create inmemory data store for HONEYCOMB_NETCONF operational metadata bind(InMemoryDOMDataStore) .annotatedWith(Names.named(OPERATIONAL)) .toProvider(new DataStoreProvider(type: LogicalDatastoreType.OPERATIONAL, name: OPERATIONAL)) .in(Singleton) + // Wrap datastores as DOMDataBroker bind(DOMDataBroker).toProvider(InmemoryDOMDataBrokerProvider).in(Singleton) + // Wrap DOMDataBroker as BA data broker bind(DataBroker) - .annotatedWith(Names.named("netconf")) + .annotatedWith(Names.named(HONEYCOMB_NETCONF)) .toProvider(BindingDataBrokerProvider) .in(Singleton) - expose(DataBroker).annotatedWith(Names.named("netconf")) + expose(DataBroker).annotatedWith(Names.named(HONEYCOMB_NETCONF)) + + // Wrap BA data broker as BindingAwareBroker (requied by HONEYCOMB_NETCONF) bind(BindingAwareBroker) - .annotatedWith(Names.named("netconf")) + .annotatedWith(Names.named(HONEYCOMB_NETCONF)) .toProvider(NetconfBindingBrokerProvider) .in(Singleton) - // Mirror of org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfMapperAggregatorModule + // Create netconf operation service factory aggregator to aggregate different services def factory = new AggregatedNetconfOperationServiceFactory() bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named("netconf-mapper-aggregator")) + .annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_AGGR)) .toInstance(factory) bind(NetconfOperationServiceFactoryListener).toInstance(factory) - // Mirror of org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.NetconfNotificationManagerModule + // Create netconf notification manager def manager = new NetconfNotificationManager() bind(NetconfNotificationCollector).toInstance(manager) bind(NetconfNotificationRegistry).toInstance(manager) bind(NetconfNotificationListener).toInstance(manager) - // Netconf notification part + // Netconf notification service factory bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named("netconf-mapper-notification")) + .annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_NOTIF)) .toProvider(NetconfNotificationMapperProvider) .in(Singleton) - expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-notification")) + expose(NetconfOperationServiceFactory).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_NOTIF)) // Netconf core part - mapping between Honeycomb and Netconf bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named("netconf-mapper-honeycomb")) + .annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_CORE)) .toProvider(NetconfMdsalMapperProvider) .in(Singleton) - expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-honeycomb")) + expose(NetconfOperationServiceFactory).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_CORE)) - // Netconf monitoring part + // Netconf monitoring service factory bind(NetconfMonitoringService).toProvider(NetconfMonitoringServiceProvider).in(Singleton) bind(NetconfOperationServiceFactory) - .annotatedWith(Names.named("netconf-mapper-monitoring")) + .annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_OPER)) .toProvider(NetconfMonitoringMapperProvider) .in(Singleton) - expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-monitoring")) + expose(NetconfOperationServiceFactory).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_OPER)) + // Create HC notification manager + HC2Netconf translator bind(NotificationCollector).toProvider(HoneycombNotificationManagerProvider).in(Singleton) bind(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf) .toProvider(HoneycombNotification2NetconfProvider) @@ -112,6 +126,9 @@ class NetconfModule extends PrivateModule { configureServer() } + /** + * Provide HONEYCOMB_NETCONF TCP and SSH servers + */ def configureServer() { bind(NioEventLoopGroup).toProvider(NettyThreadGroupProvider).in(Singleton) bind(Timer).toProvider(NettyTimerProvider).in(Singleton) diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy index 15daa6c81..c35a97352 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.groovy @@ -27,15 +27,13 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener -/** - * Mirror of org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule - */ + @Slf4j @ToString class NetconfMonitoringMapperProvider extends ProviderTrait { @Inject - @Named("netconf") + @Named(NetconfModule.HONEYCOMB_NETCONF) BindingAwareBroker bindingAwareBroker @Inject NetconfOperationServiceFactoryListener aggregator diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy index 6c58f8b89..54a773a80 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.groovy @@ -30,7 +30,7 @@ import io.fd.honeycomb.impl.NetconfMonitoringReaderFactory class NetconfMonitoringReaderFactoryProvider extends ProviderTrait { @Inject - @Named("netconf") + @Named(NetconfModule.HONEYCOMB_NETCONF) DataBroker netconfDataBroker def create() { new NetconfMonitoringReaderFactory(netconfDataBroker) } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy index 4592cf4bd..cac2a13cc 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.groovy @@ -24,15 +24,13 @@ import io.fd.honeycomb.infra.distro.ProviderTrait import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService import org.opendaylight.netconf.impl.osgi.NetconfMonitoringServiceImpl import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory -/** - * Mirror of org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfServerMonitoringModule - */ + @Slf4j @ToString class NetconfMonitoringServiceProvider extends ProviderTrait { @Inject - @Named("netconf-mapper-aggregator") + @Named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_AGGR) NetconfOperationServiceFactory aggregator @Override diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy index 02739290f..74b384317 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.groovy @@ -35,9 +35,7 @@ import org.opendaylight.netconf.notifications.NetconfNotificationRegistry import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.NetconfState import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.monitoring.rev101004.netconf.state.Capabilities import org.opendaylight.yangtools.yang.binding.InstanceIdentifier -/** - * Mirror of org.opendaylight.controller.config.yang.netconf.mdsal.notification.NetconfMdsalNotificationMapperModule - */ + @Slf4j @ToString class NetconfNotificationMapperProvider extends ProviderTrait { @@ -50,10 +48,10 @@ class NetconfNotificationMapperProvider extends ProviderTrait { @Inject - @Named("netconf") + @Named(NetconfModule.HONEYCOMB_NETCONF) DataBroker netconfDataBroker def create() { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.groovy index 91a280857..917eceeac 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.groovy @@ -28,6 +28,7 @@ class NetconfReadersModule extends AbstractModule { protected void configure() { // This should be part of NetconfModule, but that one is Private and Multibinders + private BASE_MODULES // do not work together, that's why there's a dedicated module here + // https://github.com/google/guice/issues/906 Multibinder.newSetBinder(binder(), ReaderFactory.class).with { addBinding().toProvider(NetconfMonitoringReaderFactoryProvider).in(Singleton) addBinding().toProvider(NetconfNotificationsReaderFactoryProvider).in(Singleton) diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy index 18019db57..10388f9c4 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.groovy @@ -32,9 +32,7 @@ import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFacto import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory import java.util.concurrent.TimeUnit -/** - * Mirror of org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfServerDispatcherModule - */ + @Slf4j @ToString class NetconfServerDispatcherProvider extends ProviderTrait { @@ -43,7 +41,7 @@ class NetconfServerDispatcherProvider extends ProviderTrait { @@ -48,7 +46,6 @@ class NetconfSshServerProvider extends ProviderTrait { @Inject NioEventLoopGroup nettyThreadgroup - // TODO merge with other executors .. one of the brokers creates also 2 internal executors private ScheduledExecutorService pool = Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("netconf-ssh-%d").build()) diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.groovy index c4e3523d0..1b0800207 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.groovy @@ -24,9 +24,7 @@ import io.fd.honeycomb.infra.distro.ProviderTrait import io.netty.channel.ChannelFuture import io.netty.util.concurrent.GenericFutureListener import org.opendaylight.netconf.api.NetconfServerDispatcher -/** - * Mirror of org.opendaylight.controller.config.yang.netconf.northbound.tcp.NetconfNorthboundTcpModule - */ + @Slf4j @ToString class NetconfTcpServerProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.groovy index bff8e3d8e..90948647d 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.groovy @@ -23,9 +23,7 @@ import groovy.util.logging.Slf4j import io.fd.honeycomb.infra.distro.ProviderTrait import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.netty.channel.nio.NioEventLoopGroup -/** - * Mirror of org.opendaylight.controller.config.yang.netty.threadgroup.NettyThreadgroupModule - */ + @Slf4j @ToString class NettyThreadGroupProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyTimerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyTimerProvider.groovy index 347417bd2..e889633ed 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyTimerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyTimerProvider.groovy @@ -23,9 +23,7 @@ import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration import io.fd.honeycomb.infra.distro.ProviderTrait import io.netty.util.HashedWheelTimer import io.netty.util.Timer -/** - * Mirror of org.opendaylight.controller.config.yang.netty.timer.HashedWheelTimerModule - */ + @Slf4j @ToString class NettyTimerProvider extends ProviderTrait { diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.groovy index 6ce5a1555..388aa2bbe 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/HttpsConnectorProvider.groovy @@ -11,9 +11,6 @@ import org.eclipse.jetty.util.ssl.SslContextFactory class HttpsConnectorProvider extends ProviderTrait { - public static final String KEYSTORE_PASSWORD = "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u" - public static final String KEYSTORE_NAME = "/honeycomb-keystore" - @Inject HoneycombConfiguration cfg @Inject @@ -32,12 +29,14 @@ class HttpsConnectorProvider extends ProviderTrait { // openssl pkcs12 -inkey honeycomb.key -in honeycomb.crt -export -out honeycomb.pkcs12 // keytool -importkeystore -srckeystore honeycomb.pkcs12 -srcstoretype PKCS12 -destkeystore honeycomb-keystore def sslContextFactory = new SslContextFactory() - def keystoreURL = getClass().getResource(KEYSTORE_NAME) + def keystoreURL = getClass().getResource(cfg.restconfKeystore.get()) sslContextFactory.setKeyStorePath(keystoreURL.path) - sslContextFactory.setKeyStorePassword(KEYSTORE_PASSWORD) - sslContextFactory.setKeyManagerPassword(KEYSTORE_PASSWORD) - sslContextFactory.setTrustStorePath(keystoreURL.path) - sslContextFactory.setTrustStorePassword(KEYSTORE_PASSWORD) + sslContextFactory.setKeyStorePassword(cfg.keystorePassword.get()) + sslContextFactory.setKeyManagerPassword((cfg.keystoreManagerPassword.get())) + def truststoreURL = getClass().getResource(cfg.restconfTruststore.get()) + sslContextFactory.setTrustStorePath(truststoreURL.path) + sslContextFactory.setTrustStorePassword((cfg.truststorePassword.get())) + // TODO make this more configurable sslContextFactory.setExcludeCipherSuites( "SSL_RSA_WITH_DES_CBC_SHA", "SSL_DHE_RSA_WITH_DES_CBC_SHA", diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.groovy index ff6c300ea..14e6ae6f2 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/JettyServerProvider.groovy @@ -46,7 +46,6 @@ class JettyServerProvider extends ProviderTrait { // Load Realm for basic auth def service = new HashLoginService(REALM) // Reusing the name as role - // TODO make this more configurable service.putUser(cfg.username, new Password(cfg.password), cfg.username) server.addBean(service) diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.groovy index 4a66a1c3c..e8594a8c3 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/restconf/RestconfModule.groovy @@ -27,10 +27,13 @@ import org.opendaylight.netconf.sal.rest.api.RestConnector @Slf4j class RestconfModule extends AbstractModule { + public static final String RESTCONF_HTTP = "restconf-http" + public static final String RESTCONF_HTTPS = "restconf-https" + protected void configure() { bind(Server).toProvider(JettyServerProvider).in(Singleton) - bind(ServerConnector).annotatedWith(Names.named("restconf-http")).toProvider(HttpConnectorProvider).in(Singleton) - bind(ServerConnector).annotatedWith(Names.named("restconf-https")).toProvider(HttpsConnectorProvider).in(Singleton) + bind(ServerConnector).annotatedWith(Names.named(RESTCONF_HTTP)).toProvider(HttpConnectorProvider).in(Singleton) + bind(ServerConnector).annotatedWith(Names.named(RESTCONF_HTTPS)).toProvider(HttpsConnectorProvider).in(Singleton) bind(RestConnector).toProvider(RestconfProvider).in(Singleton) } } diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy index 3ea4bcaa6..d8c4e3927 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/schema/YangBindingProviderModule.groovy @@ -22,6 +22,7 @@ import com.google.inject.Singleton import com.google.inject.multibindings.Multibinder import groovy.util.logging.Slf4j import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider + /** * Load all YangModelBindingProvider classes from classpath. *

diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/cert/honeycomb.pkcs12 b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/cert/honeycomb.pkcs12 deleted file mode 100644 index e2f4fdd82..000000000 Binary files a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/cert/honeycomb.pkcs12 and /dev/null differ diff --git a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json index ba54695de..3791cc248 100644 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json +++ b/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json @@ -6,13 +6,18 @@ "notification-service-queue-depth": 1, - "restconf-http-enabled": "false", + "restconf-http-enabled": "true", "restconf-root-path": "/restconf", "restconf-binding-address": "127.0.0.1", "restconf-port": 8181, - "restconf-https-enabled": "false", + "restconf-https-enabled": "true", "restconf-https-binding-address": "0.0.0.0", "restconf-https-port": 8443, + "restconf-keystore": "/honeycomb-keystore", + "restconf-keystore-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", + "restconf-keystore-manager-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", + "restconf-truststore": "/honeycomb-keystore", + "restconf-truststore-password": "OBF:1v9s1unr1unn1vv51zlk1t331vg91x1b1vgl1t331zly1vu51uob1uo71v8u", "restconf-websocket-port": 7779, "restconf-pool-max-size": 10, "restconf-pool-min-size": 1, @@ -25,7 +30,7 @@ "netconf-tcp-enabled" : "true", "netconf-tcp-binding-address": "127.0.0.1", "netconf-tcp-binding-port": 7777, - "netconf-ssh-enabled" : "false", + "netconf-ssh-enabled" : "true", "netconf-ssh-binding-address": "0.0.0.0", "netconf-ssh-binding-port": 2831, "netconf-notification-stream-name": "honeycomb", -- cgit 1.2.3-korg