summaryrefslogtreecommitdiffstats
path: root/lisp/lisp2vpp/src
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2016-08-31 07:46:41 +0200
committerMaros Marsalek <mmarsale@cisco.com>2016-08-31 11:10:32 +0000
commitaa3fb2c1271c948f9a3c5a4ab22ce146be13163e (patch)
tree81f358b3dd13f7e3f7c50d315bd6d6a415ce8ac8 /lisp/lisp2vpp/src
parentcb9f4515611d3cbd72b73c5a0d6521187c3d488a (diff)
HONEYCOMB-75 - Lisp implemetation
Rebased on final minimal distro Change-Id: Ib71fc59e62dda4633f4f79c5c7417a4aaf02a177 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com> Signed-off-by: Florin Coras <fcoras@cisco.com> Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src')
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java92
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/cfgattrs/LispConfiguration.java64
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/context/util/EidMappingContext.java235
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/initializers/LispInitializer.java68
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/AdjacencyCustomizer.java72
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/InterfaceCustomizer.java157
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LispStateCustomizer.java75
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java194
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocatorSetCustomizer.java130
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/MapResolverCustomizer.java132
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/PitrCfgCustomizer.java83
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java203
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java139
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java37
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java38
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java37
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java40
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java37
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java35
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java64
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java55
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java51
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java70
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java50
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java82
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java192
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java79
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java112
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java71
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java70
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java56
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java283
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java101
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java120
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java95
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java137
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java161
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java97
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java94
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java231
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java100
-rw-r--r--lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java94
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java68
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java63
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java53
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java94
-rw-r--r--lisp/lisp2vpp/src/main/resources/honeycomb-minimal-resources/config/lisp.json2
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/context/util/EidMappingContextTest.java85
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java49
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java198
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java128
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java189
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java157
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java111
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java132
-rwxr-xr-xlisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java175
56 files changed, 5837 insertions, 0 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java
new file mode 100644
index 000000000..ce95f12b7
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/LispModule.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp;
+
+
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT_PREFIX;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+import com.google.inject.name.Names;
+import io.fd.honeycomb.data.init.DataTreeInitializer;
+import io.fd.honeycomb.lisp.cfgattrs.LispConfiguration;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.initializers.LispInitializer;
+import io.fd.honeycomb.lisp.translate.read.factory.LispStateReaderFactory;
+import io.fd.honeycomb.lisp.translate.write.factory.LispWriterFactory;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import }
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
  Copyright (c) 2001, 2002, 2003, 2005 Eliot Dresselhaus

  Permission is hereby granted, free of charge, to any person obtaining
  a copy of this software and associated documentation files (the
  "Software"), to deal in the Software without restriction, including
  without limitation the rights to use, copy, modify, merge, publish,
  distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to
  the following conditions:

  The above copyright notice and this permission notice shall be
  included in all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#ifndef included_clib_bitmap_h
#define included_clib_bitmap_h

/** \file
    Bitmaps built as vectors of machine words
*/

#include <vppinfra/vec.h>
#include <vppinfra/random.h>
#include <vppinfra/error.h>
#include <vppinfra/bitops.h>	/* for count_set_bits */

typedef uword clib_bitmap_t;

/** predicate function; is an entire bitmap empty?
    @param ai - pointer to a bitmap
    @returns 1 if the entire bitmap is zero, 0 otherwise
*/
always_inline uword
clib_bitmap_is_zero (uword * ai)
{
  uword i;
  for (i = 0; i < vec_len (ai); i++)
    if (ai[i] != 0)
      return 0;
  return 1;
}

/** predicate function; are two bitmaps equal?
    @param a - pointer to a bitmap
    @param b - pointer to a bitmap
    @returns 1 if the bitmaps are equal, 0 otherwise
*/
always_inline uword
clib_bitmap_is_equal (uword * a, uword * b)
{
  uword i;
  if (vec_len (a) != vec_len (b))
    return 0;
  for (i = 0; i < vec_len (a); i++)
    if (a[i] != b[i])
      return 0;
  return 1;
}

/** Duplicate a bitmap
    @param v - pointer to a bitmap
    @returns a duplicate of the bitmap
*/
#define clib_bitmap_dup(v) vec_dup(v)

/** Free a bitmap
    @param v - pointer to the bitmap to free
*/
#define clib_bitmap_free(v) vec_free(v)

/** Number of bytes in a bitmap
    @param v - pointer to the bitmap
*/
#define clib_bitmap_bytes(v) vec_bytes(v)

/** Clear a bitmap
    @param v - pointer to the bitmap to clear
*/
#define clib_bitmap_zero(v) vec_zero(v)

/** Allocate a bitmap with the supplied number of bits
    @param [out] v - the resulting bitmap
    @param n_bits - the required number of bits
*/

#define clib_bitmap_alloc(v,n_bits) \
  v = vec_new (uword, ((n_bits) + BITS (uword) - 1) / BITS (uword))

#define clib_bitmap_vec_validate(v,i) vec_validate_aligned((v),(i),sizeof(uword))

/* Make sure that a bitmap is at least n_bits in size */
#define clib_bitmap_validate(v,n_bits) \
  clib_bitmap_vec_validate ((v), ((n_bits) - 1) / BITS (uword))

/* low-level routine to remove trailing zeros from a bitmap */
always_inline uword *
_clib_bitmap_remove_trailing_zeros (uword * a)
{
  word i;
  if (a)
    {
      for (i = _vec_len (a) - 1; i >= 0; i--)
	if (a[i] != 0)
	  break;
      _vec_len (a) = i + 1;
    }
  return a;
}

/** Sets the ith bit of a bitmap to new_value.
    No sanity checking. Be careful.
    @param a - pointer to the bitmap
    @param i - the bit position to interrogate
    @param new_value - new value for the bit
    @returns the old value of the bit
*/
always_inline uword
clib_bitmap_set_no_check (uword * a, uword i, uword new_value)
{
  uword i0 = i / BITS (a[0]);
  uword i1 = i % BITS (a[0]);
  uword bit = (uword) 1 << i1;
  uword ai, old_value;

  /* Removed ASSERT since uword * a may not be a vector. */
  /* ASSERT (i0 < vec_len (a)); */

  ai = a[i0];
  old_value = (ai & bit) != 0;
  ai &= ~bit;
  ai |= ((uword) (new_value != 0)) << i1;
  a[i0] = ai;
  return old_value;
}

/** Sets the ith bit of a bitmap to new_value
    Removes trailing zeros from the bitmap
    @param ai - pointer to the bitmap
    @param i - the bit position to interrogate
    @param value - new value for the bit
    @returns the old value of the bit
*/
always_inline uword *
clib_bitmap_set (uword * ai, uword i, uword value)
{
  uword i0 = i / BITS (ai[0]);
  uword i1 = i % BITS (ai[0]);
  uword a;

  /* Check for writing a zero to beyond end of bitmap. */
  if (value == 0 && i0 >= vec_len (ai))
    return ai;			/* Implied trailing zeros. */

  clib_bitmap_vec_validate (ai, i0);

  a = ai[i0];
  a &= ~((uword) 1 << i1);
  a |= ((uword) (value != 0)) << i1;
  ai[i0] = a;

  /* If bits have been cleared, test for zero. */
  if (a == 0)
    ai = _clib_bitmap_remove_trailing_zeros (ai);

  return ai;
}

/** Gets the ith bit value from a bitmap
    @param ai - pointer to the bitmap
    @param i - the bit position to interrogate
    @returns the indicated bit value
*/
always_inline uword
clib_bitmap_get (uword * ai, uword i)
{
  uword i0 = i / BITS (ai[0]);
  uword i1 = i % BITS (ai[0]);
  return i0 < vec_len (ai) && 0 != ((ai[i0] >> i1) & 1);
}

/** Gets the ith bit value from a bitmap
    Does not sanity-check the bit position. Be careful.
    @param ai - pointer to the bitmap
    @param i - the bit position to interrogate
    @returns the indicated bit value, or garbage if the bit position is
    out of range.
*/
always_inline uword
clib_bitmap_get_no_check (uword * ai, uword i)
{
  uword i0 = i / BITS (ai[0]);
  uword i1 = i % BITS (ai[0]);
  return 0 != ((ai[i0] >> i1) & 1);
}

always_inline uword
clib_bitmap_get_multiple_no_check (uword * ai, uword i, uword n_bits)
{
  uword i0 = i / BITS (ai[0]);
  uword i1 = i % BITS (ai[0]);
  ASSERT (i1 + n_bits <= BITS (uword));
  return 0 != ((ai[i0] >> i1) & pow2_mask (n_bits));
}

/** Gets the ith through ith + n_bits bit values from a bitmap
    @param bitmap - pointer to the bitmap
    @param i - the first bit position to retrieve
    @param n_bits - the number of bit positions to retrieve
    @returns the indicated range of bits
*/
always_inline uword
clib_bitmap_get_multiple (uword * bitmap, uword i, uword n_bits)
{
  uword i0, i1, result;
  uword l = vec_len (bitmap);

  ASSERT (n_bits <= BITS (result));

  i0 = i / BITS (bitmap[0]);
  i1 = i % BITS (bitmap[0]);

  /* Check first word. */
  result = 0;
  if (i0 < l)
    {
      result |= (bitmap[i0] >> i1);
      if (n_bits < BITS (bitmap[0]))
	result &= (((uword) 1 << n_bits) - 1);
    }

  /* Check for overlap into next word. */
  i0++;
  if (i1 + n_bits > BITS (bitmap[0]) && i0 < l)
    {
      n_bits -= BITS (bitmap[0]) - i1;
      result |=
	(bitmap[i0] & (((uword) 1 << n_bits) - 1)) << (BITS (bitmap[0]) - i1);
    }

  return result;
}

/** sets the ith through ith + n_bits bits in a bitmap
    @param bitmap - pointer to the bitmap
    @param i - the first bit position to retrieve
    @param value - the values to set
    @param n_bits - the number of bit positions to set
    @returns a pointer to the updated bitmap, which may expand and move
*/

always_inline uword *
clib_bitmap_set_multiple (uword * bitmap, uword i, uword value, uword n_bits)
{
  uword i0, i1, l, t, m;

  ASSERT (n_bits <= BITS (value));

  i0 = i / BITS (bitmap[0]);
  i1 = i % BITS (bitmap[0]);

  /* Allocate bitmap. */
  clib_bitmap_vec_validate (bitmap, (i + n_bits) / BITS (bitmap[0]));
  l = vec_len (bitmap);

  m = ~0;
  if (n_bits < BITS (value))
    m = (((uword) 1 << n_bits) - 1);
  value &= m;

  /* Insert into first word. */
  t = bitmap[i0];
  t &= ~(m << i1);
  t |= value << i1;
  bitmap[i0] = t;

  /* Insert into second word. */
  i0++;
  if (i1 + n_bits > BITS (bitmap[0]) && i0 < l)
    {
      t = BITS (bitmap[0]) - i1;
      value >>= t;
      n_bits -= t;
      t = bitmap[i0];
      m = ((uword) 1 << n_bits) - 1;
      t &= ~m;
      t |= value;
      bitmap[i0] = t;
    }

  return bitmap;
}

always_inline uword *
clib_bitmap_set_region (uword * bitmap, uword i, uword value, uword n_bits)
{
  uword a0, a1, b0;
  uword i_end, mask;

  a0 = i / BITS (bitmap[0]);
  a1 = i % BITS (bitmap[0]);

  i_end = i + n_bits;
  b0 = i_end / BITS (bitmap[0]);

  clib_bitmap_vec_validate (bitmap, b0);

  /* First word. */
  mask = n_bits < BITS (bitmap[0]) ? pow2_mask (n_bits) : ~0;
  mask <<= a1;

  if (value)
    bitmap[a0] |= mask;
  else
    bitmap[a0] &= ~mask;

  for (a0++; a0 < b0; a0++)
    bitmap[a0] = value ? ~0 : 0;

  if (a0 == b0)
    {
      word n_bits_left = n_bits - (BITS (bitmap[0]) - a1);
      mask = pow2_mask (n_bits_left);
      if (value)
	bitmap[a0] |= mask;
      else
	bitmap[a0] &= ~mask;
    }

  return bitmap;
}

/** Macro to iterate across set bits in a bitmap

    @param i - the current set bit
    @param ai - the bitmap
    @param body - the expression to evaluate for each set bit
*/
#define clib_bitmap_foreach(i,ai,body)					\
do {									\
  uword __bitmap_i, __bitmap_ai, __bitmap_len, __bitmap_first_set;	\
  __bitmap_len = vec_len ((ai));					\
  for (__bitmap_i = 0; __bitmap_i < __bitmap_len; __bitmap_i++)		\
    {									\
      __bitmap_ai = (ai)[__bitmap_i];					\
      while (__bitmap_ai != 0)						\
	{								\
	  __bitmap_first_set = first_set (__bitmap_ai);			\
	  (i) = (__bitmap_i * BITS ((ai)[0])				\
		 + min_log2 (__bitmap_first_set));			\
	  do { body; } while (0);					\
	  __bitmap_ai ^= __bitmap_first_set;				\
	}								\
    }									\
} while (0)


/** Return the lowest numbered set bit in a bitmap
    @param ai - pointer to the bitmap
    @returns lowest numbered set bit, or ~0 if the entire bitmap is zero
*/
always_inline uword
clib_bitmap_first_set (uword * ai)
{
  uword i = 0;
#if uword_bits == 64
#if defined(CLIB_HAVE_VEC256)
  while (i + 7 < vec_len (ai))
    {
      u64x4 v;
      v = u64x4_load_unaligned (ai + i) | u64x4_load_unaligned (ai + i + 4);
      if (!u64x4_is_all_zero (v))
	break;
      i += 8;
    }
#elif defined(CLIB_HAVE_VEC128) && defined(CLIB_HAVE_VEC128_UNALIGNED_LOAD_STORE)
  while (i + 3 < vec_len (ai))
    {
      u64x2 v;
      v = u64x2_load_unaligned (ai + i) | u64x2_load_unaligned (ai + i + 2);
      if (!u64x2_is_all_zero (v))
	break;
      i += 4;
    }
#endif
#endif
  for (; i < vec_len (ai); i++)
    {
      uword x = ai[i];
      if (x != 0)
	return i * BITS (ai[0]) + log2_first_set (x);
    }
  return ~0;
}

/** Return the higest numbered set bit in a bitmap
    @param ai - pointer to the bitmap
    @returns lowest numbered set bit, or ~0 if the entire bitmap is zero
*/
always_inline uword
clib_bitmap_last_set (uword * ai)
{
  uword i;

  for (i = vec_len (ai); i > 0; i--)
    {
      uword x = ai[i - 1];
      if (x != 0)
	{
	  uword first_bit;
	  first_bit = count_leading_zeros (x);
	  return (i) * BITS (ai[0]) - first_bit - 1;
	}
    }
  return ~0;
}

/** Return the lowest numbered clear bit in a bitmap
    @param ai - pointer to the bitmap
    @returns lowest numbered clear bit
*/
always_inline uword
clib_bitmap_first_clear (uword * ai)
{
  uword i;
  for (i = 0; i < vec_len (ai); i++)
    {
      uword x = ~ai[i];
      if (x != 0)
	return i * BITS (ai[0]) + log2_first_set (x);
    }
  return i * BITS (ai[0]);
}

/** Return the number of set bits in a bitmap
    @param ai - pointer to the bitmap
    @returns the number of set bits in the bitmap
*/
always_inline uword
clib_bitmap_count_set_bits (uword * ai)
{
  uword i;
  uword n_set = 0;
  for (i = 0; i < vec_len (ai); i++)
    n_set += count_set_bits (ai[i]);
  return n_set;
}

/** Logical operator across two bitmaps

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns ai = ai and bi. ai is modified, bi is not modified
*/
always_inline uword *clib_bitmap_and (uword * ai, uword * bi);

/** Logical operator across two bitmaps

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns ai = ai & ~bi. ai is modified, bi is not modified
*/
always_inline uword *clib_bitmap_andnot (uword * ai, uword * bi);

/** Logical operator across two bitmaps

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns ai = ai & ~bi. ai is modified, bi is not modified
*/
always_inline uword *clib_bitmap_or (uword * ai, uword * bi);
/** Logical operator across two bitmaps

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns ai = ai or bi. ai is modified, bi is not modified
*/
always_inline uword *clib_bitmap_or (uword * ai, uword * bi);

/** Logical operator across two bitmaps

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns ai = ai xor bi. ai is modified, bi is not modified
*/
always_inline uword *clib_bitmap_xor (uword * ai, uword * bi);

