test adding and removing shared mcast dst tunnels
[vpp.git] / test / vpp_papi_provider.py
index 7c90592..901ea27 100644 (file)
@@ -5,9 +5,9 @@ from hook import Hook
 from collections import deque
 
 # Sphinx creates auto-generated documentation by importing the python source
-# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows the
-# vpp_papi_provider.py file to be importable without having to build the whole
-# vpp api if the user only wishes to generate the test documentation.
+# files and collecting the docstrings from them. The NO_VPP_PAPI flag allows
+# the vpp_papi_provider.py file to be importable without having to build
+# the whole vpp api if the user only wishes to generate the test documentation.
 do_import = True
 try:
     no_vpp_papi = os.getenv("NO_VPP_PAPI")
@@ -219,6 +219,22 @@ class VppPapiProvider(object):
         return self.api(self.papi.sw_interface_ip6nd_ra_config,
                         {'sw_if_index': sw_if_index})
 
+    def ip6_sw_interface_ra_config(self, sw_if_index,
+                                   suppress,
+                                   send_unicast,):
+        return self.api(self.papi.sw_interface_ip6nd_ra_config,
+                        {'sw_if_index': sw_if_index,
+                         'suppress': suppress,
+                         'send_unicast': send_unicast})
+
+    def ip6_sw_interface_enable_disable(self, sw_if_index, enable):
+        """
+        Enable/Disable An interface for IPv6
+        """
+        return self.api(self.papi.sw_interface_ip6_enable_disable,
+                        {'sw_if_index': sw_if_index,
+                         'enable': enable})
+
     def vxlan_add_del_tunnel(
             self,
             src_addr,
@@ -465,6 +481,10 @@ class VppPapiProvider(object):
         return self.api(self.papi.create_loopback,
                         {'mac_address': mac})
 
+    def delete_loopback(self, sw_if_index):
+        return self.api(self.papi.delete_loopback,
+                        {'sw_if_index': sw_if_index, })
+
     def ip_add_del_route(
             self,
             dst_address,
@@ -575,6 +595,54 @@ class VppPapiProvider(object):
              }
         )
 
+    def reset_vrf(self,
+                  vrf_id,
+                  is_ipv6=0,
+                  ):
+        """ Reset VRF (remove all routes etc.) request.
+
+        :param int vrf_id: ID of the FIB table / VRF to reset.
+        :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
+        """
+
+        return self.api(
+            self.papi.reset_vrf,
+            {'vrf_id': vrf_id,
+             'is_ipv6': is_ipv6,
+             }
+        )
+
+    def reset_fib(self,
+                  vrf_id,
+                  is_ipv6=0,
+                  ):
+        """ Reset VRF (remove all routes etc.) request.
+
+        :param int vrf_id: ID of the FIB table / VRF to reset.
+        :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
+        """
+
+        return self.api(
+            self.papi.reset_fib,
+            {'vrf_id': vrf_id,
+             'is_ipv6': is_ipv6,
+             }
+        )
+
+    def ip_dump(self,
+                is_ipv6=0,
+                ):
+        """ Return IP dump.
+
+        :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
+        """
+
+        return self.api(
+            self.papi.ip_dump,
+            {'is_ipv6': is_ipv6,
+             }
+        )
+
     def sw_interface_span_enable_disable(
             self, sw_if_index_from, sw_if_index_to, state=1):
         """
@@ -775,7 +843,8 @@ class VppPapiProvider(object):
     def snat_add_static_mapping(
             self,
             local_ip,
-            external_ip,
+            external_ip=0,
+            external_sw_if_index=0xFFFFFFFF,
             local_port=0,
             external_port=0,
             addr_only=1,
@@ -786,6 +855,7 @@ class VppPapiProvider(object):
 
         :param local_ip: Local IP address
         :param external_ip: External IP address
+        :param external_sw_if_index: External interface instead of IP address
         :param local_port: Local port number (Default value = 0)
         :param external_port: External port number (Default value = 0)
         :param addr_only: 1 if address only mapping, 0 if address and port
@@ -802,6 +872,7 @@ class VppPapiProvider(object):
              'external_ip_address': external_ip,
              'local_port': local_port,
              'external_port': external_port,
+             'external_sw_if_index': external_sw_if_index,
              'vrf_id': vrf_id})
 
     def snat_add_address_range(
@@ -842,6 +913,47 @@ class VppPapiProvider(object):
         """
         return self.api(self.papi.snat_static_mapping_dump, {})
 
