Merge "Remove AD-SAL dependencies from Neutron service"
authorVina Ermagan <vermagan@cisco.com>
Tue, 17 Feb 2015 18:53:23 +0000 (18:53 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 17 Feb 2015 18:53:23 +0000 (18:53 +0000)
commons/parent/pom.xml
features/pom.xml
features/src/main/resources/features.xml
mappingservice/neutron/pom.xml
mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/Activator.java
mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/LispNeutronSubnetHandler.java

index fe8eef972db0665f0e459bfb28f07e0c30b795c5..3751ba8b275b00060d94b8e6efd8ecb991e2ee95 100644 (file)
@@ -39,6 +39,7 @@
     <karaf.resources.version>1.5.0-SNAPSHOT</karaf.resources.version>
     <lispflowmapping.version>1.2.0-SNAPSHOT</lispflowmapping.version>
     <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+    <neutron.version>0.5.0-SNAPSHOT</neutron.version>
     <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
     <nsf.version>0.5.0-SNAPSHOT</nsf.version>
     <sal.version>0.9.0-SNAPSHOT</sal.version>
         <classifier>features</classifier>
         <type>xml</type>
       </dependency>
+      <dependency>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>features-neutron</artifactId>
+        <version>${neutron.version}</version>
+        <classifier>features</classifier>
+        <type>xml</type>
+      </dependency>
       <dependency>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>features-nsf</artifactId>
index 16c3e0667c10e4de03fadccecf1aa020bc445e3e..596df3b80145ad24665b0e77f79ecbb270dada81 100644 (file)
       <classifier>features</classifier>
       <type>xml</type>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>features-neutron</artifactId>
+      <classifier>features</classifier>
+      <type>xml</type>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>features-nsf</artifactId>
index 2d35267e5a39f51d1801d9b81895adeb8f7f1242..c1da39f0e21eac21964140f00aea58f43703f3e0 100644 (file)
@@ -13,6 +13,7 @@
 
     <repository>mvn:org.opendaylight.controller/features-mdsal/${mdsal.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.controller/features-adsal/${sal.version}/xml/features</repository>
+    <repository>mvn:org.opendaylight.controller/features-neutron/${neutron.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.controller/features-nsf/${nsf.version}/xml/features</repository>
     <repository>mvn:org.opendaylight.controller/features-netconf-connector/${mdsal.version}/xml/features</repository>
 
@@ -53,7 +54,7 @@
     </feature>
 
     <feature name="odl-lispflowmapping-neutron" description="OpenDaylight :: LISP Flow Mapping :: Neutron Integration" version='${lispflowmapping.version}'>
-        <feature version="${nsf.version}">odl-adsal-northbound</feature>
+        <feature version="${neutron.version}">odl-neutron-all</feature>
         <feature version="${lispflowmapping.version}">odl-lispflowmapping-mappingservice</feature>
         <bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.neutron/${lispflowmapping.version}</bundle>
     </feature>
index 402a888f25e0dd5d25e328b5973650983a3e43b5..42042ccf390ba49e0131623287effa6af10670be 100644 (file)
   <packaging>bundle</packaging>
   <name>LISP Flow Mapping Neutron APIs</name>
   <dependencies>
-    <dependency>
-      <groupId>equinoxSDK381</groupId>
-      <artifactId>org.eclipse.osgi</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>commons.northbound</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>networkconfig.neutron</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.lispflowmapping</groupId>
       <artifactId>mappingservice.api</artifactId>
         <configuration>
           <instructions>
             <Export-Package></Export-Package>
-            <Import-Package>org.opendaylight.controller.sal.core,
-              org.opendaylight.controller.sal.utils,
-              org.opendaylight.controller.containermanager,
-              org.opendaylight.controller.switchmanager,
+            <Import-Package>org.apache.commons.net.util,
+              org.apache.felix.dm,
               org.opendaylight.controller.networkconfig.neutron,
-              org.opendaylight.controller.northbound.commons,
-              org.opendaylight.controller.northbound.commons.exception,
-              org.opendaylight.controller.northbound.commons.utils,
-              com.sun.jersey.spi.container.servlet,
-              org.opendaylight.controller.sal.authorization,
-              org.opendaylight.controller.usermanager,
               org.opendaylight.lispflowmapping.type,
               org.opendaylight.lispflowmapping.type.lisp,
               org.opendaylight.lispflowmapping.type.lisp.address,
               org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer,
               org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address,
               org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924,
-              org.slf4j,
-              org.apache.catalina.filters,
-              org.apache.felix.dm,
-                    org.apache.commons.net.util,
-              org.apache.commons.lang3.builder,
-              org.osgi.service.component,
-              org.eclipse.osgi.framework.console,
-              org.osgi.framework,</Import-Package>
+              org.slf4j</Import-Package>
             <Bundle-Activator>org.opendaylight.lispflowmapping.neutron.Activator</Bundle-Activator>
 
             <Export-Package></Export-Package>
index 53c1c5b25db0d5789ce4cb5dee4f302a5a96a51f..3f9855f31b854eb91039cab3cdd39c1316981e1c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
@@ -12,12 +12,13 @@ package org.opendaylight.lispflowmapping.neutron;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.apache.felix.dm.DependencyActivatorBase;
+import org.apache.felix.dm.DependencyManager;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
 import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
 import org.opendaylight.controller.networkconfig.neutron.INeutronPortAware;
+import org.osgi.framework.BundleContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,94 +28,40 @@ import org.slf4j.LoggerFactory;
  *
  */
 
-public class Activator extends ComponentActivatorAbstractBase {
+public class Activator extends DependencyActivatorBase {
 
-    /*
-     * Logger instance
-     */
     protected static final Logger logger = LoggerFactory.getLogger(Activator.class);
 
-    /**
-     * Function called when the activator starts just after some initializations
-     * are done by the ComponentActivatorAbstractBase.
-     *
-     */
     @Override
-    public void init() {
-        logger.debug("LISP Neutron Service is initialized!");
-
-    }
-
-    /**
-     * Function called when the activator stops just before the cleanup done by
-     * ComponentActivatorAbstractBase
-     *
-     */
-    @Override
-    public void destroy() {
-        logger.debug("LISP Neutron Service is destroyed!");
-    }
-
-    /**
-     * Function that is used to communicate to dependency manager the list of
-     * known implementations for services inside a container
-     *
-     *
-     * @return An array containing all the CLASS objects that will be
-     *         instantiated in order to get an fully working implementation
-     *         Object
-     */
-    @Override
-    public Object[] getImplementations() {
-        Object[] res = { LispNeutronService.class,
-                                        LispNeutronSubnetHandler.class,
-                                        LispNeutronPortHandler.class,
-                                        LispNeutronNetworkHandler.class};
-        return res;
-    }
-
-    /**
-     * Function that is called when configuration of the dependencies is
-     * required.
-     *
-     * @param c
-     *            dependency manager Component object, used for configuring the
-     *            dependencies exported and imported
-     * @param imp
-     *            Implementation class that is being configured, needed as long
-     *            as the same routine can configure multiple implementations
-     * @param containerName
-     *            The containerName being configured, this allow also optional
-     *            per-container different behavior if needed, usually should not
-     *            be the case though.
-     */
-    @Override
-    public void configureInstance(Component c, Object imp, String containerName) {
+    public void init(BundleContext context, DependencyManager manager) throws Exception {
         Dictionary<String, String> props = new Hashtable<String, String>();
         props.put("name", "mappingservice");
 
-        if (imp.equals(LispNeutronService.class)) {
-            c.setInterface(ILispNeutronService.class.getName(), props);
-        }
+        manager.add(createComponent()
+                .setInterface(ILispNeutronService.class.getName(), null)
+                .setImplementation(LispNeutronService.class)
+                .add(createServiceDependency().setService(IFlowMapping.class)));
 
-        if (imp.equals(LispNeutronNetworkHandler.class)) {
-            c.setInterface(new String[] { ILispNeutronService.class.getName(), INeutronNetworkAware.class.getName()}, props);
-        }
+        manager.add(createComponent()
+                .setInterface(new String[] { ILispNeutronService.class.getName(), INeutronNetworkAware.class.getName()}, props)
+                .setImplementation(LispNeutronNetworkHandler.class));
 
-        if (imp.equals(LispNeutronSubnetHandler.class)) {
-               c.setInterface(new String[] { ILispNeutronService.class.getName(), INeutronSubnetAware.class.getName()}, props);
-        }
+        manager.add(createComponent()
+                .setInterface(new String[] { ILispNeutronService.class.getName(), INeutronSubnetAware.class.getName()}, props)
+                .setImplementation(LispNeutronSubnetHandler.class)
+                .add(createServiceDependency().setService(ILispNeutronService.class)));
 
-        if (imp.equals(LispNeutronPortHandler.class)) {
-            c.setInterface(new String[] { ILispNeutronService.class.getName(), INeutronPortAware.class.getName()}, props);
-        }
+        manager.add(createComponent()
+                .setInterface(new String[] { ILispNeutronService.class.getName(), INeutronPortAware.class.getName()}, props)
+                .setImplementation(LispNeutronPortHandler.class));
 
-        c.add(createContainerServiceDependency(containerName)
-                       .setService(IFlowMapping.class)
-                       .setCallbacks("setMappingService", "unsetMappingService")
-                .setRequired(true));
+        logger.debug("LISP Neutron Service is initialized!");
 
+    }
 
+    @Override
+    public void destroy(BundleContext context, DependencyManager manager) throws Exception {
+        logger.debug("LISP Neutron Service is destroyed!");
     }
 
 }
index 63279b1527e130665f66e3cd244df017c938cc43..b503fb7abc91ba6e3d24cb5ca9b5fad74e37fa8c 100644 (file)
@@ -15,8 +15,6 @@ import org.apache.commons.net.util.SubnetUtils;
 import org.apache.commons.net.util.SubnetUtils.SubnetInfo;
 import org.opendaylight.controller.networkconfig.neutron.INeutronSubnetAware;
 import org.opendaylight.controller.networkconfig.neutron.NeutronSubnet;
-
-import org.opendaylight.controller.sal.utils.ServiceHelper;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.LispAFIAddress;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainerBuilder;
@@ -33,6 +31,9 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.
  */
 public class LispNeutronSubnetHandler extends LispNeutronService implements INeutronSubnetAware {
 
+    // The implementation for each of these services is resolved by the OSGi Service Manager
+    private volatile ILispNeutronService lispNeutronService;
+
        @Override
        public int canCreateSubnet(NeutronSubnet subnet) {
                logger.info("Neutron canCreateSubnet : Subnet name: " + subnet.getName() + " Subnet Cidr: " +
@@ -70,10 +71,8 @@ public class LispNeutronSubnetHandler extends LispNeutronService implements INeu
         LispAFIAddress lispAddress = new Ipv4Builder().setIpv4Address(new Ipv4Address(info.getNetworkAddress())).setAfi(ianaCode).build();
         LispAddressContainer addressContainer =        new LispAddressContainerBuilder().setAddress((Address) lispAddress).build();
 
-        ILispNeutronService lispService = (ILispNeutronService) ServiceHelper.getGlobalInstance(ILispNeutronService.class, this);
-
         try{
-               lispService.getMappingService().addAuthenticationKey(addressContainer, masklen, subnet.getNetworkUUID());
+               lispNeutronService.getMappingService().addAuthenticationKey(addressContainer, masklen, subnet.getNetworkUUID());
 
                logger.debug("Neutron Subnet Added to MapServer : Subnet name: " + subnet.getName() + " EID Prefix: " +
                        addressContainer.toString() + " Key: " + subnet.getNetworkUUID());
@@ -140,11 +139,9 @@ public class LispNeutronSubnetHandler extends LispNeutronService implements INeu
         LispAFIAddress lispAddress = new Ipv4Builder().setIpv4Address(new Ipv4Address(info.getNetworkAddress())).setAfi(ianaCode).build();
         LispAddressContainer addressContainer = new LispAddressContainerBuilder().setAddress((Address) lispAddress).build();
 
-        ILispNeutronService lispService = (ILispNeutronService) ServiceHelper.getGlobalInstance(ILispNeutronService.class, this);
-
         // if subnet does not exist in MapServer, return error
         try{
-               if (lispService.getMappingService().getAuthenticationKey(addressContainer, masklen) == null){
+               if (lispNeutronService.getMappingService().getAuthenticationKey(addressContainer, masklen) == null){
 
                        logger.error("Neutron canDeleteSubnet rejected : Subnet does not exist: Subnet name: " +
                                        subnet.getName() +
@@ -186,16 +183,14 @@ public class LispNeutronSubnetHandler extends LispNeutronService implements INeu
         LispAddressContainer addressContainer = new LispAddressContainerBuilder().setAddress((Address) lispAddress).build();
 
         try{
-               ILispNeutronService lispService = (ILispNeutronService) ServiceHelper.getGlobalInstance(ILispNeutronService.class, this);
-
                // if subnet does not exist in MapServer, return error
-               if (lispService.getMappingService().getAuthenticationKey(addressContainer,masklen) == null){
+               if (lispNeutronService.getMappingService().getAuthenticationKey(addressContainer,masklen) == null){
                    logger.error("Neutron Delete Subnet Failed: Subnet does not exist: Subnet name: " + subnet.getName() +
                                " Eid Prefix: " + addressContainer.toString() +
                                "Key: " + subnet.getNetworkUUID());
                    return;
                }
-               lispService.getMappingService().removeAuthenticationKey(addressContainer, masklen);
+               lispNeutronService.getMappingService().removeAuthenticationKey(addressContainer, masklen);
 
                logger.debug("Neutron Subnet Deleted from MapServer : Subnet name: " + subnet.getName() +
                                " Eid Prefix: " + addressContainer.toString() +