/* ALU function definition macro for functions taking two bitmaps. */
#define _(name, body, check_zero)				\
always_inline uword *						\
clib_bitmap_##name (uword * ai, uword * bi)			\
{								\
  uword i, a, b, bi_len, n_trailing_zeros;			\
								\
  n_trailing_zeros = 0;						\
  bi_len = vec_len (bi);					\
  if (bi_len > 0)						\
    clib_bitmap_vec_validate (ai, bi_len - 1);			\
  for (i = 0; i < vec_len (ai); i++)				\
    {								\
      a = ai[i];						\
      b = i < bi_len ? bi[i] : 0;				\
      do { body; } while (0);					\
      ai[i] = a;						\
      if (check_zero)						\
	n_trailing_zeros = a ? 0 : (n_trailing_zeros + 1);	\
    }								\
  if (check_zero)						\
    _vec_len (ai) -= n_trailing_zeros;				\
  return ai;							\
}

/* ALU functions: */
/* *INDENT-OFF* */
_(and, a = a & b, 1)
_(andnot, a = a & ~b, 1)
_(or, a = a | b, 0)
_(xor, a = a ^ b, 1)
/* *INDENT-ON* */
#undef _
/** Logical operator across two bitmaps which duplicates the first bitmap

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns aiDup = ai and bi. Neither ai nor bi are modified
*/
always_inline uword *clib_bitmap_dup_and (uword * ai, uword * bi);

/** Logical operator across two bitmaps which duplicates the first bitmap

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns aiDup = ai & ~bi. Neither ai nor bi are modified
*/
always_inline uword *clib_bitmap_dup_andnot (uword * ai, uword * bi);

/** Logical operator across two bitmaps which duplicates the first bitmap

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns aiDup = ai or bi. Neither ai nor bi are modified
*/
always_inline uword *clib_bitmap_dup_or (uword * ai, uword * bi);

/** Logical operator across two bitmaps which duplicates the first bitmap

    @param ai - pointer to the destination bitmap
    @param bi - pointer to the source bitmap
    @returns aiDup = ai xor bi. Neither ai nor bi are modified
*/
always_inline uword *clib_bitmap_dup_xor (uword * ai, uword * bi);

