+ :param vni: Vni.
+ :param deid: Destination eid address.
+ :param deid_prefix: Destination eid address prefix_len.
+ :param seid: Source eid address.
+ :param seid_prefix: Source eid address prefix_len.
+ :param rloc: Receiver locator.
+ :param is_mac: Set to True if the deid/seid is MAC address.
+ :type node: dict
+ :type vni: int
+ :type deid: str
+ :type deid_prefix: int
+ :type seid: str
+ :type seid_prefix: int
+ :type rloc: str
+ :type is_mac: bool
+ """
+
+ if not is_mac:
+ eid_type = 0 if ip_address(unicode(deid)).version == 4 else 1
+ eid_packed = ip_address(unicode(deid)).packed
+ seid_packed = ip_address(unicode(seid)).packed
+ eid_len = deid_prefix
+ seid_len = seid_prefix
+ else:
+ eid_type = 2
+ eid_packed = L2Util.mac_to_bin(deid)
+ seid_packed = L2Util.mac_to_bin(seid)
+ eid_len = 0
+ seid_len = 0
+
+ rlocs = [dict(is_ip4=1 if ip_address(unicode(rloc)).version == 4 else 0,
+ addr=ip_address(unicode(rloc)).packed)]
+
+ args = dict(is_add=1,
+ is_src_dst=1,
+ vni=int(vni),
+ eid_type=eid_type,
+ eid=eid_packed,
+ eid_len=eid_len,
+ seid=seid_packed,
+ seid_len=seid_len,
+ rloc_num=1,
+ rlocs=rlocs)
+
+ cmd = 'lisp_add_del_remote_mapping'
+ err_msg = "Failed to add remote mapping on host {host}".format(
+ host=node['host'])
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)
+
+ @staticmethod
+ def vpp_del_lisp_remote_mapping(node, vni, deid, deid_prefix, seid,
+ seid_prefix, rloc):
+ """Delete lisp remote mapping on the VPP node in topology.
+
+ :param node: VPP node.
+ :param vni: Vni.
+ :param deid: Destination eid address.
+ :param deid_prefix: Destination eid address prefix_len.
+ :param seid: Source eid address.
+ :param seid_prefix: Source eid address prefix_len.
+ :param rloc: Receiver locator.
+ :type node: dict
+ :type vni: int
+ :type deid: str
+ :type deid_prefix: int
+ :type seid: str
+ :type seid_prefix: int
+ :type rloc: str
+ """
+
+ # used only with IPs
+ is_mac = False
+
+ if not is_mac:
+ eid_type = 0 if ip_address(unicode(deid)).version == 4 else 1
+ eid_packed = ip_address(unicode(deid)).packed
+ seid_packed = ip_address(unicode(seid)).packed
+ eid_len = deid_prefix
+ seid_len = seid_prefix
+ else:
+ eid_type = 2
+ eid_packed = L2Util.mac_to_bin(deid)
+ seid_packed = L2Util.mac_to_bin(seid)
+ eid_len = 0
+ seid_len = 0
+
+ rlocs = [dict(is_ip4=1 if ip_address(unicode(rloc)).version == 4 else 0,
+ addr=ip_address(unicode(rloc)).packed)]
+
+ args = dict(is_add=0,
+ is_src_dst=1,
+ vni=int(vni),
+ eid_type=eid_type,
+ eid=eid_packed,
+ eid_len=eid_len,
+ seid=seid_packed,
+ seid_len=seid_len,
+ rloc_num=1,
+ rlocs=rlocs)
+
+ cmd = 'lisp_add_del_remote_mapping'
+ err_msg = "Failed to delete remote mapping on host {host}".format(
+ host=node['host'])
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)
+
+class LispAdjacency(object):
+ """Class for lisp adjacency API."""
+
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def vpp_add_lisp_adjacency(node, vni, deid, deid_prefix, seid,
+ seid_prefix, is_mac=False):
+ """Add lisp adjacency on the VPP node in topology.
+
+ :param node: VPP node.
+ :param vni: Vni.
+ :param deid: Destination eid address.
+ :param deid_prefix: Destination eid address prefix_len.
+ :param seid: Source eid address.
+ :param seid_prefix: Source eid address prefix_len.
+ :param is_mac: Set to True if the deid/seid is MAC address.
+ :type node: dict
+ :type vni: int
+ :type deid: str
+ :type deid_prefix: int
+ :type seid: str
+ :type seid_prefix: int
+ :type is_mac: bool
+ """
+
+ if not is_mac:
+ eid_type = 0 if ip_address(unicode(deid)).version == 4 else 1
+ reid = ip_address(unicode(deid)).packed
+ leid = ip_address(unicode(seid)).packed
+ reid_len = deid_prefix
+ leid_len = seid_prefix
+ else:
+ eid_type = 2
+ reid = L2Util.mac_to_bin(deid)
+ leid = L2Util.mac_to_bin(seid)
+ reid_len = 0
+ leid_len = 0
+
+ args = dict(is_add=1,
+ vni=int(vni),
+ eid_type=eid_type,
+ reid=reid,
+ reid_len=reid_len,
+ leid=leid,
+ leid_len=leid_len)
+
+ cmd = 'lisp_add_del_adjacency'
+ err_msg = "Failed to add lisp adjacency on host {host}".format(
+ host=node['host'])
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)
+
+ @staticmethod
+ def vpp_del_lisp_adjacency(node, vni, deid, deid_prefix, seid,
+ seid_prefix):
+ """Delete lisp adjacency on the VPP node in topology.
+
+ :param node: VPP node.
+ :param vni: Vni.
+ :param deid: Destination eid address.
+ :param deid_prefix: Destination eid address prefix_len.
+ :param seid: Source eid address.
+ :param seid_prefix: Source eid address prefix_len.
+ :type node: dict
+ :type vni: int
+ :type deid: str
+ :type deid_prefix: int
+ :type seid: str
+ :type seid_prefix: int
+ """
+
+ # used only with IPs
+ is_mac = False
+
+ if not is_mac:
+ eid_type = 0 if ip_address(unicode(deid)).version == 4 else 1
+ reid = ip_address(unicode(deid)).packed
+ leid = ip_address(unicode(seid)).packed
+ reid_len = deid_prefix
+ leid_len = seid_prefix
+ else:
+ eid_type = 2
+ reid = L2Util.mac_to_bin(deid)
+ leid = L2Util.mac_to_bin(seid)
+ reid_len = 0
+ leid_len = 0
+
+ args = dict(is_add=0,
+ vni=int(vni),
+ eid_type=eid_type,
+ reid=reid,
+ reid_len=reid_len,
+ leid=leid,
+ leid_len=leid_len)
+
+ cmd = 'lisp_add_del_adjacency'
+ err_msg = "Failed to delete lisp adjacency on host {host}".format(
+ host=node['host'])
+
+ with PapiSocketExecutor(node) as papi_exec:
+ papi_exec.add(cmd, **args).get_reply(err_msg)
+
+class LispGpeStatus(object):
+ """Clas for LISP GPE status manipulation."""
+
+ def __init__(self):
+ pass
+
+ @staticmethod
+ def vpp_lisp_gpe_enable_disable(node, state):
+ """Change the state of LISP GPE - enable or disable.
+
+ :param node: VPP node.
+ :param state: Requested state - enable or disable.