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 java.util.Dictionary;
14 import java.util.Hashtable;
16 import org.apache.felix.dm.DependencyActivatorBase;
17 import org.apache.felix.dm.DependencyManager;
18 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
19 import org.opendaylight.neutron.spi.INeutronFirewallAware;
20 import org.opendaylight.neutron.spi.INeutronFirewallPolicyAware;
21 import org.opendaylight.neutron.spi.INeutronFirewallRuleAware;
22 import org.opendaylight.neutron.spi.INeutronFloatingIPAware;
23 import org.opendaylight.neutron.spi.INeutronLoadBalancerAware;
24 import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
25 import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolAware;
26 import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolCRUD;
27 import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolMemberAware;
28 import org.opendaylight.neutron.spi.INeutronNetworkAware;
29 import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
30 import org.opendaylight.neutron.spi.INeutronPortAware;
31 import org.opendaylight.neutron.spi.INeutronPortCRUD;
32 import org.opendaylight.neutron.spi.INeutronRouterAware;
33 import org.opendaylight.neutron.spi.INeutronSecurityGroupAware;
34 import org.opendaylight.neutron.spi.INeutronSecurityRuleAware;
35 import org.opendaylight.neutron.spi.INeutronSubnetAware;
36 import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
37 import org.opendaylight.ovsdb.openstack.netvirt.api.*;
38 import org.opendaylight.ovsdb.openstack.netvirt.impl.BridgeConfigurationManagerImpl;
39 import org.opendaylight.ovsdb.openstack.netvirt.impl.ConfigurationServiceImpl;
40 import org.opendaylight.ovsdb.openstack.netvirt.impl.EventDispatcherImpl;
41 import org.opendaylight.ovsdb.openstack.netvirt.impl.OvsdbInventoryServiceImpl;
42 import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
43 import org.opendaylight.ovsdb.openstack.netvirt.impl.NodeCacheManagerImpl;
44 import org.opendaylight.ovsdb.openstack.netvirt.impl.OpenstackRouter;
45 import org.opendaylight.ovsdb.openstack.netvirt.impl.ProviderNetworkManagerImpl;
46 import org.opendaylight.ovsdb.openstack.netvirt.impl.SecurityServicesImpl;
47 import org.opendaylight.ovsdb.openstack.netvirt.impl.TenantNetworkManagerImpl;
48 import org.opendaylight.ovsdb.openstack.netvirt.impl.VlanConfigurationCacheImpl;
50 import org.osgi.framework.BundleContext;
53 * OSGi bundle activator for the OVSDB Neutron Interface.
55 public class Activator extends DependencyActivatorBase {
58 public void init(BundleContext context, DependencyManager manager) throws Exception {
60 manager.add(createComponent()
61 .setInterface(ConfigurationService.class.getName(), null)
62 .setImplementation(ConfigurationServiceImpl.class)
63 .add(createServiceDependency().setService(OvsdbConfigurationService.class)));
65 manager.add(createComponent()
66 .setInterface(BridgeConfigurationManager.class.getName(), null)
67 .setImplementation(BridgeConfigurationManagerImpl.class)
68 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
69 .add(createServiceDependency().setService(NetworkingProviderManager.class))
70 .add(createServiceDependency().setService(OvsdbConfigurationService.class)));
72 manager.add(createComponent()
73 .setInterface(TenantNetworkManager.class.getName(), null)
74 .setImplementation(TenantNetworkManagerImpl.class)
75 .add(createServiceDependency().setService(OvsdbConfigurationService.class))
76 .add(createServiceDependency().setService(OvsdbConnectionService.class))
77 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
78 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
79 .add(createServiceDependency().setService(VlanConfigurationCache.class)));
81 manager.add(createComponent()
82 .setInterface(VlanConfigurationCache.class.getName(), null)
83 .setImplementation(VlanConfigurationCacheImpl.class)
84 .add(createServiceDependency().setService(OvsdbConfigurationService.class))
85 .add(createServiceDependency().setService(TenantNetworkManager.class)));
87 Dictionary<String, Object> floatingIPHandlerPorperties = new Hashtable<>();
88 floatingIPHandlerPorperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
89 AbstractEvent.HandlerType.NEUTRON_FLOATING_IP);
91 manager.add(createComponent()
92 .setInterface(new String[]{INeutronFloatingIPAware.class.getName(), AbstractHandler.class.getName()},
93 floatingIPHandlerPorperties)
94 .setImplementation(FloatingIPHandler.class)
95 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
96 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
98 Dictionary<String, Object> networkHandlerProperties = new Hashtable<>();
99 networkHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_NETWORK);
101 manager.add(createComponent()
102 .setInterface(new String[]{INeutronNetworkAware.class.getName(), AbstractHandler.class.getName()},
103 networkHandlerProperties)
104 .setImplementation(NetworkHandler.class)
105 .add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true))
106 .add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true))
107 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
108 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
109 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
110 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
111 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
113 Dictionary<String, Object> subnetHandlerProperties = new Hashtable<>();
114 subnetHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_SUBNET);
116 manager.add(createComponent()
117 .setInterface(new String[]{INeutronSubnetAware.class.getName(), AbstractHandler.class.getName()},
118 subnetHandlerProperties)
119 .setImplementation(SubnetHandler.class)
120 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
121 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
123 Dictionary<String, Object> portHandlerProperties = new Hashtable<>();
124 portHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_PORT);
126 manager.add(createComponent()
127 .setInterface(new String[]{INeutronPortAware.class.getName(), AbstractHandler.class.getName()},
128 portHandlerProperties)
129 .setImplementation(PortHandler.class)
130 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
131 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
132 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
133 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
135 Dictionary<String, Object> routerHandlerProperties = new Hashtable<>();
136 routerHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_ROUTER);
138 manager.add(createComponent()
139 .setInterface(new String[]{INeutronRouterAware.class.getName(), AbstractHandler.class.getName()},
140 routerHandlerProperties)
141 .setImplementation(RouterHandler.class)
142 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
143 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
145 Dictionary<String, Object> southboundHandlerProperties = new Hashtable<>();
146 southboundHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.SOUTHBOUND);
148 manager.add(createComponent()
149 .setInterface(new String[]{OvsdbInventoryListener.class.getName(),
150 NodeCacheListener.class.getName(),
151 AbstractHandler.class.getName()},
152 southboundHandlerProperties)
153 .setImplementation(SouthboundHandler.class)
154 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
155 .add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true))
156 //.add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true))
157 .add(createServiceDependency().setService(NetworkingProviderManager.class).setRequired(true))
158 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
159 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
160 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
161 //.add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true))
162 .add(createServiceDependency().setService(OvsdbInventoryService.class).setRequired(true))
163 .add(createServiceDependency().setService(NodeCacheManager.class).setRequired(true)));
165 Dictionary<String, Object> lbaasHandlerProperties = new Hashtable<>();
166 lbaasHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
167 AbstractEvent.HandlerType.NEUTRON_LOAD_BALANCER);
169 manager.add(createComponent()
170 .setInterface(new String[]{INeutronLoadBalancerAware.class.getName(),
171 NodeCacheListener.class.getName(), AbstractHandler.class.getName()},
172 lbaasHandlerProperties)
173 .setImplementation(LBaaSHandler.class)
174 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
175 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
176 .add(createServiceDependency().setService(INeutronLoadBalancerCRUD.class).setRequired(true))
177 .add(createServiceDependency().setService(INeutronLoadBalancerPoolCRUD.class).setRequired(true))
178 .add(createServiceDependency().setService(LoadBalancerProvider.class).setRequired(true))
179 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
180 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true))
181 .add(createServiceDependency().setService(NodeCacheManager.class).setRequired(true)));
183 Dictionary<String, Object> lbaasPoolHandlerProperties = new Hashtable<>();
184 lbaasPoolHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
185 AbstractEvent.HandlerType.NEUTRON_LOAD_BALANCER_POOL);
187 manager.add(createComponent()
188 .setInterface(new String[]{INeutronLoadBalancerPoolAware.class.getName(),
189 AbstractHandler.class.getName()}, lbaasPoolHandlerProperties)
190 .setImplementation(LBaaSPoolHandler.class)
191 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
192 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
193 .add(createServiceDependency().setService(INeutronLoadBalancerCRUD.class).setRequired(true))
194 .add(createServiceDependency().setService(LoadBalancerProvider.class).setRequired(true))
195 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
196 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true))
197 .add(createServiceDependency().setService(NodeCacheManager.class).setRequired(true)));
199 Dictionary<String, Object> lbaasPoolMemberHandlerProperties = new Hashtable<>();
200 lbaasPoolMemberHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
201 AbstractEvent.HandlerType.NEUTRON_LOAD_BALANCER_POOL_MEMBER);
203 manager.add(createComponent()
204 .setInterface(new String[]{INeutronLoadBalancerPoolMemberAware.class.getName(),
205 AbstractHandler.class.getName()}, lbaasPoolMemberHandlerProperties)
206 .setImplementation(LBaaSPoolMemberHandler.class)
207 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
208 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
209 .add(createServiceDependency().setService(INeutronLoadBalancerCRUD.class).setRequired(true))
210 .add(createServiceDependency().setService(INeutronLoadBalancerPoolCRUD.class).setRequired(true))
211 .add(createServiceDependency().setService(LoadBalancerProvider.class).setRequired(true))
212 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
213 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true))
214 .add(createServiceDependency().setService(NodeCacheManager.class).setRequired(true)));
216 Dictionary<String, Object> portSecurityHandlerProperties = new Hashtable<>();
217 portSecurityHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
218 AbstractEvent.HandlerType.NEUTRON_PORT_SECURITY);
220 manager.add(createComponent()
221 .setInterface(new String[]{INeutronSecurityRuleAware.class.getName(),
222 INeutronSecurityGroupAware.class.getName(), AbstractHandler.class.getName()},
223 portSecurityHandlerProperties)
224 .setImplementation(PortSecurityHandler.class)
225 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true)));
227 manager.add(createComponent()
228 .setInterface(new String[]{SecurityServicesManager.class.getName()}, null)
229 .setImplementation(SecurityServicesImpl.class)
230 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true)));
232 Dictionary<String, Object> fWaasHandlerProperties = new Hashtable<>();
233 fWaasHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_FWAAS);
235 manager.add(createComponent()
236 .setInterface(new String[]{INeutronFirewallAware.class.getName(),
237 INeutronFirewallRuleAware.class.getName(), INeutronFirewallPolicyAware.class.getName(),
238 AbstractHandler.class.getName()}, fWaasHandlerProperties)
239 .setImplementation(FWaasHandler.class)
240 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true)));
242 manager.add(createComponent()
243 .setInterface(NetworkingProviderManager.class.getName(), null)
244 .setImplementation(ProviderNetworkManagerImpl.class)
245 .add(createServiceDependency().setService(NetworkingProvider.class)
246 .setCallbacks("providerAdded", "providerRemoved")));
248 manager.add(createComponent()
249 .setInterface(EventDispatcher.class.getName(), null)
250 .setImplementation(EventDispatcherImpl.class)
251 .add(createServiceDependency()
252 .setService(AbstractHandler.class)
253 .setCallbacks("eventHandlerAdded", "eventHandlerRemoved")));
255 manager.add(createComponent()
256 .setInterface(NeutronL3Adapter.class.getName(), null)
257 .setImplementation(NeutronL3Adapter.class)
258 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
259 .add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true))
260 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
261 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
262 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
263 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true))
264 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
265 /* ToDo, we should probably just use the NetworkingProvider interface
266 * This should provide a way of getting service implementations
267 * Either that, or we should do service lookup at runtime based on getProvider().getName()
268 * This is a shortcut as for now there will only be one implementation of these classes.
270 .add(createServiceDependency().setService(ArpProvider.class).setRequired(false))
271 .add(createServiceDependency().setService(InboundNatProvider.class).setRequired(false))
272 .add(createServiceDependency().setService(OutboundNatProvider.class).setRequired(false))
273 .add(createServiceDependency().setService(RoutingProvider.class).setRequired(false))
274 .add(createServiceDependency().setService(L3ForwardingProvider.class).setRequired(false)));
276 manager.add(createComponent()
277 .setInterface(MultiTenantAwareRouter.class.getName(), null)
278 .setImplementation(OpenstackRouter.class));
280 Dictionary<String, Object> nodeCacheManagerProperties = new Hashtable<>();
281 nodeCacheManagerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NODE);
282 manager.add(createComponent()
283 .setInterface(new String[]{NodeCacheManager.class.getName(), AbstractHandler.class.getName()},
284 nodeCacheManagerProperties)
285 .setImplementation(NodeCacheManagerImpl.class)
286 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
287 .add(createServiceDependency().setService(NodeCacheListener.class)
288 .setCallbacks("cacheListenerAdded", "cacheListenerRemoved")));
290 manager.add(createComponent()
291 .setInterface(new String[] {OvsdbConnectionService.class.getName(),
292 OvsdbConfigurationService.class.getName(),
293 OvsdbInventoryService.class.getName()}, null)
294 .setImplementation(OvsdbInventoryServiceImpl.class)
295 .add(createServiceDependency().setService(OvsdbInventoryListener.class)
296 .setCallbacks("listenerAdded", "listenerRemoved"))
297 .add(createServiceDependency().setService(BindingAwareBroker.class).setRequired(true)));
301 public void destroy(BundleContext context, DependencyManager manager) throws Exception {