MPLS Exp-null Tests
[vpp.git] / test / vpp_papi_provider.py
index 454f3ed..f0eb410 100644 (file)
@@ -1,7 +1,19 @@
-import vpp_papi
+import os
 from logging import error
 from hook import Hook
 
+do_import = True
+try:
+    no_vpp_papi = os.getenv("NO_VPP_PAPI")
+    if no_vpp_papi == "1":
+        do_import = False
+except:
+    pass
+
+if do_import:
+    import vpp_papi
+
+
 # from vnet/vnet/mpls/mpls_types.h
 MPLS_IETF_MAX_LABEL = 0xfffff
 MPLS_LABEL_INVALID = MPLS_IETF_MAX_LABEL + 1
@@ -16,7 +28,7 @@ class VppPapiProvider(object):
     """
 
     def __init__(self, name, shm_prefix):
-        self.hook = Hook()
+        self.hook = Hook("vpp-papi-provider")
         self.name = name
         self.shm_prefix = shm_prefix
 
@@ -94,6 +106,18 @@ class VppPapiProvider(object):
             args = (0, b'')
         return self.api(vpp_papi.sw_interface_dump, args)
 
+    def sw_interface_set_table(self, sw_if_index, is_ipv6, table_id):
+        """
+          Set the IPvX Table-id for the Interface
+
+        :param sw_if_index:
+        :param is_ipv6:
+        :param table_id:
+
+        """
+        return self.api(vpp_papi.sw_interface_set_table,
+                        (sw_if_index, is_ipv6, table_id))
+
     def sw_interface_add_del_address(self, sw_if_index, addr, addr_len,
                                      is_ipv6=0, is_add=1, del_all=0):
         """
@@ -109,6 +133,17 @@ class VppPapiProvider(object):
         return self.api(vpp_papi.sw_interface_add_del_address,
                         (sw_if_index, is_add, is_ipv6, del_all, addr_len, addr))
 
+    def sw_interface_enable_disable_mpls(self, sw_if_index,
+                                         is_enable=1):
+        """
+        Enable/Disable MPLS on the interface
+        :param sw_if_index:
+        :param is_enable:  (Default value = 1)
+
+        """
+        return self.api(vpp_papi.sw_interface_set_mpls_enable,
+                        (sw_if_index, is_enable))
+
     def sw_interface_ra_suppress(self, sw_if_index):
         suppress = 1
         managed = 0
@@ -130,7 +165,6 @@ class VppPapiProvider(object):
                          default_router, max_interval, min_interval,
                          lifetime, initial_count, initial_interval, async))
 
-
     def vxlan_add_del_tunnel(
             self,
             src_addr,
@@ -177,7 +211,7 @@ class VppPapiProvider(object):
         :param rx_sw_if_index: Software interface index of Rx interface.
         :param tx_sw_if_index: Software interface index of Tx interface.
         :param enable: Create cross-connect if equal to 1, delete cross-connect
-        if equal to 0.
+                       if equal to 0.
         :type rx_sw_if_index: str or int
         :type rx_sw_if_index: str or int
         :type enable: int