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