L2_POP_1 = 3
+class UnexpectedApiReturnValueError(Exception):
+ """ exception raised when the API return value is unexpected """
+ pass
+
+
class VppPapiProvider(object):
"""VPP-api provider using vpp-papi
"return value instead of %d in %s" % \
(reply.retval, repr(reply))
self.test_class.logger.info(msg)
- raise Exception(msg)
+ raise UnexpectedApiReturnValueError(msg)
elif self._expect_api_retval == self._zero:
if hasattr(reply, 'retval') and reply.retval != expected_retval:
msg = "API call failed, expected zero return value instead "\
"of %d in %s" % (expected_retval, repr(reply))
self.test_class.logger.info(msg)
- raise Exception(msg)
+ raise UnexpectedApiReturnValueError(msg)
else:
raise Exception("Internal error, unexpected value for "
"self._expect_api_retval %s" %
'address_length': addr_len,
'address': addr})
+ def sw_interface_set_unnumbered(self, sw_if_index, ip_sw_if_index,
+ is_add=1):
+ """ Set the Interface to be unnumbered
+
+ :param is_add: (Default value = 1)
+ :param sw_if_index - interface That will be unnumbered
+ :param ip_sw_if_index - interface with an IP addres
+
+ """
+ return self.api(self.papi.sw_interface_set_unnumbered,
+ {'sw_if_index': ip_sw_if_index,
+ 'unnumbered_sw_if_index': sw_if_index,
+ 'is_add': is_add})
+
def sw_interface_enable_disable_mpls(self, sw_if_index,
is_enable=1):
"""
sw_if_index,
mac_address,
dst_address,
- vrf_id=0,
is_add=1,
is_ipv6=0,
is_static=0,
:param sw_if_index:
:param mac_address:
:param dst_address:
- :param vrf_id: (Default value = 0)
:param is_add: (Default value = 1)
:param is_ipv6: (Default value = 0)
:param is_static: (Default value = 0)
return self.api(
self.papi.ip_neighbor_add_del,
- {'vrf_id': vrf_id,
- 'sw_if_index': sw_if_index,
+ {'sw_if_index': sw_if_index,
'is_add': is_add,
'is_ipv6': is_ipv6,
'is_static': is_static,
}
)
+ def ip_neighbor_dump(self,
+ sw_if_index,
+ is_ipv6=0):
+ """ Return IP neighbor dump.
+
+ :param sw_if_index:
+ :param int is_ipv6: 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
+ """
+
+ return self.api(
+ self.papi.ip_neighbor_dump,
+ {'is_ipv6': is_ipv6,
+ 'sw_if_index': sw_if_index
+ }
+ )
+
+ def proxy_arp_add_del(self,
+ low_address,
+ hi_address,
+ vrf_id=0,
+ is_add=1):
+ """ Config Proxy Arp Range.
+
+ :param low_address: Start address in the rnage to Proxy for
+ :param hi_address: End address in the rnage to Proxy for
+ :param vrf_id: The VRF/table in which to proxy
+ """
+
+ return self.api(
+ self.papi.proxy_arp_add_del,
+ {'vrf_id': vrf_id,
+ 'is_add': is_add,
+ 'low_address': low_address,
+ 'hi_address': hi_address,
+ }
+ )
+
+ def proxy_arp_intfc_enable_disable(self,
+ sw_if_index,
+ is_enable=1):
+ """ Enable/Disable an interface for proxy ARP requests
+
+ :param sw_if_index: Interface
+ :param enable_disable: Enable/Disable
+ """
+
+ return self.api(
+ self.papi.proxy_arp_intfc_enable_disable,
+ {'sw_if_index': sw_if_index,
+ 'enable_disable': is_enable
+ }
+ )
+
def reset_vrf(self,
vrf_id,
is_ipv6=0,
def bfd_auth_keys_dump(self):
return self.api(self.papi.bfd_auth_keys_dump, {})
+ def bfd_udp_set_echo_source(self, sw_if_index):
+ return self.api(self.papi.bfd_udp_set_echo_source,
+ {'sw_if_index': sw_if_index})
+
+ def bfd_udp_del_echo_source(self):
+ return self.api(self.papi.bfd_udp_del_echo_source, {})
+
def classify_add_del_table(
self,
is_add,