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.networkconfig.neutron.INeutronFirewallAware;
19 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallPolicyAware;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronFirewallRuleAware;
21 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPAware;
22 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerAware;
23 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerCRUD;
24 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolAware;
25 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolCRUD;
26 import org.opendaylight.controller.networkconfig.neutron.INeutronLoadBalancerPoolMemberAware;
27 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
28 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
29 import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
30 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
31 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterAware;
32 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupAware;
33 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleAware;
34 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
35 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
36 import org.opendaylight.controller.switchmanager.IInventoryListener;
37 import org.opendaylight.controller.switchmanager.ISwitchManager;
38 import org.opendaylight.ovsdb.openstack.netvirt.api.ArpProvider;
39 import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager;
40 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
41 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
42 import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
43 import org.opendaylight.ovsdb.openstack.netvirt.api.InboundNatProvider;
44 import org.opendaylight.ovsdb.openstack.netvirt.api.L3ForwardingProvider;
45 import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerProvider;
46 import org.opendaylight.ovsdb.openstack.netvirt.api.MultiTenantAwareRouter;
47 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProvider;
48 import org.opendaylight.ovsdb.openstack.netvirt.api.NetworkingProviderManager;
49 import org.opendaylight.ovsdb.openstack.netvirt.api.OutboundNatProvider;
50 import org.opendaylight.ovsdb.openstack.netvirt.api.RoutingProvider;
51 import org.opendaylight.ovsdb.openstack.netvirt.api.SecurityServicesManager;
52 import org.opendaylight.ovsdb.openstack.netvirt.api.TenantNetworkManager;
53 import org.opendaylight.ovsdb.openstack.netvirt.api.VlanConfigurationCache;
54 import org.opendaylight.ovsdb.openstack.netvirt.impl.BridgeConfigurationManagerImpl;
55 import org.opendaylight.ovsdb.openstack.netvirt.impl.ConfigurationServiceImpl;
56 import org.opendaylight.ovsdb.openstack.netvirt.impl.EventDispatcherImpl;
57 import org.opendaylight.ovsdb.openstack.netvirt.impl.NeutronL3Adapter;
58 import org.opendaylight.ovsdb.openstack.netvirt.impl.OpenstackRouter;
59 import org.opendaylight.ovsdb.openstack.netvirt.impl.ProviderNetworkManagerImpl;
60 import org.opendaylight.ovsdb.openstack.netvirt.impl.SecurityServicesImpl;
61 import org.opendaylight.ovsdb.openstack.netvirt.impl.TenantNetworkManagerImpl;
62 import org.opendaylight.ovsdb.openstack.netvirt.impl.VlanConfigurationCacheImpl;
63 import org.opendaylight.ovsdb.plugin.api.OvsdbConfigurationService;
64 import org.opendaylight.ovsdb.plugin.api.OvsdbConnectionService;
65 import org.opendaylight.ovsdb.plugin.api.OvsdbInventoryListener;
67 import org.osgi.framework.BundleContext;
70 * OSGi bundle activator for the OVSDB Neutron Interface.
72 public class Activator extends DependencyActivatorBase {
75 public void init(BundleContext context, DependencyManager manager) throws Exception {
77 manager.add(createComponent()
78 .setInterface(ConfigurationService.class.getName(), null)
79 .setImplementation(ConfigurationServiceImpl.class)
80 .add(createServiceDependency().setService(OvsdbConfigurationService.class)));
82 manager.add(createComponent()
83 .setInterface(BridgeConfigurationManager.class.getName(), null)
84 .setImplementation(BridgeConfigurationManagerImpl.class)
85 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
86 .add(createServiceDependency().setService(NetworkingProviderManager.class))
87 .add(createServiceDependency().setService(OvsdbConfigurationService.class)));
89 manager.add(createComponent()
90 .setInterface(TenantNetworkManager.class.getName(), null)
91 .setImplementation(TenantNetworkManagerImpl.class)
92 .add(createServiceDependency().setService(NetworkingProviderManager.class))
93 .add(createServiceDependency().setService(OvsdbConfigurationService.class))
94 .add(createServiceDependency().setService(OvsdbConnectionService.class))
95 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
96 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
97 .add(createServiceDependency().setService(VlanConfigurationCache.class)));
99 manager.add(createComponent()
100 .setInterface(VlanConfigurationCache.class.getName(), null)
101 .setImplementation(VlanConfigurationCacheImpl.class)
102 .add(createServiceDependency().setService(OvsdbConfigurationService.class))
103 .add(createServiceDependency().setService(TenantNetworkManager.class)));
105 Dictionary<String, Object> floatingIPHandlerPorperties = new Hashtable<>();
106 floatingIPHandlerPorperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
107 AbstractEvent.HandlerType.NEUTRON_FLOATING_IP);
109 manager.add(createComponent()
110 .setInterface(new String[]{INeutronFloatingIPAware.class.getName(), AbstractHandler.class.getName()},
111 floatingIPHandlerPorperties)
112 .setImplementation(FloatingIPHandler.class)
113 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
114 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
116 Dictionary<String, Object> networkHandlerProperties = new Hashtable<>();
117 networkHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_NETWORK);
119 manager.add(createComponent()
120 .setInterface(new String[]{INeutronNetworkAware.class.getName(), AbstractHandler.class.getName()},
121 networkHandlerProperties)
122 .setImplementation(NetworkHandler.class)
123 .add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true))
124 .add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true))
125 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
126 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
127 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
128 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
129 .add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true))
130 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
131 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
133 Dictionary<String, Object> subnetHandlerProperties = new Hashtable<>();
134 subnetHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_SUBNET);
136 manager.add(createComponent()
137 .setInterface(new String[]{INeutronSubnetAware.class.getName(), AbstractHandler.class.getName()},
138 subnetHandlerProperties)
139 .setImplementation(SubnetHandler.class)
140 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
141 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
143 Dictionary<String, Object> portHandlerProperties = new Hashtable<>();
144 portHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_PORT);
146 manager.add(createComponent()
147 .setInterface(new String[]{INeutronPortAware.class.getName(), AbstractHandler.class.getName()},
148 portHandlerProperties)
149 .setImplementation(PortHandler.class)
150 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
151 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
152 .add(createServiceDependency().setService(OvsdbInventoryListener.class).setRequired(true))
153 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
154 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
156 Dictionary<String, Object> routerHandlerProperties = new Hashtable<>();
157 routerHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_ROUTER);
159 manager.add(createComponent()
160 .setInterface(new String[]{INeutronRouterAware.class.getName(), AbstractHandler.class.getName()},
161 routerHandlerProperties)
162 .setImplementation(RouterHandler.class)
163 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
164 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
166 Dictionary<String, Object> southboundHandlerProperties = new Hashtable<>();
167 southboundHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.SOUTHBOUND);
169 manager.add(createComponent()
170 .setInterface(new String[]{OvsdbInventoryListener.class.getName(), IInventoryListener.class.getName(),
171 AbstractHandler.class.getName()},
172 southboundHandlerProperties)
173 .setImplementation(SouthboundHandler.class)
174 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
175 .add(createServiceDependency().setService(BridgeConfigurationManager.class).setRequired(true))
176 .add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true))
177 .add(createServiceDependency().setService(NetworkingProviderManager.class).setRequired(true))
178 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
179 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
180 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
181 .add(createServiceDependency().setService(NeutronL3Adapter.class).setRequired(true)));
183 Dictionary<String, Object> lbaasHandlerProperties = new Hashtable<>();
184 lbaasHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
185 AbstractEvent.HandlerType.NEUTRON_LOAD_BALANCER);
187 manager.add(createComponent()
188 .setInterface(new String[]{INeutronLoadBalancerAware.class.getName(),
189 IInventoryListener.class.getName(), AbstractHandler.class.getName()},
190 lbaasHandlerProperties)
191 .setImplementation(LBaaSHandler.class)
192 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
193 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
194 .add(createServiceDependency().setService(INeutronLoadBalancerCRUD.class).setRequired(true))
195 .add(createServiceDependency().setService(INeutronLoadBalancerPoolCRUD.class).setRequired(true))
196 .add(createServiceDependency().setService(LoadBalancerProvider.class).setRequired(true))
197 .add(createServiceDependency().setService(ISwitchManager.class).setRequired(true))
198 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
199 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true)));
201 Dictionary<String, Object> lbaasPoolHandlerProperties = new Hashtable<>();
202 lbaasPoolHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
203 AbstractEvent.HandlerType.NEUTRON_LOAD_BALANCER_POOL);
205 manager.add(createComponent()
206 .setInterface(new String[]{INeutronLoadBalancerPoolAware.class.getName(),
207 AbstractHandler.class.getName()}, lbaasPoolHandlerProperties)
208 .setImplementation(LBaaSPoolHandler.class)
209 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
210 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
211 .add(createServiceDependency().setService(INeutronLoadBalancerCRUD.class).setRequired(true))
212 .add(createServiceDependency().setService(LoadBalancerProvider.class).setRequired(true))
213 .add(createServiceDependency().setService(ISwitchManager.class).setRequired(true))
214 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
215 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true)));
217 Dictionary<String, Object> lbaasPoolMemberHandlerProperties = new Hashtable<>();
218 lbaasPoolMemberHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
219 AbstractEvent.HandlerType.NEUTRON_LOAD_BALANCER_POOL_MEMBER);
221 manager.add(createComponent()
222 .setInterface(new String[] {INeutronLoadBalancerPoolMemberAware.class.getName(),
223 AbstractHandler.class.getName()}, lbaasPoolMemberHandlerProperties)
224 .setImplementation(LBaaSPoolMemberHandler.class)
225 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
226 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
227 .add(createServiceDependency().setService(INeutronLoadBalancerCRUD.class).setRequired(true))
228 .add(createServiceDependency().setService(INeutronLoadBalancerPoolCRUD.class).setRequired(true))
229 .add(createServiceDependency().setService(LoadBalancerProvider.class).setRequired(true))
230 .add(createServiceDependency().setService(ISwitchManager.class).setRequired(true))
231 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
232 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true)));
234 Dictionary<String, Object> portSecurityHandlerProperties = new Hashtable<>();
235 portSecurityHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY,
236 AbstractEvent.HandlerType.NEUTRON_PORT_SECURITY);
238 manager.add(createComponent()
239 .setInterface(new String[]{INeutronSecurityRuleAware.class.getName(),
240 INeutronSecurityGroupAware.class.getName(), AbstractHandler.class.getName()},
241 portSecurityHandlerProperties)
242 .setImplementation(PortSecurityHandler.class)
243 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true))
244 .add(createServiceDependency().setService(SecurityServicesManager.class).setRequired(true)));
246 manager.add(createComponent()
247 .setInterface(new String[]{SecurityServicesManager.class.getName()}, null)
248 .setImplementation(SecurityServicesImpl.class));
250 Dictionary<String, Object> fWaasHandlerProperties = new Hashtable<>();
251 fWaasHandlerProperties.put(Constants.EVENT_HANDLER_TYPE_PROPERTY, AbstractEvent.HandlerType.NEUTRON_FWAAS);
253 manager.add(createComponent()
254 .setInterface(new String[] {INeutronFirewallAware.class.getName(),
255 INeutronFirewallRuleAware.class.getName(), INeutronFirewallPolicyAware.class.getName(),
256 AbstractHandler.class.getName()}, fWaasHandlerProperties)
257 .setImplementation(FWaasHandler.class)
258 .add(createServiceDependency().setService(EventDispatcher.class).setRequired(true)));
260 manager.add(createComponent()
261 .setInterface(NetworkingProviderManager.class.getName(), null)
262 .setImplementation(ProviderNetworkManagerImpl.class)
263 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
264 .add(createServiceDependency().setService(NetworkingProvider.class)
265 .setCallbacks("providerAdded", "providerRemoved")));
267 manager.add(createComponent()
268 .setInterface(EventDispatcher.class.getName(), null)
269 .setImplementation(EventDispatcherImpl.class)
270 .add(createServiceDependency()
271 .setService(AbstractHandler.class)
272 .setCallbacks("eventHandlerAdded", "eventHandlerRemoved")));
274 manager.add(createComponent()
275 .setInterface(NeutronL3Adapter.class.getName(), null)
276 .setImplementation(NeutronL3Adapter.class)
277 .add(createServiceDependency().setService(ConfigurationService.class).setRequired(true))
278 .add(createServiceDependency().setService(TenantNetworkManager.class).setRequired(true))
279 .add(createServiceDependency().setService(NetworkingProviderManager.class).setRequired(true))
280 .add(createServiceDependency().setService(OvsdbConfigurationService.class).setRequired(true))
281 .add(createServiceDependency().setService(OvsdbConnectionService.class).setRequired(true))
282 .add(createServiceDependency().setService(INeutronNetworkCRUD.class).setRequired(true))
283 .add(createServiceDependency().setService(INeutronSubnetCRUD.class).setRequired(true))
284 .add(createServiceDependency().setService(INeutronPortCRUD.class).setRequired(true))
285 .add(createServiceDependency().setService(MultiTenantAwareRouter.class).setRequired(true))
286 /* ToDo, we should probably just use the NetworkingProvider interface
287 * This should provide a way of getting service implementations
288 * Either that, or we should do service lookup at runtime based on getProvider().getName()
289 * This is a shortcut as for now there will only be one implementation of these classes.
291 .add(createServiceDependency().setService(ArpProvider.class).setRequired(false))
292 .add(createServiceDependency().setService(InboundNatProvider.class).setRequired(false))
293 .add(createServiceDependency().setService(OutboundNatProvider.class).setRequired(false))
294 .add(createServiceDependency().setService(RoutingProvider.class).setRequired(false))
295 .add(createServiceDependency().setService(L3ForwardingProvider.class).setRequired(false)));
297 manager.add(createComponent()
298 .setInterface(MultiTenantAwareRouter.class.getName(), null)
299 .setImplementation(OpenstackRouter.class));
303 public void destroy(BundleContext context, DependencyManager manager) throws Exception {