Update vpp-agent version
[csit.git] / resources / libraries / python / LispSetup.py
index 5315101..5ef8bc0 100644 (file)
@@ -46,16 +46,17 @@ class LispRemoteMapping(object):
 
     @staticmethod
     def vpp_add_lisp_remote_mapping(node, vni, deid, deid_prefix, seid,
-                                    seid_prefix, rloc):
+                                    seid_prefix, rloc, is_mac=False):
         """Add lisp remote mapping on the VPP node in topology.
 
         :param node: VPP node.
         :param vni: Vni.
         :param deid: Destination eid address.
-        :param deid_predix: Destination eid address prefix_len.
+        :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
@@ -63,8 +64,14 @@ class LispRemoteMapping(object):
         :type seid: str
         :type seid_prefix: int
         :type rloc: str
+        :type is_mac: bool
         """
-
+        if is_mac:
+            deid_prefix = ''
+            seid_prefix = ''
+        else:
+            deid_prefix = '/{}'.format(deid_prefix)
+            seid_prefix = '/{}'.format(seid_prefix)
         VatExecutor.cmd_from_template(node,
                                       'lisp/add_lisp_remote_mapping.vat',
                                       vni=vni,
@@ -82,7 +89,7 @@ class LispRemoteMapping(object):
         :param node: VPP node.
         :param vni: Vni.
         :param deid: Destination eid address.
-        :param deid_predix: Destination eid address prefix_len.
+        :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.
@@ -103,6 +110,8 @@ class LispRemoteMapping(object):
                                       seid=seid,
                                       seid_prefix=seid_prefix,
                                       rloc=rloc)
+
+
 class LispAdjacency(object):
     """Class for lisp adjacency API."""
 
@@ -111,23 +120,30 @@ class LispAdjacency(object):
 
     @staticmethod
     def vpp_add_lisp_adjacency(node, vni, deid, deid_prefix, seid,
-                               seid_prefix):
+                               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_predix: Destination eid address prefix_len.
+        :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 is_mac:
+            deid_prefix = ''
+            seid_prefix = ''
+        else:
+            deid_prefix = '/{}'.format(deid_prefix)
+            seid_prefix = '/{}'.format(seid_prefix)
         VatExecutor.cmd_from_template(node,
                                       'lisp/add_lisp_adjacency.vat',
                                       vni=vni,
@@ -144,7 +160,7 @@ class LispAdjacency(object):
         :param node: VPP node.
         :param vni: Vni.
         :param deid: Destination eid address.
-        :param deid_predix: Destination eid address prefix_len.
+        :param deid_prefix: Destination eid address prefix_len.
         :param seid: Source eid address.
         :param seid_prefix: Source eid address prefix_len.
         :type node: dict
@@ -164,6 +180,26 @@ class LispAdjacency(object):
                                       seid_prefix=seid_prefix)
 
 
+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.
+        :type node: dict
+        :type state: str
+        """
+
+        VatExecutor.cmd_from_template(node, 'lisp/lisp_gpe_status.vat',
+                                      state=state)
+
+
 class LispGpeIface(object):
     """Class for Lisp gpe interface API."""
 
@@ -180,11 +216,33 @@ class LispGpeIface(object):
         :type state: str
         """
 
-        VatExecutor.cmd_from_template(node,
-                                      'lisp/lisp_gpe_iface.vat',
+        VatExecutor.cmd_from_template(node, 'lisp/lisp_gpe_iface.vat',
                                       state=state)
 
 
+class LispGpeForwardEntry(object):
+    """The functionality needed for these methods is not implemented in VPP
+    (VAT). Bug https://jira.fd.io/browse/VPP-334 was open to cover this issue.
+
+    TODO: Implement when VPP-334 is fixed.
+    """
+
+    def __init__(self):
+        pass
+
+    @staticmethod
+    def add_lisp_gpe_forward_entry(node, *args):
+        """Not implemented"""
+        # TODO: Implement when VPP-334 is fixed.
+        pass
+
+    @staticmethod
+    def del_lisp_gpe_forward_entry(node, *args):
+        """Not implemented"""
+        # TODO: Implement when VPP-334 is fixed.
+        pass
+
+
 class LispMapResolver(object):
     """Class for Lisp map resolver API."""
 
@@ -544,3 +602,32 @@ class LispSetup(object):
 
         lgi = LispGpeIface()
         lgi.vpp_lisp_gpe_iface(node, state)
+
+
+class LispEidTableMap(object):
+    """
+    Class for EID table map.
+    """
+
+    @staticmethod
+    def vpp_lisp_eid_table_mapping(node, vni, bd_id=None, vrf=None):
+        """
+        Map LISP VNI to either bridge domain ID, or VRF ID.
+
+        :param node: VPP node.
+        :param vni: Lisp VNI.
+        :param bd_id: Bridge domain ID.
+        :param vrf: VRF id.
+        :type node: dict
+        :type vni: int
+        :type bd_id: int
+        :type vrf: int
+        """
+        if bd_id:
+            bd_or_vrf = 'bd_index {}'.format(bd_id)
+        else:
+            bd_or_vrf = 'vrf {}'.format(vrf)
+        VatExecutor.cmd_from_template(node,
+                                      'lisp/lisp_eid_table_add_del_map.vat',
+                                      vni=vni,
+                                      bd_or_vrf=bd_or_vrf)