2 * Copyright (c) 2016 Cisco and/or its affiliates.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package io.fd.honeycomb.infra.distro.netconf
19 import com.google.inject.PrivateModule
20 import com.google.inject.Singleton
21 import com.google.inject.name.Names
22 import io.fd.honeycomb.infra.distro.data.BindingDataBrokerProvider
23 import io.fd.honeycomb.infra.distro.data.DataStoreProvider
24 import io.fd.honeycomb.infra.distro.data.HoneycombNotificationManagerProvider
25 import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider
26 import io.fd.honeycomb.notification.NotificationCollector
27 import io.netty.channel.nio.NioEventLoopGroup
28 import io.netty.util.Timer
29 import org.opendaylight.controller.md.sal.binding.api.DataBroker
30 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType
31 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker
32 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore
33 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker
34 import org.opendaylight.netconf.api.NetconfServerDispatcher
35 import org.opendaylight.netconf.api.monitoring.NetconfMonitoringService
36 import org.opendaylight.netconf.impl.osgi.AggregatedNetconfOperationServiceFactory
37 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactory
38 import org.opendaylight.netconf.mapping.api.NetconfOperationServiceFactoryListener
39 import org.opendaylight.netconf.notifications.NetconfNotificationCollector
40 import org.opendaylight.netconf.notifications.NetconfNotificationListener
41 import org.opendaylight.netconf.notifications.NetconfNotificationRegistry
42 import org.opendaylight.netconf.notifications.impl.NetconfNotificationManager
44 import static InmemoryDOMDataBrokerProvider.CONFIG
45 import static InmemoryDOMDataBrokerProvider.OPERATIONAL
47 class NetconfModule extends PrivateModule {
50 protected void configure() {
51 bind(InMemoryDOMDataStore)
52 .annotatedWith(Names.named(CONFIG))
53 .toProvider(new DataStoreProvider(type: LogicalDatastoreType.CONFIGURATION, name: CONFIG))
55 bind(InMemoryDOMDataStore)
56 .annotatedWith(Names.named(OPERATIONAL))
57 .toProvider(new DataStoreProvider(type: LogicalDatastoreType.OPERATIONAL, name: OPERATIONAL))
59 bind(DOMDataBroker).toProvider(InmemoryDOMDataBrokerProvider).in(Singleton)
62 .annotatedWith(Names.named("netconf"))
63 .toProvider(BindingDataBrokerProvider)
65 expose(DataBroker).annotatedWith(Names.named("netconf"))
66 bind(BindingAwareBroker)
67 .annotatedWith(Names.named("netconf"))
68 .toProvider(NetconfBindingBrokerProvider)
71 // Mirror of org.opendaylight.controller.config.yang.config.netconf.northbound.impl.NetconfMapperAggregatorModule
72 def factory = new AggregatedNetconfOperationServiceFactory()
73 bind(NetconfOperationServiceFactory)
74 .annotatedWith(Names.named("netconf-mapper-aggregator"))
76 bind(NetconfOperationServiceFactoryListener).toInstance(factory)
78 // Mirror of org.opendaylight.controller.config.yang.netconf.northbound.notification.impl.NetconfNotificationManagerModule
79 def manager = new NetconfNotificationManager()
80 bind(NetconfNotificationCollector).toInstance(manager)
81 bind(NetconfNotificationRegistry).toInstance(manager)
82 bind(NetconfNotificationListener).toInstance(manager)
84 // Netconf notification part
85 bind(NetconfOperationServiceFactory)
86 .annotatedWith(Names.named("netconf-mapper-notification"))
87 .toProvider(NetconfNotificationMapperProvider)
89 expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-notification"))
91 // Netconf core part - mapping between Honeycomb and Netconf
92 bind(NetconfOperationServiceFactory)
93 .annotatedWith(Names.named("netconf-mapper-honeycomb"))
94 .toProvider(NetconfMdsalMapperProvider)
96 expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-honeycomb"))
98 // Netconf monitoring part
99 bind(NetconfMonitoringService).toProvider(NetconfMonitoringServiceProvider).in(Singleton)
100 bind(NetconfOperationServiceFactory)
101 .annotatedWith(Names.named("netconf-mapper-monitoring"))
102 .toProvider(NetconfMonitoringMapperProvider)
104 expose(NetconfOperationServiceFactory).annotatedWith(Names.named("netconf-mapper-monitoring"))
106 bind(NotificationCollector).toProvider(HoneycombNotificationManagerProvider).in(Singleton)
107 bind(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf)
108 .toProvider(HoneycombNotification2NetconfProvider)
110 expose(HoneycombNotification2NetconfProvider.HoneycombNotification2Netconf)
115 def configureServer() {
116 bind(NioEventLoopGroup).toProvider(NettyThreadGroupProvider).in(Singleton)
117 bind(Timer).toProvider(NettyTimerProvider).in(Singleton)
118 bind(NetconfServerDispatcher).toProvider(NetconfServerDispatcherProvider).in(Singleton)
119 bind(NetconfTcpServerProvider.NetconfTcpServer).toProvider(NetconfTcpServerProvider).in(Singleton)
120 expose(NetconfTcpServerProvider.NetconfTcpServer)
121 bind(NetconfSshServerProvider.NetconfSshServer).toProvider(NetconfSshServerProvider).in(Singleton)
122 expose(NetconfSshServerProvider.NetconfSshServer)