Merge remote branch 'origin/release-1.0.X' into develop 19/5019/1
authorDavid Goldberg <david.goldberg@contextream.com>
Thu, 30 Jan 2014 09:45:17 +0000 (11:45 +0200)
committerDavid Goldberg <david.goldberg@contextream.com>
Thu, 30 Jan 2014 09:47:05 +0000 (11:47 +0200)
Change-Id: I4ddd7e3ca9b57565254ab45f231eb112469a9bbd
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
32 files changed:
.gitignore
.gitreview [new file with mode: 0644]
commons/build_tools/pom.xml
commons/code-parent/pom.xml
commons/parent/pom.xml
commons/unittest_tools/pom.xml
distribution/pom.xml
mappingservice/.gitignore
mappingservice/api/pom.xml
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IMapRequestResultHandler.java [moved from mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IMapReplyHandler.java with 69% similarity]
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IMapResolverAsync.java
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/type/sbplugin/ILispSouthboundPlugin.java
mappingservice/config/pom.xml
mappingservice/implementation/ms.impl-tests.launch
mappingservice/implementation/pom.xml
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/LispMappingService.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/lisp/MapResolver.java
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/util/LispNotificationHelper.java
mappingservice/integrationtest/pom.xml
mappingservice/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/integrationtest/src/test/resources/logback.xml
mappingservice/neutron/pom.xml [new file with mode: 0644]
mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/Activator.java [new file with mode: 0644]
mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/ILispNeutronService.java [new file with mode: 0644]
mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/LispNeutronService.java [new file with mode: 0644]
mappingservice/northbound/pom.xml
mappingservice/pom.xml
mappingservice/southbound/pom.xml
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java
mappingservice/yangmodel/.gitignore
mappingservice/yangmodel/pom.xml
pom.xml

index 1fcf7c2ef3340fe99f9cd2d3572cf6966e6fcd71..b5bbeaa81c6279c93210f8c19e257eb0e4ec8606 100644 (file)
@@ -2,4 +2,9 @@
 *.settings
 *.classpath
 *target
+*target-ide
 *logs
+*.ipr
+*.iml
+*.iws
+.idea
diff --git a/.gitreview b/.gitreview
new file mode 100644 (file)
index 0000000..76ace75
--- /dev/null
@@ -0,0 +1,4 @@
+[gerrit]
+host=git.opendaylight.org
+port=29418
+project=lispflowmapping.git
index a6e1f62f856b0ab78147f487e31b5f45026b06a6..fb3643fe3e21c5465a2ad7ae65e7d9570bffc52d 100644 (file)
@@ -4,11 +4,11 @@
        <parent>
                 <groupId>org.opendaylight.lispflowmapping</groupId>
                 <artifactId>lispflowmapping-commons</artifactId>
-                <version>1.0.1-SNAPSHOT</version>
+                <version>1.1.0-SNAPSHOT</version>
                 <relativePath>../parent</relativePath>
        </parent>
        <artifactId>common.build.tools</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
index 50f2c9179ea9166673adf474d7e0096117809dcf..dcb2263581113808278669d5838eb4b4fc1550d9 100644 (file)
@@ -4,12 +4,12 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>lispflowmapping-commons</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../parent</relativePath>
        </parent>
        <artifactId>lispflowmapping-code-commons</artifactId>
        <packaging>pom</packaging>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
                <developerConnection>scm:git:ssh://git.opendaylight.org:29418/lispflowmapping.git</developerConnection>
index efc1c265028f5248e5b642af9c767404f5423b07..dea89550bb6a46f4f3d48456669cf0278f938193 100644 (file)
@@ -2,8 +2,8 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.opendaylight.lispflowmapping</groupId>
        <artifactId>lispflowmapping-commons</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
-       <description />
+       <version>1.1.0-SNAPSHOT</version>
+       <description></description>
        <packaging>pom</packaging>
        <url>http://www.opendaylight.org</url>
        <scm>
@@ -13,7 +13,7 @@
                <tag>HEAD</tag>
        </scm>
        <properties>
-               <lispflowmapping.version>1.0.1-SNAPSHOT</lispflowmapping.version>
+               <lispflowmapping.version>1.1.0-SNAPSHOT</lispflowmapping.version>
                <jacoco.version>0.5.3.201107060350</jacoco.version>
                <enforcer.version>1.3.1</enforcer.version>
                <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
