2.172. vpp_papi_provider module

exception vpp_papi_provider.CliFailedCommandError

Bases: Exception

cli command failed.

exception vpp_papi_provider.CliSyntaxError

Bases: Exception

cli command had a syntax error.

exception vpp_papi_provider.UnexpectedApiReturnValueError

Bases: Exception

exception raised when the API return value is unexpected

class vpp_papi_provider.VppPapiProvider(name, test_class, read_timeout)

Bases: object

VPP-api provider using vpp-papi

@property hook: hook object providing before and after api/cli hooks

api(api_fn, api_args, expected_retval=0)

Call API function and check it’s return value. Call the appropriate hooks before and after the API call

Parameters
  • api_fn – API function to call

  • api_args – tuple of API function arguments

  • expected_retval – Expected return value (Default value = 0)

Returns

reply from the API

assert_negative_api_retval()

Expect API failure - used with with, e.g.: with self.vapi.assert_negative_api_retval():

self.vapi.<api call expected to fail>

assert_zero_api_retval()

Expect API success - used with with, e.g.: with self.vapi.assert_negative_api_retval():

self.vapi.<api call expected to succeed>

note: this is useful only inside another with block

as success is the default expected value

bier_disp_entry_add_del(bdti, bp, payload_proto, next_hop_afi, next_hop, next_hop_tbl_id=0, next_hop_rpf_id=-1, next_hop_is_ip4=1, is_add=1)

BIER Route add/del

bier_disp_entry_dump(bdti)
bier_disp_table_add_del(bdti, is_add=1)

BIER Disposition Table add/del

bier_disp_table_dump()
bier_imp_add(bti, src, ibytes, is_add=1)

BIER Imposition Add

bier_imp_del(bi_index)

BIER Imposition del

bier_imp_dump()
bier_route_add_del(bti, bp, paths, is_add=1, is_replace=0)

BIER Route add/del

bier_route_dump(bti)
bier_table_add_del(bti, mpls_label, is_add=1)

BIER Table add/del

bier_table_dump()
cli(cli)

Execute a CLI, calling the before/after hooks appropriately.

Parameters

cli – CLI to execute

Returns

CLI output

cli_return_response(cli)

Execute a CLI, calling the before/after hooks appropriately. Return the reply without examining it

Parameters

cli – CLI to execute

Returns

response object

collect_events()

Collect all events from the internal queue and clear the queue.

connect()

Connect the API to VPP

create_loopback(mac='')
Parameters

mac – (Optional)

create_vlan_subif(sw_if_index, vlan)
Parameters
  • vlan

  • sw_if_index

disconnect()

Disconnect the API from VPP

factory(name, apifn)
gbp_contract_dump()

GBP contract Dump

gbp_endpoint_dump()

GBP endpoint Dump

gbp_ext_itf_dump()

GBP recirc Dump

gbp_recirc_dump()

GBP recirc Dump

gbp_subnet_dump()

GBP Subnet Dump

gbp_vxlan_tunnel_dump()

GBP VXLAN tunnel add/del

igmp_clear_interface(sw_if_index)

Remove all (S,G)s from specified interface doesn’t send IGMP report!

igmp_enable_disable(sw_if_index, enable, host)

Enable/disable IGMP on a given interface

igmp_listen(filter, sw_if_index, saddrs, gaddr)

Listen for new (S,G) on specified interface

Parameters
  • enable – add/del

  • sw_if_index – interface sw index

  • saddr – source ip4 addr

  • gaddr – group ip4 addr

igmp_proxy_device_add_del(vrf_id, sw_if_index, add)

Add/del IGMP proxy device

igmp_proxy_device_add_del_interface(vrf_id, sw_if_index, add)

Add/del interface to/from IGMP proxy device

input_acl_set_interface(is_add, sw_if_index, ip4_table_index=4294967295, ip6_table_index=4294967295, l2_table_index=4294967295)
Parameters
  • is_add

  • sw_if_index

  • ip4_table_index – (Default value = 0xFFFFFFFF)

  • ip6_table_index – (Default value = 0xFFFFFFFF)

  • l2_table_index – (Default value = 0xFFFFFFFF)

ip6nd_send_router_solicitation(sw_if_index, irt=1, mrt=120, mrc=0, mrd=0)
ip_mroute_dump(table_id, is_ip6=False)
ip_neighbor_add_del(sw_if_index, mac_address, ip_address, is_add=1, flags=0)

Add neighbor MAC to IPv4 or IPv6 address.

Parameters
  • sw_if_index

  • mac_address

  • dst_address

  • is_add – (Default value = 1)

  • flags – (Default value = 0/NONE)

ip_route_dump(table_id, is_ip6=False)
ip_route_v2_dump(table_id, is_ip6=False, src=0)
ipsec_backend_dump()
ipsec_interface_add_del_spd(spd_id, sw_if_index, is_add=1)

IPSEC interface SPD add/del - Wrapper to associate/disassociate SPD to interface in VPP Sample CLI : ‘set interface ipsec spd GigabitEthernet0/6/0 1’

:param spd_id - SPD ID to associate with the interface . mandatory :param sw_if_index - Interface Index which needs to ipsec association mandatory :param is_add - add(1) or del(0) association with interface (Default 1 - add) . optional :returns: reply from the API

ipsec_select_backend(protocol, index)
ipsec_spd_add_del(spd_id, is_add=1)

SPD add/del - Wrapper to add or del ipsec SPD Sample CLI : ‘ipsec spd add 1’

