Neutron API v2.0 bindings and APIs for security groups/rules.
[controller.git] / opendaylight / networkconfiguration / neutron / implementation / src / main / java / org / opendaylight / controller / networkconfig / neutron / implementation / Activator.java
1 /*
2  * Copyright IBM Corporation, 2013.  All rights reserved.
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
9 package org.opendaylight.controller.networkconfig.neutron.implementation;
10
11 import java.util.Hashtable;
12 import java.util.Dictionary;
13
14 import org.apache.felix.dm.Component;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
18 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
19 import org.opendaylight.controller.configuration.IConfigurationContainerService;
20 import org.opendaylight.controller.networkconfig.neutron.INeutronFloatingIPCRUD;
21 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkCRUD;
22 import org.opendaylight.controller.networkconfig.neutron.INeutronPortCRUD;
23 import org.opendaylight.controller.networkconfig.neutron.INeutronRouterCRUD;
24 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetCRUD;
25 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityGroupCRUD;
26 import org.opendaylight.controller.networkconfig.neutron.INeutronSecurityRuleCRUD;
27 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
28
29 public class Activator extends ComponentActivatorAbstractBase {
30     protected static final Logger logger = LoggerFactory
31     .getLogger(Activator.class);
32
33     /**
34      * Function called when the activator starts just after some
35      * initializations are done by the
36      * ComponentActivatorAbstractBase.
37      *
38      */
39     @Override
40     public void init() {
41
42     }
43
44     /**
45      * Function called when the activator stops just before the
46      * cleanup done by ComponentActivatorAbstractBase
47      *
48      */
49     @Override
50     public void destroy() {
51
52     }
53
54     /**
55      * Function that is used to communicate to dependency manager the
56      * list of known implementations for services inside a container
57      *
58      *
59      * @return An array containing all the CLASS objects that will be
60      * instantiated in order to get an fully working implementation
61      * Object
62      */
63     @Override
64     public Object[] getImplementations() {
65         Object[] res = { NeutronFloatingIPInterface.class,
66                 NeutronRouterInterface.class,
67                 NeutronPortInterface.class,
68                 NeutronSubnetInterface.class,
69                 NeutronNetworkInterface.class };
70         return res;
71     }
72
73     /**
74      * Function that is called when configuration of the dependencies
75      * is required.
76      *
77      * @param c dependency manager Component object, used for
78      * configuring the dependencies exported and imported
79      * @param imp Implementation class that is being configured,
80      * needed as long as the same routine can configure multiple
81      * implementations
82      * @param containerName The containerName being configured, this allow
83      * also optional per-container different behavior if needed, usually
84      * should not be the case though.
85      */
86     @Override
87     public void configureInstance(Component c, Object imp, String containerName) {
88         if (imp.equals(NeutronFloatingIPInterface.class)) {
89             // export the service
90             c.setInterface(
91                     new String[] { INeutronFloatingIPCRUD.class.getName(),
92                                    IConfigurationContainerAware.class.getName()}, null);
93             Dictionary<String, String> props = new Hashtable<String, String>();
94             props.put("salListenerName", "neutron");
95             c.add(createContainerServiceDependency(containerName)
96                     .setService(IClusterContainerServices.class)
97                     .setCallbacks("setClusterContainerService",
98                     "unsetClusterContainerService").setRequired(true));
99             c.add(createContainerServiceDependency(containerName).setService(
100                     IConfigurationContainerService.class).setCallbacks(
101                     "setConfigurationContainerService",
102                     "unsetConfigurationContainerService").setRequired(true));
103         }
104         if (imp.equals(NeutronRouterInterface.class)) {
105             // export the service
106             c.setInterface(
107                     new String[] { INeutronRouterCRUD.class.getName(),
108                                    IConfigurationContainerAware.class.getName()}, null);
109             Dictionary<String, String> props = new Hashtable<String, String>();
110             props.put("salListenerName", "neutron");
111             c.add(createContainerServiceDependency(containerName)
112                     .setService(IClusterContainerServices.class)
113                     .setCallbacks("setClusterContainerService",
114                     "unsetClusterContainerService").setRequired(true));
115             c.add(createContainerServiceDependency(containerName).setService(
116                     IConfigurationContainerService.class).setCallbacks(
117                     "setConfigurationContainerService",
118                     "unsetConfigurationContainerService").setRequired(true));
119         }
120         if (imp.equals(NeutronPortInterface.class)) {
121             // export the service
122             c.setInterface(
123                     new String[] { INeutronPortCRUD.class.getName(),
124                                    IConfigurationContainerAware.class.getName()}, null);
125             Dictionary<String, String> props = new Hashtable<String, String>();
126             props.put("salListenerName", "neutron");
127             c.add(createContainerServiceDependency(containerName)
128                     .setService(IClusterContainerServices.class)
129                     .setCallbacks("setClusterContainerService",
130                     "unsetClusterContainerService").setRequired(true));
131             c.add(createContainerServiceDependency(containerName).setService(
132                     IConfigurationContainerService.class).setCallbacks(
133                     "setConfigurationContainerService",
134                     "unsetConfigurationContainerService").setRequired(true));
135         }
136         if (imp.equals(NeutronSubnetInterface.class)) {
137             // export the service
138             c.setInterface(
139                     new String[] { INeutronSubnetCRUD.class.getName(),
140                                    IConfigurationContainerAware.class.getName()}, null);
141             Dictionary<String, String> props = new Hashtable<String, String>();
142             props.put("salListenerName", "neutron");
143             c.add(createContainerServiceDependency(containerName)
144                     .setService(IClusterContainerServices.class)
145                     .setCallbacks("setClusterContainerService",
146                     "unsetClusterContainerService").setRequired(true));
147             c.add(createContainerServiceDependency(containerName).setService(
148                     IConfigurationContainerService.class).setCallbacks(
149                     "setConfigurationContainerService",
150                     "unsetConfigurationContainerService").setRequired(true));
151         }
152         if (imp.equals(NeutronNetworkInterface.class)) {
153             // export the service
154             c.setInterface(
155                     new String[] { INeutronNetworkCRUD.class.getName(),
156                                    IConfigurationContainerAware.class.getName()}, null);
157             Dictionary<String, String> props = new Hashtable<String, String>();
158             props.put("salListenerName", "neutron");
159             c.add(createContainerServiceDependency(containerName)
160                     .setService(IClusterContainerServices.class)
161                     .setCallbacks("setClusterContainerService",
162                     "unsetClusterContainerService").setRequired(true));
163             c.add(createContainerServiceDependency(containerName).setService(
164                     IConfigurationContainerService.class).setCallbacks(
165                     "setConfigurationContainerService",
166                     "unsetConfigurationContainerService").setRequired(true));
167         }
168         if (imp.equals(NeutronSecurityGroupInterface.class)) {
169             // export the service
170             c.setInterface(
171                 new String[] { INeutronSecurityGroupCRUD.class.getName(),
172                     IConfigurationContainerAware.class.getName()}, null);
173             Dictionary<String, String> props = new Hashtable<String, String>();
174             props.put("salListenerName", "neutron");
175             c.add(createContainerServiceDependency(containerName)
176                 .setService(IClusterContainerServices.class)
177                 .setCallbacks("setClusterContainerService",
178                     "unsetClusterContainerService").setRequired(true));
179             c.add(createContainerServiceDependency(containerName).setService(
180                 IConfigurationContainerService.class).setCallbacks(
181                 "setConfigurationContainerService",
182                 "unsetConfigurationContainerService").setRequired(true));
183         }
184         if (imp.equals(NeutronSecurityRuleInterface.class)) {
185             // export the service
186             c.setInterface(
187                 new String[] { INeutronSecurityRuleCRUD.class.getName(),
188                     IConfigurationContainerAware.class.getName()}, null);
189             Dictionary<String, String> props = new Hashtable<String, String>();
190             props.put("salListenerName", "neutron");
191             c.add(createContainerServiceDependency(containerName)
192                 .setService(IClusterContainerServices.class)
193                 .setCallbacks("setClusterContainerService",
194                     "unsetClusterContainerService").setRequired(true));
195             c.add(createContainerServiceDependency(containerName).setService(
196                 IConfigurationContainerService.class).setCallbacks(
197                 "setConfigurationContainerService",
198                 "unsetConfigurationContainerService").setRequired(true));
199         }
200     }
201 }