index 9dcafa99fa5ffeb6d0d8bd0fdc0d71e7d5495f33..ba09b19ce88a9adb22d4a8158b29c3db537081fc 100644 (file)
@@ -4,11 +4,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>lispflowmapping-commons</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../parent</relativePath>
        </parent>
        <artifactId>common.unittest.tools</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>jar</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
index 062189e8fb16ada9fcd2527c99f05c2e435bc0d8..0670a643bc21f85c32320629ccb2129c16b386cb 100644 (file)
@@ -3,7 +3,7 @@
   <parent>
     <groupId>org.opendaylight.lispflowmapping</groupId>
     <artifactId>lispflowmapping-commons</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <relativePath>../commons/parent</relativePath>
   </parent>
 
index 9249a1998cca225bae923fba8bb3b8cccaef9e43..8e99c05d156396a0f55eb7b145cd8f524e12278a 100644 (file)
@@ -4,4 +4,5 @@ northbound/META-INF
 southbound/META-INF
 integrationtest/META-INF
 northbound/src/main/resources/META-INF
+neutron/src/main/resources/META-INF
 config/META-INF
index bb7dc37ee8aac35db6f1f64486bf0bfbdbdddb61..d9f821916d75b22aad9e6242ce3ab894f7f829f4 100644 (file)
@@ -4,11 +4,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.api</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
similarity index 69%
rename from mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IMapReplyHandler.java
rename to mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/lisp/IMapRequestResultHandler.java
index ee4a0af2401ff8cbbe26054cce18b703d2dd284a..5ccb288ab27594cbfb0131e66fba7f8a8e2170b2 100644 (file)
@@ -7,11 +7,16 @@
  */
 package org.opendaylight.lispflowmapping.interfaces.lisp;
 
+import java.net.InetAddress;
+
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
 
 /**
  * An interface for dealing with a map reply message.
  */