:param spd_id - SPD ID to be created in the vpp . mandatory :param is_add - create (1) or delete(0) SPD (Default 1 - add) .

optional

Returns

reply from the API

ipsec_spd_dump(spd_id, sa_id=4294967295)
ipsec_spd_entry_add_del(spd_id, sa_id, local_address_start, local_address_stop, remote_address_start, remote_address_stop, local_port_start=0, local_port_stop=65535, remote_port_start=0, remote_port_stop=65535, protocol=0, policy=0, priority=100, is_outbound=1, is_add=1, is_ipv6=0, is_ip_any=0)
IPSEC policy SPD add/del -

Wrapper to configure ipsec SPD policy entries in VPP

Parameters
  • spd_id – SPD ID for the policy

  • local_address_start – local-ip-range start address

:param local_address_stop : local-ip-range stop address :param remote_address_start: remote-ip-range start address :param remote_address_stop : remote-ip-range stop address :param local_port_start: (Default value = 0) :param local_port_stop: (Default value = 65535) :param remote_port_start: (Default value = 0) :param remote_port_stop: (Default value = 65535) :param protocol: Any(0), AH(51) & ESP(50) protocol (Default value = 0) :param sa_id: Security Association ID for mapping it to SPD :param policy: bypass(0), discard(1), resolve(2) or protect(3) action

(Default value = 0)

Parameters
  • priority – value for the spd action (Default value = 100)

  • is_outbound – flag for inbound(0) or outbound(1) (Default value = 1)

  • is_add – (Default value = 1)

ipsec_spd_interface_dump(spd_index=None)
ipsec_spds_dump()
ipsec_tunnel_if_add_del(local_ip, remote_ip, local_spi, remote_spi, crypto_alg, local_crypto_key, remote_crypto_key, integ_alg, local_integ_key, remote_integ_key, is_add=1, esn=0, salt=0, anti_replay=1, renumber=0, udp_encap=0, show_instance=4294967295)
mfib_signal_dump()
mpls_ip_bind_unbind(label, prefix, table_id=0, ip_table_id=0, is_bind=1)
mpls_route_add_del(table_id, label, eos, eos_proto, is_multicast, paths, is_add, is_multipath)

MPLS Route add/del

mpls_route_dump(table_id)
mpls_table_add_del(table_id, is_add=1)

:param table_id :param is_add: (Default value = 1)

mpls_table_dump()
mpls_tunnel_add_del(tun_sw_if_index, paths, is_add=1, l2_only=0, is_multicast=0)
output_acl_set_interface(is_add, sw_if_index, ip4_table_index=4294967295, ip6_table_index=4294967295, l2_table_index=4294967295)
Parameters
  • is_add

  • sw_if_index

  • ip4_table_index – (Default value = 0xFFFFFFFF)

  • ip6_table_index – (Default value = 0xFFFFFFFF)

  • l2_table_index – (Default value = 0xFFFFFFFF)

p2p_ethernet_add(sw_if_index, remote_mac, subif_id)

Create p2p ethernet subinterface

Parameters
  • sw_if_index – main (parent) interface

  • remote_mac – client (remote) mac address

p2p_ethernet_del(sw_if_index, remote_mac)

Delete p2p ethernet subinterface

Parameters
  • sw_if_index – main (parent) interface

  • remote_mac – client (remote) mac address

ppcli(cli)

Helper method to print CLI command in case of info logging level.

Parameters

cli – CLI to execute

Returns

CLI output

pppoe_add_del_session(client_ip, client_mac, session_id=0, is_add=1, decap_vrf_id=0)
Parameters
  • is_add – (Default value = 1)

  • is_ipv6 – (Default value = 0)

  • client_ip

  • session_id – (Default value = 0)

  • client_mac

  • decap_vrf_id – (Default value = 0)

punt_socket_deregister(reg)

Unregister punt socket

punt_socket_register(reg, pathname, header_version=1)

Register punt socket

register_hook(hook)

Replace hook registration with new hook

Parameters

hook

set_ipfix_exporter(collector_address, src_address, path_mtu, template_interval, vrf_id=0, collector_port=4739, udp_checksum=0)
sr_mpls_policy_add(bsid, weight, type, segments)
sr_mpls_policy_del(bsid)
sw_interface_set_mac_address(sw_if_index, mac)
udp_encap_add(src_ip, dst_ip, src_port, dst_port, table_id=0)

Add a GRE tunnel :param src_ip: :param dst_ip: :param src_port: :param dst_port: :param outer_fib_id: (Default value = 0)

udp_encap_del(id)
udp_encap_dump()
vxlan_gbp_tunnel_dump(sw_if_index=4294967295)
vxlan_gpe_add_del_tunnel(src_addr, dst_addr, mcast_sw_if_index=4294967295, is_add=1, is_ipv6=0, encap_vrf_id=0, decap_vrf_id=0, protocol=3, vni=0)
Parameters
  • local

  • remote

  • is_add – (Default value = 1)

  • is_ipv6 – (Default value = 0)

  • encap_vrf_id – (Default value = 0)

  • decap_vrf_id – (Default value = 0)

  • mcast_sw_if_index – (Default value = 0xFFFFFFFF)

  • protocol – (Default value = 3)

  • vni – (Default value = 0)

wait_for_event(timeout, name=None)

Wait for and return next event.

want_igmp_events(enable=1)
want_interface_events(enable_disable=1)
want_udp_encap_stats(enable=1)
vpp_papi_provider.as_fn_signature(d)