diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2017-07-11 17:56:04 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2017-07-14 12:20:49 +0000 |
commit | 7d22608d89d8ff8c32e72d15039f1f27b7d659a8 (patch) | |
tree | a189335e86d6321b3fd3ba708f3c686ef1b2c566 /infra/minimal-distribution-core | |
parent | b65cd89989ead7082089bf6f333e56b03f619606 (diff) |
HONEYCOMB-360 - Netconf Northbound Intefaces provider separation
- Netconf configuration included under netconf.json
Change-Id: If2a51d689e9bfc950da73f15a438277839140f8a
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'infra/minimal-distribution-core')
17 files changed, 26 insertions, 1150 deletions
diff --git a/infra/minimal-distribution-core/pom.xml b/infra/minimal-distribution-core/pom.xml index 646d93ff3..4e74dc481 100644 --- a/infra/minimal-distribution-core/pom.xml +++ b/infra/minimal-distribution-core/pom.xml @@ -64,37 +64,8 @@ <groupId>org.opendaylight.controller</groupId> <artifactId>sal-core-api</artifactId> </dependency> - <!-- ODL-Netconf --> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>netconf-impl</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>netconf-ssh</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>mdsal-netconf-notification</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>mdsal-netconf-monitoring</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>mdsal-netconf-connector</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>ietf-netconf-monitoring</artifactId> - </dependency> - <dependency> - <groupId>org.opendaylight.netconf</groupId> - <artifactId>ietf-netconf-monitoring-extension</artifactId> - </dependency> - <!-- Used by mdsal as provided/runtime dependency--> + <!-- OSGI Even tough not running in OSGI, dependency needs to be here since some deprecated MD-SAL APIs rely on osgi core --> <dependency> <groupId>org.osgi</groupId> @@ -108,26 +79,41 @@ <artifactId>common</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>io.fd.honeycomb.northbound</groupId> + <artifactId>restconf</artifactId> + <version>${project.version}</version> + </dependency> <!-- HC --> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>data-impl</artifactId> + <groupId>io.fd.honeycomb</groupId> + <artifactId>cfg-init</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>honeycomb-impl</artifactId> + <groupId>io.fd.honeycomb</groupId> + <artifactId>notification-api</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>notification-impl</artifactId> + <groupId>io.fd.honeycomb</groupId> + <artifactId>rpc-impl</artifactId> <version>${project.version}</version> </dependency> <dependency> - <groupId>${project.groupId}</groupId> - <artifactId>rpc-impl</artifactId> + <groupId>io.fd.honeycomb</groupId> + <artifactId>data-impl</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.fd.honeycomb</groupId> + <artifactId>honeycomb-impl</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>io.fd.honeycomb</groupId> + <artifactId>notification-impl</artifactId> <version>${project.version}</version> </dependency> diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java index 392248771..cccbe8e06 100644 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java +++ b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/cfgattrs/HoneycombConfiguration.java @@ -31,18 +31,6 @@ import net.jmob.guice.conf.core.Syntax; @BindConfig(value = "honeycomb", syntax = Syntax.JSON) public class HoneycombConfiguration { - public boolean isNetconfTcpEnabled() { - return Boolean.valueOf(netconfTcp); - } - - public boolean isNetconfSshEnabled() { - return Boolean.valueOf(netconfSsh); - } - - public boolean isNetconfEnabled() { - return isNetconfTcpEnabled() || isNetconfSshEnabled(); - } - public boolean isConfigPersistenceEnabled() { return persistConfig.isPresent() && Boolean.valueOf(persistConfig.get()); } @@ -65,23 +53,6 @@ public class HoneycombConfiguration { @InjectConfig("notification-service-queue-depth") public int notificationServiceQueueDepth; - @InjectConfig("netconf-netty-threads") - public Integer netconfNettyThreads; - @InjectConfig("netconf-tcp-enabled") - public String netconfTcp; - @InjectConfig("netconf-tcp-binding-address") - public Optional<String> netconfTcpBindingAddress; - @InjectConfig("netconf-tcp-binding-port") - public Optional<Integer> netconfTcpBindingPort; - @InjectConfig("netconf-ssh-enabled") - public String netconfSsh; - @InjectConfig("netconf-ssh-binding-address") - public Optional<String> netconfSshBindingAddress; - @InjectConfig("netconf-ssh-binding-port") - public Optional<Integer> netconfSshBindingPort; - @InjectConfig("netconf-notification-stream-name") - public Optional<String> netconfNotificationStreamName = Optional.of("honeycomb"); - @Override public String toString() { return MoreObjects.toStringHelper(this) @@ -90,14 +61,6 @@ public class HoneycombConfiguration { .add("peristConfigPath", peristConfigPath) .add("persistedConfigRestorationType", persistedConfigRestorationType) .add("notificationServiceQueueDepth", notificationServiceQueueDepth) - .add("netconfNettyThreads", netconfNettyThreads) - .add("netconfTcp", netconfTcp) - .add("netconfTcpBindingAddress", netconfTcpBindingAddress) - .add("netconfTcpBindingPort", netconfTcpBindingPort) - .add("netconfSsh", netconfSsh) - .add("netconfSshBindingAddress", netconfSshBindingAddress) - .add("netconfSshBindingPort", netconfSshBindingPort) - .add("netconfNotificationStreamName", netconfNotificationStreamName) .toString(); } } diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java deleted file mode 100644 index 49872ea67..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/HoneycombNotification2NetconfProvider.java +++ /dev/null @@ -1,130 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import io.fd.honeycomb.notification.NotificationCollector; -import io.fd.honeycomb.notification.impl.NotificationProducerRegistry; -import io.fd.honeycomb.notification.impl.TranslationUtil; -import java.util.List; -import java.util.stream.Collectors; -import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.dom.api.DOMNotification; -import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener; -import org.opendaylight.controller.md.sal.dom.broker.impl.DOMNotificationRouter; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -import org.opendaylight.netconf.notifications.NetconfNotificationCollector; -import org.opendaylight.netconf.notifications.NotificationPublisherRegistration; -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.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.model.api.SchemaPath; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class HoneycombNotification2NetconfProvider - extends ProviderTrait<HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf> { - - private static final Logger LOG = LoggerFactory.getLogger(HoneycombNotification2NetconfProvider.class); - - @Inject - private DOMNotificationRouter notificationRouter; - @Inject - private SchemaService schemaService; - @Inject - private HoneycombConfiguration cfgAttributes; - @Inject - private NotificationCollector hcNotificationCollector; - @Inject - private NetconfNotificationCollector netconfNotificationCollector; - - @Override - protected HoneycombNotification2Netconf create() { - final StreamNameType streamType = new StreamNameType(cfgAttributes.netconfNotificationStreamName.get()); - - // Register as HONEYCOMB_NETCONF notification publisher under configured name - final NotificationPublisherRegistration netconfNotifReg = netconfNotificationCollector - .registerNotificationPublisher(new StreamBuilder().setName(streamType).setReplaySupport(false) - .setDescription(cfgAttributes.netconfNotificationStreamName.get()).build()); - - // Notification Translator, get notification from HC producers and put into HONEYCOMB_NETCONF notification collector - final DOMNotificationListener domNotificationListener = - new TranslatingNotificationListener(netconfNotifReg, streamType, schemaService); - - // NotificationManager is used to provide list of available notifications (which are all of the notifications registered) - // TODO HONEYCOMB-165 make available notifications configurable here so that any number of notification streams for netconf - // can be configured on top of a single notification manager - LOG.debug("Current notifications to be exposed over HONEYCOMB_NETCONF: {}", - hcNotificationCollector.getNotificationTypes()); - List<SchemaPath> currentNotificationSchemaPaths = hcNotificationCollector.getNotificationTypes().stream() - .map(notifType -> SchemaPath.create(true, NotificationProducerRegistry.getQName(notifType))) - .collect(Collectors.toList()); - - // Register as listener to HC'OPERATIONAL DOM notification service - // TODO HONEYCOMB-166 This should only be triggered when HONEYCOMB_NETCONF notifications are activated - // Because this way we actually start all notification producers - // final Collection<QName> notificationQNames = - ListenerRegistration<DOMNotificationListener> domNotifListenerReg = notificationRouter - .registerNotificationListener(domNotificationListener, currentNotificationSchemaPaths); - - LOG.info("Exposing HONEYCOMB_NETCONF notification stream: {}", streamType.getValue()); - return new HoneycombNotification2Netconf(domNotifListenerReg, netconfNotifReg); - } - - public static final class HoneycombNotification2Netconf { - private final ListenerRegistration<DOMNotificationListener> domNotifListenerReg; - private final NotificationPublisherRegistration netconfNotifReg; - - public HoneycombNotification2Netconf(final ListenerRegistration<DOMNotificationListener> domNotifListenerReg, - final NotificationPublisherRegistration netconfNotifReg) { - this.domNotifListenerReg = domNotifListenerReg; - this.netconfNotifReg = netconfNotifReg; - } - - public ListenerRegistration<DOMNotificationListener> getDomNotifListenerReg() { - return domNotifListenerReg; - } - - public NotificationPublisherRegistration getNetconfNotifReg() { - return netconfNotifReg; - } - } - - private static final class TranslatingNotificationListener implements DOMNotificationListener { - - private static final Logger LOG = LoggerFactory.getLogger(TranslatingNotificationListener.class); - - private final NotificationPublisherRegistration netconfNotifReg; - private final StreamNameType streamType; - private final SchemaService schemaService; - - TranslatingNotificationListener(final NotificationPublisherRegistration netconfNotifReg, - final StreamNameType streamType, final SchemaService schemaService) { - this.netconfNotifReg = netconfNotifReg; - this.streamType = streamType; - this.schemaService = schemaService; - } - - @Override - public void onNotification(@Nonnull final DOMNotification notif) { - LOG.debug("Propagating notification: {} into HONEYCOMB_NETCONF", notif.getType()); - netconfNotifReg.onNotification(streamType, TranslationUtil.notificationToXml(notif, schemaService.getGlobalContext())); - } - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.java deleted file mode 100644 index 0ca25f635..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfBindingBrokerProvider.java +++ /dev/null @@ -1,36 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.impl.FakeBindingAwareBroker; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; - -public final class NetconfBindingBrokerProvider extends ProviderTrait<BindingAwareBroker> { - - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF) - private DataBroker dataBroker; - - @Override - protected FakeBindingAwareBroker create() { - return new FakeBindingAwareBroker(dataBroker); - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.java deleted file mode 100644 index 0cb68ba23..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMdsalMapperProvider.java +++ /dev/null @@ -1,47 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import org.opendaylight.controller.sal.core.api.Broker; -import org.opendaylight.controller.sal.core.api.model.SchemaService; -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; - -public final class NetconfMdsalMapperProvider extends ProviderTrait<NetconfOperationServiceFactory> { - - @Inject - private SchemaService schemaService; - @Inject - private NetconfOperationServiceFactoryListener aggregator; - @Inject - private ModuleInfoBackedContext moduleInfoBackedContext; - @Inject - private Broker domBroker; - - @Override - protected MdsalNetconfOperationServiceFactory create() { - MdsalNetconfOperationServiceFactory mdsalNetconfOperationServiceFactory = - new MdsalNetconfOperationServiceFactory(schemaService, moduleInfoBackedContext); - domBroker.registerConsumer(mdsalNetconfOperationServiceFactory); - aggregator.onAddNetconfOperationServiceFactory(mdsalNetconfOperationServiceFactory); - return mdsalNetconfOperationServiceFactory; - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java deleted file mode 100644 index f3fddf36b..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfModule.java +++ /dev/null @@ -1,131 +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.infra.distro.netconf; - -import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.CONFIG; -import static io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider.OPERATIONAL; - -import com.google.inject.PrivateModule; -import com.google.inject.Singleton; -import com.google.inject.binder.AnnotatedElementBuilder; -import com.google.inject.name.Names; -import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider; -import io.fd.honeycomb.infra.distro.data.DataStoreProvider; -import io.fd.honeycomb.infra.distro.data.HoneycombNotificationManagerProvider; -import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider; -import io.fd.honeycomb.notification.NotificationCollector; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.HashedWheelTimer; -import io.netty.util.Timer; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; -import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.netconf.api.NetconfServerDispatcher; -import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService; -import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; -import org.opendaylight.netconf.notifications.NetconfNotificationCollector; -import org.opendaylight.netconf.notifications.NetconfNotificationListener; -import org.opendaylight.netconf.notifications.NetconfNotificationRegistry; -import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager; - -public 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.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.CONFIG)) - .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.CONFIG, LogicalDatastoreType.CONFIGURATION)) - .in(Singleton.class); - - // Create inmemory data store for HONEYCOMB_NETCONF operational metadata - bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.OPERATIONAL)) - .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.OPERATIONAL, LogicalDatastoreType.OPERATIONAL)) - .in(Singleton.class); - // Wrap datastores as DOMDataBroker - bind(DOMDataBroker.class).toProvider(InmemoryDOMDataBrokerProvider.class).in(Singleton.class); - - // Wrap DOMDataBroker as BA data broker - bind(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_NETCONF)).toProvider(BindingDataBrokerProvider.class) - .in(Singleton.class); - expose(DataBroker.class).annotatedWith(Names.named(HONEYCOMB_NETCONF)); - - // Wrap BA data broker as BindingAwareBroker (requied by HONEYCOMB_NETCONF) - bind(BindingAwareBroker.class).annotatedWith(Names.named(HONEYCOMB_NETCONF)) - .toProvider(NetconfBindingBrokerProvider.class).in(Singleton.class); - - // Create netconf operation service factory aggregator to aggregate different services - AggregatedNetconfOperationServiceFactory factory = new AggregatedNetconfOperationServiceFactory(); - bind(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_AGGR)) - .toInstance(factory); - bind(NetconfOperationServiceFactoryListener.class).toInstance(factory); - - // Create netconf notification manager - NetconfNotificationManager manager = new NetconfNotificationManager(); - bind(NetconfNotificationCollector.class).toInstance(manager); - bind(NetconfNotificationRegistry.class).toInstance(manager); - bind(NetconfNotificationListener.class).toInstance(manager); - - // Netconf notification service factory - bind(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_NOTIF)) - .toProvider(NetconfNotificationMapperProvider.class).in(Singleton.class); - expose(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_NOTIF)); - - // Netconf core part - mapping between Honeycomb and Netconf - bind(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_CORE)) - .toProvider(NetconfMdsalMapperProvider.class).in(Singleton.class); - expose(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_CORE)); - - // Netconf monitoring service factory - bind(NetconfMonitoringService.class).toProvider(NetconfMonitoringServiceProvider.class).in(Singleton.class); - bind(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_OPER)) - .toProvider(NetconfMonitoringMapperProvider.class).in(Singleton.class); - expose(NetconfOperationServiceFactory.class).annotatedWith(Names.named(HONEYCOMB_NETCONF_MAPPER_OPER)); - - // Create HC notification manager + HC2Netconf translator - bind(NotificationCollector.class).toProvider(HoneycombNotificationManagerProvider.class).in(Singleton.class); - bind(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class) - .toProvider(HoneycombNotification2NetconfProvider.class).in(Singleton.class); - expose(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf.class); - - configureServer(); - } - - /** - * Provide HONEYCOMB_NETCONF TCP and SSH servers. - */ - private AnnotatedElementBuilder configureServer() { - bind(NioEventLoopGroup.class).toProvider(NettyThreadGroupProvider.class).in(Singleton.class); - bind(Timer.class).toInstance(new HashedWheelTimer()); - bind(NetconfServerDispatcher.class).toProvider(NetconfServerDispatcherProvider.class).in(Singleton.class); - bind(NetconfTcpServerProvider.NetconfTcpServer.class).toProvider(NetconfTcpServerProvider.class) - .in(Singleton.class); - expose(NetconfTcpServerProvider.NetconfTcpServer.class); - bind(NetconfSshServerProvider.NetconfSshServer.class).toProvider(NetconfSshServerProvider.class) - .in(Singleton.class); - return expose(NetconfSshServerProvider.NetconfSshServer.class); - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.java deleted file mode 100644 index 9169409d2..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringMapperProvider.java +++ /dev/null @@ -1,83 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import java.lang.reflect.Constructor; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService; -import org.opendaylight.netconf.mapping.api.NetconfOperationService; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public final class NetconfMonitoringMapperProvider extends ProviderTrait<NetconfOperationServiceFactory> { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfMonitoringMapperProvider.class); - - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF) - private BindingAwareBroker bindingAwareBroker; - @Inject - private NetconfOperationServiceFactoryListener aggregator; - @Inject - private NetconfMonitoringService monitoringService; - - @Override - protected NetconfOperationServiceFactory create() { - try { - final Class<?> monitoringWriterCls = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.MonitoringToMdsalWriter"); - Constructor<?> declaredConstructor = - monitoringWriterCls.getDeclaredConstructor(NetconfMonitoringService.class); - declaredConstructor.setAccessible(true); - final BindingAwareProvider writer = (BindingAwareProvider) declaredConstructor.newInstance(monitoringService); - bindingAwareBroker.registerProvider(writer); - - final Class<?> moduleClass = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule"); - final Class<?> monitoringMapperCls = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule$MdsalMonitoringMapper"); - declaredConstructor = - monitoringMapperCls.getDeclaredConstructor(NetconfMonitoringService.class); - declaredConstructor.setAccessible(true); - final NetconfOperationService mdSalMonitoringMapper = - (NetconfOperationService) declaredConstructor.newInstance(monitoringService); - - final Class<?> monitoringMpperFactory = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.monitoring.NetconfMdsalMonitoringMapperModule$MdSalMonitoringMapperFactory"); - declaredConstructor = - monitoringMpperFactory.getDeclaredConstructor(NetconfOperationService.class, moduleClass, monitoringWriterCls); - declaredConstructor.setAccessible(true); - // The second argument is null, it should be the parent cfg-subsystem module class instance, that we dont have - // it's used only during close so dont close the factory using its close() method - final NetconfOperationServiceFactory mdSalMonitoringMapperFactory = - (NetconfOperationServiceFactory) declaredConstructor.newInstance(mdSalMonitoringMapper, null, writer); - aggregator.onAddNetconfOperationServiceFactory(mdSalMonitoringMapperFactory); - return mdSalMonitoringMapperFactory; - } catch (final ReflectiveOperationException e) { - final String msg = "Unable to instantiate operation service factory using reflection"; - LOG.error(msg, e); - throw new IllegalStateException(msg, e); - } - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java deleted file mode 100644 index 1931a57b6..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringReaderFactoryProvider.java +++ /dev/null @@ -1,62 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.translate.read.ReaderFactory; -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import io.fd.honeycomb.translate.util.read.BindingBrokerReader; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -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.NetconfStateBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - - -public final class NetconfMonitoringReaderFactoryProvider extends ProviderTrait<ReaderFactory> { - - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF) - private DataBroker netconfDataBroker; - - @Override - protected NetconfMonitoringReaderFactory create() { - return new NetconfMonitoringReaderFactory(netconfDataBroker); - } - - /** - * {@link io.fd.honeycomb.translate.read.ReaderFactory} initiating reader into NETCONF's dedicated data store. - * Making NETCONF operational data available over NETCONF/RESTCONF - */ - private static final class NetconfMonitoringReaderFactory implements ReaderFactory { - - private final DataBroker netconfMonitoringBindingBrokerDependency; - - NetconfMonitoringReaderFactory(final DataBroker netconfMonitoringBindingBrokerDependency) { - this.netconfMonitoringBindingBrokerDependency = netconfMonitoringBindingBrokerDependency; - } - - @Override - public void init(final ModifiableReaderRegistryBuilder registry) { - registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(NetconfState.class), - netconfMonitoringBindingBrokerDependency, - LogicalDatastoreType.OPERATIONAL, NetconfStateBuilder.class)); - } - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.java deleted file mode 100644 index d8d7adeb4..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfMonitoringServiceProvider.java +++ /dev/null @@ -1,37 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService; -import org.opendaylight.netconf.impl.osgi.NetconfMonitoringServiceImpl; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; - - -public class NetconfMonitoringServiceProvider extends ProviderTrait<NetconfMonitoringService> { - - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_AGGR) - private NetconfOperationServiceFactory aggregator; - - @Override - protected NetconfMonitoringServiceImpl create() { - return new NetconfMonitoringServiceImpl(aggregator); - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.java deleted file mode 100644 index 4f869b1dc..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationMapperProvider.java +++ /dev/null @@ -1,98 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import java.lang.reflect.Constructor; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener; -import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; -import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener; -import org.opendaylight.netconf.mdsal.notification.NetconfNotificationOperationServiceFactory; -import org.opendaylight.netconf.notifications.BaseNotificationPublisherRegistration; -import org.opendaylight.netconf.notifications.NetconfNotificationCollector; -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.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class NetconfNotificationMapperProvider extends ProviderTrait<NetconfOperationServiceFactory> { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfNotificationMapperProvider.class); - - public static final InstanceIdentifier<Capabilities> capabilitiesIdentifier = - InstanceIdentifier.create(NetconfState.class).child(Capabilities.class).builder().build(); - @Inject - private NetconfNotificationCollector notificationCollector; - @Inject - private NetconfNotificationRegistry notificationRegistry; - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF) - private BindingAwareBroker bindingAwareBroker; - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF) - private DataBroker dataBroker; - @Inject - private NetconfOperationServiceFactoryListener aggregator; - - @Override - protected NetconfNotificationOperationServiceFactory create() { - try { - final Class<?> notificationWriter = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.notification.NotificationToMdsalWriter"); - Constructor<?> declaredConstructor = - notificationWriter.getDeclaredConstructor(NetconfNotificationCollector.class); - declaredConstructor.setAccessible(true); - final BindingAwareProvider writer = - (BindingAwareProvider) declaredConstructor.newInstance(notificationCollector); - bindingAwareBroker.registerProvider(writer); - - final Class<?> notifPublisherCls = Class.forName( - "org.opendaylight.controller.config.yang.netconf.mdsal.notification.CapabilityChangeNotificationProducer"); - declaredConstructor = - notifPublisherCls.getDeclaredConstructor(BaseNotificationPublisherRegistration.class); - declaredConstructor.setAccessible(true); - final DataTreeChangeListener<Capabilities> publisher = - (DataTreeChangeListener<Capabilities>) declaredConstructor.newInstance( - notificationCollector.registerBaseNotificationPublisher()); - - ListenerRegistration<DataTreeChangeListener<Capabilities>> capabilityChangeListenerRegistration = dataBroker - .registerDataTreeChangeListener( - new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, capabilitiesIdentifier), - publisher); - NetconfNotificationOperationServiceFactory netconfNotificationOperationServiceFactory = - new NetconfNotificationOperationServiceFactory(notificationRegistry); - aggregator.onAddNetconfOperationServiceFactory(netconfNotificationOperationServiceFactory); - - return netconfNotificationOperationServiceFactory; - } catch (final ReflectiveOperationException e) { - final String msg = "Unable to instantiate notification mapper using reflection"; - LOG.error(msg, e); - throw new IllegalStateException(msg, e); - } - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.java deleted file mode 100644 index 326abec08..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfNotificationsReaderFactoryProvider.java +++ /dev/null @@ -1,57 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.translate.read.ReaderFactory; -import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder; -import io.fd.honeycomb.translate.util.read.BindingBrokerReader; -import javax.annotation.Nonnull; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.Netconf; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netmod.notification.rev080714.NetconfBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; - -public final class NetconfNotificationsReaderFactoryProvider extends ProviderTrait<ReaderFactory> { - - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF) - private DataBroker netconfDataBroker; - - @Override - protected ReaderFactory create() { - return new NotificationReaderFactory(netconfDataBroker); - } - - private static final class NotificationReaderFactory implements ReaderFactory { - private final DataBroker netconfDataBroker; - - NotificationReaderFactory(final DataBroker netconfDataBroker) { - this.netconfDataBroker = netconfDataBroker; - } - - @Override - public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) { - registry.add(new BindingBrokerReader<>(InstanceIdentifier.create(Netconf.class), netconfDataBroker, - LogicalDatastoreType.OPERATIONAL, NetconfBuilder.class)); - } - - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.java deleted file mode 100644 index cb45f5d6d..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfReadersModule.java +++ /dev/null @@ -1,34 +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.infra.distro.netconf; - -import com.google.inject.AbstractModule; -import com.google.inject.Singleton; -import com.google.inject.multibindings.Multibinder; -import io.fd.honeycomb.translate.read.ReaderFactory; - -public 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 - final Multibinder<ReaderFactory> binder = Multibinder.newSetBinder(binder(), ReaderFactory.class); - binder.addBinding().toProvider(NetconfMonitoringReaderFactoryProvider.class).in(Singleton.class); - binder.addBinding().toProvider(NetconfNotificationsReaderFactoryProvider.class).in(Singleton.class); - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.java deleted file mode 100644 index c5f0fc320..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfServerDispatcherProvider.java +++ /dev/null @@ -1,72 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import com.google.inject.name.Named; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.Timer; -import java.util.concurrent.TimeUnit; -import org.opendaylight.netconf.api.NetconfServerDispatcher; -import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService; -import org.opendaylight.netconf.impl.NetconfServerDispatcherImpl; -import org.opendaylight.netconf.impl.SessionIdProvider; -import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory; -import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory; - -public final class NetconfServerDispatcherProvider extends ProviderTrait<NetconfServerDispatcher> { - private static final long CONNECTION_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(20); - - @Inject - @Named(NetconfModule.HONEYCOMB_NETCONF_MAPPER_AGGR) - private NetconfOperationServiceFactory aggregator; - @Inject - private NetconfMonitoringService monitoringService; - @Inject - private Timer timer; - @Inject - private NioEventLoopGroup nettyThreadgroup; - - @Override - protected NetconfServerDispatcherImpl create() { - AggregatedNetconfOperationServiceFactory netconfOperationProvider = - new AggregatedNetconfOperationServiceFactory(); - netconfOperationProvider.onAddNetconfOperationServiceFactory(aggregator); - - NetconfServerSessionNegotiatorFactory serverNegotiatorFactory = - new NetconfServerSessionNegotiatorFactory(timer, netconfOperationProvider, new SessionIdProvider(), - CONNECTION_TIMEOUT_MILLIS, monitoringService); - NetconfServerDispatcherImpl.ServerChannelInitializer serverChannelInitializer = - new NetconfServerDispatcherImpl.ServerChannelInitializer(serverNegotiatorFactory); - - return new NetconfServerDispatcherImpl(serverChannelInitializer, nettyThreadgroup, nettyThreadgroup); - } - - private static final class NetconfServerSessionNegotiatorFactory extends - org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory { - - NetconfServerSessionNegotiatorFactory(final Timer timer, - final AggregatedNetconfOperationServiceFactory netconfOperationProvider, - final SessionIdProvider sessionIdProvider, - final long connectionTimeoutMillis, - final NetconfMonitoringService monitoringService) { - super(timer, netconfOperationProvider, sessionIdProvider, connectionTimeoutMillis, monitoringService, - org.opendaylight.netconf.impl.NetconfServerSessionNegotiatorFactory.DEFAULT_BASE_CAPABILITIES); - } - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java deleted file mode 100644 index b13d9c165..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfSshServerProvider.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2017 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.infra.distro.netconf; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.InitializationException; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import io.fd.honeycomb.northbound.CredentialsConfiguration; -import io.netty.channel.ChannelFuture; -import io.netty.channel.local.LocalAddress; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.concurrent.GenericFutureListener; -import io.netty.util.concurrent.GlobalEventExecutor; -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider; -import org.opendaylight.netconf.api.NetconfServerDispatcher; -import org.opendaylight.netconf.auth.AuthProvider; -import org.opendaylight.netconf.ssh.SshProxyServer; -import org.opendaylight.netconf.ssh.SshProxyServerConfigurationBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public final class NetconfSshServerProvider extends ProviderTrait<NetconfSshServerProvider.NetconfSshServer> { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfSshServerProvider.class); - - @Inject - private NetconfServerDispatcher dispatcher; - @Inject - private HoneycombConfiguration cfgAttributes; - @Inject - private NioEventLoopGroup nettyThreadgroup; - @Inject - private CredentialsConfiguration credentialsCfg; - - private ScheduledExecutorService pool = - Executors.newScheduledThreadPool(1, new ThreadFactoryBuilder().setNameFormat("netconf-ssh-%d").build()); - - @Override - protected NetconfSshServer create() { - InetAddress sshBindingAddress = null; - try { - sshBindingAddress = InetAddress.getByName(cfgAttributes.netconfSshBindingAddress.get()); - } catch (UnknownHostException e) { - throw new IllegalArgumentException("Illegal binding address", e); - } - - final InetSocketAddress bindingAddress = - new InetSocketAddress(sshBindingAddress, cfgAttributes.netconfSshBindingPort.get()); - - LocalAddress localAddress = new LocalAddress(cfgAttributes.netconfSshBindingPort.toString()); - ChannelFuture localServer = dispatcher.createLocalServer(localAddress); - - final SshProxyServer sshProxyServer = new SshProxyServer(pool, nettyThreadgroup, GlobalEventExecutor.INSTANCE); - - final SshProxyServerConfigurationBuilder sshConfigBuilder = new SshProxyServerConfigurationBuilder(); - sshConfigBuilder.setBindingAddress(bindingAddress); - sshConfigBuilder.setLocalAddress(localAddress); - // Only simple authProvider checking ConfigAttributes, checking the config file - sshConfigBuilder.setAuthenticator(new SimplelAuthProvider(credentialsCfg)); - sshConfigBuilder.setIdleTimeout(Integer.MAX_VALUE); - sshConfigBuilder.setKeyPairProvider(new PEMGeneratorHostKeyProvider()); - - localServer.addListener(new SshServerBinder(sshProxyServer, sshConfigBuilder, bindingAddress)); - - return new NetconfSshServer(localServer, sshProxyServer); - } - - public static final class NetconfSshServer { - private ChannelFuture localServer; - private SshProxyServer sshProxyServer; - - NetconfSshServer(final ChannelFuture localServer, - final SshProxyServer sshProxyServer) { - this.localServer = localServer; - this.sshProxyServer = sshProxyServer; - } - - public Object getLocalServer() { - return localServer; - } - - public Object getSshProxyServer() { - return sshProxyServer; - } - } - - private static final class SimplelAuthProvider implements AuthProvider { - - private final CredentialsConfiguration cfgAttributes; - - SimplelAuthProvider(final CredentialsConfiguration cfgAttributes) { - this.cfgAttributes = cfgAttributes; - } - - @Override - public boolean authenticated(final String uname, final String passwd) { - return cfgAttributes.username.equals(uname) && cfgAttributes.password.equals(passwd); - } - } - - private static final class SshServerBinder implements GenericFutureListener<ChannelFuture> { - private final SshProxyServer sshProxyServer; - private final SshProxyServerConfigurationBuilder sshConfigBuilder; - private final InetSocketAddress bindingAddress; - - SshServerBinder(final SshProxyServer sshProxyServer, - final SshProxyServerConfigurationBuilder sshConfigBuilder, - final InetSocketAddress bindingAddress) { - this.sshProxyServer = sshProxyServer; - this.sshConfigBuilder = sshConfigBuilder; - this.bindingAddress = bindingAddress; - } - - @Override - public void operationComplete(final ChannelFuture future) { - if (future.isDone() && !future.isCancelled()) { - try { - sshProxyServer.bind(sshConfigBuilder.createSshProxyServerConfiguration()); - LOG.info("Netconf SSH endpoint started successfully at {}", bindingAddress); - } catch (final IOException e) { - throw new InitializationException("Unable to start SSH netconf server", e); - } - - } else { - LOG.warn("Unable to start SSH netconf server at {}", bindingAddress, future.cause()); - throw new InitializationException("Unable to start SSH netconf server", future.cause()); - } - - } - - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java deleted file mode 100644 index 37679d056..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NetconfTcpServerProvider.java +++ /dev/null @@ -1,86 +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.infra.distro.netconf; - -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.InitializationException; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import io.netty.channel.ChannelFuture; -import io.netty.util.concurrent.GenericFutureListener; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.UnknownHostException; -import org.opendaylight.netconf.api.NetconfServerDispatcher; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public final class NetconfTcpServerProvider extends ProviderTrait<NetconfTcpServerProvider.NetconfTcpServer> { - - private static final Logger LOG = LoggerFactory.getLogger(NetconfTcpServerProvider.class); - - @Inject - private NetconfServerDispatcher dispatcher; - @Inject - private HoneycombConfiguration cfgAttributes; - - @Override - protected NetconfTcpServer create() { - InetAddress name = null; - try { - name = InetAddress.getByName(cfgAttributes.netconfTcpBindingAddress.get()); - } catch (UnknownHostException e) { - throw new IllegalArgumentException("Illegal binding address", e); - } - - final InetSocketAddress unresolved = new InetSocketAddress(name, cfgAttributes.netconfTcpBindingPort.get()); - - ChannelFuture tcpServer = dispatcher.createServer(unresolved); - tcpServer.addListener(new TcpLoggingListener(unresolved)); - return new NetconfTcpServer(tcpServer); - } - - public static final class NetconfTcpServer { - private Object tcpServer; - - NetconfTcpServer(final ChannelFuture tcpServer) { - this.tcpServer = tcpServer; - } - - public Object getTcpServer() { - return tcpServer; - } - } - - private static final class TcpLoggingListener implements GenericFutureListener<ChannelFuture> { - private final InetSocketAddress unresolved; - - TcpLoggingListener(final InetSocketAddress unresolved) { - this.unresolved = unresolved; - } - - @Override - public void operationComplete(ChannelFuture future) throws Exception { - if (future.isDone() && future.isSuccess()) { - LOG.info("Netconf TCP endpoint started successfully at {}", unresolved); - } else { - LOG.warn("Unable to start TCP netconf server at {}", unresolved, future.cause()); - throw new InitializationException("Unable to start TCP netconf server", future.cause()); - } - } - } -} diff --git a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.java b/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.java deleted file mode 100644 index c34d8c1f4..000000000 --- a/infra/minimal-distribution-core/src/main/java/io/fd/honeycomb/infra/distro/netconf/NettyThreadGroupProvider.java +++ /dev/null @@ -1,35 +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.infra.distro.netconf; - -import com.google.common.util.concurrent.ThreadFactoryBuilder; -import com.google.inject.Inject; -import io.fd.honeycomb.binding.init.ProviderTrait; -import io.fd.honeycomb.infra.distro.cfgattrs.HoneycombConfiguration; -import io.netty.channel.nio.NioEventLoopGroup; - -public final class NettyThreadGroupProvider extends ProviderTrait<NioEventLoopGroup> { - - @Inject - private HoneycombConfiguration cfgAttributes; - - @Override - protected NioEventLoopGroup create() { - return new NioEventLoopGroup(cfgAttributes.netconfNettyThreads, - new ThreadFactoryBuilder().setNameFormat("netconf-netty-%d").build()); - } -} diff --git a/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json b/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json index ab934db5a..0fde4bfe5 100644 --- a/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json +++ b/infra/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/config/honeycomb.json @@ -1,19 +1,9 @@ - { +{ "persist-context": "true", "persisted-context-path": "/var/lib/honeycomb/persist/context/data.json", "persisted-context-restoration-type": "Merge", "persist-config": "true", "persisted-config-path": "/var/lib/honeycomb/persist/config/data.json", "persisted-config-restoration-type": "Merge", - - "notification-service-queue-depth": 1, - - "netconf-netty-threads": 2, - "netconf-tcp-enabled" : "true", - "netconf-tcp-binding-address": "127.0.0.1", - "netconf-tcp-binding-port": 7777, - "netconf-ssh-enabled" : "true", - "netconf-ssh-binding-address": "0.0.0.0", - "netconf-ssh-binding-port": 2831, - "netconf-notification-stream-name": "honeycomb" + "notification-service-queue-depth": 1 }
\ No newline at end of file |