+    def snat_show_config(self):
+        """Show S-NAT config
+        :return: S-NAT config parameters
+        """
+        return self.api(self.papi.snat_show_config, {})
+
+    def snat_add_interface_addr(
+            self,
+            sw_if_index,
+            is_add=1):
+        """Add/del S-NAT address from interface
+
+        :param sw_if_index: Software index of the interface
+        :param is_add: 1 if add, 0 if delete (Default value = 1)
+        """
+        return self.api(self.papi.snat_add_del_interface_addr,
+                        {'is_add': is_add, 'sw_if_index': sw_if_index})
+
+    def snat_interface_addr_dump(self):
+        """Dump S-NAT addresses interfaces
+        :return: Dictionary of S-NAT addresses interfaces
+        """
+        return self.api(self.papi.snat_interface_addr_dump, {})
+
+    def snat_ipfix(
+            self,
+            domain_id=1,
+            src_port=4739,
+            enable=1):
+        """Enable/disable S-NAT IPFIX logging
+
+        :param domain_id: Observation domain ID (Default value = 1)
+        :param src_port: Source port number (Default value = 4739)
+        :param enable: 1 if enable, 0 if disable (Default value = 1)
+        """
+        return self.api(
+            self.papi.snat_ipfix_enable_disable,
+            {'domain_id': domain_id,
+             'src_port': src_port,
+             'enable': enable})
+
     def control_ping(self):
         self.api(self.papi.control_ping)
 
@@ -895,12 +1007,11 @@ class VppPapiProvider(object):
             miss_next_index=0xFFFFFFFF,
             current_data_flag=0,
             current_data_offset=0):
-
         """
         :param is_add:
         :param mask:
-        :param match_n_vectors (Default value = 1):
-        :param table_index (Default value = 0xFFFFFFFF)
+        :param match_n_vectors: (Default value = 1)
+        :param table_index: (Default value = 0xFFFFFFFF)
         :param nbuckets:  (Default value = 2)
         :param memory_size:  (Default value = 2097152)
         :param skip_n_vectors:  (Default value = 0)
@@ -912,17 +1023,17 @@ class VppPapiProvider(object):
 
         return self.api(
             self.papi.classify_add_del_table,
-            {'is_add' : is_add,
-             'table_index' : table_index,
-             'nbuckets' : nbuckets,
+            {'is_add': is_add,
+             'table_index': table_index,
+             'nbuckets': nbuckets,
              'memory_size': memory_size,
-             'skip_n_vectors' : skip_n_vectors,
-             'match_n_vectors' : match_n_vectors,
-             'next_table_index' : next_table_index,
-             'miss_next_index' : miss_next_index,
-             'current_data_flag' : current_data_flag,
-             'current_data_offset' : current_data_offset,
-             'mask' : mask})
+             'skip_n_vectors': skip_n_vectors,
+             'match_n_vectors': match_n_vectors,
+             'next_table_index': next_table_index,
+             'miss_next_index': miss_next_index,
+             'current_data_flag': current_data_flag,
+             'current_data_offset': current_data_offset,
+             'mask': mask})
 
     def classify_add_del_session(
             self,
@@ -947,14 +1058,14 @@ class VppPapiProvider(object):
 
         return self.api(
             self.papi.classify_add_del_session,
-            {'is_add' : is_add,
-             'table_index' : table_index,
-             'hit_next_index' : hit_next_index,
-             'opaque_index' : opaque_index,
-             'advance' : advance,
-             'action' : action,
-             'metadata' : metadata,
-             'match' : match})
+            {'is_add': is_add,
+             'table_index': table_index,
+             'hit_next_index': hit_next_index,
+             'opaque_index': opaque_index,
+             'advance': advance,
+             'action': action,
+             'metadata': metadata,
+             'match': match})
 
     def input_acl_set_interface(
             self,
@@ -973,8 +1084,29 @@ class VppPapiProvider(object):
 
         return self.api(
             self.papi.input_acl_set_interface,
-            {'sw_if_index' : sw_if_index,
-             'ip4_table_index' : ip4_table_index,
-             'ip6_table_index' : ip6_table_index,
-             'l2_table_index' : l2_table_index,
-             'is_add' : is_add})
+            {'sw_if_index': sw_if_index,
+             'ip4_table_index': ip4_table_index,
+             'ip6_table_index': ip6_table_index,
+             'l2_table_index': l2_table_index,
+             'is_add': is_add})
+
+    def set_ipfix_exporter(
+            self,
+            collector_address,
+            src_address,
+            path_mtu,
+            template_interval,
+            vrf_id=0,
+            collector_port=4739,
+            udp_checksum=0):
+        return self.api(
+            self.papi.set_ipfix_exporter,
+            {
+                'collector_address': collector_address,
+                'collector_port': collector_port,
+                'src_address': src_address,
+                'vrf_id': vrf_id,
+                'path_mtu': path_mtu,
+                'template_interval': template_interval,
+                'udp_checksum': udp_checksum,
+            })