Merge "JUnit Test - AuthenticationKeyDataListenerTest"
authorLori Jakab <lorand.jakab@gmail.com>
Thu, 9 Jun 2016 00:26:41 +0000 (00:26 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 9 Jun 2016 00:26:41 +0000 (00:26 +0000)
features/src/main/features/features.xml
mappingservice/lisp-proto/src/main/java/org/opendaylight/lispflowmapping/lisp/util/LispAddressUtil.java
mappingservice/southbound/pom.xml
mappingservice/southbound/src/main/config/default-config.xml
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/lisp/LispSouthboundHandler.java
mappingservice/southbound/src/main/yang/odl-lisp-sb-impl.yang

index 9e5ee068e9afb57374624bd86a39e3b228145630..0b92ebb7e466f85df9ac51b0f161baacd50704d8 100644 (file)
@@ -58,6 +58,7 @@
         <feature version="${mdsal.version}">odl-mdsal-broker</feature>
         <feature version='${project.version}'>odl-lispflowmapping-models</feature>
         <feature version="${project.version}">odl-lispflowmapping-inmemorydb</feature>
+        <bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.dsbackend/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.mapcache/{{VERSION}}</bundle>
         <bundle>mvn:org.opendaylight.lispflowmapping/mappingservice.southbound/{{VERSION}}</bundle>
         <configfile finalname="${configfile.directory}/lfm-mappingservice-sb.xml">
index 66d9f735f6e64ae686f94a2a4119cbae48de094e..4e4f4a78029df0169c3d85babf05a4d01ad806d9 100644 (file)
@@ -492,10 +492,10 @@ public final class LispAddressUtil {
         } else if (address.getIpAddress() != null) {
             if (address.getIpAddress().getIpv4Address() != null) {
                 LispAddressUtil.toEid(new Ipv4AddressBinary(InetAddresses.forString(
-                        address.getIpPrefix().getIpv4Prefix().getValue()).getAddress()), iid);
+                        address.getIpAddress().getIpv4Address().getValue()).getAddress()), iid);
             } else if (address.getIpAddress().getIpv6Address() != null) {
                 LispAddressUtil.toEid(new Ipv6AddressBinary(InetAddresses.forString(
-                        address.getIpPrefix().getIpv6Prefix().getValue()).getAddress()), iid);
+                        address.getIpAddress().getIpv6Address().getValue()).getAddress()), iid);
             }
         }
         return LispAddressUtil.asEid(address, iid);
index ad8c0fbeccf80284bde22772ad28614eeed20866..048b91c10e32897c75cfacedec28d740cf190ddc 100644 (file)
       <groupId>${project.groupId}</groupId>
       <artifactId>mappingservice.inmemorydb</artifactId>
     </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>mappingservice.dsbackend</artifactId>
+    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>mappingservice.lisp-proto</artifactId>
index 37d6c0c15d118877a511b53e36dd567410df7df3..063189d9df9828a936a7ffe3944bfc19d7084eae 100644 (file)
@@ -4,7 +4,6 @@
     <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
     <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
     <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lisp-sb:impl?module=odl-lisp-sb-impl&amp;revision=2015-05-17</capability>
-    <capability>urn:opendaylight:params:xml:ns:yang:controller:config:lfm:mappingservice-dao:inmemorydb?module=odl-mappingservice-dao-inmemorydb&amp;revision=2015-10-07</capability>
   </required-capabilities>
   <configuration>
     <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
index 3c034e44fec371c9550f976b01e0572373d60816..fb0bf9d99fc1b9b9da14b7a4639511b7b2ab3603 100644 (file)
@@ -79,6 +79,7 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
             lispSouthboundHandler.setNotificationProvider(this.notificationPublishService);
             lispSouthboundHandler.setMapRegisterCacheEnabled(mapRegisterCacheEnabled);
             lispSouthboundHandler.init();
+            lispSouthboundHandler.restoreDaoFromDatastore();
 
             lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
             lispXtrSouthboundHandler.setNotificationProvider(this.notificationPublishService);
index 2d1d267d37bbbf834d085921d4d64585d7cd68a9..681b635b733d129a753496f98a7b69083cfcbb13 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Map;
 import java.util.Objects;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.lispflowmapping.dsbackend.DataStoreBackEnd;
 import org.opendaylight.lispflowmapping.inmemorydb.HashMapDb;
 import org.opendaylight.lispflowmapping.southbound.authentication.LispAuthenticationUtil;
 import org.opendaylight.lispflowmapping.interfaces.lisp.ILispAuthentication;
@@ -65,6 +66,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.ma
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.list.MappingRecordItem;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.transport.address.TransportAddressBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
 import org.opendaylight.yangtools.yang.binding.Notification;
 import org.slf4j.Logger;
@@ -94,6 +96,7 @@ public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramP
     private LispSouthboundStats lispSbStats = null;
     private SimpleMapCache smc;
     private AuthenticationKeyDataListener authenticationKeyDataListener;
+    private DataStoreBackEnd dsbe;
 
     public LispSouthboundHandler(LispSouthboundPlugin lispSbPlugin) {
         this.lispSbPlugin = lispSbPlugin;
@@ -492,9 +495,27 @@ public class LispSouthboundHandler extends SimpleChannelInboundHandler<DatagramP
         this.mapRegisterCacheEnabled = mapRegisterCacheEnabled;
     }
 
+    /**
+    * Restore all keys from MDSAL datastore
+    */
+   public void restoreDaoFromDatastore() {
+       final List<AuthenticationKey> authKeys = dsbe.getAllAuthenticationKeys();
+       LOG.info("Restoring {} keys from datastore into southbound DAO", authKeys.size());
+
+       for (AuthenticationKey authKey : authKeys) {
+           final Eid key = authKey.getEid();
+           final MappingAuthkey mappingAuthkey = authKey.getMappingAuthkey();
+           LOG.debug("Adding authentication key '{}' with key-ID {} for {}", mappingAuthkey.getKeyString(),
+                   mappingAuthkey.getKeyType(),
+                   LispAddressStringifier.getString(key));
+           smc.addAuthenticationKey(key, mappingAuthkey);
+       }
+    }
+
     public void init() {
         Preconditions.checkNotNull(dataBroker);
         Preconditions.checkNotNull(smc);
         this.authenticationKeyDataListener = new AuthenticationKeyDataListener(dataBroker, smc);
+        dsbe = new DataStoreBackEnd(dataBroker);
     }
 }
index dbaf306da158c2fee14eb1c07ba4d214856be1f1..dfe5c9e77bd37367a849c160ce04c019a6c96ad9 100644 (file)
@@ -9,7 +9,6 @@ module odl-lisp-sb-impl {
     import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
     import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
     import odl-lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
-    import odl-mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
 
     description
         "This module contains the base YANG definitions for