Merge remote branch 'origin/release-1.0.X' into mer 00/4800/1
authorDavid Goldberg <david.goldberg@contextream.com>
Fri, 24 Jan 2014 05:42:16 +0000 (07:42 +0200)
committerDavid Goldberg <david.goldberg@contextream.com>
Fri, 24 Jan 2014 05:42:23 +0000 (07:42 +0200)
Conflicts:
mappingservice/integrationtest/pom.xml

Change-Id: I62fc34b7c566198dc62ee1d20026ded5e579f303
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
30 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/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

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 60a97f0ae4a44e6024b73bedf6a1878b327ee771..d497ecfb81e4477a2deafa8d5a5923ae541f3c09 100644 (file)
@@ -6,11 +6,11 @@
        <parent>
                 <groupId>org.opendaylight.lispflowmapping</groupId>
                 <artifactId>lispflowmapping-commons</artifactId>
-                <version>1.0.0-SNAPSHOT</version>
+                <version>1.1.0-SNAPSHOT</version>
                 <relativePath>../parent</relativePath>
        </parent>
        <artifactId>common.build.tools</artifactId>
-       <version>1.0.0-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 9de62d9ad62451734f246b6f18ab6a271840430d..4f2166c82f956d112b1ca7954d7401423a8a2a0e 100644 (file)
@@ -6,12 +6,12 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>lispflowmapping-commons</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../parent</relativePath>
        </parent>
        <artifactId>lispflowmapping-code-commons</artifactId>
        <packaging>pom</packaging>
-       <version>1.0.0-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 e946ccdba60716cabd10de5d9042366330acfa3e..903d53017cb9500d905346197fc9afa9142b95f5 100644 (file)
@@ -3,7 +3,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.opendaylight.lispflowmapping</groupId>
        <artifactId>lispflowmapping-commons</artifactId>
-       <version>1.0.0-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <description></description>
        <packaging>pom</packaging>
        <url>http://www.opendaylight.org</url>
@@ -14,7 +14,7 @@
                <tag>HEAD</tag>
        </scm>
        <properties>
-               <lispflowmapping.version>1.0.0-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 78ad3b1e613957b571c36e3c98257fc70fa6e8bf..9aa8591fb2acb73a06926a0b1d902f37966d51f5 100644 (file)
@@ -6,11 +6,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>lispflowmapping-commons</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../parent</relativePath>
        </parent>
        <artifactId>common.unittest.tools</artifactId>
-       <version>1.0.0-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 fb13114d15905e8628ab19a44d1a9992c53d099c..894f928de5f7ed3272b2e5480dc9863501469b46 100644 (file)
@@ -6,7 +6,7 @@ http://maven.apache.org/maven-v4_0_0.xsd">
   <parent>
     <groupId>org.opendaylight.lispflowmapping</groupId>
     <artifactId>lispflowmapping-commons</artifactId>
-    <version>1.0.0-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 2829e5e147ea1d8a32550db597f89f8e18533d46..508dced01b9519b004b70e7edc248274b0131601 100644 (file)
@@ -6,11 +6,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.api</artifactId>
-       <version>1.0.0-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 20683b50c0a9c7863ae40e1f742f9aa4b91c01d4..44a0713f133ebbec363e4b1f94bcd8d32e893384 100644 (file)
@@ -6,7 +6,7 @@
        <parent>
                <artifactId>lispflowmapping-commons</artifactId>
                <groupId>org.opendaylight.lispflowmapping</groupId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../../commons/parent</relativePath>
        </parent>
        <artifactId>mappingservice.config</artifactId>
index 6ab380076c0d2af62e519a10cd2881b0e43fa0df..cd0ee2e7465afeae947964170ed5b58a8ae939ca 100644 (file)
@@ -6,11 +6,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.implementation</artifactId>
-       <version>1.0.0-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
@@ -60,6 +60,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 1b63bee4cb8eac8cf4aac3a97d8cd00192452735..beb8bff8a5d7c029d67e7d087fb067d38e80079b 100644 (file)
                </plugins>
        </build>
        <properties>
-               <lispflowmapping.version>1.0.0-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..0f1bca1
--- /dev/null
@@ -0,0 +1,94 @@
+<?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>org.opendaylight.lispflowmapping</groupId>
+      <artifactId>mappingservice.api</artifactId>
+      <version>${lispflowmapping.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>containermanager</artifactId>
+      <version>0.5.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>commons.northbound</artifactId>
+      <version>0.4.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>networkconfig.neutron</artifactId>
+      <version>0.4.1-SNAPSHOT</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 01f57872659462bc9949575661f987621853ac0a..c1e37a0040cfcae10ae1c7440f33de78bdc2126e 100644 (file)
@@ -5,11 +5,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.northbound</artifactId>
-       <version>1.0.0-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 68ab06a08ce7246acaa7fe3b071ea0075e8d7969..8bc9849795e49851d79fd9a42d2a6d15c253bdd5 100644 (file)
@@ -6,11 +6,11 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>lispflowmapping-code-commons</artifactId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>../commons/code-parent</relativePath>
        </parent>
        <artifactId>mappingservice-parent</artifactId>
-       <version>1.0.0-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>pom</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
@@ -25,6 +25,7 @@
                 <module>implementation</module>
                 <module>southbound</module>
                 <module>northbound</module>
+                <module>neutron</module>
                 <module>integrationtest</module>
         </modules>
        <dependencies>
index b97faf30aa26c17b999ca1fa3298612b5ea8a831..dd608237ec55b4eda9fd02a2880ca2701565492c 100644 (file)
@@ -6,7 +6,7 @@
        <parent>
                <groupId>org.opendaylight.lispflowmapping</groupId>
                <artifactId>mappingservice-parent</artifactId>
-               <version>1.0.0-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 0c7226d280a37fc82b8ec1da2789c5f134e724ed..1a9479b4aebb0c4dea402c6d10d58e934e6cada0 100755 (executable)
@@ -4,11 +4,11 @@
        <parent>
                <artifactId>mappingservice-parent</artifactId>
                <groupId>org.opendaylight.lispflowmapping</groupId>
-               <version>1.0.0-SNAPSHOT</version>
+               <version>1.1.0-SNAPSHOT</version>
                <relativePath>..</relativePath>
        </parent>
        <artifactId>mappingservice.yangmodel</artifactId>
-       <version>1.0.0-SNAPSHOT</version>
+       <version>1.1.0-SNAPSHOT</version>
        <packaging>bundle</packaging>
        <scm>
                <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>