Honeynode test tool
[transportpce.git] / tests / honeynode / honeynode-plugin-impl / src / main / java / io / fd / honeycomb / transportpce / device / DeviceModule.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
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:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package io.fd.honeycomb.transportpce.device;
17
18 import com.google.inject.PrivateModule;
19 import com.google.inject.Singleton;
20 import com.google.inject.name.Names;
21
22 import io.fd.honeycomb.infra.distro.data.DataStoreProvider;
23 import io.fd.honeycomb.infra.distro.data.InmemoryDOMDataBrokerProvider;
24
25 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
26 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
27 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
28 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 /**
33  * Module class instantiating device-plugin plugin components.
34  */
35
36 public final class DeviceModule extends PrivateModule {
37
38     private static final Logger LOG = LoggerFactory.getLogger(DeviceModule.class);
39     public static final String DEVICE_DATABROKER = "device-databroker";
40     public static final String DEVICE_DATABROKER_NONPERSIST = "device-databroker-nopersist";
41
42     @Override
43     protected void configure() {
44         LOG.info("Initializing Device Module");
45         // Create inmemory config data store for DEVICE
46         bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.CONFIG))
47             .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.CONFIG, LogicalDatastoreType.CONFIGURATION))
48             .in(Singleton.class);
49         // Create inmemory operational data store for DEVICE
50         bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.OPERATIONAL))
51             .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.OPERATIONAL, LogicalDatastoreType.OPERATIONAL))
52             .in(Singleton.class);
53
54         // Wrap datastores as DOMDataBroker
55         // TODO make executor service configurable
56         bind(DOMDataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER))
57             .toProvider(InmemoryDOMDataBrokerProvider.class).in(Singleton.class);
58         expose(DOMDataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER));
59
60         // Wrap DOMDataBroker as BA data broker
61         bind(DataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER)).toProvider(DeviceBindingDataBrokerProvider.class)
62             .in(Singleton.class);
63         expose(DataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER));
64
65         //install device configuration module
66         install(new DeviceConfigurationModule());
67         LOG.info("Device Module intitailized !");
68     }
69
70 }
71