da654bf55f4bc9fed927daed45618eed425e307e
[ovsdb.git] / openstack / net-virt-providers / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / providers / Activator.java
1 /*
2  * Copyright (C) 2013 Red Hat, Inc.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Authors : Madhu Venugopal, Brent Salisbury, Dave Tucker
9  */
10
11 package org.opendaylight.ovsdb.openstack.netvirt.providers;
12
13 import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
14 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
15 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
16 import org.opendaylight.controller.switchmanager.ISwitchManager;
17 import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
18 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
19 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
20 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProvider;
21 import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
22 import org.opendaylight.ovsdb.plugin.IConnectionServiceInternal;
23 import org.opendaylight.ovsdb.plugin.OvsdbConfigService;
24
25 import org.apache.felix.dm.Component;
26
27 import java.util.Properties;
28
29 /**
30  * OSGi Bundle Activator for the Neutron providers
31  */
32 public class Activator extends ComponentActivatorAbstractBase {
33     /**
34      * Function called when the activator starts just after some
35      * initializations are done by the
36      * ComponentActivatorAbstractBase.
37      */
38     @Override
39     public void init() {
40     }
41
42     /**
43      * Function called when the activator stops just before the
44      * cleanup done by ComponentActivatorAbstractBase.
45      *
46      */
47     @Override
48     public void destroy() {
49     }
50
51     /**
52      * Function that is used to communicate to dependency manager the
53      * list of known implementations for services inside a container.
54      *
55      * @return An array containing all the CLASS objects that will be
56      * instantiated in order to get an fully working implementation
57      * Object
58      */
59     @Override
60     public Object[] getImplementations() {
61         Object[] res = {MdsalConsumerImpl.class,
62                         OF10Provider.class,
63                         OF13Provider.class};
64         return res;
65     }
66
67     /**
68      * Function that is called when configuration of the dependencies
69      * is required.
70      *
71      * @param c dependency manager Component object, used for
72      * configuring the dependencies exported and imported
73      * @param imp Implementation class that is being configured,
74      * needed as long as the same routine can configure multiple
75      * implementations
76      * @param containerName The containerName being configured, this allow
77      * also optional per-container different behavior if needed, usually
78      * should not be the case though.
79      */
80     @Override
81     public void configureInstance(Component c, Object imp,
82                                   String containerName) {
83
84         if (imp.equals(MdsalConsumerImpl.class)) {
85             c.setInterface(MdsalConsumer.class.getName(), null);
86             c.add(createServiceDependency().setService(BindingAwareBroker.class).setRequired(true));
87         }
88
89         if (imp.equals(OF10Provider.class)) {
90             Properties of10Properties = new Properties();
91             of10Properties.put(Constants.SOUTHBOUND_PROTOCOL_PROPERTY, "ovsdb");
92             of10Properties.put(Constants.OPENFLOW_VERSION_PROPERTY, Constants.OPENFLOW10);
93
94             c.setInterface(NetworkingProvider.class.getName(), of10Properties);
95             c.add(createServiceDependency()
96                           .setService(ConfigurationService.class)
97                           .setRequired(true));
98             c.add(createServiceDependency()
99                           .setService(BridgeConfigurationManager.class)
100                           .setRequired(true));
101             c.add(createServiceDependency()
102                           .setService(TenantNetworkManager.class)
103                           .setRequired(true));
104             c.add(createServiceDependency().setService(OvsdbConfigService.class).setRequired(true));
105             c.add(createServiceDependency().setService(IConnectionServiceInternal.class).setRequired(true));
106             c.add(createServiceDependency().
107                     setService(IForwardingRulesManager.class).
108                     setRequired(true));
109             c.add(createServiceDependency().
110                     setService(ISwitchManager.class).
111                     setRequired(true));
112         }
113
114         if (imp.equals(OF13Provider.class)) {
115             Properties of13Properties = new Properties();
116             of13Properties.put(Constants.SOUTHBOUND_PROTOCOL_PROPERTY, "ovsdb");
117             of13Properties.put(Constants.OPENFLOW_VERSION_PROPERTY, Constants.OPENFLOW13);
118
119             c.setInterface(NetworkingProvider.class.getName(), of13Properties);
120             c.add(createServiceDependency()
121                           .setService(ConfigurationService.class)
122                           .setRequired(true));
123             c.add(createServiceDependency()
124                           .setService(BridgeConfigurationManager.class)
125                           .setRequired(true));
126             c.add(createServiceDependency()
127                           .setService(TenantNetworkManager.class)
128                           .setRequired(true));
129             c.add(createServiceDependency().setService(OvsdbConfigService.class).setRequired(true));
130             c.add(createServiceDependency().setService(IConnectionServiceInternal.class).setRequired(true));
131             c.add(createServiceDependency().setService(MdsalConsumer.class).setRequired(true));
132         }
133     }
134 }