#define _(name)						\
  always_inline uword *					\
  clib_bitmap_dup_##name (uword * ai, uword * bi)	\
{ return clib_bitmap_##name (clib_bitmap_dup (ai), bi); }

/* *INDENT-OFF* */
_(and);
_(andnot);
_(or);
_(xor);
/* *INDENT-ON* */
#undef _

/* ALU function definition macro for functions taking one bitmap and an
 * immediate. */
#define _(name, body, check_zero)			\
always_inline uword *					\
clib_bitmap_##name (uword * ai, uword i)		\
{							\
  uword i0 = i / BITS (ai[0]);				\
  uword i1 = i % BITS (ai[0]);				\
  uword a, b;						\
  clib_bitmap_vec_validate (ai, i0);			\
  a = ai[i0];						\
  b = (uword) 1 << i1;					\
  do { body; } while (0);				\
  ai[i0] = a;						\
  if (check_zero && a == 0)				\
    ai = _clib_bitmap_remove_trailing_zeros (ai);	\
  return ai;						\
}

/* ALU functions immediate: */
/* *INDENT-OFF* */
_(andi, a = a & b, 1)
_(andnoti, a = a & ~b, 1)
_(ori, a = a | b, 0)
_(xori, a = a ^ b, 1)
/* *INDENT-ON* */
#undef _

/* ALU function definition macro for functions taking one bitmap and an
 * immediate. No tail trimming */
#define _(name, body)					\
always_inline uword *					\
clib_bitmap_##name##_notrim (uword * ai, uword i)	\
{							\
  uword i0 = i / BITS (ai[0]);				\
  uword i1 = i % BITS (ai[0]);				\
  uword a, b;						\
  clib_bitmap_vec_validate (ai, i0);			\
  a = ai[i0];						\
  b = (uword) 1 << i1;					\
  do { body; } while (0);				\
  ai[i0] = a;						\
  return ai;						\
}

/* ALU functions immediate: */
/* *INDENT-OFF* */
_(andi, a = a & b)
_(andnoti, a = a & ~b)
_(ori, a = a | b)
_(xori, a = a ^ b)
#undef _
/* *INDENT-ON* */

/** Return a random bitmap of the requested length
    @param ai - pointer to the destination bitmap
    @param n_bits - number of bits to allocate
    @param [in,out] seed - pointer to the random number seed
    @returns a reasonably random bitmap based. See random.h.
*/
always_inline uword *
clib_bitmap_random (uword * ai, uword n_bits, u32 * seed)
{
  vec_reset_length (ai);

  if (n_bits > 0)
    {
      uword i = n_bits - 1;
      uword i0, i1;
      uword log2_rand_max;

      log2_rand_max = min_log2 (random_u32_max ());

      i0 = i / BITS (ai[0]);
      i1 = i % BITS (ai[0]);

      clib_bitmap_vec_validate (ai, i0);
      for (i = 0; i <= i0; i++)
	{
	  uword n;
	  for (n = 0; n < BITS (ai[i]); n += log2_rand_max)
	    ai[i] |= random_u32 (seed) << n;
	}
      if (i1 + 1 < BITS (ai[0]))
	ai[i0] &= (((uword) 1 << (i1 + 1)) - 1);
    }
  return ai;
}

/** Return the next set bit in a bitmap starting at bit i
    @param ai - pointer to the bitmap
    @param i - first bit position to test
    @returns first set bit position at or after i,
    ~0 if no further set bits are found
*/
always_inline uword
clib_bitmap_next_set (uword * ai, uword i)
{
  uword i0 = i / BITS (ai[0]);
  uword i1 = i % BITS (ai[0]);
  uword t;

  if (i0 < vec_len (ai))
    {
      t = (ai[i0] >> i1) << i1;
      if (t)
	return log2_first_set (t) + i0 * BITS (ai[0]);

      for (i0++; i0 < vec_len (ai); i0++)
	{
	  t = ai[i0];
	  if (t)
	    return log2_first_set (t) + i0 * BITS (ai[0]);
	}
    }

  return ~0;
}

/** Return the next clear bit in a bitmap starting at bit i
    @param ai - pointer to the bitmap
    @param i - first bit position to test
    @returns first clear bit position at or after i
*/
always_inline uword
clib_bitmap_next_clear (uword * ai, uword i)
{
  uword i0 = i / BITS (ai[0]);
  uword i1 = i % BITS (ai[0]);
  uword t;

  if (i0 < vec_len (ai))
    {
      t = (~ai[i0] >> i1) << i1;
      if (t)
	return log2_first_set (t) + i0 * BITS (ai[0]);

      for (i0++; i0 < vec_len (ai); i0++)
	{
	  t = ~ai[i0];
	  if (t)
	    return log2_first_set (t) + i0 * BITS (ai[0]);
	}

      /* no clear bit left in bitmap, return bit just beyond bitmap */
      return (i0 * BITS (ai[0])) + 1;
    }
  return i;
}

/** unformat an any sized hexadecimal bitmask into a bitmap

    uword * bitmap;
    rv = unformat ("%U", unformat_bitmap_mask, &bitmap);

    Standard unformat_function_t arguments

    @param input - pointer an unformat_input_t
    @param va - varargs list comprising a single uword **
    @returns 1 on success, 0 on failure
*/
static inline uword
unformat_bitmap_mask (unformat_input_t * input, va_list * va)
{
  u8 *v = 0;			/* hexadecimal vector */
  uword **bitmap_return = va_arg (*va, uword **);
  uword *bitmap = 0;

  if (unformat (input, "%U", unformat_hex_string, &v))
    {
      int i, s = vec_len (v) - 1;	/* 's' for significance or shift */

      /* v[0] holds the most significant byte */
      for (i = 0; s >= 0; i++, s--)
	bitmap = clib_bitmap_set_multiple (bitmap,
					   s * BITS (v[i]), v[i],
					   BITS (v[i]));

      vec_free (v);
      *bitmap_return = bitmap;
      return 1;
    }

  return 0;
}

/** unformat a list of bit ranges into a bitmap (eg "0-3,5-7,11" )

    uword * bitmap;
    rv = unformat ("%U", unformat_bitmap_list, &bitmap);

    Standard unformat_function_t arguments

    @param input - pointer an unformat_input_t
    @param va - varargs list comprising a single uword **
    @returns 1 on success, 0 on failure
*/
static inline uword
unformat_bitmap_list (unformat_input_t * input, va_list * va)
{
  uword **bitmap_return = va_arg (*va, uword **);
  uword *bitmap = 0;

  u32 a, b;

  while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
    {
      int i;
      if (unformat (input, "%u-%u,", &a, &b))
	;
      else if (unformat (input, "%u,", &a))
	b = a;
      else if (unformat (input, "%u-%u", &a, &b))
	;
      else if (unformat (input, "%u", &a))
	b = a;
      else if (bitmap)
	{
	  unformat_put_input (input);
	  break;
	}
      else
	goto error;

      if (b < a)
	goto error;

      for (i = a; i <= b; i++)
	bitmap = clib_bitmap_set (bitmap, i, 1);
    }
  *bitmap_return = bitmap;
  return 1;
error:
  clib_bitmap_free (bitmap);
  return 0;
}

/** Format a bitmap as a string of hex bytes

    uword * bitmap;
    s = format ("%U", format_bitmap_hex, bitmap);

    Standard format_function_t arguments

    @param s - string under construction
    @param args - varargs list comprising a single uword *
    @returns string under construction
*/
static inline u8 *
format_bitmap_hex (u8 * s, va_list * args)
{
  uword *bitmap = va_arg (*args, uword *);
  int i, is_trailing_zero = 1;

  if (!bitmap)
    return format (s, "0");

  i = vec_bytes (bitmap) * 2;

  while (i > 0)
    {
      u8 x = clib_bitmap_get_multiple (bitmap, --i * 4, 4);

      if (x && is_trailing_zero)
	is_trailing_zero = 0;

      if (x || !is_trailing_zero)
	s = format (s, "%x", x);
    }
  return s;
}
#endif /* included_clib_bitmap_h */

/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */
edException;
+import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispStateBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.ShowLispPitr;
+import org.openvpp.jvpp.core.dto.ShowLispPitrReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Customizer for reading {@link PitrCfg}<br> Currently unsupported in jvpp
+ */
+public class PitrCfgCustomizer extends FutureJVppCustomizer implements ReaderCustomizer<PitrCfg, PitrCfgBuilder> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(PitrCfgCustomizer.class);
+
+ public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public PitrCfgBuilder getBuilder(InstanceIdentifier<PitrCfg> id) {
+ return new PitrCfgBuilder();
+ }
+
+ @Override
+ public void readCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfgBuilder builder, ReadContext ctx)
+ throws ReadFailedException {
+ LOG.debug("Reading status for Lisp Pitr node {}", id);
+
+ ShowLispPitrReply reply;
+
+ try {
+ reply = getPitrStatus();
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new ReadFailedException(id, e);
+ }
+
+ builder.setLocatorSet(TranslateUtils.toString(reply.locatorSetName));
+ LOG.debug("Reading status for Lisp Pitr node {} successfull", id);
+ }
+
+ @Override
+ public void merge(Builder<? extends DataObject> parentBuilder, PitrCfg readValue) {
+ ((LispStateBuilder) parentBuilder).setPitrCfg(readValue);
+ }
+
+ public ShowLispPitrReply getPitrStatus() throws TimeoutException, VppBaseCallException {
+ return getReply(getFutureJVpp().showLispPitr(new ShowLispPitr()).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
new file mode 100755
index 000000000..81405ecec
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/RemoteMappingCustomizer.java
@@ -0,0 +1,203 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.valueOf;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
+import static io.fd.honeycomb.lisp.translate.util.EidConverter.compareAddresses;
+import static io.fd.honeycomb.lisp.translate.util.EidConverter.getArrayAsEidLocal;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.read.dump.check.MappingsDumpCheck;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.QuantityType;
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispEidTableDetails;
+import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Customizer for reading {@code RemoteMapping}<br>
+ */
+public class RemoteMappingCustomizer extends FutureJVppCustomizer
+ implements ListReaderCustomizer<RemoteMapping, RemoteMappingKey, RemoteMappingBuilder> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(RemoteMappingCustomizer.class);
+ private static final String KEY = RemoteMappingCustomizer.class.getName();
+
+ private final DumpCacheManager<LispEidTableDetailsReplyDump, MappingsDumpParams> dumpManager;
+ private final EidMappingContext remoteMappingContext;
+
+ public RemoteMappingCustomizer(@Nonnull FutureJVppCore futureJvpp,
+ @Nonnull EidMappingContext remoteMappingContext) {
+ super(futureJvpp);
+ this.remoteMappingContext = checkNotNull(remoteMappingContext, "Remote mappings not present");
+ this.dumpManager =
+ new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableDetailsReplyDump, MappingsDumpParams>()
+ .withExecutor(new MappingsDumpExecutor(futureJvpp))
+ .withNonEmptyPredicate(new MappingsDumpCheck())
+ .build();
+ }
+
+
+ @Override
+ public RemoteMappingBuilder getBuilder(InstanceIdentifier<RemoteMapping> id) {
+ return new RemoteMappingBuilder();
+ }
+
+ private Eid copyEid(
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid eid) {
+ return new EidBuilder().setAddress(eid.getAddress()).setAddressType(eid.getAddressType())
+ .setVirtualNetworkId(eid.getVirtualNetworkId()).build();
+ }
+
+ @Override
+ public void readCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMappingBuilder builder,
+ ReadContext ctx)
+ throws ReadFailedException {
+ checkState(id.firstKeyOf(RemoteMapping.class) != null, "No key present for id({})", id);
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent VNI table not specified");
+
+ final MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
+ checkState(remoteMappingContext.containsEid(mappingId, ctx.getMappingContext()),
+ "No mapping stored for id %s", mappingId);
+
+ final long vni = id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier();
+ final String remoteMappingId = id.firstKeyOf(RemoteMapping.class).getId().getValue();
+ final Eid eid = copyEid(remoteMappingContext.getEid(mappingId, ctx.getMappingContext()));
+ final MappingsDumpParams dumpParams = new MappingsDumpParamsBuilder()
+ .setVni(Long.valueOf(vni).intValue())
+ .setEidSet(QuantityType.SPECIFIC)
+ .setEidType(EidConverter.getEidType(eid))
+ .setEid(EidConverter.getEidAsByteArray(eid))
+ .setPrefixLength(EidConverter.getPrefixLength(eid))
+ .build();
+
+ LOG.debug("Dumping data for LocalMappings(id={})", id);
+ Optional<LispEidTableDetailsReplyDump> replyOptional;
+ try {
+ replyOptional =
+ dumpManager.getDump(bindKey("SPECIFIC_" + remoteMappingId), ctx.getModificationCache(), dumpParams);
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+
+ if (replyOptional.isPresent()) {
+ LOG.debug("Valid dump loaded");
+
+ LispEidTableDetails details = replyOptional.get().lispEidTableDetails.stream()
+ .filter(a -> compareAddresses(eid.getAddress(),
+ getArrayAsEidLocal(valueOf(a.eidType), a.eid).getAddress()))
+ .collect(
+ RWUtils.singleItemCollector());
+
+ builder.setEid(EidConverter.getArrayAsEidRemote(valueOf(details.eidType), details.eid));
+ builder.setKey(new RemoteMappingKey(new MappingId(id.firstKeyOf(RemoteMapping.class).getId())));
+ builder.setTtl(resolveTtl(details.ttl));
+ builder.setAuthoritative(
+ new RemoteMapping.Authoritative(TranslateUtils.byteToBoolean(details.authoritative)));
+
+ } else {
+ LOG.debug("No data dumped");
+ }
+ }
+
+ //compensate ~0 as default value of ttl
+ private static long resolveTtl(final int ttlValue) {
+ return ttlValue == -1
+ ? Integer.MAX_VALUE
+ : ttlValue;
+ }
+
+ @Override
+ public List<RemoteMappingKey> getAllIds(InstanceIdentifier<RemoteMapping> id, ReadContext context)
+ throws ReadFailedException {
+
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent VNI table not specified");
+
+ //requesting all remote with specific vni
+ final MappingsDumpParams dumpParams = new MappingsDumpParamsBuilder()
+ .setVni(Long.valueOf(id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier()).intValue())
+ .setEidSet(QuantityType.ALL)
+ .setFilter(FilterType.REMOTE)
+ .build();
+
+ LOG.debug("Dumping data for LocalMappings(id={})", id);
+ Optional<LispEidTableDetailsReplyDump> replyOptional;
+ try {
+ replyOptional = dumpManager.getDump(bindKey("ALL_REMOTE"), context.getModificationCache(), dumpParams);
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+
+ if (replyOptional.isPresent()) {
+ LOG.debug("Valid dump loaded");
+ return replyOptional.get()
+ .lispEidTableDetails
+ .stream()
+ .map(detail -> new RemoteMappingKey(
+ new MappingId(
+ remoteMappingContext.getId(
+ EidConverter.getArrayAsEidRemote(
+ valueOf(detail.eidType), detail.eid),
+ context.getMappingContext()))))
+ .collect(Collectors.toList());
+ } else {
+ LOG.debug("No data dumped");
+ return Collections.emptyList();
+ }
+ }
+
+ @Override
+ public void merge(Builder<? extends DataObject> builder, List<RemoteMapping> readData) {
+ ((RemoteMappingsBuilder) builder).setRemoteMapping(readData);
+ }
+
+ private String bindKey(String prefix) {
+ return prefix + "_" + KEY;
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java
new file mode 100755
index 000000000..60d6b9dc3
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizer.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read;
+
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor.NO_PARAMS;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.check.VniTableDumpCheck;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.VniTableDumpExecutor;
+import io.fd.honeycomb.translate.read.ReadContext;
+import io.fd.honeycomb.translate.read.ReadFailedException;
+import io.fd.honeycomb.translate.spi.read.ListReaderCustomizer;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetails;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Handles the reads of {@link VniTable} nodes
+ */
+public class VniTableCustomizer extends FutureJVppCustomizer
+ implements ListReaderCustomizer<VniTable, VniTableKey, VniTableBuilder> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
+
+ private static final String LISP_TABLE_ID_DUMP = VniTableCustomizer.class.getName();
+ private final DumpCacheManager<LispEidTableMapDetailsReplyDump, Void> dumpManager;
+
+ public VniTableCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispEidTableMapDetailsReplyDump, Void>()
+ .withExecutor(new VniTableDumpExecutor(futureJvpp))
+ .withNonEmptyPredicate(new VniTableDumpCheck())
+ .build();
+ }
+
+ private static VniTableKey detailsToKey(final LispEidTableMapDetails lispEidTableMapDetails) {
+ return new VniTableKey(Integer.valueOf(lispEidTableMapDetails.vni).longValue());
+
+ }
+
+ @Override
+ public void merge(@Nonnull final Builder<? extends DataObject> builder, @Nonnull final List<VniTable> readData) {
+ ((EidTableBuilder) builder).setVniTable(readData);
+ }
+
+ @Nonnull
+ @Override
+ public VniTableBuilder getBuilder(@Nonnull final InstanceIdentifier<VniTable> id) {
+ return new VniTableBuilder();
+ }
+
+ @Nonnull
+ @Override
+ public List<VniTableKey> getAllIds(@Nonnull final InstanceIdentifier<VniTable> id,
+ @Nonnull final ReadContext context)
+ throws ReadFailedException {
+ LOG.trace("Reading all IDS...");
+
+ Optional<LispEidTableMapDetailsReplyDump> optionalReply;
+ try {
+ optionalReply = dumpManager.getDump(LISP_TABLE_ID_DUMP, context.getModificationCache(), NO_PARAMS);
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+
+ if (!optionalReply.isPresent()) {
+ return Collections.emptyList();
+ }
+
+ LispEidTableMapDetailsReplyDump reply = optionalReply.get();
+ LOG.debug("Dumped ...");
+
+ // Just transform received details into a list of keys
+ final List<VniTableKey> collect = reply.lispEidTableMapDetails.stream().map(VniTableCustomizer::detailsToKey)
+ .collect(Collectors.toList());
+ LOG.debug("All IDs found: {} ...", collect);
+ return collect;
+ }
+
+ @Override
+ public void readCurrentAttributes(@Nonnull final InstanceIdentifier<VniTable> id,
+ @Nonnull final VniTableBuilder builder, @Nonnull final ReadContext ctx)
+ throws ReadFailedException {
+
+ checkState(id.firstKeyOf(VniTable.class) != null, "No VNI present");
+ VniTableKey key = new VniTableKey(id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier());
+
+ Optional<LispEidTableMapDetailsReplyDump> optionalReply;
+ try {
+ optionalReply = dumpManager.getDump(LISP_TABLE_ID_DUMP, ctx.getModificationCache(), NO_PARAMS);
+ } catch (DumpExecutionFailedException e) {
+ throw new ReadFailedException(id, e);
+ }
+
+ if (!optionalReply.isPresent()) {
+ return;
+ }
+
+ //transforming right away to single detail(specific request should do the magic)
+ LispEidTableMapDetails details =
+ optionalReply.get().lispEidTableMapDetails.stream().filter(a -> detailsToKey(a).equals(key))
+ .collect(RWUtils.singleItemCollector());
+
+ builder.setVirtualNetworkIdentifier((long) details.vni);
+ builder.setTableId((long) details.vrf);
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java
new file mode 100644
index 000000000..530be98ed
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorDumpCheck.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException;
+import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
+
+public class LocatorDumpCheck implements EntityDumpNonEmptyCheck<LispLocatorDetailsReplyDump> {
+
+ @Override
+ public void assertNotEmpty(final LispLocatorDetailsReplyDump data) throws DumpCheckFailedException {
+
+ if (data == null) {
+ throw new DumpEmptyException("Locator dump is null");
+ }
+
+ if (data.lispLocatorDetails == null) {
+ throw new DumpEmptyException("Locator dump is empty");
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java
new file mode 100755
index 000000000..eac757d50
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/LocatorSetsDumpCheck.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+
+public class LocatorSetsDumpCheck implements EntityDumpNonEmptyCheck<LispLocatorSetDetailsReplyDump> {
+
+ @Override
+ public void assertNotEmpty(final LispLocatorSetDetailsReplyDump data) throws DumpCheckFailedException {
+
+ if (data == null) {
+ throw new DumpEmptyException("Locator sets dump is null");
+ }
+
+ if (data.lispLocatorSetDetails == null) {
+ throw new DumpEmptyException("Locator sets dump is empty");
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java
new file mode 100755
index 000000000..e018702ee
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MapResolverDumpCheck.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
+
+public class MapResolverDumpCheck implements EntityDumpNonEmptyCheck<LispMapResolverDetailsReplyDump> {
+
+ @Override
+ public void assertNotEmpty(final LispMapResolverDetailsReplyDump data) throws DumpCheckFailedException {
+ if (data == null) {
+ throw new DumpEmptyException("Map resolvers dump is null");
+ }
+
+ if (data.lispMapResolverDetails == null) {
+ throw new DumpEmptyException("Map resolvers dump is empty");
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java
new file mode 100755
index 000000000..f34ea1b8e
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/MappingsDumpCheck.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException;
+import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+
+/**
+ * Common dump check for both local and remote mappings
+ */
+public class MappingsDumpCheck implements EntityDumpNonEmptyCheck<LispEidTableDetailsReplyDump> {
+
+ @Override
+ public void assertNotEmpty(final LispEidTableDetailsReplyDump data) throws DumpCheckFailedException {
+ if (data == null) {
+ throw new DumpEmptyException("Mappings dump is null");
+ }
+
+ if (data.lispEidTableDetails == null) {
+ throw new DumpEmptyException("Mappings dump is empty");
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java
new file mode 100755
index 000000000..942d974e6
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/check/VniTableDumpCheck.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.check;
+
+
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpNonEmptyCheck;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.DumpCheckFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.check.i.DumpEmptyException;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+
+public class VniTableDumpCheck implements EntityDumpNonEmptyCheck<LispEidTableMapDetailsReplyDump> {
+
+ @Override
+ public void assertNotEmpty(final LispEidTableMapDetailsReplyDump data) throws DumpCheckFailedException {
+ if (data == null) {
+ throw new DumpEmptyException("Vni table dump is null");
+ }
+
+ if (data.lispEidTableMapDetails == null) {
+ throw new DumpEmptyException("Bni table dump is empty");
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java
new file mode 100644
index 000000000..fbd2003e8
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/AbstractDumpExecutor.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Abstract holder for jvpp refference
+ */
+public abstract class AbstractDumpExecutor {
+
+ protected final FutureJVppCore vppApi;
+
+ protected AbstractDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference cannot be null");
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
new file mode 100644
index 000000000..16e6deaab
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutor.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispLocatorDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Executor for dumping of locators
+ */
+public class LocatorDumpExecutor extends AbstractDumpExecutor
+ implements EntityDumpExecutor<LispLocatorDetailsReplyDump, LocatorDumpParams> {
+
+
+ public LocatorDumpExecutor(@Nonnull final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public LispLocatorDetailsReplyDump executeDump(final LocatorDumpParams params) throws DumpExecutionFailedException {
+ checkNotNull(params, "Params for dump request not present");
+
+ LispLocatorDump request = new LispLocatorDump();
+ request.locatorSetIndex = params.getLocatorSetIndex();
+ request.filter = params.getFilter();
+
+ try {
+ return TranslateUtils.getReply(vppApi.lispLocatorDump(request).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException
+ .wrapTimeoutException("Locator dump ended in timeout with params" + params.toString(), e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException
+ .wrapFailedCallException("Locator dump failed with params" + params.toString(), e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
new file mode 100755
index 000000000..d074bae52
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutor.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class LocatorSetsDumpExecutor extends AbstractDumpExecutor
+ implements EntityDumpExecutor<LispLocatorSetDetailsReplyDump, Void> {
+
+ public LocatorSetsDumpExecutor(@Nonnull FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ public LispLocatorSetDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException {
+
+ LispLocatorSetDump request = new LispLocatorSetDump();
+ request.filter = 0;
+
+ try {
+ return TranslateUtils
+ .getReply(vppApi.lispLocatorSetDump(request).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException.wrapTimeoutException("Locator sets dump ended in timeout", e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException.wrapFailedCallException("Locator sets dump failed", e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
new file mode 100755
index 000000000..ec1cabd54
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutor.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispMapResolverDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispMapResolverDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class MapResolversDumpExecutor extends AbstractDumpExecutor
+ implements EntityDumpExecutor<LispMapResolverDetailsReplyDump, Void> {
+
+ public MapResolversDumpExecutor(@Nonnull FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ public LispMapResolverDetailsReplyDump executeDump(final Void params) throws DumpExecutionFailedException {
+ try {
+ return TranslateUtils.getReply(vppApi.lispMapResolverDump(new LispMapResolverDump()).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException
+ .wrapTimeoutException("Map resolver dump execution ended in timeout", e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException.wrapFailedCallException("Map resolver dump execution failed", e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
new file mode 100755
index 000000000..d43713967
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutor.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispEidTableDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Common dump executor for both local and remote mappings
+ */
+public class MappingsDumpExecutor extends AbstractDumpExecutor
+ implements EntityDumpExecutor<LispEidTableDetailsReplyDump, MappingsDumpParams> {
+
+ public MappingsDumpExecutor(@Nonnull FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+
+ @Override
+ public LispEidTableDetailsReplyDump executeDump(final MappingsDumpParams params)
+ throws DumpExecutionFailedException {
+ checkNotNull(params, "Params for dump request not present");
+
+ LispEidTableDump request = new LispEidTableDump();
+ request.eid = params.getEid();
+ request.eidSet = params.getEidSet();
+ request.eidType = params.getEidType();
+ request.prefixLength = params.getPrefixLength();
+ request.vni = params.getVni();
+ request.filter = params.getFilter();
+
+ try {
+ return TranslateUtils.getReply(vppApi.lispEidTableDump(request).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException
+ .wrapTimeoutException("Mappings dump execution timed out with params " + params.toString(), e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException
+ .wrapFailedCallException("Mappings dump execution failed with params " + params.toString(), e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
new file mode 100755
index 000000000..cb5f06393
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutor.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor;
+
+
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpCallFailedException;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.i.DumpTimeoutException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump;
+import org.openvpp.jvpp.core.dto.LispEidTableMapDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class VniTableDumpExecutor extends AbstractDumpExecutor
+ implements EntityDumpExecutor<LispEidTableMapDetailsReplyDump, Void> {
+
+ public VniTableDumpExecutor(@Nonnull FutureJVppCore api) {
+ super(api);
+ }
+
+ @Override
+ public LispEidTableMapDetailsReplyDump executeDump(Void params) throws DumpExecutionFailedException {
+ try {
+ return TranslateUtils.getReply(vppApi.lispEidTableMapDump(new LispEidTableMapDump()).toCompletableFuture());
+ } catch (TimeoutException e) {
+ throw DumpTimeoutException.wrapTimeoutException("Eid table map dump ended in timeout", e);
+ } catch (VppBaseCallException e) {
+ throw DumpCallFailedException.wrapFailedCallException("Eid table map dump failed", e);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java
new file mode 100644
index 000000000..eda1e9771
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/LocatorDumpParams.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor.params;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Params for dumping locators
+ */
+public final class LocatorDumpParams {
+
+ private final int locatorSetIndex;
+ private final byte filter;
+
+ private LocatorDumpParams(LocatorDumpParamsBuilder builder) {
+ this.locatorSetIndex = builder.locatorSetIndex;
+ this.filter = builder.filter;
+ }
+
+ public int getLocatorSetIndex() {
+ return locatorSetIndex;
+ }
+
+ public byte getFilter() {
+ return filter;
+ }
+
+ /**
+ * Enum for filtering which locators to dump
+ */
+ public enum LocatorDumpFilter {
+
+ ALL(0),
+ LOCAL(1),
+ REMOTE(2);
+
+ private final int value;
+
+ private LocatorDumpFilter(int value) {
+ this.value = value;
+ }
+
+ public final int getValue() {
+ return value;
+ }
+ }
+
+ public static final class LocatorDumpParamsBuilder {
+
+ public int locatorSetIndex;
+ public byte filter;
+
+
+ public LocatorDumpParamsBuilder setLocatorSetIndex(final int locatorSetIndex) {
+ this.locatorSetIndex = locatorSetIndex;
+ return this;
+ }
+
+ public LocatorDumpParamsBuilder setFilter(final LocatorDumpFilter filter) {
+ this.filter = Integer.valueOf(checkNotNull(filter, "Cannot set null filter").getValue()).byteValue();
+ return this;
+ }
+
+ public LocatorDumpParams build() {
+ return new LocatorDumpParams(this);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java
new file mode 100755
index 000000000..1f7990c9b
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/dump/executor/params/MappingsDumpParams.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.dump.executor.params;
+
+import io.fd.honeycomb.lisp.translate.read.dump.executor.MappingsDumpExecutor;
+import java.util.Arrays;
+
+/**
+ * Parameters for executing {@link MappingsDumpExecutor}
+ */
+public final class MappingsDumpParams {
+
+ private final byte eidSet;
+ private final byte prefixLength;
+ private final int vni;
+ private final byte eidType;
+ private final byte[] eid;
+ private final byte filter;
+
+ private MappingsDumpParams(MappingsDumpParamsBuilder builder) {
+ this.eidSet = builder.eidSet;
+ this.prefixLength = builder.prefixLength;
+ this.vni = builder.vni;
+ this.eidType = builder.eidType;
+ this.eid = builder.eid;
+ this.filter = builder.filter;
+ }
+
+
+ public byte getEidSet() {
+ return eidSet;
+ }
+
+ public byte getPrefixLength() {
+ return prefixLength;
+ }
+
+ public int getVni() {
+ return vni;
+ }
+
+ public byte getEidType() {
+ return eidType;
+ }
+
+ public byte[] getEid() {
+ return eid;
+ }
+
+ public final byte getFilter() {
+ return filter;
+ }
+
+ @Override
+ public String toString() {
+ return "MappingsDumpParams{" +
+ "eidSet=" + eidSet +
+ ", prefixLength=" + prefixLength +
+ ", vni=" + vni +
+ ", eidType=" + eidType +
+ ", eid=" + Arrays.toString(eid) +
+ ", filter=" + filter +
+ '}';
+ }
+
+ /**
+ * Type of requested mapping eid
+ */
+ public enum EidType {
+ IPV4(0),
+ IPV6(1),
+ MAC(2);
+
+ private final int value;
+
+ private EidType(final int value) {
+ this.value = value;
+ }
+
+ public static final EidType valueOf(int value) {
+ switch (value) {
+ case 0:
+ return IPV4;
+ case 1:
+ return IPV6;
+ case 2:
+ return MAC;
+ default:
+ throw new IllegalArgumentException("Illegal value");
+ }
+ }
+
+ public final int getValue() {
+ return this.value;
+ }
+ }
+
+ /**
+ * Type of requested mapping
+ */
+ public enum FilterType {
+ ALL(0),
+ LOCAL(1),
+ REMOTE(2);
+
+ private final int value;
+
+ private FilterType(final int value) {
+ this.value = value;
+ }
+
+ public final int getValue() {
+ return this.value;
+ }
+ }
+
+ public enum QuantityType {
+ ALL(0),
+ SPECIFIC(1);
+
+ private final int value;
+
+ private QuantityType(final int value) {
+ this.value = value;
+ }
+
+ public final int getValue() {
+ return this.value;
+ }
+ }
+
+ public static final class MappingsDumpParamsBuilder {
+ private byte eidSet;
+ private byte prefixLength;
+ private int vni;
+ private byte eidType;
+ private byte[] eid;
+ private byte filter;
+
+ public static final MappingsDumpParamsBuilder newInstance() {
+ return new MappingsDumpParamsBuilder();
+ }
+
+ public MappingsDumpParamsBuilder setEidSet(final QuantityType quantityType) {
+ this.eidSet = (byte) quantityType.getValue();
+ return this;
+ }
+
+ public MappingsDumpParamsBuilder setPrefixLength(final byte prefixLength) {
+ this.prefixLength = prefixLength;
+ return this;
+ }
+
+ public MappingsDumpParamsBuilder setVni(final int vni) {
+ this.vni = vni;
+ return this;
+ }
+
+ public MappingsDumpParamsBuilder setEidType(final EidType eidType) {
+ this.eidType = (byte) eidType.getValue();
+ return this;
+ }
+
+ public MappingsDumpParamsBuilder setEid(final byte[] eid) {
+ this.eid = eid;
+ return this;
+ }
+
+ public MappingsDumpParamsBuilder setFilter(final FilterType filterType) {
+ this.filter = (byte) filterType.getValue();
+ return this;
+ }
+
+ public MappingsDumpParams build() {
+ return new MappingsDumpParams(this);
+ }
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
new file mode 100644
index 000000000..318b6f2f1
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/AbstractLispReaderFactoryBase.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.factory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Basic attributes for lisp reader factories
+ */
+abstract class AbstractLispReaderFactoryBase {
+
+ protected final InstanceIdentifier<LispState> lispStateId;
+ protected final FutureJVppCore vppApi;
+ protected NamingContext interfaceContext;
+ protected NamingContext locatorSetContext;
+ protected EidMappingContext localMappingContext;
+ protected EidMappingContext remoteMappingContext;
+
+ protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi) {
+ this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP api refference is null");
+ }
+
+ protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final EidMappingContext localMappingContext,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP api reference is null");
+ this.interfaceContext = checkNotNull(interfaceContext,
+ "Interface naming context is null,for readers that don't need this dependency,use different constructor");
+ this.localMappingContext = checkNotNull(localMappingContext,
+ "Local mappings reference is null,for readers that don't need this dependency use different constructor");
+ this.remoteMappingContext = checkNotNull(remoteMappingContext,
+ "Remote mappings reference is null,for readers that don't need this dependency use different constructor");
+ }
+
+ protected AbstractLispReaderFactoryBase(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final NamingContext locatorSetContext,
+ @Nonnull final EidMappingContext localMappingContext,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ this.lispStateId = checkNotNull(lispStateId, "Lisp state identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP api reference is null");
+ this.interfaceContext = checkNotNull(interfaceContext,
+ "Interface naming context is null,for readers that don't need this dependency,use different constructor");
+ this.locatorSetContext = checkNotNull(locatorSetContext,
+ "Locator set naming context is null,for readers that don't need this dependency,use different constructor");
+ this.localMappingContext = checkNotNull(localMappingContext,
+ "Local mappings reference is null,for readers that don't need this dependency use different constructor");
+ this.remoteMappingContext = checkNotNull(remoteMappingContext,
+ "Remote mappings reference is null,for readers that don't need this dependency use different constructor");
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java
new file mode 100755
index 000000000..905d0faff
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/EidTableReaderFactory.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.factory;
+
+
+import com.google.common.collect.ImmutableSet;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.read.AdjacencyCustomizer;
+import io.fd.honeycomb.lisp.translate.read.LocalMappingCustomizer;
+import io.fd.honeycomb.lisp.translate.read.RemoteMappingCustomizer;
+import io.fd.honeycomb.lisp.translate.read.VniTableCustomizer;
+import io.fd.honeycomb.translate.impl.read.GenericListReader;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.AdjacenciesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappingsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory that produces {@code Reader} for {@code EidTable}<br> with all its inhired child readers
+ */
+final class EidTableReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
+
+ private EidTableReaderFactory(final InstanceIdentifier<LispState> lispStateId,
+ final FutureJVppCore vppApi,
+ final NamingContext interfaceContext,
+ final NamingContext locatorSetContext,
+ final EidMappingContext localMappingContext,
+ final EidMappingContext remoteMappingContext) {
+ super(lispStateId, vppApi,interfaceContext, locatorSetContext, localMappingContext, remoteMappingContext);
+ }
+
+ public static EidTableReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final NamingContext locatorSetContext,
+ @Nonnull final EidMappingContext localMappingContext,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ return new EidTableReaderFactory(lispStateId, vppApi, interfaceContext, locatorSetContext, localMappingContext,
+ remoteMappingContext);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
+ InstanceIdentifier<EidTable> eidTableInstanceIdentifier = lispStateId.child(EidTable.class);
+ InstanceIdentifier<VniTable> vniTableInstanceIdentifier = eidTableInstanceIdentifier.child(VniTable.class);
+ InstanceIdentifier<LocalMappings> localMappingsInstanceIdentifier =
+ vniTableInstanceIdentifier.child(LocalMappings.class);
+ InstanceIdentifier<RemoteMappings> remoteMappingsInstanceIdentifier =
+ vniTableInstanceIdentifier.child(RemoteMappings.class);
+ InstanceIdentifier<Adjacencies> adjacenciesInstanceIdentifier =
+ vniTableInstanceIdentifier.child(Adjacencies.class);
+
+ registry.addStructuralReader(eidTableInstanceIdentifier, EidTableBuilder.class);
+ registry.add(new GenericListReader<>(vniTableInstanceIdentifier, new VniTableCustomizer(vppApi)));
+
+ registry.addStructuralReader(localMappingsInstanceIdentifier, LocalMappingsBuilder.class);
+
+ final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
+ registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid.class)),
+ new GenericListReader<>(localMappingsInstanceIdentifier.child(LocalMapping.class),
+ new LocalMappingCustomizer(vppApi, locatorSetContext, localMappingContext)));
+
+ registry.addStructuralReader(remoteMappingsInstanceIdentifier, RemoteMappingsBuilder.class);
+
+ final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId = InstanceIdentifier.create(RemoteMapping.class);
+ registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid.class)),
+ new GenericListReader<>(remoteMappingsInstanceIdentifier.child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+
+ registry.addStructuralReader(adjacenciesInstanceIdentifier, AdjacenciesBuilder.class);
+
+ final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
+ registry.subtreeAdd(
+ ImmutableSet.of(adjacencySubtreeId.child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
+ new GenericListReader<>(adjacenciesInstanceIdentifier.child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java
new file mode 100755
index 000000000..8444066d7
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LispStateReaderFactory.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.factory;
+
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.INTERFACE_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.read.LispStateCustomizer;
+import io.fd.honeycomb.lisp.translate.read.PitrCfgCustomizer;
+import io.fd.honeycomb.translate.impl.read.GenericReader;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Initialize readers for {@link LispState}
+ */
+public class LispStateReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
+
+ @Inject
+ public LispStateReaderFactory(final FutureJVppCore vppApi,
+ @Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
+ @Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
+ @Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
+ @Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext) {
+ super(InstanceIdentifier.create(LispState.class), vppApi, interfaceContext, locatorSetContext,
+ localMappingContext,
+ remoteMappingContext);
+ }
+
+
+ @Override
+ public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
+
+ registry.add(new GenericReader<>(lispStateId, new LispStateCustomizer(vppApi)));
+
+ LocatorSetsReaderFactory.newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext).init(registry);
+ MapResolversReaderFactory.newInstance(lispStateId, vppApi).init(registry);
+ EidTableReaderFactory
+ .newInstance(lispStateId, vppApi, interfaceContext, locatorSetContext, localMappingContext,
+ remoteMappingContext)
+ .init(registry);
+
+ registry.add(new GenericReader<>(lispStateId.child(PitrCfg.class), new PitrCfgCustomizer(vppApi)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
new file mode 100755
index 000000000..053f3d858
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/LocatorSetsReaderFactory.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.factory;
+
+
+import io.fd.honeycomb.lisp.translate.read.InterfaceCustomizer;
+import io.fd.honeycomb.lisp.translate.read.LocatorSetCustomizer;
+import io.fd.honeycomb.translate.impl.read.GenericListReader;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.Interface;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Produces reader for {@link LocatorSets} <br> and all its inhired child readers
+ */
+public class LocatorSetsReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
+
+
+ private LocatorSetsReaderFactory(final InstanceIdentifier<LispState> lispStateId,
+ final FutureJVppCore vppApi,
+ final NamingContext interfaceContext,
+ final NamingContext locatorSetContext
+ ) {
+ super(lispStateId, vppApi);
+ this.interfaceContext=interfaceContext;
+ this.locatorSetContext = locatorSetContext;
+ }
+
+ public static final LocatorSetsReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi,
+ final NamingContext interfaceContext,
+ @Nonnull final NamingContext locatorSetContext) {
+ return new LocatorSetsReaderFactory(lispStateId, vppApi, interfaceContext,locatorSetContext);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
+ InstanceIdentifier<LocatorSets> locatorSetsInstanceIdentifier = lispStateId.child(LocatorSets.class);
+ InstanceIdentifier<LocatorSet> locatorSetInstanceIdentifier =
+ locatorSetsInstanceIdentifier.child(LocatorSet.class);
+
+ registry.addStructuralReader(locatorSetsInstanceIdentifier, LocatorSetsBuilder.class);
+ registry.add(new GenericListReader<>(locatorSetInstanceIdentifier, new LocatorSetCustomizer(vppApi)));
+ registry.add(new GenericListReader<>(locatorSetInstanceIdentifier.child(Interface.class),
+ new InterfaceCustomizer(vppApi, interfaceContext, locatorSetContext)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java
new file mode 100755
index 000000000..c26f17234
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/factory/MapResolversReaderFactory.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.read.factory;
+
+
+import io.fd.honeycomb.lisp.translate.read.MapResolverCustomizer;
+import io.fd.honeycomb.translate.impl.read.GenericListReader;
+import io.fd.honeycomb.translate.read.ReaderFactory;
+import io.fd.honeycomb.translate.read.registry.ModifiableReaderRegistryBuilder;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolvers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolversBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Builds reader for {@link MapResolvers}<br> and all its inhired child readers
+ */
+public class MapResolversReaderFactory extends AbstractLispReaderFactoryBase implements ReaderFactory {
+
+ private MapResolversReaderFactory(final InstanceIdentifier<LispState> lispStateId, final FutureJVppCore vppApi) {
+ super(lispStateId, vppApi);
+ }
+
+ public static MapResolversReaderFactory newInstance(@Nonnull final InstanceIdentifier<LispState> lispStateId,
+ @Nonnull final FutureJVppCore vppApi) {
+ return new MapResolversReaderFactory(lispStateId, vppApi);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableReaderRegistryBuilder registry) {
+
+ InstanceIdentifier<MapResolvers> mapResolversInstanceIdentifier = lispStateId.child(MapResolvers.class);
+
+ registry.addStructuralReader(mapResolversInstanceIdentifier, MapResolversBuilder.class);
+ registry.add(new GenericListReader<>(mapResolversInstanceIdentifier.child(MapResolver.class),
+ new MapResolverCustomizer(vppApi)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java
new file mode 100755
index 000000000..4c8fa691b
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java
@@ -0,0 +1,283 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.util;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
+
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import java.util.Arrays;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Mac;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.EidBuilder;
+
+
+/**
+ * Helper class that converts {@code SimpleAddress} to eid format for vpp
+ */
+public final class EidConverter {
+
+ private EidConverter() {
+ throw new UnsupportedOperationException("Cannot instantiate utility class " + EidConverter.class.getName());
+ }
+
+ public static byte getPrefixLength(
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
+ return resolverPrefixLength(address.getAddress());
+ }
+
+ public static byte getPrefixLength(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
+ return resolverPrefixLength(address.getAddress());
+ }
+
+ public static byte getPrefixLength(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
+ return resolverPrefixLength(address.getAddress());
+ }
+
+ private static byte resolverPrefixLength(Address address) {
+
+ switch (resolveType(address)) {
+ case IPV4:
+ return 32;
+ case IPV6:
+ return (byte) 128;
+ case MAC:
+ return 0;
+ default:
+ throw new IllegalArgumentException("Illegal type");
+ }
+ }
+
+ public static Eid getArrayAsEidLocal(EidType type, byte[] address) {
+
+ switch (type) {
+ case IPV4: {
+ return new EidBuilder().setAddress(
+ new Ipv4Builder().setIpv4(TranslateUtils.arrayToIpv4AddressNoZoneReversed(address)).build())
+ .build();
+ }
+ case IPV6: {
+ return new EidBuilder().setAddress(
+ new Ipv6Builder().setIpv6(TranslateUtils.arrayToIpv6AddressNoZoneReversed(address)).build())
+ .build();
+ }
+ case MAC: {
+ return new EidBuilder().setAddress(
+ new MacBuilder().setMac(new MacAddress(TranslateUtils.byteArrayToMacSeparated(address)))
+ .build()).build();
+ }
+ default: {
+ throw new IllegalStateException("Unknown type detected");
+ }
+ }
+ }
+
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid getArrayAsEidRemote(
+ EidType type, byte[] address) {
+
+ switch (type) {
+ case IPV4: {
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv4Builder().setIpv4(TranslateUtils.arrayToIpv4AddressNoZoneReversed(address))
+ .build())
+ .build();
+ }
+ case IPV6: {
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv6Builder().setIpv6(TranslateUtils.arrayToIpv6AddressNoZoneReversed(address))
+ .build())
+ .build();
+ }
+ case MAC: {
+ return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new MacBuilder().setMac(new MacAddress(TranslateUtils.byteArrayToMacSeparated(address)))
+ .build()).build();
+ }
+ default: {
+ throw new IllegalStateException("Unknown type detected");
+ }
+ }
+ }
+
+ public static String getArrayAsEidString(
+ EidType type, byte[] address) {
+ switch (type) {
+ case IPV4: {
+ return TranslateUtils.arrayToIpv4AddressNoZoneReversed(address).getValue();
+ }
+ case IPV6: {
+ return TranslateUtils.arrayToIpv6AddressNoZoneReversed(address).getValue();
+ }
+ case MAC: {
+ //as wrong as it looks ,its right(second param is not end index,but count)
+ return TranslateUtils.byteArrayToMacSeparated(Arrays.copyOfRange(address, 0, 6));
+ }
+ default: {
+ throw new IllegalStateException("Unknown type detected");
+ }
+ }
+ }
+
+
+ public static EidType getEidType(
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
+ checkNotNull(address, "SimpleAddress cannot be null");
+
+ return resolveType(address.getAddress());
+ }
+
+ public static EidType getEidType(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
+ checkNotNull(address, "SimpleAddress cannot be null");
+
+ return resolveType(address.getAddress());
+ }
+
+
+ public static EidType getEidType(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
+ checkNotNull(address, "Address cannot be null");
+
+ return resolveType(address.getAddress());
+ }
+
+
+ public static EidType getEidType(final LocalEid address) {
+ checkNotNull(address, "Address cannot be null");
+
+ return resolveType(address.getAddress());
+ }
+
+ public static EidType getEidType(final RemoteEid address) {
+ checkNotNull(address, "Address cannot be null");
+
+ return resolveType(address.getAddress());
+ }
+
+ private static EidType resolveType(
+ Address address) {
+
+ if (address instanceof Ipv4) {
+ return IPV4;
+ } else if (address instanceof Ipv6) {
+ return IPV6;
+ } else if (address instanceof Mac) {
+ return MAC;
+ } else {
+ //TODO - other types
+ throw new IllegalStateException("Unknown type detected");
+ }
+ }
+
+ public static byte[] getEidAsByteArray(
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
+ checkNotNull(address, "Eid cannot be null");
+
+ return resolveByteArray(getEidType(address), address.getAddress());
+ }
+
+ public static byte[] getEidAsByteArray(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid address) {
+ checkNotNull(address, "Eid cannot be null");
+
+ return resolveByteArray(getEidType(address), address.getAddress());
+ }
+
+ public static byte[] getEidAsByteArray(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid address) {
+ checkNotNull(address, "Eid cannot be null");
+
+ return resolveByteArray(getEidType(address), address.getAddress());
+ }
+
+ public static byte[] getEidAsByteArray(final LocalEid address) {
+ checkNotNull(address, "Eid cannot be null");
+
+ return resolveByteArray(getEidType(address), address.getAddress());
+ }
+
+
+ public static byte[] getEidAsByteArray(final RemoteEid address) {
+ checkNotNull(address, "Eid cannot be null");
+
+ return resolveByteArray(getEidType(address), address.getAddress());
+ }
+
+ private static byte[] resolveByteArray(EidType type, Address address) {
+ switch (type) {
+ case IPV4:
+ return TranslateUtils
+ .ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(((Ipv4) address).getIpv4()));
+ case IPV6:
+ return TranslateUtils
+ .ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(((Ipv6) address).getIpv6()));
+ case MAC:
+ return TranslateUtils.parseMac(((Mac) address).getMac().getValue());
+ default:
+ //TODO - other types
+ throw new IllegalArgumentException("Unsupported type");
+ }
+ }
+
+ public static boolean compareEids(
+ LispAddress first,
+ LispAddress second) {
+
+ return compareAddresses(checkNotNull(first, "First eid is null").getAddress(),
+ checkNotNull(second, "Second eid is null").getAddress());
+ }
+
+ public static boolean compareAddresses(Address firstAddress, Address secondAddress) {
+
+ checkNotNull(firstAddress, "First address is null");
+ checkNotNull(secondAddress, "Second address is null");
+
+ if (firstAddress instanceof Ipv4 && secondAddress instanceof Ipv4) {
+ return ((Ipv4) firstAddress).getIpv4().getValue().equals(((Ipv4) secondAddress).getIpv4().getValue());
+ }
+
+ if (firstAddress instanceof Ipv6 && secondAddress instanceof Ipv6) {
+ return ((Ipv6) firstAddress).getIpv6().getValue().equals(((Ipv6) secondAddress).getIpv6().getValue());
+ }
+
+ if (firstAddress instanceof Mac && secondAddress instanceof Mac) {
+ return ((Mac) firstAddress).getMac().getValue().equals(((Mac) secondAddress).getMac().getValue());
+ }
+
+ throw new IllegalArgumentException("Unsupported eid type " + firstAddress.getClass());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
new file mode 100755
index 000000000..d321510be
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
+
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.AdjacencyKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelAdjacency;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Adjacency, AdjacencyKey> {
+
+ public AdjacencyCustomizer(@Nonnull final FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id,
+ @Nonnull final Adjacency dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ try {
+ addDelAdjacency(true, id, dataAfter);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id,
+ @Nonnull final Adjacency dataBefore, @Nonnull final Adjacency dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Adjacency> id,
+ @Nonnull final Adjacency dataBefore, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ try {
+ addDelAdjacency(false, id, dataBefore);
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+ }
+
+ private void addDelAdjacency(boolean add, final InstanceIdentifier<Adjacency> id, Adjacency data)
+ throws TimeoutException, VppBaseCallException {
+
+ checkState(id.firstKeyOf(VniTable.class) != null, "Unable to find parent VNI for {}", id);
+ final int vni = id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue();
+
+ EidType localEidType = EidConverter.getEidType(data.getLocalEid());
+ EidType remoteEidType = EidConverter.getEidType(data.getRemoteEid());
+
+ checkArgument(localEidType ==
+ remoteEidType, "Local[%s] and Remote[%s] eid types must be the same", localEidType, remoteEidType);
+
+ LispAddDelAdjacency request = new LispAddDelAdjacency();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.seid = EidConverter.getEidAsByteArray(data.getLocalEid());
+ request.seidLen = (byte) request.seid.length;
+ request.deid = EidConverter.getEidAsByteArray(data.getRemoteEid());
+ request.seidLen = (byte) request.deid.length;
+ request.eidType = (byte) localEidType.getValue();
+ request.vni = vni;
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelAdjacency(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
new file mode 100755
index 000000000..c26bbf377
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizer.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.io.UnsupportedEncodingException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelLocator;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for updating {@link Interface}
+ *
+ * @see Interface
+ */
+public class InterfaceCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<Interface, InterfaceKey> {
+
+ private final NamingContext interfaceContext;
+
+ public InterfaceCustomizer(@Nonnull FutureJVppCore futureJvpp, @Nonnull NamingContext interfaceContext) {
+ super(futureJvpp);
+ this.interfaceContext = checkNotNull(interfaceContext, "Naming context is null");
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<Interface> id, Interface dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataAfter, "Interface is null");
+ checkNotNull(dataAfter.getPriority(), "Priority is null");
+ checkNotNull(dataAfter.getWeight(), "Weight is null");
+ checkState(id.firstKeyOf(Interface.class) != null, "Parent interface not found");
+ checkState(id.firstKeyOf(LocatorSet.class) != null, "Parent locator set not found");
+
+ String interfaceName = id.firstKeyOf(Interface.class).getInterfaceRef();
+ String locatorSetName = id.firstKeyOf(LocatorSet.class).getName();
+
+ checkState(interfaceContext.containsIndex(interfaceName, writeContext.getMappingContext()),
+ "No mapping stored for interface %s", interfaceName);
+
+ try {
+ addDelInterfaceAndReply(true, dataAfter,
+ interfaceContext.getIndex(interfaceName, writeContext.getMappingContext()), locatorSetName);
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<Interface> id, Interface dataBefore, Interface dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<Interface> id, Interface dataBefore,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataBefore, "Interface is null");
+ checkNotNull(dataBefore.getPriority(), "Priority is null");
+ checkNotNull(dataBefore.getWeight(), "Weight is null");
+ checkState(id.firstKeyOf(Interface.class) != null, "Parent interface not found");
+ checkState(id.firstKeyOf(LocatorSet.class) != null, "Parent locator set not found");
+
+ String interfaceName = id.firstKeyOf(Interface.class).getInterfaceRef();
+ String locatorSetName = id.firstKeyOf(LocatorSet.class).getName();
+
+ checkState(interfaceContext.containsIndex(interfaceName, writeContext.getMappingContext()),
+ "No mapping stored for interface %s", interfaceName);
+ try {
+ addDelInterfaceAndReply(false, dataBefore,
+ interfaceContext.getIndex(interfaceName, writeContext.getMappingContext()), locatorSetName);
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+ }
+
+ private void addDelInterfaceAndReply(boolean add, Interface data, int interfaceIndex, String locatorSetName)
+ throws VppBaseCallException, TimeoutException, UnsupportedEncodingException {
+ LispAddDelLocator request = new LispAddDelLocator();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.priority = data.getPriority().byteValue();
+ request.weight = data.getWeight().byteValue();
+ request.swIfIndex = interfaceIndex;
+ request.locatorSetName = locatorSetName.getBytes(UTF_8);
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelLocator(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
new file mode 100755
index 000000000..05c162d0c
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LispCustomizer.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import com.google.common.base.Preconditions;
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletionStage;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispEnableDisable;
+import org.openvpp.jvpp.core.dto.LispEnableDisableReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Handles updates of {@link Lisp} node. Takes care of LISP enable/disable
+ */
+public class LispCustomizer extends FutureJVppCustomizer implements WriterCustomizer<Lisp> {
+
+ public LispCustomizer(final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<Lisp> id, @Nonnull final Lisp dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ Preconditions.checkNotNull(dataAfter, "Lisp is null");
+
+ try {
+ enableDisableLisp(dataAfter.isEnable());
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<Lisp> id, @Nonnull final Lisp dataBefore,
+ @Nonnull final Lisp dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+ Preconditions.checkNotNull(dataAfter, "Lisp is null");
+
+ try {
+ enableDisableLisp(dataAfter.isEnable());
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<Lisp> id, @Nonnull final Lisp dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ Preconditions.checkNotNull(dataBefore, "Lisp is null");
+
+ try {
+ enableDisableLisp(false);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ }
+
+
+ private void enableDisableLisp(final boolean enable) throws VppBaseCallException, TimeoutException {
+ final CompletionStage<LispEnableDisableReply> lispEnableDisableReplyCompletionStage =
+ getFutureJVpp().lispEnableDisable(getRequest(enable));
+ TranslateUtils.getReply(lispEnableDisableReplyCompletionStage.toCompletableFuture());
+ }
+
+ private LispEnableDisable getRequest(final boolean enable) {
+ final LispEnableDisable lispEnableDisable = new LispEnableDisable();
+ lispEnableDisable.isEn = TranslateUtils.booleanToByte(enable);
+ return lispEnableDisable;
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
new file mode 100755
index 000000000..eec4b8269
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizer.java
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.io.UnsupportedEncodingException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelLocalEid;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer that writes changes for {@link LocalMapping}
+ */
+public class LocalMappingCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<LocalMapping, LocalMappingKey> {
+
+ private final EidMappingContext localMappingsContext;
+
+ public LocalMappingCustomizer(@Nonnull FutureJVppCore futureJvpp, @Nonnull EidMappingContext localMappingsContext) {
+ super(futureJvpp);
+ this.localMappingsContext = checkNotNull(localMappingsContext, "No local mappings context defined");
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataAfter, "Mapping is null");
+ checkNotNull(dataAfter.getEid(), "Eid is null");
+ checkNotNull(dataAfter.getLocatorSet(), "Locator set is null");
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+
+ //checks whether value with specified mapping-id does not exist in mapping allready
+ MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
+ checkState(!localMappingsContext
+ .containsEid(mappingId, writeContext.getMappingContext()),
+ "Local mapping with id %s already defined", id);
+
+
+ try {
+ addDelMappingAndReply(true, dataAfter,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ //adds mapping for id and eid
+ localMappingsContext.addEid(mappingId, dataAfter.getEid(), writeContext.getMappingContext());
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataBefore,
+ LocalMapping dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<LocalMapping> id, LocalMapping dataBefore,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataBefore, "Mapping is null");
+ checkNotNull(dataBefore.getEid(), "Eid is null");
+ checkNotNull(dataBefore.getLocatorSet(), "LocatorSet is null");
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+
+ //checks whether value with specified mapping-id does exist in mapping,so there is something to delete
+ MappingId mappingId = id.firstKeyOf(LocalMapping.class).getId();
+ checkState(localMappingsContext
+ .containsEid(mappingId, writeContext.getMappingContext()),
+ "Local mapping with id %s not present in mapping", id);
+
+ try {
+ addDelMappingAndReply(false, dataBefore,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ //removes value also from mapping
+ localMappingsContext.removeEid(mappingId, writeContext.getMappingContext());
+ }
+
+ private void addDelMappingAndReply(boolean add, LocalMapping data, int vni) throws VppBaseCallException,
+ TimeoutException, UnsupportedEncodingException {
+
+ LispAddDelLocalEid request = new LispAddDelLocalEid();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.eid = EidConverter.getEidAsByteArray(data.getEid());
+ request.eidType = (byte) EidConverter.getEidType(data.getEid()).getValue();
+ request.locatorSetName = data.getLocatorSet().getBytes(UTF_8);
+ request.vni = vni;
+
+ //default prefixes
+ if (request.eidType == IPV4.getValue()) {
+ request.prefixLen = 32;
+ } else if (request.eidType == IPV6.getValue()) {
+ request.prefixLen = (byte) 128;
+ }
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelLocalEid(request).toCompletableFuture());
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
new file mode 100755
index 000000000..c2db3b845
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizer.java
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static io.fd.honeycomb.translate.v3po.util.TranslateUtils.getReply;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.lisp.translate.read.dump.check.LocatorSetsDumpCheck;
+import io.fd.honeycomb.lisp.translate.read.dump.executor.LocatorSetsDumpExecutor;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.util.RWUtils;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.v3po.util.cache.DumpCacheManager;
+import io.fd.honeycomb.translate.v3po.util.cache.EntityDumpExecutor;
+import io.fd.honeycomb.translate.v3po.util.cache.exceptions.execution.DumpExecutionFailedException;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.io.UnsupportedEncodingException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelLocatorSet;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for {@link LocatorSet} entity
+ *
+ * @see LocatorSet
+ */
+public class LocatorSetCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<LocatorSet, LocatorSetKey> {
+
+ private final NamingContext locatorSetContext;
+ private final DumpCacheManager<LispLocatorSetDetailsReplyDump, Void> dumpManager;
+
+ public LocatorSetCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final NamingContext locatorSetContext) {
+ super(futureJvpp);
+ this.locatorSetContext = checkNotNull(locatorSetContext, "Locator set context cannot be null");
+ this.dumpManager = new DumpCacheManager.DumpCacheManagerBuilder<LispLocatorSetDetailsReplyDump, Void>()
+ .withExecutor(new LocatorSetsDumpExecutor(futureJvpp))
+ .withNonEmptyPredicate(new LocatorSetsDumpCheck())
+ .build();
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
+ @Nonnull LocatorSet dataAfter,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+
+ checkNotNull(dataAfter, "LocatorSet is null");
+
+ final String locatorSetName = dataAfter.getName();
+ checkNotNull(locatorSetName, "LocatorSet name is null");
+
+ //TODO check and fill mapping when api returns index of created locator set
+ // checkState(!locatorSetContext.containsIndex(locatorSetName, writeContext.getMappingContext()),
+ // "Locator set with name %s allready defined", locatorSetName);
+
+ try {
+ addDelLocatorSetAndReply(true, dataAfter.getName());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ //TODO - REMOVE FROM MASTER AFTER VPP-323
+ try {
+ locatorSetContext
+ .addName(getLocatorSetIndex(locatorSetName, writeContext.getModificationCache()), locatorSetName,
+ writeContext.getMappingContext());
+ } catch (DumpExecutionFailedException e) {
+ throw new WriteFailedException(id,
+ new IllegalStateException("Unable to create mapping for locator set " + locatorSetName, e));
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
+ @Nonnull LocatorSet dataBefore,
+ @Nonnull LocatorSet dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull InstanceIdentifier<LocatorSet> id,
+ @Nonnull LocatorSet dataBefore,
+ @Nonnull WriteContext writeContext) throws WriteFailedException {
+
+ checkNotNull(dataBefore, "LocatorSet is null");
+
+ final String locatorSetName = dataBefore.getName();
+ checkNotNull(locatorSetName, "LocatorSet name is null");
+
+ try {
+ addDelLocatorSetAndReply(false, dataBefore.getName());
+ } catch (VppBaseCallException | TimeoutException | UnsupportedEncodingException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ //removes mapping after successful delete
+ locatorSetContext.removeName(locatorSetName, writeContext.getMappingContext());
+ }
+
+ private void addDelLocatorSetAndReply(boolean add, String name)
+ throws VppBaseCallException, TimeoutException, UnsupportedEncodingException {
+
+ LispAddDelLocatorSet addDelSet = new LispAddDelLocatorSet();
+
+ addDelSet.isAdd = TranslateUtils.booleanToByte(add);
+ addDelSet.locatorSetName = name.getBytes(UTF_8);
+
+
+ getReply(getFutureJVpp().lispAddDelLocatorSet(addDelSet).toCompletableFuture());
+ }
+
+ //TODO - REMOVE FROM MASTER AFTER VPP-323
+ // total hack
+ public int getLocatorSetIndex(final String name, final ModificationCache cache)
+ throws DumpExecutionFailedException {
+
+ Optional<LispLocatorSetDetailsReplyDump> reply = dumpManager
+ .getDump(io.fd.honeycomb.lisp.translate.read.LocatorSetCustomizer.LOCATOR_SETS_CACHE_ID, cache,
+ EntityDumpExecutor.NO_PARAMS);
+
+ if (reply.isPresent()) {
+ return reply.get().lispLocatorSetDetails.stream()
+ .filter(a -> name.equals(TranslateUtils.toString(a.locatorSetName)))
+ .collect(RWUtils.singleItemCollector())
+ .locatorSetIndex;
+ } else {
+ throw new IllegalStateException("Unable to find index of locator set " + name);
+ }
+ }
+
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java
new file mode 100755
index 000000000..02c9f4255
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizer.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolverKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelMapResolver;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Handles updates of {@link MapResolver} list
+ */
+public class MapResolverCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<MapResolver, MapResolverKey> {
+
+ public MapResolverCustomizer(final FutureJVppCore vppApi) {
+ super(vppApi);
+ }
+
+ @Override
+ public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
+ @Nonnull final MapResolver dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataAfter, "Data is null");
+ checkNotNull(dataAfter.getIpAddress(), "Address is null");
+
+ try {
+ addDelMapResolverAndReply(true, dataAfter);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
+ @Nonnull final MapResolver dataBefore, @Nonnull final MapResolver dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<MapResolver> id,
+ @Nonnull final MapResolver dataBefore, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataBefore, "Data is null");
+ checkNotNull(dataBefore.getIpAddress(), "Address is null");
+
+ try {
+ addDelMapResolverAndReply(false, dataBefore);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+ }
+
+ private void addDelMapResolverAndReply(boolean add, MapResolver data) throws VppBaseCallException,
+ TimeoutException {
+
+ LispAddDelMapResolver request = new LispAddDelMapResolver();
+ request.isAdd = TranslateUtils.booleanToByte(add);
+
+
+ boolean ipv6 = TranslateUtils.isIpv6(data.getIpAddress());
+
+ request.isIpv6 = TranslateUtils.booleanToByte(ipv6);
+ request.ipAddress = TranslateUtils.ipAddressToArray(ipv6, data.getIpAddress());
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelMapResolver(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
new file mode 100755
index 000000000..ab3be2add
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizer.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import io.fd.honeycomb.translate.spi.write.WriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispPitrSetLocatorSet;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for {@code PitrCfg}
+ */
+public class PitrCfgCustomizer extends FutureJVppCustomizer implements WriterCustomizer<PitrCfg> {
+
+ public PitrCfgCustomizer(FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ checkNotNull(dataAfter, "PitrCfg is null");
+ checkNotNull(dataAfter.getLocatorSet(), "Locator set name is null");
+
+ try {
+ addDelPitrSetLocatorSetAndReply(true, dataAfter);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataBefore, PitrCfg dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataAfter, "PitrCfg is null");
+ checkNotNull(dataAfter.getLocatorSet(), "Locator set name is null");
+
+ try {
+ addDelPitrSetLocatorSetAndReply(true, dataAfter);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<PitrCfg> id, PitrCfg dataBefore, WriteContext writeContext)
+ throws WriteFailedException {
+ checkNotNull(dataBefore, "PitrCfg is null");
+ checkNotNull(dataBefore.getLocatorSet(), "Locator set name is null");
+
+ try {
+ addDelPitrSetLocatorSetAndReply(false, dataBefore);
+ } catch (VppBaseCallException | TimeoutException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+ }
+
+ private void addDelPitrSetLocatorSetAndReply(boolean add, PitrCfg data)
+ throws VppBaseCallException, TimeoutException {
+
+ LispPitrSetLocatorSet request = new LispPitrSetLocatorSet();
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.lsName = data.getLocatorSet().getBytes(UTF_8);
+
+ TranslateUtils.getReply(getFutureJVpp().lispPitrSetLocatorSet(request).toCompletableFuture());
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
new file mode 100755
index 000000000..e8e37969e
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizer.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer.LocatorListType.NEGATIVE;
+import static io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer.LocatorListType.POSITIVE;
+
+import com.google.common.base.Preconditions;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.util.EidConverter;
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.TimeoutException;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6AddressNoZone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MapReplyAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.LocatorList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.NegativeMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.PositiveMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.dto.LispAddDelRemoteMapping;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Customizer for {@link RemoteMapping}
+ */
+public class RemoteMappingCustomizer extends FutureJVppCustomizer
+ implements ListWriterCustomizer<RemoteMapping, RemoteMappingKey> {
+
+ private final EidMappingContext remoteMappingContext;
+
+ public RemoteMappingCustomizer(@Nonnull final FutureJVppCore futureJvpp,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ super(futureJvpp);
+ this.remoteMappingContext = remoteMappingContext;
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataAfter, "Mapping is null");
+ checkNotNull(dataAfter.getEid(), "Eid is null");
+ checkState(id.firstKeyOf(VniTable.class) != null, "Parent vni table not found");
+
+ //checks whether mapping not already contains such key
+ MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
+ checkState(!remoteMappingContext.containsEid(mappingId, writeContext.getMappingContext()),
+ "Mapping for id %s already defined", mappingId);
+
+ try {
+ addDelRemoteMappingAndReply(true, dataAfter,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | IOException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ //after successfull adition adds mapping
+ remoteMappingContext.addEid(mappingId, dataAfter.getEid(), writeContext.getMappingContext());
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataBefore,
+ RemoteMapping dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<RemoteMapping> id, RemoteMapping dataBefore,
+ WriteContext writeContext) throws WriteFailedException {
+ checkNotNull(dataBefore, "Mapping is null");
+ checkNotNull(dataBefore.getEid(), "Eid is null");
+
+ //checks whether mapping already contains such key
+ MappingId mappingId = id.firstKeyOf(RemoteMapping.class).getId();
+ checkState(remoteMappingContext.containsEid(mappingId, writeContext.getMappingContext()),
+ "Mapping for id %s is not existing,nothing to remove", mappingId);
+
+ try {
+ addDelRemoteMappingAndReply(false, dataBefore,
+ id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue());
+ } catch (VppBaseCallException | TimeoutException | IOException e) {
+ throw new WriteFailedException.DeleteFailedException(id, e);
+ }
+
+ //remote mapping after successfull remove of data
+ remoteMappingContext.removeEid(mappingId, writeContext.getMappingContext());
+ }
+
+ private void addDelRemoteMappingAndReply(boolean add, RemoteMapping data, int vni)
+ throws VppBaseCallException, TimeoutException, IOException {
+
+ LispAddDelRemoteMapping request = new LispAddDelRemoteMapping();
+
+ request.isAdd = TranslateUtils.booleanToByte(add);
+ request.vni = vni;
+ request.eidType = (byte) EidConverter.getEidType(data.getEid()).getValue();
+ request.eid = EidConverter.getEidAsByteArray(data.getEid());
+
+ //this is not length of eid array,but prefix length(bad naming by vpp)
+ request.eidLen = EidConverter.getPrefixLength(data.getEid());
+
+ if (LocatorListType.NEGATIVE
+ .equals(resolveType(data.getLocatorList()))) {
+ request.action = (byte) extractAction(data.getLocatorList()).getIntValue();
+ } else {
+ Rlocs rlocs = extractRemoteLocators(data.getLocatorList());
+
+ checkArgument(rlocs != null, "No remote locators set for Positive mapping");
+
+ request.rlocs = locatorsToBinaryData(rlocs.getLocator());
+ request.rlocNum = Integer.valueOf(rlocs.getLocator().size()).byteValue();
+ }
+
+ TranslateUtils.getReply(getFutureJVpp().lispAddDelRemoteMapping(request).toCompletableFuture());
+ }
+
+ private static LocatorListType resolveType(LocatorList locatorList) {
+ checkNotNull(locatorList, "Locator List cannot be null");
+
+ if (locatorList instanceof PositiveMapping) {
+ return POSITIVE;
+ } else {
+ return NEGATIVE;
+ }
+ }
+
+ private static MapReplyAction extractAction(LocatorList locatorList) {
+ checkNotNull(locatorList, "Locator List cannot be null");
+ Preconditions.checkArgument(NEGATIVE.equals(resolveType(locatorList)),
+ "Action can be extracted only from Negative Mapping");
+
+ return ((NegativeMapping) locatorList).getMapReplyAction();
+ }
+
+ private static Rlocs extractRemoteLocators(LocatorList locatorList) {
+ checkNotNull(locatorList, "Locator List cannot be null");
+ Preconditions.checkArgument(POSITIVE.equals(resolveType(locatorList)),
+ "RLocs can be extracted only from Positive Mapping");
+
+ return ((PositiveMapping) locatorList).getRlocs();
+ }
+
+ private static byte[] locatorsToBinaryData(List<Locator> locators) throws IOException {
+ checkNotNull(locators, "Cannot convert null list");
+
+ ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
+
+ DataOutputStream out = new DataOutputStream(byteArrayOut);
+
+
+ for (Locator locator : locators) {
+ boolean isIpv4;
+ byte[] address;
+
+ //first byte says that its v4/v6
+ isIpv4 = !TranslateUtils.isIpv6(locator.getAddress());
+ out.writeByte(TranslateUtils.booleanToByte(isIpv4));
+
+ //then writes priority
+ out.write(locator.getPriority());
+
+ //and weight
+ out.write(locator.getWeight());
+
+ if (isIpv4) {
+ //vpp in this case needs address as 16 byte array,regardless if it is ivp4 or ipv6
+ address = Arrays.copyOf(
+ TranslateUtils
+ .ipv4AddressNoZoneToArray(new Ipv4AddressNoZone(locator.getAddress().getIpv4Address())),
+ 16);
+
+ out.write(address);
+ } else {
+ out.write(TranslateUtils
+ .ipv6AddressNoZoneToArray(new Ipv6AddressNoZone(locator.getAddress().getIpv6Address())));
+ }
+ }
+
+ return byteArrayOut.toByteArray();
+ }
+
+ public enum LocatorListType {
+
+ /**
+ * Represents locator list as negative mapping
+ */
+ NEGATIVE,
+
+ /**
+ * Represents locator list as positive mapping
+ */
+ POSITIVE
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
new file mode 100755
index 000000000..ad1d41de9
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/VniTableCustomizer.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
+import io.fd.honeycomb.translate.v3po.util.FutureJVppCustomizer;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.TimeoutException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.VppBaseCallException;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+import org.openvpp.jvpp.core.dto.LispEidTableAddDelMap;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Customizer for {@code TableId}
+ */
+public class VniTableCustomizer extends FutureJVppCustomizer implements ListWriterCustomizer<VniTable, VniTableKey> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VniTableCustomizer.class);
+
+ public VniTableCustomizer(FutureJVppCore futureJvpp) {
+ super(futureJvpp);
+ }
+
+ @Override
+ public void writeCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataAfter, WriteContext writeContext)
+ throws WriteFailedException {
+
+ checkNotNull(dataAfter.getTableId(), "VRF cannot be null");
+ checkNotNull(dataAfter.getVirtualNetworkIdentifier(), "VNI cannot be null");
+
+ LOG.debug("Writing {}", id);
+
+ try {
+ addDelMap(true, dataAfter.getVirtualNetworkIdentifier().intValue(), dataAfter.getTableId().intValue());
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataAfter, e);
+ }
+
+ LOG.debug("Write of {} successful", id);
+ }
+
+ @Override
+ public void updateCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataBefore, VniTable dataAfter,
+ WriteContext writeContext) throws WriteFailedException {
+ throw new UnsupportedOperationException("Operation not supported");
+ }
+
+ @Override
+ public void deleteCurrentAttributes(InstanceIdentifier<VniTable> id, VniTable dataBefore, WriteContext writeContext)
+ throws WriteFailedException {
+ checkNotNull(dataBefore.getTableId(), "VRF cannot be null");
+ checkNotNull(dataBefore.getVirtualNetworkIdentifier(), "VNI cannot be null");
+
+ LOG.debug("Removing {}", id);
+
+ try {
+ addDelMap(false, dataBefore.getVirtualNetworkIdentifier().intValue(), dataBefore.getTableId().intValue());
+ } catch (TimeoutException | VppBaseCallException e) {
+ throw new WriteFailedException.CreateFailedException(id, dataBefore, e);
+ }
+
+ LOG.debug("Remove of {} successful", id);
+ }
+
+ private void addDelMap(boolean isAdd, int vni, int vrf) throws TimeoutException, VppBaseCallException {
+
+ LispEidTableAddDelMap request = new LispEidTableAddDelMap();
+
+ request.isAdd = TranslateUtils.booleanToByte(isAdd);
+ request.vni = vni;
+ request.dpTable = vrf;
+ request.isL2 = 0;
+
+ TranslateUtils.getReply(getFutureJVpp().lispEidTableAddDelMap(request).toCompletableFuture());
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java
new file mode 100644
index 000000000..fed1cf64d
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/AbstractLispWriterFactoryBase.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write.factory;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Basic attributes for lisp writer factories
+ */
+abstract class AbstractLispWriterFactoryBase {
+
+ protected final InstanceIdentifier<Lisp> lispInstanceIdentifier;
+ protected final FutureJVppCore vppApi;
+ protected NamingContext interfaceContext;
+ protected NamingContext locatorSetContext;
+ protected EidMappingContext localMappingContext;
+ protected EidMappingContext remoteMappingContext;
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext,
+ NamingContext locatorSetContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ this.locatorSetContext = locatorSetContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ EidMappingContext localMappingContext,
+ EidMappingContext remoteMappingContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.localMappingContext = localMappingContext;
+ this.remoteMappingContext = remoteMappingContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext,
+ NamingContext locatorSetContext,
+ EidMappingContext localMappingContext,
+ EidMappingContext remoteMappingContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ this.locatorSetContext = locatorSetContext;
+ this.localMappingContext = localMappingContext;
+ this.remoteMappingContext = remoteMappingContext;
+ }
+
+ protected AbstractLispWriterFactoryBase(@Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ NamingContext interfaceContext,
+ EidMappingContext localMappingContext,
+ EidMappingContext remoteMappingContext) {
+ this.lispInstanceIdentifier = checkNotNull(lispInstanceIdentifier, "Lisp identifier is null");
+ this.vppApi = checkNotNull(vppApi, "VPP Api refference is null");
+ this.interfaceContext = interfaceContext;
+ this.localMappingContext = localMappingContext;
+ this.remoteMappingContext = remoteMappingContext;
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java
new file mode 100755
index 000000000..ec95afc5e
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LispWriterFactory.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write.factory;
+
+
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.INTERFACE_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCAL_MAPPING_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.LOCATOR_SET_CONTEXT;
+import static io.fd.honeycomb.lisp.cfgattrs.LispConfiguration.REMOTE_MAPPING_CONTEXT;
+
+import com.google.inject.Inject;
+import com.google.inject.name.Named;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.write.LispCustomizer;
+import io.fd.honeycomb.lisp.translate.write.PitrCfgCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericWriter;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Initialize writers for {@link Lisp}
+ */
+public final class LispWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ @Inject
+ public LispWriterFactory(final FutureJVppCore vppApi,
+ @Named(INTERFACE_CONTEXT) final NamingContext interfaceContext,
+ @Named(LOCATOR_SET_CONTEXT) final NamingContext locatorSetContext,
+ @Named(LOCAL_MAPPING_CONTEXT) final EidMappingContext localMappingContext,
+ @Named(REMOTE_MAPPING_CONTEXT) final EidMappingContext remoteMappingContext) {
+ super(InstanceIdentifier.create(Lisp.class), vppApi, interfaceContext, locatorSetContext, localMappingContext,
+ remoteMappingContext);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+ registry.add(new GenericWriter<>(lispInstanceIdentifier, new LispCustomizer(vppApi)));
+
+ VniTableWriterFactory.newInstance(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext)
+ .init(registry);
+ LocatorSetsWriterFactory.newInstance(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext)
+ .init(registry);
+ MapResolversWriterFactory.newInstance(lispInstanceIdentifier, vppApi).init(registry);
+
+ registry.add(new GenericWriter<>(lispInstanceIdentifier.child(PitrCfg.class), new PitrCfgCustomizer(vppApi)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java
new file mode 100755
index 000000000..2139eaf26
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/LocatorSetsWriterFactory.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write.factory;
+
+import io.fd.honeycomb.lisp.translate.write.InterfaceCustomizer;
+import io.fd.honeycomb.lisp.translate.write.LocatorSetCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.Interface;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory producing writers for {@code LocatorSets}
+ */
+final class LocatorSetsWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ private LocatorSetsWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ final FutureJVppCore vppApi,
+ final NamingContext interfaceContext,
+ final NamingContext locatorSetContext) {
+ super(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext);
+ }
+
+ public static LocatorSetsWriterFactory newInstance(
+ @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final NamingContext interfaceContext,
+ @Nonnull final NamingContext locatorSetContext) {
+ return new LocatorSetsWriterFactory(lispInstanceIdentifier, vppApi, interfaceContext, locatorSetContext);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+ InstanceIdentifier<LocatorSet> locatorSetId =
+ lispInstanceIdentifier.child(LocatorSets.class).child(LocatorSet.class);
+
+ registry.add(new GenericListWriter<>(locatorSetId, new LocatorSetCustomizer(vppApi, locatorSetContext)));
+ registry.add(new GenericListWriter<>(locatorSetId.child(Interface.class),
+ new InterfaceCustomizer(vppApi, interfaceContext)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java
new file mode 100755
index 000000000..00fa959d5
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/MapResolversWriterFactory.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write.factory;
+
+
+import io.fd.honeycomb.lisp.translate.write.MapResolverCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.MapResolvers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory responsible for producing writers for {@code MapResolvers}
+ */
+final class MapResolversWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ private MapResolversWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ final FutureJVppCore vppApi) {
+ super(lispInstanceIdentifier, vppApi, null);
+ }
+
+ public static MapResolversWriterFactory newInstance(
+ @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi) {
+ return new MapResolversWriterFactory(lispInstanceIdentifier, vppApi);
+ }
+
+ @Override
+ public void init(@Nonnull final ModifiableWriterRegistryBuilder registry) {
+ registry.add(new GenericListWriter<>(lispInstanceIdentifier.child(MapResolvers.class).child(MapResolver.class),
+ new MapResolverCustomizer(vppApi)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java
new file mode 100755
index 000000000..4a78fb819
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/factory/VniTableWriterFactory.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write.factory;
+
+import com.google.common.collect.ImmutableSet;
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.lisp.translate.write.AdjacencyCustomizer;
+import io.fd.honeycomb.lisp.translate.write.LocalMappingCustomizer;
+import io.fd.honeycomb.lisp.translate.write.RemoteMappingCustomizer;
+import io.fd.honeycomb.lisp.translate.write.VniTableCustomizer;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
+import io.fd.honeycomb.translate.write.WriterFactory;
+import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.Adjacencies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.Adjacency;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.LocalEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.adjacencies.adjacency.RemoteEid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.Rlocs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+/**
+ * Factory for producing writers for {@code EidTable}
+ */
+final class VniTableWriterFactory extends AbstractLispWriterFactoryBase implements WriterFactory {
+
+ private VniTableWriterFactory(final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ final FutureJVppCore vppApi,
+ final EidMappingContext localMappingContext,
+ final EidMappingContext remoteMappingContext) {
+ super(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext);
+ }
+
+ public static VniTableWriterFactory newInstance(
+ @Nonnull final InstanceIdentifier<Lisp> lispInstanceIdentifier,
+ @Nonnull final FutureJVppCore vppApi,
+ @Nonnull final EidMappingContext localMappingContext,
+ @Nonnull final EidMappingContext remoteMappingContext) {
+ return new VniTableWriterFactory(lispInstanceIdentifier, vppApi, localMappingContext, remoteMappingContext);
+ }
+
+ @Override
+ public void init(final ModifiableWriterRegistryBuilder registry) {
+ final InstanceIdentifier<VniTable> vniTableId =
+ lispInstanceIdentifier.child(EidTable.class).child(VniTable.class);
+
+ registry.add(new GenericListWriter<>(vniTableId, new VniTableCustomizer(vppApi)));
+
+
+ final InstanceIdentifier<LocalMapping> localMappingSubtreeId = InstanceIdentifier.create(LocalMapping.class);
+ registry.subtreeAdd(ImmutableSet.of(localMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid.class)),
+ new GenericListWriter<>(vniTableId.child(LocalMappings.class).child(LocalMapping.class),
+ new LocalMappingCustomizer(vppApi, localMappingContext)));
+
+ final InstanceIdentifier<RemoteMapping> remoteMappingSubtreeId = InstanceIdentifier.create(RemoteMapping.class);
+ registry.subtreeAdd(ImmutableSet.of(remoteMappingSubtreeId
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid.class),
+ remoteMappingSubtreeId.child(Rlocs.class),
+ remoteMappingSubtreeId.child(Rlocs.class).child(Locator.class)),
+ new GenericListWriter<>(vniTableId.child(RemoteMappings.class).child(RemoteMapping.class),
+ new RemoteMappingCustomizer(vppApi, remoteMappingContext)));
+
+ final InstanceIdentifier<Adjacency> adjacencySubtreeId = InstanceIdentifier.create(Adjacency.class);
+ registry.subtreeAdd(ImmutableSet.of(adjacencySubtreeId
+ .child(LocalEid.class), adjacencySubtreeId.child(RemoteEid.class)),
+ new GenericListWriter<>(vniTableId.child(Adjacencies.class).child(Adjacency.class),
+ new AdjacencyCustomizer(vppApi)));
+ }
+}
diff --git a/lisp/lisp2vpp/src/main/resources/honeycomb-minimal-resources/config/lisp.json b/lisp/lisp2vpp/src/main/resources/honeycomb-minimal-resources/config/lisp.json
new file mode 100644
index 000000000..7a73a41bf
--- /dev/null
+++ b/lisp/lisp2vpp/src/main/resources/honeycomb-minimal-resources/config/lisp.json
@@ -0,0 +1,2 @@
+{
+} \ No newline at end of file
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/context/util/EidMappingContextTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/context/util/EidMappingContextTest.java
new file mode 100644
index 000000000..710477a70
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/context/util/EidMappingContextTest.java
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2016 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.context.util;
+
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.MappingContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.MappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.EidBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class EidMappingContextTest {
+
+ private EidMappingContext eidMappingContext;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+ eidMappingContext = new EidMappingContext("eid-eidMappingContext");
+ }
+
+ @Test
+ public void testStoreAndGet() {
+ Eid eid =
+ new EidBuilder().setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build()).build();
+ MappingId id = new MappingId("first");
+
+ eidMappingContext.addEid(id, eid, mappingContext);
+ when(mappingContext.read(Mockito.any(InstanceIdentifier.class)))
+ .thenReturn(Optional.of(
+ new MappingBuilder().setId(id).setEid(copyEid(eid)).build()
+ ));
+
+ Eid sameEid =
+ new EidBuilder().setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("192.168.2.1")).build()).build();
+ MappingId sameId = new MappingId("first");
+
+ assertTrue(eidMappingContext.containsEid(sameId, mappingContext));
+
+ org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid
+ loadedEid = eidMappingContext.getEid(sameId, mappingContext);
+
+ assertEquals("192.168.2.1", ((Ipv4) (loadedEid.getAddress())).getIpv4().getValue());
+ }
+
+ private org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid copyEid(
+ Eid eid) {
+ return new org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.EidBuilder()
+ .setAddress(eid.getAddress())
+ .setAddressType(eid.getAddressType())
+ .setVirtualNetworkId(eid.getVirtualNetworkId())
+ .build();
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java
new file mode 100755
index 000000000..15087ef24
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/util/EidConverterTest.java
@@ -0,0 +1,49 @@
+package io.fd.honeycomb.lisp.translate.util;
+
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV4;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.IPV6;
+import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.MAC;
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
+
+public class EidConverterTest {
+
+ @Test
+ public void testGetEidType() {
+ assertEquals(IPV4, EidConverter
+ .getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build()));
+
+ assertEquals(IPV6, EidConverter
+ .getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new Ipv6Builder().setIpv6(
+ new Ipv6Address("2001:0db8:0a0b:12f0:0000:0000:0000:0001"))
+ .build())
+ .build()));
+
+ assertEquals(MAC, EidConverter
+ .getEidType(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder()
+ .setAddress(
+ new MacBuilder().setMac(
+ new MacAddress("aa:bb:cc:dd:ee:ff"))
+ .build())
+ .build()));
+
+ //TODO testing of other types when they are implemented
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
new file mode 100755
index 000000000..6dccdfeab
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/InterfaceCustomizerTest.java
@@ -0,0 +1,198 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.base.Optional;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.naming.context.rev160513.contexts.naming.context.mappings.MappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.LocatorSets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.InterfaceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.locator.set.InterfaceKey;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispAddDelLocator;
+import org.openvpp.jvpp.core.dto.LispAddDelLocatorReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class InterfaceCustomizerTest {
+
+ @Mock
+ private FutureJVppCore fakeJvpp;
+
+ @Mock
+ private WriteContext writeContext;
+
+ @Mock
+ private MappingContext mappingContext;
+
+ @Captor
+ private ArgumentCaptor<LispAddDelLocator> intfCaptor;
+
+ private NamingContext namingContext;
+ private InstanceIdentifier<Interface> id;
+ private CompletableFuture<LispAddDelLocatorReply> completeFuture;
+ private LispAddDelLocatorReply fakeReply;
+ private Interface intf;
+ private InterfaceCustomizer customizer;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+
+ id = InstanceIdentifier.builder(Lisp.class)
+ .child(LocatorSets.class)
+ .child(LocatorSet.class, new LocatorSetKey("Locator"))
+ .child(Interface.class, new InterfaceKey("Interface"))
+ .build();
+
+ intf = new InterfaceBuilder()
+ .setPriority((short) 1)
+ .setWeight((short) 2)
+ .build();
+
+ namingContext = new NamingContext("PREFIX", "INSTANCE");
+
+ customizer = new InterfaceCustomizer(fakeJvpp, namingContext);
+
+ fakeReply = new LispAddDelLocatorReply();
+
+ completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+
+ when(writeContext.getMappingContext()).thenReturn(mappingContext);
+ when(mappingContext.read(Mockito.any()))
+ .thenReturn(Optional.of((DataObject) new MappingBuilder().setIndex(5).setName("interface").build()));
+ when(fakeJvpp.lispAddDelLocator(any(LispAddDelLocator.class))).thenReturn(completeFuture);
+
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ new InterfaceCustomizer(mock(FutureJVppCore.class), new NamingContext("PREFIX", "INSTANCE"))
+ .writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullPriority() throws WriteFailedException {
+ Interface intf = mock(Interface.class);
+ when(intf.getWeight()).thenReturn((short) 1);
+ when(intf.getPriority()).thenReturn(null);
+
+ new InterfaceCustomizer(mock(FutureJVppCore.class), new NamingContext("PREFIX", "INSTANCE"))
+ .writeCurrentAttributes(null, intf, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullWeight() throws WriteFailedException {
+ Interface intf = mock(Interface.class);
+ when(intf.getWeight()).thenReturn(null);
+ when(intf.getPriority()).thenReturn((short) 1);
+
+ new InterfaceCustomizer(mock(FutureJVppCore.class), new NamingContext("PREFIX", "INSTANCE"))
+ .writeCurrentAttributes(null, intf, null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+ customizer.writeCurrentAttributes(id, intf, writeContext);
+
+ verify(fakeJvpp, times(1)).lispAddDelLocator(intfCaptor.capture());
+
+ LispAddDelLocator request = intfCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isAdd);
+ assertEquals(2, request.weight);
+ assertEquals(1, request.priority);
+ assertEquals(5, request.swIfIndex);
+ assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ new InterfaceCustomizer(fakeJvpp, namingContext)
+ .updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ new InterfaceCustomizer(fakeJvpp, namingContext)
+ .deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullPriority() throws WriteFailedException {
+ Interface interf = mock(Interface.class);
+ when(interf.getWeight()).thenReturn((short) 1);
+ when(interf.getPriority()).thenReturn(null);
+
+ new InterfaceCustomizer(mock(FutureJVppCore.class), new NamingContext("PREFIX", "INSTANCE"))
+ .deleteCurrentAttributes(null, interf, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullWeight() throws WriteFailedException {
+ Interface interf = mock(Interface.class);
+ when(interf.getWeight()).thenReturn(null);
+ when(interf.getPriority()).thenReturn((short) 1);
+
+ new InterfaceCustomizer(mock(FutureJVppCore.class), new NamingContext("PREFIX", "INSTANCE"))
+ .deleteCurrentAttributes(null, interf, null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+ customizer.deleteCurrentAttributes(id, intf, writeContext);
+
+ verify(fakeJvpp, times(1)).lispAddDelLocator(intfCaptor.capture());
+
+ LispAddDelLocator request = intfCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(0, request.isAdd);
+ assertEquals(2, request.weight);
+ assertEquals(1, request.priority);
+ assertEquals(5, request.swIfIndex);
+ assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java
new file mode 100755
index 000000000..aaa73303c
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LispCustomizerTest.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.LispBuilder;
+import org.openvpp.jvpp.core.dto.LispEnableDisable;
+import org.openvpp.jvpp.core.dto.LispEnableDisableReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class LispCustomizerTest {
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ new LispCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, null, null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+ Lisp intf = new LispBuilder().setEnable(true).build();
+
+ ArgumentCaptor<LispEnableDisable> mappingCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+
+ LispEnableDisableReply fakeReply = new LispEnableDisableReply();
+
+ CompletableFuture<LispEnableDisableReply> completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+
+ when(fakeJvpp.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(completeFuture);
+
+ new LispCustomizer(fakeJvpp).writeCurrentAttributes(null, intf, null);
+
+ verify(fakeJvpp, times(1)).lispEnableDisable(mappingCaptor.capture());
+
+ LispEnableDisable request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isEn);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testUpdateCurrentAttributesNullData() throws WriteFailedException {
+ new LispCustomizer(mock(FutureJVppCore.class)).updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test
+ public void testUpdateCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+ Lisp lisp = new LispBuilder().setEnable(true).build();
+
+ ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+
+ LispEnableDisableReply fakeReply = new LispEnableDisableReply();
+
+ CompletableFuture<LispEnableDisableReply> completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+
+ when(fakeJvpp.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(completeFuture);
+
+ new LispCustomizer(fakeJvpp).updateCurrentAttributes(null, null, lisp, null);
+
+ verify(fakeJvpp, times(1)).lispEnableDisable(lispCaptor.capture());
+
+ LispEnableDisable request = lispCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isEn);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ new LispCustomizer(mock(FutureJVppCore.class)).deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+ Lisp lisp = new LispBuilder().setEnable(true).build();
+
+ ArgumentCaptor<LispEnableDisable> lispCaptor = ArgumentCaptor.forClass(LispEnableDisable.class);
+
+ LispEnableDisableReply fakeReply = new LispEnableDisableReply();
+
+ CompletableFuture<LispEnableDisableReply> completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+
+ when(fakeJvpp.lispEnableDisable(any(LispEnableDisable.class))).thenReturn(completeFuture);
+
+ new LispCustomizer(fakeJvpp).deleteCurrentAttributes(null, lisp, null);
+
+ verify(fakeJvpp, times(1)).lispEnableDisable(lispCaptor.capture());
+
+ LispEnableDisable request = lispCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(0, request.isEn);
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
new file mode 100755
index 000000000..2b28ce6b9
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocalMappingCustomizerTest.java
@@ -0,0 +1,189 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.LocalMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.LocalMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.local.mappings.local.mapping.EidBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispAddDelLocalEid;
+import org.openvpp.jvpp.core.dto.LispAddDelLocalEidReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class LocalMappingCustomizerTest {
+
+ @Mock
+ private FutureJVppCore fakeJvpp;
+
+ @Captor
+ private ArgumentCaptor<LispAddDelLocalEid> mappingCaptor;
+
+ private MappingId mappingId;
+ private InstanceIdentifier<LocalMapping> id;
+ private LocalMapping mapping;
+ private LispAddDelLocalEidReply fakeReply;
+ private CompletableFuture<LispAddDelLocalEidReply> completeFuture;
+ private LocalMappingCustomizer customizer;
+ private EidMappingContext localMappingContext;
+ private WriteContext writeContext;
+ private MappingContext mappingCtx;
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+
+ final Eid
+ eid = new EidBuilder().setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build();
+
+
+ mappingId = new MappingId("REMOTE");
+ final LocalMappingKey key = new LocalMappingKey(mappingId);
+ localMappingContext = new EidMappingContext("local");
+ mappingCtx = mock(MappingContext.class);
+ writeContext = mock(WriteContext.class);
+
+ mapping = new LocalMappingBuilder()
+ .setEid(eid)
+ .setLocatorSet("Locator")
+ .build();
+
+ id = InstanceIdentifier.builder(Lisp.class)
+ .child(EidTable.class)
+ .child(VniTable.class, new VniTableKey(25L))
+ .child(LocalMappings.class)
+ .child(LocalMapping.class, new LocalMappingKey(new MappingId("local")))
+ .build();
+
+ fakeReply = new LispAddDelLocalEidReply();
+ completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+ customizer = new LocalMappingCustomizer(fakeJvpp, localMappingContext);
+
+ when(fakeJvpp.lispAddDelLocalEid(any(LispAddDelLocalEid.class))).thenReturn(completeFuture);
+ when(writeContext.getMappingContext()).thenReturn(mappingCtx);
+ when(mappingCtx.read(Mockito.any())).thenReturn(com.google.common.base.Optional
+ .of(new LocalMappingBuilder().setKey(key).setId(mappingId).setEid(eid).build()));
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullEid() throws WriteFailedException {
+
+ LocalMapping mapping = mock(LocalMapping.class);
+ when(mapping.getEid()).thenReturn(null);
+ when(mapping.getLocatorSet()).thenReturn("Locator");
+
+ new LocalMappingCustomizer(mock(FutureJVppCore.class), localMappingContext)
+ .writeCurrentAttributes(null, mapping, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullLocator() throws WriteFailedException {
+
+ LocalMapping mapping = mock(LocalMapping.class);
+ when(mapping.getEid()).thenReturn(mock(Eid.class));
+ when(mapping.getLocatorSet()).thenReturn(null);
+
+ customizer.writeCurrentAttributes(null, mapping, writeContext);
+ }
+
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ //to simulate no mapping
+ when(mappingCtx.read(Mockito.any())).thenReturn(com.google.common.base.Optional.absent());
+
+ customizer.writeCurrentAttributes(id, mapping, writeContext);
+
+ verify(fakeJvpp, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+
+ LispAddDelLocalEid request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(0, request.eidType);
+ assertEquals(1, request.isAdd);
+ assertEquals(25, request.vni);
+ assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ new LocalMappingCustomizer(mock(FutureJVppCore.class), localMappingContext)
+ .updateCurrentAttributes(null, null, null, writeContext);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ customizer.deleteCurrentAttributes(id, mapping, writeContext);
+
+ verify(fakeJvpp, times(1)).lispAddDelLocalEid(mappingCaptor.capture());
+
+ LispAddDelLocalEid request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(0, request.eidType);
+ assertEquals(0, request.isAdd);
+ assertEquals(25, request.vni);
+ assertEquals("Locator", TranslateUtils.toString(request.locatorSetName));
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
new file mode 100755
index 000000000..e7fb88ae5
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/LocatorSetCustomizerTest.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.ImmutableList;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.ModificationCache;
+import io.fd.honeycomb.translate.v3po.util.NamingContext;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.nio.charset.StandardCharsets;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSetBuilder;
+import org.openvpp.jvpp.core.dto.LispAddDelLocatorSet;
+import org.openvpp.jvpp.core.dto.LispAddDelLocatorSetReply;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetails;
+import org.openvpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class LocatorSetCustomizerTest {
+
+ private FutureJVppCore fakeJvpp;
+ private NamingContext locatorSetContext;
+ private MappingContext mappingContext;
+ private ModificationCache cache;
+ private WriteContext context;
+
+ @Before
+ public void init() {
+ fakeJvpp = mock(FutureJVppCore.class);
+ locatorSetContext = new NamingContext("locator-set", "instance");
+ context = mock(WriteContext.class);
+ mappingContext = mock(MappingContext.class);
+ cache = new ModificationCache();
+ when(context.getMappingContext()).thenReturn(mappingContext);
+ when(context.getModificationCache()).thenReturn(cache);
+ }
+
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext).writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext)
+ .writeCurrentAttributes(null, mock(LocatorSet.class), null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+
+ LocatorSet locatorSet = new LocatorSetBuilder()
+ .setName("Locator")
+ .build();
+
+ ArgumentCaptor<LispAddDelLocatorSet> locatorSetCaptor = ArgumentCaptor.forClass(LispAddDelLocatorSet.class);
+
+ LispAddDelLocatorSetReply fakeReply = new LispAddDelLocatorSetReply();
+
+ CompletableFuture<LispAddDelLocatorSetReply> completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+
+ when(fakeJvpp.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
+
+ final LispLocatorSetDetailsReplyDump reply = new LispLocatorSetDetailsReplyDump();
+ LispLocatorSetDetails details = new LispLocatorSetDetails();
+ details.locatorSetName = "Locator".getBytes(StandardCharsets.UTF_8);
+ reply.lispLocatorSetDetails = ImmutableList.of(details);
+
+ cache.put(io.fd.honeycomb.lisp.translate.read.LocatorSetCustomizer.LOCATOR_SETS_CACHE_ID, reply);
+
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext).writeCurrentAttributes(null, locatorSet, context);
+
+ verify(fakeJvpp, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
+
+ LispAddDelLocatorSet request = locatorSetCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals(1, request.isAdd);
+
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext).updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext).deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext)
+ .deleteCurrentAttributes(null, mock(LocatorSet.class), null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+
+ LocatorSet locatorSet = new LocatorSetBuilder()
+ .setName("Locator")
+ .build();
+
+ ArgumentCaptor<LispAddDelLocatorSet> locatorSetCaptor = ArgumentCaptor.forClass(LispAddDelLocatorSet.class);
+
+ LispAddDelLocatorSetReply fakeReply = new LispAddDelLocatorSetReply();
+
+ CompletableFuture<LispAddDelLocatorSetReply> completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+
+ when(fakeJvpp.lispAddDelLocatorSet(any(LispAddDelLocatorSet.class))).thenReturn(completeFuture);
+
+ new LocatorSetCustomizer(fakeJvpp, locatorSetContext).deleteCurrentAttributes(null, locatorSet, context);
+
+ verify(fakeJvpp, times(1)).lispAddDelLocatorSet(locatorSetCaptor.capture());
+
+ LispAddDelLocatorSet request = locatorSetCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals("Locator", new String(request.locatorSetName));
+ assertEquals(0, request.isAdd);
+
+ }
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
new file mode 100755
index 000000000..63be37a23
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/MapResolverCustomizerTest.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolverBuilder;
+import org.openvpp.jvpp.core.dto.LispAddDelMapResolver;
+import org.openvpp.jvpp.core.dto.LispAddDelMapResolverReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class MapResolverCustomizerTest {
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ new MapResolverCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ new MapResolverCustomizer(mock(FutureJVppCore.class))
+ .writeCurrentAttributes(null, new MapResolverBuilder().build(), null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+
+ MapResolverCustomizer customizer = new MapResolverCustomizer(fakeJvpp);
+ Ipv4Address address = new Ipv4Address("192.168.2.1");
+ MapResolver resolver = new MapResolverBuilder().setIpAddress(new IpAddress(address)).build();
+
+ ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
+
+ LispAddDelMapResolverReply fakeReply = new LispAddDelMapResolverReply();
+
+ CompletableFuture<LispAddDelMapResolverReply> finalStage = new CompletableFuture<>();
+ finalStage.complete(fakeReply);
+
+ when(fakeJvpp.lispAddDelMapResolver(any(LispAddDelMapResolver.class))).thenReturn(finalStage);
+
+ customizer.writeCurrentAttributes(null, resolver, null);
+ verify(fakeJvpp, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
+
+ LispAddDelMapResolver request = resolverCaptor.getValue();
+ assertEquals(1, request.isAdd);
+ assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ }
+
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ new MapResolverCustomizer(mock(FutureJVppCore.class)).updateCurrentAttributes(null, null, null, null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+
+ MapResolverCustomizer customizer = new MapResolverCustomizer(fakeJvpp);
+ Ipv4Address address = new Ipv4Address("192.168.2.1");
+ MapResolver resolver = new MapResolverBuilder().setIpAddress(new IpAddress(address)).build();
+
+ ArgumentCaptor<LispAddDelMapResolver> resolverCaptor = ArgumentCaptor.forClass(LispAddDelMapResolver.class);
+
+ LispAddDelMapResolverReply fakeReply = new LispAddDelMapResolverReply();
+
+ CompletableFuture<LispAddDelMapResolverReply> finalStage = new CompletableFuture<>();
+ finalStage.complete(fakeReply);
+
+ when(fakeJvpp.lispAddDelMapResolver(any(LispAddDelMapResolver.class))).thenReturn(finalStage);
+
+ customizer.deleteCurrentAttributes(null, resolver, null);
+ verify(fakeJvpp, times(1)).lispAddDelMapResolver(resolverCaptor.capture());
+
+ LispAddDelMapResolver request = resolverCaptor.getValue();
+ assertEquals(0, request.isAdd);
+ assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.ipAddress).getValue());
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java
new file mode 100755
index 000000000..5f1ffb888
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/PitrCfgCustomizerTest.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfg;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.pitr.cfg.grouping.PitrCfgBuilder;
+import org.openvpp.jvpp.core.dto.LispPitrSetLocatorSet;
+import org.openvpp.jvpp.core.dto.LispPitrSetLocatorSetReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class PitrCfgCustomizerTest {
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ new PitrCfgCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ new PitrCfgCustomizer(mock(FutureJVppCore.class)).writeCurrentAttributes(null, mock(PitrCfg.class), null);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws InterruptedException, ExecutionException, WriteFailedException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+
+ PitrCfgCustomizer customizer = new PitrCfgCustomizer(fakeJvpp);
+ PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+
+ LispPitrSetLocatorSetReply fakeReply = new LispPitrSetLocatorSetReply();
+
+ CompletableFuture<LispPitrSetLocatorSetReply> finalStage = new CompletableFuture<>();
+ finalStage.complete(fakeReply);
+
+ when(fakeJvpp.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(finalStage);
+
+ customizer.writeCurrentAttributes(null, cfg, null);
+ verify(fakeJvpp, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ LispPitrSetLocatorSet request = cfgCaptor.getValue();
+ assertEquals(1, request.isAdd);
+ assertEquals("Locator", new String(request.lsName));
+ }
+
+ @Test
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+
+ PitrCfgCustomizer customizer = new PitrCfgCustomizer(fakeJvpp);
+ PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+
+ LispPitrSetLocatorSetReply fakeReply = new LispPitrSetLocatorSetReply();
+
+ CompletableFuture<LispPitrSetLocatorSetReply> finalStage = new CompletableFuture<>();
+ finalStage.complete(fakeReply);
+
+ when(fakeJvpp.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(finalStage);
+
+ customizer.writeCurrentAttributes(null, cfg, null);
+ verify(fakeJvpp, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ LispPitrSetLocatorSet request = cfgCaptor.getValue();
+ assertEquals(1, request.isAdd);
+ assertEquals("Locator", new String(request.lsName));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ new PitrCfgCustomizer(mock(FutureJVppCore.class)).deleteCurrentAttributes(null, null, null);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesBadData() throws WriteFailedException {
+ new PitrCfgCustomizer(mock(FutureJVppCore.class)).deleteCurrentAttributes(null, mock(PitrCfg.class), null);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ FutureJVppCore fakeJvpp = mock(FutureJVppCore.class);
+
+ PitrCfgCustomizer customizer = new PitrCfgCustomizer(fakeJvpp);
+ PitrCfg cfg = new PitrCfgBuilder().setLocatorSet("Locator").build();
+
+ ArgumentCaptor<LispPitrSetLocatorSet> cfgCaptor = ArgumentCaptor.forClass(LispPitrSetLocatorSet.class);
+
+ LispPitrSetLocatorSetReply fakeReply = new LispPitrSetLocatorSetReply();
+
+ CompletableFuture<LispPitrSetLocatorSetReply> finalStage = new CompletableFuture<>();
+ finalStage.complete(fakeReply);
+
+ when(fakeJvpp.lispPitrSetLocatorSet(any(LispPitrSetLocatorSet.class))).thenReturn(finalStage);
+
+ customizer.deleteCurrentAttributes(null, cfg, null);
+ verify(fakeJvpp, times(1)).lispPitrSetLocatorSet(cfgCaptor.capture());
+
+ LispPitrSetLocatorSet request = cfgCaptor.getValue();
+ assertEquals(0, request.isAdd);
+ assertEquals("Locator", new String(request.lsName));
+ }
+
+}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
new file mode 100755
index 000000000..7797db1f7
--- /dev/null
+++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/write/RemoteMappingCustomizerTest.java
@@ -0,0 +1,175 @@
+/*
+ * Copyright (c) 2015 Cisco and/or its affiliates.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.fd.honeycomb.lisp.translate.write;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import io.fd.honeycomb.lisp.context.util.EidMappingContext;
+import io.fd.honeycomb.translate.MappingContext;
+import io.fd.honeycomb.translate.v3po.util.TranslateUtils;
+import io.fd.honeycomb.translate.write.WriteContext;
+import io.fd.honeycomb.translate.write.WriteFailedException;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Captor;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.Lisp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MapReplyAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.MappingId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.EidTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.RemoteMappings;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.RemoteMappingKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.Eid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.EidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.NegativeMappingBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.Locator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.vni.table.remote.mappings.remote.mapping.locator.list.positive.mapping.rlocs.LocatorBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.openvpp.jvpp.core.dto.LispAddDelRemoteMapping;
+import org.openvpp.jvpp.core.dto.LispAddDelRemoteMappingReply;
+import org.openvpp.jvpp.core.future.FutureJVppCore;
+
+
+public class RemoteMappingCustomizerTest {
+
+ @Mock
+ private FutureJVppCore fakeJvpp;
+
+ @Captor
+ private ArgumentCaptor<LispAddDelRemoteMapping> mappingCaptor;
+
+ private MappingId mappingId;
+ private RemoteMappingCustomizer customizer;
+ private RemoteMapping intf;
+ private LispAddDelRemoteMappingReply fakeReply;
+ private CompletableFuture<LispAddDelRemoteMappingReply> completeFuture;
+ private InstanceIdentifier<RemoteMapping> id;
+ private EidMappingContext remoteMappingContext;
+ private WriteContext writeContext;
+ private MappingContext mapping;
+
+
+ @Before
+ public void init() {
+ MockitoAnnotations.initMocks(this);
+
+ final Eid eid = new EidBuilder().setAddress(
+ new Ipv4Builder().setIpv4(
+ new Ipv4Address("192.168.2.1"))
+ .build())
+ .build();
+
+ mappingId = new MappingId("REMOTE");
+ final RemoteMappingKey key = new RemoteMappingKey(mappingId);
+ remoteMappingContext = new EidMappingContext("remote");
+ mapping = mock(MappingContext.class);
+ writeContext = mock(WriteContext.class);
+
+
+ intf = new RemoteMappingBuilder()
+ .setEid(
+ eid)
+ .setLocatorList(new NegativeMappingBuilder().setMapReplyAction(MapReplyAction.Drop).build())
+ .build();
+
+ id = InstanceIdentifier.builder(Lisp.class).child(EidTable.class)
+ .child(VniTable.class, new VniTableKey(25L))
+ .child(RemoteMappings.class)
+ .child(RemoteMapping.class, key).build();
+
+ fakeReply = new LispAddDelRemoteMappingReply();
+ completeFuture = new CompletableFuture<>();
+ completeFuture.complete(fakeReply);
+ customizer = new RemoteMappingCustomizer(fakeJvpp, remoteMappingContext);
+
+ when(fakeJvpp.lispAddDelRemoteMapping(Mockito.any())).thenReturn(completeFuture);
+ when(writeContext.getMappingContext()).thenReturn(mapping);
+ when(mapping.read(Mockito.any())).thenReturn(com.google.common.base.Optional
+ .of(new RemoteMappingBuilder().setKey(key).setId(mappingId).setEid(eid).build()));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.writeCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testWriteCurrentAttributesBadData() throws WriteFailedException {
+ customizer
+ .writeCurrentAttributes(null, mock(RemoteMapping.class), writeContext);
+ }
+
+ @Test
+ public void testWriteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ //to simulate no mapping
+ when(mapping.read(Mockito.any())).thenReturn(com.google.common.base.Optional.absent());
+
+ customizer.writeCurrentAttributes(id, intf, writeContext);
+
+ verify(fakeJvpp, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
+
+ LispAddDelRemoteMapping request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(1, request.isAdd);
+ assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(25, request.vni);
+ }
+
+ @Test(expected = UnsupportedOperationException.class)
+ public void testUpdateCurrentAttributes() throws WriteFailedException {
+ customizer.updateCurrentAttributes(null, null, null, writeContext);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testDeleteCurrentAttributesNullData() throws WriteFailedException {
+ customizer.deleteCurrentAttributes(null, null, writeContext);
+ }
+
+ @Test
+ public void testDeleteCurrentAttributes() throws WriteFailedException, InterruptedException, ExecutionException {
+ customizer.deleteCurrentAttributes(id, intf, writeContext);
+
+ verify(fakeJvpp, times(1)).lispAddDelRemoteMapping(mappingCaptor.capture());
+
+ LispAddDelRemoteMapping request = mappingCaptor.getValue();
+
+ assertNotNull(request);
+ assertEquals(0, request.isAdd);
+ assertEquals("1.2.168.192", TranslateUtils.arrayToIpv4AddressNoZone(request.eid).getValue());
+ assertEquals(25, request.vni);
+ }
+
+}