2 * Copyright (C) 2013 Red Hat, Inc.
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
8 * Authors : Madhu Venugopal, Brent Salisbury, Dave Tucker
11 package org.opendaylight.ovsdb.openstack.netvirt;
13 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
14 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
15 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
16 import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
17 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
18 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterAware;
19 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupAware;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleAware;
21 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
22 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
23 import org.opendaylight.controller.switchmanager.IInventoryListener;
24 import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
25 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
26 import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
27 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProvider;
28 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
29 import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
30 import org.opendaylight.ovsdb.openstack.netvirt.api.VlanConfigurationCache;
31 import org.opendaylight.ovsdb.openstack.netvirt.impl.BridgeConfigurationManagerImpl;
32 import org.opendaylight.ovsdb.openstack.netvirt.impl.ConfigurationServiceImpl;
33 import org.opendaylight.ovsdb.openstack.netvirt.impl.EventDispatcherImpl;
34 import org.opendaylight.ovsdb.openstack.netvirt.impl.ProviderNetworkManagerImpl;
35 import org.opendaylight.ovsdb.openstack.netvirt.impl.TenantNetworkManagerImpl;
36 import org.opendaylight.ovsdb.openstack.netvirt.impl.VlanConfigurationCacheImpl;
37 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
38 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
39 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
41 import org.apache.felix.dm.Component;
43 import java.util.Properties;
46 * OSGi bundle activator for the OVSDB Neutron Interface.
48 public class Activator extends ComponentActivatorAbstractBase {
50 * Function called when the activator starts just after some
51 * initializations are done by the
52 * ComponentActivatorAbstractBase.
59 * Function called when the activator stops just before the
60 * cleanup done by ComponentActivatorAbstractBase.
64 public void destroy() {
68 * Function that is used to communicate to dependency manager the
69 * list of known implementations for services inside a container.
71 * @return An array containing all the CLASS objects that will be
72 * instantiated in order to get an fully working implementation
76 public Object[] getImplementations() {
77 Object[] res = {ConfigurationServiceImpl.class,
78 BridgeConfigurationManagerImpl.class,
79 TenantNetworkManagerImpl.class,
80 VlanConfigurationCacheImpl.class,
81 FloatingIPHandler.class,
86 SouthboundHandler.class,
87 PortSecurityHandler.class,
88 ProviderNetworkManagerImpl.class,
89 EventDispatcherImpl.class};
94 * Function that is called when configuration of the dependencies
97 * @param c dependency manager Component object, used for
98 * configuring the dependencies exported and imported
99 * @param imp Implementation class that is being configured,
100 * needed as long as the same routine can configure multiple
102 * @param containerName The containerName being configured, this allow
103 * also optional per-container different behavior if needed, usually
104 * should not be the case though.
107 public void configureInstance(Component c, Object imp,
108 String containerName) {
109 if (imp.equals(ConfigurationServiceImpl.class)) {
110 c.setInterface(org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class.getName(), null);
111 c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
114 if (imp.equals(BridgeConfigurationManagerImpl.class)) {
115 c.setInterface(BridgeConfigurationManager.class.getName(), null);
116 c.add(createServiceDependency().setService(
117 org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class).setRequired(true));
118 c.add(createServiceDependency().setService(NetworkingProviderManager.class));
119 c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
122 if (imp.equals(TenantNetworkManagerImpl.class)) {
123 c.setInterface(TenantNetworkManager.class.getName(), null);
124 c.add(createServiceDependency().setService(NetworkingProviderManager.class));
125 c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
126 c.add(createServiceDependency().setService(OvsdbConnectionService.class));
127 c.add(createServiceDependency().
128 setService(INeutronNetworkCRUD.class).
130 c.add(createServiceDependency().
131 setService(INeutronPortCRUD.class).
133 c.add(createServiceDependency().setService(VlanConfigurationCache.class));
136 if (imp.equals(VlanConfigurationCacheImpl.class)) {
137 c.setInterface(VlanConfigurationCache.class.getName(), null);
138 c.add(createServiceDependency().setService(OvsdbConfigurationService.class));
139 c.add(createServiceDependency().setService(TenantNetworkManager.class));
142 if (imp.equals(FloatingIPHandler.class)) {
143 Properties floatingIPHandlerPorperties = new Properties();
144 floatingIPHandlerPorperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
145 AbstractEvent.HandlerType.NEUTRON_FLOATING_IP);
146 c.setInterface(new String[] {INeutronFloatingIPAware.class.getName(),
147 AbstractHandler.class.getName()},
148 floatingIPHandlerPorperties);
149 c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
150 c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
151 c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
152 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
155 if (imp.equals(NetworkHandler.class)) {
156 Properties networkHandlerProperties = new Properties();
157 networkHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
158 AbstractEvent.HandlerType.NEUTRON_NETWORK);
159 c.setInterface(new String[] {INeutronNetworkAware.class.getName(),
160 AbstractHandler.class.getName()},
161 networkHandlerProperties);
162 c.add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true));
163 c.add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true));
164 c.add(createServiceDependency().setService(
165 org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class).setRequired(true));
166 c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
167 c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
168 c.add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true));
169 c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
170 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
173 if (imp.equals(SubnetHandler.class)) {
174 Properties subnetHandlerProperties = new Properties();
175 subnetHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_SUBNET);
176 c.setInterface(new String[] {INeutronSubnetAware.class.getName(),
177 AbstractHandler.class.getName()},
178 subnetHandlerProperties);
179 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
182 if (imp.equals(PortHandler.class)) {
183 Properties portHandlerProperties = new Properties();
184 portHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_PORT);
185 c.setInterface(new String[] {INeutronPortAware.class.getName(),
186 AbstractHandler.class.getName()},
187 portHandlerProperties);
188 c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
189 c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
190 c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
191 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
194 if (imp.equals(RouterHandler.class)) {
195 Properties routerHandlerProperties = new Properties();
196 routerHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_ROUTER);
197 c.setInterface(new String[] {INeutronRouterAware.class.getName(),
198 AbstractHandler.class.getName()},
199 routerHandlerProperties);
200 c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
201 c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
202 c.add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true));
203 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
206 if (imp.equals(SouthboundHandler.class)) {
207 Properties southboundHandlerProperties = new Properties();
208 southboundHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.SOUTHBOUND);
209 c.setInterface(new String[] {OvsdbInventoryListener.class.getName(),
210 IInventoryListener.class.getName(),
211 AbstractHandler.class.getName()},
212 southboundHandlerProperties);
213 c.add(createServiceDependency().setService(
214 org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class).setRequired(true));
215 c.add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true));
216 c.add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true));
217 c.add(createServiceDependency().setService(NetworkingProviderManager.class).setRequired(true));
218 c.add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true));
219 c.add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true));
220 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
223 if (imp.equals(PortSecurityHandler.class)) {
224 Properties portSecurityHandlerProperties = new Properties();
225 portSecurityHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
226 AbstractEvent.HandlerType.NEUTRON_PORT_SECURITY);
227 c.setInterface(new String[] {INeutronSecurityRuleAware.class.getName(),
228 INeutronSecurityGroupAware.class.getName(),
229 AbstractHandler.class.getName()},
230 portSecurityHandlerProperties);
231 c.add(createServiceDependency().setService(EventDispatcher.class).setRequired(true));
234 if (imp.equals(ProviderNetworkManagerImpl.class)) {
235 c.setInterface(NetworkingProviderManager.class.getName(), null);
236 c.add(createServiceDependency()
237 .setService(org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService.class)
239 c.add(createServiceDependency()
240 .setService(NetworkingProvider.class)
241 .setCallbacks("providerAdded", "providerRemoved"));
244 if (imp.equals(EventDispatcherImpl.class)) {
245 c.setInterface(EventDispatcher.class.getName(), null);
246 c.add(createServiceDependency()
247 .setService(AbstractHandler.class)
248 .setCallbacks("eventHandlerAdded", "eventHandlerRemoved"));