2.150. 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, shm_prefix, 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

app_namespace_add_del(namespace_id, ip4_fib_id=0, ip6_fib_id=0, sw_if_index=4294967295, secret=0)
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()
bond_create(mode, lb, numa_only, use_custom_mac, mac_address='', interface_id=4294967295)
Parameters
  • mode – mode

  • lb – load balance

  • numa_only – tx on local numa node for lacp mode

  • use_custom_mac – use custom mac

  • mac_address – mac address

  • interface_id – custom interface ID

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)
feature_gso_enable_disable(sw_if_index, enable_disable=1)
gbp_bridge_domain_add(bd_id, rd_id, flags, bvi_sw_if_index, uu_fwd_sw_if_index, bm_flood_sw_if_index)

GBP bridge-domain Add

gbp_bridge_domain_del(bd_id)

GBP bridge-domain Del

gbp_contract_dump()

GBP contract Dump

gbp_endpoint_add(sw_if_index, ips, mac, sclass, flags, tun_src, tun_dst)

GBP endpoint Add

gbp_endpoint_del(handle)

GBP endpoint Del

gbp_endpoint_dump()

GBP endpoint Dump

gbp_endpoint_group_add(vnid, sclass, bd, rd, uplink_sw_if_index, retention)

GBP endpoint group Add

gbp_endpoint_group_del(sclass)

GBP endpoint group Del

gbp_ext_itf_add_del(is_add, sw_if_index, bd_id, rd_id, flags)

GBP recirc Add/Del

gbp_ext_itf_dump()

GBP recirc Dump

gbp_recirc_add_del(is_add, sw_if_index, sclass, is_ext)

GBP recirc Add/Del

gbp_recirc_dump()

GBP recirc Dump

gbp_route_domain_add(rd_id, scope, ip4_table_id, ip6_table_id, ip4_uu_sw_if_index, ip6_uu_sw_if_index)

GBP route-domain Add

gbp_route_domain_del(rd_id)

GBP route-domain Del

gbp_subnet_add_del(is_add, rd_id, prefix, type, sw_if_index=4294967295, sclass=65535)

GBP Subnet Add/Del

gbp_subnet_dump()

GBP Subnet Dump

gbp_vxlan_tunnel_add(vni, bd_rd_id, mode, src)

GBP VXLAN tunnel add

gbp_vxlan_tunnel_del(vni)

GBP VXLAN tunnel del

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_punt_police(policer_index, is_ip6=0, is_add=1)
ip_punt_redirect(rx_sw_if_index, tx_sw_if_index, address, is_add=1)
ip_punt_redirect_dump(sw_if_index, is_ipv6=0)
ip_route_dump(table_id, is_ip6=False)
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_sa_dump(sa_id=None)
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

pipe_delete(parent_sw_if_index)
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)

proxy_arp_add_del(low, hi, table_id=0, is_add=1)

Config Proxy Arp Range.

Parameters
  • low_address – Start address in the rnage to Proxy for

  • hi_address – End address in the rnage to Proxy for

  • vrf_id – The VRF/table in which to proxy

proxy_arp_intfc_enable_disable(sw_if_index, is_enable=1)

Enable/Disable an interface for proxy ARP requests

Parameters
  • sw_if_index – Interface

  • enable_disable – Enable/Disable

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

session_enable_disable(is_enabled)
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)
svs_enable_disable(af, table_id, sw_if_index, is_enable=1)
svs_route_add_del(table_id, prefix, src_table_id, is_add=1)
svs_table_add_del(af, table_id, is_add=1)
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)