-public interface IMapReplyHandler {
+public interface IMapRequestResultHandler {
     public void handleMapReply(MapReply mapReply);
+
+    public void handleNonProxyMapRequest(MapRequest mapRequest, InetAddress targetAddress);
 }
index dd89bcd1ceca6ef8bebd8b1c13e2e8865ed2fd8a..97fbd1d1b6be38665d06a0da164d0d1f7d2d9198 100644 (file)
@@ -13,5 +13,5 @@ import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
  * The async map resolver interface for dealing with async map request calls.
  */
 public interface IMapResolverAsync extends IGeneralMapResolver {
-    public void handleMapRequest(MapRequest request, IMapReplyHandler callback);
+    public void handleMapRequest(MapRequest request, IMapRequestResultHandler callback);
 }
index e9643189484b163686ae0c1af305bad637e91374..be8b799d884fc55e6c295c6f0b02dc916d285e23 100644 (file)
@@ -12,6 +12,7 @@ import java.util.concurrent.Future;
 
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
 import org.opendaylight.yangtools.yang.binding.RpcService;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 
@@ -38,4 +39,13 @@ public interface ILispSouthboundPlugin extends RpcService {
      */
     Future<RpcResult<java.lang.Void>> handleMapReply(MapReply mapReply, InetAddress targetAddress);
 
+    /**
+     * Handle a non proxy map request by sending it to the correct xTR.
+     * 
+     * @param mapRequest
+     * @param targetAddress
+     * @return
+     */
+    Future<RpcResult<java.lang.Void>> handleMapRequest(MapRequest mapRequest, InetAddress targetAddress);
+
 }
\ No newline at end of file
index 8f381ddef6895300e895d38650c29f985f0ba2da..5c0cd3f995bcb592c79553880aad934d4419d63a 100644 (file)
@@ -4,7 +4,7 @@
        <parent>
                <artifactId>lispflowmapping-commons</artifactId>
                <groupId>org.opendaylight.lispflowmapping</groupId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../../commons/parent</relativePath>
        </parent>
        <artifactId>mappingservice.config</artifactId>
index a0ce3e68a34fab3d18985b376b7e1b5fb6fc1ae8..7bbd0257db2874a13f5a7949298f1ac1049bcf6f 100644 (file)
@@ -16,4 +16,5 @@
 <stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
 <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
 <stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="mappingservice.implementation"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
 </launchConfiguration>
index a5eeed96962c53019b666921ce7fff8d73d9efa2..bc65e08daeb1ddf21749efb8168a15951774b82a 100644 (file)
@@ -4,11 +4,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.implementation</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
@@ -58,6 +58,7 @@
                                                        org.opendaylight.controller.sal.core,
                                                        org.apache.felix.dm,
                                                        org.apache.commons.lang3,
+                                                       org.apache.commons.lang3.tuple,
                                                        org.apache.commons.lang3.builder,
                                                        org.osgi.service.component,
                                                        org.slf4j,
index 5da7d31fb028bd47dee4c08c55822ce20f443ee3..99d2f17d8d4a1d2f798a52ec85b664b8b1e79cf0 100644 (file)
@@ -11,6 +11,8 @@ package org.opendaylight.lispflowmapping.implementation;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
+import org.apache.commons.lang3.tuple.MutablePair;
+import org.apache.commons.lang3.tuple.Pair;
 import org.eclipse.osgi.framework.console.CommandInterpreter;
 import org.eclipse.osgi.framework.console.CommandProvider;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
@@ -31,7 +33,7 @@ import org.opendaylight.lispflowmapping.interfaces.dao.IQueryAll;
 import org.opendaylight.lispflowmapping.interfaces.dao.IRowVisitor;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapNotifyHandler;
-import org.opendaylight.lispflowmapping.interfaces.lisp.IMapReplyHandler;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IMapRequestResultHandler;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapServerAsync;
 import org.opendaylight.lispflowmapping.type.sbplugin.ILispSouthboundPlugin;
@@ -55,7 +57,7 @@ import org.slf4j.LoggerFactory;
 import com.google.common.net.InetAddresses;
 
 public class LispMappingService implements CommandProvider, IFlowMapping, BindingAwareConsumer, //
-        IMapReplyHandler, IMapNotifyHandler {
+        IMapRequestResultHandler, IMapNotifyHandler {
     protected static final Logger logger = LoggerFactory.getLogger(LispMappingService.class);
 
     private ILispDAO lispDao = null;
@@ -65,6 +67,7 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     private volatile boolean shouldAuthenticate;
     private ThreadLocal<MapReply> tlsMapReply = new ThreadLocal<MapReply>();
     private ThreadLocal<MapNotify> tlsMapNotify = new ThreadLocal<MapNotify>();
+    private ThreadLocal<Pair<MapRequest, InetAddress>> tlsMapRequest = new ThreadLocal<Pair<MapRequest, InetAddress>>();
 
     private ILispSouthboundPlugin lispSB = null;
 
@@ -187,10 +190,16 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
 
     public MapReply handleMapRequest(MapRequest request) {
         tlsMapReply.set(null);
+        tlsMapRequest.set(null);
         mapResolver.handleMapRequest(request, this);
         // After this invocation we assume that the thread local is filled with
         // the reply
-        return tlsMapReply.get();
+        if (tlsMapRequest.get() != null) {
+            getLispSB().handleMapRequest(tlsMapRequest.get().getLeft(), tlsMapRequest.get().getRight());
+            return null;
+        } else {
+            return tlsMapReply.get();
+        }
 
     }
 
@@ -280,4 +289,10 @@ public class LispMappingService implements CommandProvider, IFlowMapping, Bindin
     public void handleMapNotify(MapNotify notify) {
         tlsMapNotify.set(notify);
     }
+
+    @Override
+    public void handleNonProxyMapRequest(MapRequest mapRequest, InetAddress targetAddress) {
+        tlsMapRequest.set(new MutablePair<MapRequest, InetAddress>(mapRequest, targetAddress));
+    }
+
 }
index b213261c4d1f067628c992dfc13592a7565d95df..3f12d4c97da767ed024b4a866aa5d759297e4c09 100644 (file)
@@ -12,12 +12,13 @@ import java.util.ArrayList;
 import java.util.Map;
 
 import org.opendaylight.lispflowmapping.implementation.dao.MappingServiceKeyUtil;
+import org.opendaylight.lispflowmapping.implementation.util.LispNotificationHelper;
 import org.opendaylight.lispflowmapping.implementation.util.MaskUtil;
 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
 import org.opendaylight.lispflowmapping.interfaces.dao.IMappingServiceKey;
 import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceRLOC;
 import org.opendaylight.lispflowmapping.interfaces.dao.MappingServiceValue;
-import org.opendaylight.lispflowmapping.interfaces.lisp.IMapReplyHandler;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IMapRequestResultHandler;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IMapResolverAsync;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.eidrecords.EidRecord;
@@ -49,9 +50,22 @@ public class MapResolver implements IMapResolverAsync {
         this.shouldIterateMask = iterateMask;
     }
 
-    public void handleMapRequest(MapRequest request, IMapReplyHandler callback) {
+    public void handleMapRequest(MapRequest request, IMapRequestResultHandler callback) {
         if (dao == null) {
             logger.warn("handleMapRequest called while dao is uninitialized");
+            return;
+        }
+        if (request.isPitr()) {
+            if (request.getEidRecord().size() > 0) {
+                EidRecord eid = request.getEidRecord().get(0);
+                Map<String, ?> locators = getLocators(eid);
+                MappingServiceValue value = (MappingServiceValue) locators.get("value");
+                if (value.getRlocs() != null && value.getRlocs().size() > 0) {
+                    callback.handleNonProxyMapRequest(request,
+                            LispNotificationHelper.getInetAddressFromContainer(value.getRlocs().get(0).getRecord().getLispAddressContainer()));
+                }
+            }
+
         } else {
             MapReplyBuilder builder = new MapReplyBuilder();
             builder.setEchoNonceEnabled(false);
@@ -68,11 +82,7 @@ public class MapResolver implements IMapResolverAsync {
                 recordBuilder.setMaskLength(eid.getMask());
                 recordBuilder.setLispAddressContainer(eid.getLispAddressContainer());
                 recordBuilder.setLocatorRecord(new ArrayList<LocatorRecord>());
-                IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(eid.getLispAddressContainer(), eid.getMask());
-                Map<String, ?> locators = dao.get(key);
-                if (shouldIterateMask() && locators == null && MaskUtil.isMaskable(key.getEID().getAddress())) {
-                    locators = findMaskLocators(key);
-                }
+                Map<String, ?> locators = getLocators(eid);
                 if (locators != null) {
                     MappingServiceValue value = (MappingServiceValue) locators.get("value");
 
@@ -94,6 +104,15 @@ public class MapResolver implements IMapResolverAsync {
         }
     }
 
+    private Map<String, ?> getLocators(EidRecord eid) {
+        IMappingServiceKey key = MappingServiceKeyUtil.generateMappingServiceKey(eid.getLispAddressContainer(), eid.getMask());
+        Map<String, ?> locators = dao.get(key);
+        if (shouldIterateMask() && locators == null && MaskUtil.isMaskable(key.getEID().getAddress())) {
+            locators = findMaskLocators(key);
+        }
+        return locators;
+    }
+
     private Map<String, ?> findMaskLocators(IMappingServiceKey key) {
         int mask = key.getMask();
         while (mask > 0) {
index be8dac0ef9d9d8aa0f89f100d0939b8dccd96b14..5c773e48fff6e5896cd2c064bccceef4f79cc989 100644 (file)
@@ -11,6 +11,8 @@ import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.LispAddressContainer;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.lispaddress.lispaddresscontainer.address.Ipv4;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.mapregisternotification.MapRegister;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.mapregisternotification.MapRegisterBuilder;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.maprequestnotification.MapRequest;
@@ -46,21 +48,31 @@ public class LispNotificationHelper {
     }
 
     public static InetAddress getInetAddressFromIpAddress(IpAddress ipAddress) {
-        InetAddress address = InetAddress.getLoopbackAddress();
-        if (ipAddress == null) {
-            return address;
-        }
-        if (ipAddress.getIpv4Address() != null) {
-            try {
-                address = Inet4Address.getByName(ipAddress.getIpv4Address().getValue());
-            } catch (UnknownHostException e) {
-            }
-        } else if (ipAddress.getIpv6Address() != null) {
-            try {
-                address = Inet4Address.getByName(ipAddress.getIpv6Address().getValue());
-            } catch (UnknownHostException e) {
+        InetAddress address = null;
+        if (ipAddress != null) {
+            if (ipAddress.getIpv4Address() != null) {
+                address = getAddressByName(ipAddress.getIpv4Address().getValue());
+            } else if (ipAddress.getIpv6Address() != null) {
+                address = getAddressByName(ipAddress.getIpv6Address().getValue());
             }
         }
+        if (address == null) {
+            address = InetAddress.getLoopbackAddress();
+        }
         return address;
     }
+
+    public static InetAddress getInetAddressFromContainer(LispAddressContainer container) {
+        Ipv4Address ipAddress = ((Ipv4) LispAFIConvertor.toAFI(container)).getIpv4Address();
+        return getAddressByName(ipAddress.getValue());
+    }
+
+    public static InetAddress getAddressByName(String IPAddress) {
+        try {
+            InetAddress address = InetAddress.getByName(IPAddress);
+            return address;
+        } catch (UnknownHostException e) {
+            return null;
+        }
+    }
 }
index 4b0e5c820776ba17b7c1cdd9ec8021208677b3c8..deccf7f7592dbae9997c4f9fca26b74072b54ec7 100644 (file)
                </plugins>
        </build>
        <properties>
-               <lispflowmapping.version>1.0.1-SNAPSHOT</lispflowmapping.version>
+               <lispflowmapping.version>1.1.0-SNAPSHOT</lispflowmapping.version>
                <exam.version>3.0.0</exam.version>
                <url.version>1.5.0</url.version>
                <!-- Sonar jacoco plugin to get integration test coverage info -->
                        <artifactId>jersey-client</artifactId>
                        <version>${jersey.version}</version>
                </dependency>
+               <dependency>
+        <groupId>com.sun.jersey</groupId>
+        <artifactId>jersey-json</artifactId>
+        <version>${jersey.version}</version>
+      </dependency>
                <dependency>
                        <groupId>org.opendaylight.yangtools.thirdparty</groupId>
                        <artifactId>xtend-lib-osgi</artifactId>
index 080759b013b3712009eb0ccdecda029e59d90f37..19510163c99d9872332669bf20388e02a9a5412c 100644 (file)
@@ -652,6 +652,7 @@ public class MappingServiceIntegrationTest {
 
         // Retrieve the RLOC from the database
         MapRequestBuilder mapRequestBuilder = new MapRequestBuilder();
+        mapRequestBuilder.setPitr(false);
         mapRequestBuilder.setEidRecord(new ArrayList<EidRecord>());
         mapRequestBuilder.getEidRecord().add(
                 new EidRecordBuilder().setMask((short) mask).setLispAddressContainer(LispAFIConvertor.toContainer(eid)).build());
@@ -1412,10 +1413,38 @@ public class MappingServiceIntegrationTest {
         return mr;
     }
 
+    @Test
+    public void nonProxyTest() throws SocketTimeoutException, SocketException {
+        String eid = "10.0.0.1";
+        String rloc = "127.0.0.3";
+        MapRegister mr = createMapRegister(LispAFIConvertor.asIPAfiAddress(eid));
+        LocatorRecord record = new LocatorRecordBuilder(mr.getEidToLocatorRecord().get(0).getLocatorRecord().get(0)).setLispAddressContainer(
+                LispAFIConvertor.toContainer(LispAFIConvertor.asIPAfiAddress(rloc))).build();
+        mr.getEidToLocatorRecord().get(0).getLocatorRecord().set(0, record);
+        sendMapRegister(mr);
+        receiveMapNotify();
+        MapRequest mapRequest = createMapRequest(LispAFIConvertor.asIPAfiAddress(eid));
+        MapRequestBuilder builder = new MapRequestBuilder(mapRequest);
+        builder.setPitr(true);
+        mapRequest = builder.build();
+        sendMapRequest(mapRequest);
+        socket = new DatagramSocket(new InetSocketAddress(rloc, LispMessage.PORT_NUM));
+        MapRequest recievedMapRequest = receiveMapRequest();
+        assertEquals(mapRequest.getNonce(), recievedMapRequest.getNonce());
+        assertEquals(mapRequest.getSourceEid(), recievedMapRequest.getSourceEid());
+        assertEquals(mapRequest.getItrRloc(), recievedMapRequest.getItrRloc());
+        assertEquals(mapRequest.getEidRecord(), recievedMapRequest.getEidRecord());
+
+    }
+
     private MapReply receiveMapReply() throws SocketTimeoutException {
         return MapReplySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
     }
 
+    private MapRequest receiveMapRequest() throws SocketTimeoutException {
+        return MapRequestSerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
+    }
+
     private MapNotify receiveMapNotify() throws SocketTimeoutException {
         return MapNotifySerializer.getInstance().deserialize(ByteBuffer.wrap(receivePacket().getData()));
     }
index 4655c0eece6044469700682071d03bf86fcbd381..1cabb0aee3b8857c905de97f19735098a21b2b47 100644 (file)
@@ -6,6 +6,7 @@
       </pattern>
     </encoder>
   </appender>
+  <logger name="org.opendaylight.lispflowmapping" level="debug"/>
 
   <root level="warn">
     <appender-ref ref="STDOUT" />
diff --git a/mappingservice/neutron/pom.xml b/mappingservice/neutron/pom.xml
new file mode 100644 (file)
index 0000000..763c874
--- /dev/null
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.opendaylight.lispflowmapping</groupId>
+               <artifactId>mappingservice-parent</artifactId>
+               <version>1.1.0-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+
+       <artifactId>mappingservice.neutron</artifactId>
+       <version>1.1.0-SNAPSHOT</version>
+       <packaging>bundle</packaging>
+       <scm>
+               <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
+               <developerConnection>scm:git:ssh://git.opendaylight.org:29418/lispflowmapping.git</developerConnection>
+               <url>https://wiki.opendaylight.org/view/OpenDaylight_Lisp_Flow_Mapping:Main</url>
+               <tag>HEAD</tag>
+       </scm>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <version>2.3.6</version>
+                               <extensions>true</extensions>
+                               <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,
+                                                       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.lispflowmapping.interfaces.lisp,
+                                                       org.slf4j,
+                                                       org.apache.catalina.filters,
+                                                       org.apache.felix.dm,
+                                                       org.apache.commons.lang3.builder,
+                                                       org.osgi.service.component,
+                                                       org.eclipse.osgi.framework.console,
+                                                       org.osgi.framework,
+                                               </Import-Package>
+                                               <Bundle-Activator>
+                                                       org.opendaylight.lispflowmapping.neutron.Activator
+                                               </Bundle-Activator>
+
+                                               <Export-Package>
+                                               </Export-Package>
+                                       </instructions>
+                                       <manifestLocation>${project.basedir}/src/main/resources/META-INF</manifestLocation>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>equinoxSDK381</groupId>
+                       <artifactId>org.eclipse.osgi</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.lispflowmapping</groupId>
+                       <artifactId>mappingservice.api</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>sal</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>containermanager</artifactId>
+                       <version>0.5.1-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>commons.northbound</artifactId>
+                       <version>0.4.1</version>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>networkconfig.neutron</artifactId>
+                       <version>0.4.1</version>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/Activator.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/Activator.java
new file mode 100644 (file)
index 0000000..d2422d9
--- /dev/null
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2013 Contextream, 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+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.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Main application activator class for registering the dependencies and
+ * initialising the Mapping Service application.
+ * 
+ */
+
+public class Activator extends ComponentActivatorAbstractBase {
+
+    /*
+     * 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() {
+    }
+
+    /**
+     * Function called when the activator stops just before the cleanup done by
+     * ComponentActivatorAbstractBase
+     * 
+     */
+    @Override
+    public void destroy() {
+    }
+
+    /**
+     * 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 };
+        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) {
+        
+        //partially based on OpenDove code
+        if (imp.equals(LispNeutronService.class)) {
+            c.setInterface(
+                    new String[] { INeutronNetworkAware.class.getName(),
+                               ILispNeutronService.class.getName()}, //Is this necessary? 
+                               null); // null or props here?
+            Dictionary<String, String> props = new Hashtable<String, String>();
+            props.put("name", "mappingservice");
+            c.add(createContainerServiceDependency(containerName)
+                       .setService(IFlowMapping.class)
+                       .setCallbacks("setFlowMappingService", "unsetFlowMappingService")
+                    .setRequired(true));
+        }
+    }
+    
+    
+
+    /**
+     * Method which tells how many Global implementations are supported by the
+     * bundle. This way we can tune the number of components created. This
+     * components will be created ONLY at the time of bundle startup and will be
+     * destroyed only at time of bundle destruction, this is the major
+     * difference with the implementation retrieved via getImplementations where
+     * all of them are assumed to be in a container !
+     * 
+     * 
+     * @return The list of implementations the bundle will support, in Global
+     *         version
+     */
+    @Override
+    protected Object[] getGlobalImplementations() {
+        return null;
+    }
+
+    /**
+     * Configure the dependency for a given instance Global
+     * 
+     * @param c
+     *            Component assigned for this instance, this will be what will
+     *            be used for configuration
+     * @param imp
+     *            implementation to be configured
+     * @param containerName
+     *            container on which the configuration happens
+     */
+    @Override
+    protected void configureGlobalInstance(Component c, Object imp) {
+
+    }
+}
diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/ILispNeutronService.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/ILispNeutronService.java
new file mode 100644 (file)
index 0000000..87c7f69
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2013 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,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.lispflowmapping.neutron;
+
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+
+public interface ILispNeutronService {
+       
+       public IFlowMapping getMappingService();
+
+}
diff --git a/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/LispNeutronService.java b/mappingservice/neutron/src/main/java/org/opendaylight/lispflowmapping/neutron/LispNeutronService.java
new file mode 100644 (file)
index 0000000..31fd4d2
--- /dev/null
@@ -0,0 +1,94 @@
+package org.opendaylight.lispflowmapping.neutron;
+
+import org.eclipse.osgi.framework.console.CommandProvider;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+import org.opendaylight.controller.networkconfig.neutron.INeutronNetworkAware;
+import org.opendaylight.controller.networkconfig.neutron.NeutronNetwork;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LispNeutronService implements ILispNeutronService, INeutronNetworkAware{
+       protected static final Logger logger = LoggerFactory.getLogger(LispNeutronService.class);
+    private IFlowMapping mappingService;
+       
+       
+    public IFlowMapping getMappingService(){
+       return this.mappingService;
+    }
+    
+    void setFlowMappingService(IFlowMapping mappingService) {
+        logger.debug("FlowMapping set in LispNeutron");
+        this.mappingService = mappingService;
+    }
+
+    void unsetFlowMappingService(IFlowMapping mappingService) {
+        logger.debug("LispDAO was unset in LISP Neutron");
+        this.mappingService = null;
+    }
+    
+    public void init() {
+        logger.debug("LISP Neutron Service is initialized!");
+    }
+
+    public void start() {
+        logger.info("LISP Neutron Service is up!");
+
+        // OSGI console
+        registerWithOSGIConsole();
+    }
+
+    private void registerWithOSGIConsole() {
+        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+        bundleContext.registerService(CommandProvider.class.getName(), this, null);
+    }
+
+    public void stop() {
+        logger.info("LISP Neutron Service is down!");
+    }
+
+    public void destroy() {
+        logger.debug("LISP Neutron Service is destroyed!");
+        mappingService = null;
+    }
+
+    // callbacks for INeutronNetworkAware. Based on OpenDove project
+
+    public int canCreateNetwork(NeutronNetwork network) {
+       logger.info("hello world!");
+       logger.info("canCreateNetwork called!");
+       logger.info("Network name: "+network.getNetworkName());
+//        if (network.getAdminStateUp() != null && !network.isAdminStateUp())
+//            return 400;
+        return 200;
+    }
+    public void neutronNetworkCreated(NeutronNetwork input) {
+       logger.info("neutronNetworkCreated called!");
+        return;
+    }
+
+    public int canUpdateNetwork(NeutronNetwork delta, NeutronNetwork original) {
+       logger.info("canUpdateNetwork called!");
+        if (delta.getNetworkName() != null || delta.getAdminStateUp() != null ||
+                delta.getShared() != null || delta.getRouterExternal() != null)
+            return 403;
+        return 200;
+    }
+
+    public void neutronNetworkUpdated(NeutronNetwork network) {
+       logger.info("neutronNetworkUpdated called!");
+        return;
+    }
+
+    public int canDeleteNetwork(NeutronNetwork network) {
+       logger.info("canDeleteNetwork called!");
+        return 200;
+    }
+
+    public void neutronNetworkDeleted(NeutronNetwork network) {
+       logger.info("neutronNetworkDeleted called!");
+        return;
+    }
+       
+}
index a95fec8d060004cd077ba39bbe35251cfe8639c3..71d64c4bca30d8cbdd94ea5efe73f6d374def78c 100644 (file)
@@ -4,11 +4,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.northbound</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
index d491262cab2a1032ae4739acc8c230a991284da1..b4eb8341b91235258fe3b292f13b4d02bc187271 100644 (file)
@@ -4,11 +4,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>lispflowmapping-code-commons</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../commons/code-parent</relativePath>
        </parent>
        <artifactId>mappingservice-parent</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>pom</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
@@ -23,6 +23,7 @@
                 <module>implementation</module>
                 <module>southbound</module>
                 <module>northbound</module>
+                <module>neutron</module>
                 <module>integrationtest</module>
         </modules>
        <dependencies>
index 4aeb808049269f4a3e6a0f5cd2b81ccad2e95384..df76f29a278c95e0c7f18888509b632c26657021 100644 (file)
@@ -4,7 +4,7 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.southbound</artifactId>
index 92a596ae3b3db60c36277e31e5c73a045194abb9..df364457482e62112ad2c778f41151cba1e5bc02 100644 (file)
@@ -25,11 +25,13 @@ import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
 import org.opendaylight.lispflowmapping.implementation.serializer.LispMessage;
 import org.opendaylight.lispflowmapping.implementation.serializer.MapNotifySerializer;
 import org.opendaylight.lispflowmapping.implementation.serializer.MapReplySerializer;
+import org.opendaylight.lispflowmapping.implementation.serializer.MapRequestSerializer;
 import org.opendaylight.lispflowmapping.southbound.lisp.LispSouthboundService;
 import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispPlugin;
 import org.opendaylight.lispflowmapping.type.sbplugin.ILispSouthboundPlugin;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapNotify;
 import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapReply;
+import org.opendaylight.yang.gen.v1.lispflowmapping.rev131031.MapRequest;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.FrameworkUtil;
@@ -45,6 +47,7 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
     private volatile DatagramSocket socket = null;
     private final String MAP_NOTIFY = "MapNotify";
     private final String MAP_REPlY = "MapReply";
+    private final String MAP_REQUEST = "MapRequest";
     private volatile String bindingAddress = null;
     private volatile boolean stillRunning = false;
     private volatile boolean alreadyInit = false;
@@ -212,6 +215,17 @@ public class LispSouthboundPlugin extends AbstractBindingAwareProvider implement
         return null;
     }
 
+    public Future<RpcResult<Void>> handleMapRequest(MapRequest mapRequest, InetAddress address) {
+        logger.trace("handleMapRequest called!!");
+        if (mapRequest != null) {
+            ByteBuffer outBuffer = MapRequestSerializer.getInstance().serialize(mapRequest);
+            handleSerializedLispBuffer(address, outBuffer, MAP_REQUEST);
+        } else {
+            logger.debug("MapRequest was null");
+        }
+        return null;
+    }
+
     public void setLispAddress(String address) {
         synchronized (startLock) {
             if (bindingAddress != null && bindingAddress.equals(address)) {
index a26e08ff5fc72ab1976a950f9f4e983f806eb2f7..a670d1c7beb24dcfe39d5d329930e3e3b93ddd42 100644 (file)
@@ -1,2 +1,3 @@
 /target
 /META-INF
+/target
index 9b9629951aaebfc52a71373ddd4fecb70c37d9b6..43395aad25d1e8344249d165accd21a74c7c503c 100755 (executable)
@@ -3,11 +3,11 @@
        <parent>
                <artifactId>mappingservice-parent</artifactId>
                <groupId>org.opendaylight.lispflowmapping</groupId>
-               <version>1.0.1-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.yangmodel</artifactId>
-       <version>1.0.1-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
diff --git a/pom.xml b/pom.xml
index 77ee22097073b158200ecda4f8f94a8a09ae87aa..72daa273256c32ab5f2709dc60a2f2de258bf589 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
   <parent>
     <groupId>org.opendaylight.lispflowmapping</groupId>
     <artifactId>lispflowmapping-commons</artifactId>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.1.0-SNAPSHOT</version>
     <relativePath>commons/parent</relativePath>
   </parent>