diff options
Diffstat (limited to 'infra')
39 files changed, 201 insertions, 178 deletions
diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestorationType.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestorationType.java deleted file mode 100644 index 51b1d8bbe..000000000 --- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestorationType.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2016 Cisco and/or its affiliates. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package io.fd.honeycomb.data.init; - -/** - * Type of operation to use when writing restored data - */ -public enum RestorationType { - Put, Merge -} diff --git a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java index 2f3f7c99e..c4033a98c 100644 --- a/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java +++ b/infra/cfg-init/src/main/java/io/fd/honeycomb/data/init/RestoringInitializer.java @@ -108,4 +108,11 @@ public class RestoringInitializer implements DataTreeInitializer { @Override public void close() {} + + /** + * Type of operation to use when writing restored data + */ + public static enum RestorationType { + Put, Merge + } } 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<String> restconfHttpsBindingAddress @InjectConfig("restconf-https-port") Optional<Integer> 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<String> restconfKeystore = Optional.of("/honeycomb-keystore") + @InjectConfig("restconf-keystore-password") + Optional<String> keystorePassword + @InjectConfig("restconf-keystore-manager-password") + Optional<String> 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<String> restconfTruststore + @InjectConfig("restconf-truststore-password") + Optional<String> truststorePassword + + // This is the way for optional attributes with default values to work @InjectConfig("restconf-websocket-port") Optional<Integer> 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<Integer> 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<Broker> { @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<NotificationCollector> { 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<DOMDataBroker> { 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<ModifiableDataManager> { @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<DataTree> { 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<DataTree> { 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<MappingContext> { @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<ReadableDataManager> { @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<InitializerRegistry> { @Inject - @Named("honeycomb-context") + @Named(ContextPipelineModule.HONEYCOMB_CONTEXT) DataTreeInitializer contextInitializer @Inject - @Named("honeycomb-config") + @Named(ConfigAndOperationalPipelineModule.HONEYCOMB_CONFIG) DataTreeInitializer configInitializer @Inject(optional = true) Set<DataTreeInitializer> 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<ModifiableDataManager> { @@ -38,10 +37,10 @@ class ModifiableDTDelegInitProvider extends ProviderTrait<ModifiableDataManager> @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<RestoringInitializer> { @@ -46,7 +44,7 @@ abstract class PersistedFileInitializerProvider extends ProviderTrait<RestoringI @Override def create() { new RestoringInitializer(schemaService, Paths.get(getPersistPath()), - domDataBroker, RestorationType.valueOf(restorationType), getDataStoreType()) + domDataBroker, RestoringInitializer.RestorationType.valueOf(restorationType), getDataStoreType()) } abstract String getPersistPath() diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy index f8c9aaae3..f3ced2e3f 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.groovy @@ -30,9 +30,7 @@ import io.fd.honeycomb.notification.impl.TranslationUtil import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.netconf.streams.StreamBuilder import org.opendaylight.yangtools.yang.model.api.SchemaPath -/** - * Mirror of org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.notification.impl.rev160601.HoneycombNotificationToNetconfTranslatorModule - */ + @Slf4j @ToString class HoneycombNotification2NetconfProvider extends ProviderTrait<HoneycombNotification2Netconf> { @@ -48,39 +46,37 @@ class HoneycombNotification2NetconfProvider extends ProviderTrait<HoneycombNotif @Inject NetconfNotificationCollector netconfNotificationCollector - // TODO refactor HoneycombNotificationToNetconfTranslatorModule for easier reuse here - @Override def create() { def streamType = new StreamNameType(cfgAttributes.netconfNotificationStreamName.get()); - // Register as NETCONF notification publisher under configured name + // Register as HONEYCOMB_NETCONF notification publisher under configured name def netconfNotifReg = netconfNotificationCollector.registerNotificationPublisher(new StreamBuilder() .setName(streamType) .setReplaySupport(false) .setDescription(cfgAttributes.netconfNotificationStreamName.get()).build()); - // Notification Translator, get notification from HC producers and put into NETCONF notification collector + // Notification Translator, get notification from HC producers and put into HONEYCOMB_NETCONF notification collector def domNotificationListener = { notif -> - 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<QName> 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<BindingAwareBroker> { @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<NetconfOperationServiceFactory> { 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<NetconfOperationServiceFactory> { @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<ReaderFactory> { @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<NetconfMonitoringService> { @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<NetconfOperationServiceFactory> { @@ -50,10 +48,10 @@ class NetconfNotificationMapperProvider extends ProviderTrait<NetconfOperationSe @Inject NetconfNotificationRegistry notificationRegistry @Inject - @Named("netconf") + @Named(NetconfModule.HONEYCOMB_NETCONF) BindingAwareBroker bindingAwareBroker @Inject - @Named("netconf") + @Named(NetconfModule.HONEYCOMB_NETCONF) DataBroker dataBroker @Inject NetconfOperationServiceFactoryListener aggregator diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy index 2db186299..c714cdd14 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.groovy @@ -32,13 +32,12 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier import javax.annotation.Nonnull -// TODO backport to karaf distro @Slf4j @ToString class NetconfNotificationsReaderFactoryProvider extends ProviderTrait<ReaderFactory> { @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<NetconfServerDispatcher> { @@ -43,7 +41,7 @@ class NetconfServerDispatcherProvider extends ProviderTrait<NetconfServerDispatc private static final long CONNECTION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20) @Inject - @Named("netconf-mapper-aggregator") + @Named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_AGGR) NetconfOperationServiceFactory aggregator @Inject NetconfMonitoringService monitoringService diff --git a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.groovy b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.groovy index 8b1b5bec2..55daca23d 100644 --- a/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.groovy +++ b/infra/minimal-distribution/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.groovy @@ -34,9 +34,7 @@ import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder import java.util.concurrent.Executors import java.util.concurrent.ScheduledExecutorService -/** - * Mirror of org.opendaylight.controller.config.yang.netconf.northbound.ssh.NetconfNorthboundSshModule - */ + @Slf4j @ToString class NetconfSshServerProvider extends ProviderTrait<NetconfSshServer> { @@ -48,7 +46,6 @@ class NetconfSshServerProvider extends ProviderTrait<NetconfSshServer> { @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<NetconfTcpServer> { 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<NioEventLoopGroup> { 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<Timer> { 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<ServerConnector> { - 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<ServerConnector> { // 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<Server> { // 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. * <p/> 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 Binary files differdeleted file mode 100644 index e2f4fdd82..000000000 --- a/infra/minimal-distribution/src/main/resources/honeycomb-minimal-resources/cert/honeycomb.pkcs12 +++ /dev/null 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", |