clean test environment
[transportpce.git] / tests / honeynode / 2.2.1 / 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 import io.fd.honeycomb.transportpce.device.configuration.DeviceConfigurationModule;
25 import io.fd.honeycomb.transportpce.device.configuration.NetconfConfigurationModule;
26 import io.fd.honeycomb.transportpce.device.configuration.PmConfigurationModule;
27
28 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
29 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
30 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
31 import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStore;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
34
35 /**
36  * Module class instantiating device-plugin plugin components.
37  */
38
39 public final class DeviceModule extends PrivateModule {
40
41     private static final Logger LOG = LoggerFactory.getLogger(DeviceModule.class);
42     public static final String DEVICE_DATABROKER = "device-databroker";
43     public static final String DEVICE_DATABROKER_NONPERSIST = "device-databroker-nopersist";
44
45     @Override
46     protected void configure() {
47         LOG.info("Initializing Device Module");
48         // Create inmemory config data store for DEVICE
49         bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.CONFIG))
50             .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.CONFIG, LogicalDatastoreType.CONFIGURATION))
51             .in(Singleton.class);
52         // Create inmemory operational data store for DEVICE
53         bind(InMemoryDOMDataStore.class).annotatedWith(Names.named(InmemoryDOMDataBrokerProvider.OPERATIONAL))
54             .toProvider(new DataStoreProvider(InmemoryDOMDataBrokerProvider.OPERATIONAL, LogicalDatastoreType.OPERATIONAL))
55             .in(Singleton.class);
56
57         // Wrap datastores as DOMDataBroker
58         // TODO make executor service configurable
59         bind(DOMDataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER))
60             .toProvider(InmemoryDOMDataBrokerProvider.class).in(Singleton.class);
61         expose(DOMDataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER));
62
63         // Wrap DOMDataBroker as BA data broker
64         bind(DataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER)).toProvider(DeviceBindingDataBrokerProvider.class)
65             .in(Singleton.class);
66         expose(DataBroker.class).annotatedWith(Names.named(DEVICE_DATABROKER));
67
68         //install device configuration module
69         install(new DeviceConfigurationModule());
70
71         //install pm configuration module
72         install(new PmConfigurationModule());
73         LOG.info("Device Module intitailized !");
74
75       //install netconf configuration module
76         install(new NetconfConfigurationModule());
77         LOG.info("Netconf Module intitailized !");
78     }
79
80 }
81