Merge "NXM_NX_NSP openflow extended match support."
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / 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;
12
13 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
14 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
15 import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
16 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
17 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterAware;
18 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupAware;
19 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleAware;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
21 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
22 import org.opendaylight.controller.switchmanager.IInventoryListener;
23 import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
24 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProvider;
25 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
26 import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
27 import org.opendaylight.ovsdb.openstack.netvirt.api.VlanConfigurationCache;
28 import org.opendaylight.ovsdb.openstack.netvirt.impl.BridgeConfigurationManagerImpl;
29 import org.opendaylight.ovsdb.openstack.netvirt.impl.ConfigurationServiceImpl;
30 import org.opendaylight.ovsdb.openstack.netvirt.impl.ProviderNetworkManagerImpl;
31 import org.opendaylight.ovsdb.openstack.netvirt.impl.TenantNetworkManagerImpl;
32 import org.opendaylight.ovsdb.openstack.netvirt.impl.VlanConfigurationCacheImpl;
33 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
34 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
35 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
36
37 import org.apache.felix.dm.Component;
38
39 /**
40  * OSGi bundle activator for the OVSDB Neutron Interface.
41  */
42 public class Activator extends ComponentActivatorAbstractBase {
43     /**
44      * Function called when the activator starts just after some
45      * initializations are done by the
46      * ComponentActivatorAbstractBase.
47      */
48     @Override
49     public void init() {
50     }
51
52     /**
53      * Function called when the activator stops just before the
54      * cleanup done by ComponentActivatorAbstractBase.
55      *
56      */
57     @Override
58     public void destroy() {
59     }
60
61     /**
62      * Function that is used to communicate to dependency manager the
63      * list of known implementations for services inside a container.
64      *
65      * @return An array containing all the CLASS objects that will be
66      * instantiated in order to get an fully working implementation
67      * Object
68      */
69     @Override
70     public Object[] getImplementations() {
71         Object[] res = {ConfigurationServiceImpl.class,
72                         BridgeConfigurationManagerImpl.class,
73                         TenantNetworkManagerImpl.class,
74                         VlanConfigurationCacheImpl.class,
75                         NetworkHandler.class,
76                         SubnetHandler.class,
77                         PortHandler.class,
78                         RouterHandler.class,
79                         SouthboundHandler.class,
80                         PortSecurityHandler.class,
81                         ProviderNetworkManagerImpl.class};
82         return res;
83     }
84
85     /**
86      * Function that is called when configuration of the dependencies
87      * is required.
88      *
89      * @param c dependency manager Component object, used for
90      * configuring the dependencies exported and imported
91      * @param imp Implementation class that is being configured,
92      * needed as long as the same routine can configure multiple
93      * implementations
94      * @param containerName The containerName being configured, this allow
95      * also optional per-container different behavior if needed, usually
96      * should not be the case though.
97      */
98     @Override
99     public void configureInstance(Component c, Object imp,
100                                   String containerName) {
101         if (imp.equals(ConfigurationServiceImpl.class)) {
102             c.setInterface(org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class.getName(), null);
103             c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
104         }
105
106         if (imp.equals(BridgeConfigurationManagerImpl.class)) {
107             c.setInterface(BridgeConfigurationManager.class.getName(), null);
108             c.add(createServiceDependency().setService(
109                     org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class).setRequired(true));
110             c.add(createServiceDependency().setService(NetworkingProviderManager.class));
111             c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
112         }
113
114         if (imp.equals(TenantNetworkManagerImpl.class)) {
115             c.setInterface(TenantNetworkManager.class.getName(), null);
116             c.add(createServiceDependency().setService(NetworkingProviderManager.class));
117             c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
118             c.add(createServiceDependency().setService(OvsdbConnectionService.class));
119             c.add(createServiceDependency().
120                     setService(INeutronNetworkCRUD.class).
121                     setRequired(true));
122             c.add(createServiceDependency().
123                     setService(INeutronPortCRUD.class).
124                     setRequired(true));
125             c.add(createServiceDependency().setService(VlanConfigurationCache.class));
126         }
127
128         if (imp.equals(VlanConfigurationCacheImpl.class)) {
129             c.setInterface(VlanConfigurationCache.class.getName(), null);
130             c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
131             c.add(createServiceDependency().setService(TenantNetworkManager.class));
132         }
133
134         if (imp.equals(NetworkHandler.class)) {
135             c.setInterface(INeutronNetworkAware.class.getName(), null);
136             c.add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true));
137             c.add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true));
138             c.add(createServiceDependency().setService(
139                     org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class).setRequired(true));
140             c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
141             c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
142             c.add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true));
143             c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
144         }
145
146         if (imp.equals(SubnetHandler.class)) {
147             c.setInterface(INeutronSubnetAware.class.getName(), null);
148         }
149
150         if (imp.equals(PortHandler.class)) {
151             c.setInterface(INeutronPortAware.class.getName(), null);
152             c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
153             c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
154             c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
155         }
156
157         if (imp.equals(RouterHandler.class)) {
158             c.setInterface(INeutronRouterAware.class.getName(), null);
159             c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
160             c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
161             c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
162         }
163
164         if (imp.equals(SouthboundHandler.class)) {
165             c.setInterface(new String[] {OvsdbInventoryListener.class.getName(),
166                                          IInventoryListener.class.getName()}, null);
167             c.add(createServiceDependency().setService(
168                     org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class).setRequired(true));
169             c.add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true));
170             c.add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true));
171             c.add(createServiceDependency().setService(NetworkingProviderManager.class).setRequired(true));
172             c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
173             c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
174         }
175
176         if (imp.equals(PortSecurityHandler.class)) {
177             c.setInterface(new String[] {INeutronSecurityRuleAware.class.getName(),
178                                          INeutronSecurityGroupAware.class.getName()}, null);
179         }
180
181         if (imp.equals(ProviderNetworkManagerImpl.class)) {
182             c.setInterface(NetworkingProviderManager.class.getName(), null);
183             c.add(createServiceDependency()
184                     .setService(org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class)
185                     .setRequired(true));
186             c.add(createServiceDependency()
187                     .setService(NetworkingProvider.class)
188                     .setCallbacks("providerAdded", "providerRemoved"));
189         }
190     }
191 }