2.46. vpp_papi_provider module¶
-
exception
vpp_papi_provider.
UnexpectedApiReturnValueError
¶ Bases:
exceptions.Exception
exception raised when the API return value is unexpected
-
class
vpp_papi_provider.
VppPapiProvider
(name, shm_prefix, test_class)¶ 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
-
bfd_auth_del_key
(conf_key_id)¶
-
bfd_auth_keys_dump
()¶
-
bfd_auth_set_key
(conf_key_id, auth_type, key)¶
-
bfd_udp_add
(sw_if_index, desired_min_tx, required_min_rx, detect_mult, local_addr, peer_addr, is_ipv6=0, bfd_key_id=None, conf_key_id=None)¶
-
bfd_udp_auth_activate
(sw_if_index, local_addr, peer_addr, is_ipv6=0, bfd_key_id=None, conf_key_id=None, is_delayed=False)¶
-
bfd_udp_auth_deactivate
(sw_if_index, local_addr, peer_addr, is_ipv6=0, is_delayed=False)¶
-
bfd_udp_del
(sw_if_index, local_addr, peer_addr, is_ipv6=0)¶
-
bfd_udp_del_echo_source
()¶
-
bfd_udp_mod
(sw_if_index, desired_min_tx, required_min_rx, detect_mult, local_addr, peer_addr, is_ipv6=0)¶
-
bfd_udp_session_dump
()¶
-
bfd_udp_session_set_flags
(admin_up_down, sw_if_index, local_addr, peer_addr, is_ipv6=0)¶
-
bfd_udp_set_echo_source
(sw_if_index)¶
-
bridge_domain_add_del
(bd_id, flood=1, uu_flood=1, forward=1, learn=1, arp_term=0, is_add=1)¶ Create/delete bridge domain.
Parameters: - bd_id (int) – Bridge domain index.
- flood (int) – Enable/disable bcast/mcast flooding in the BD. (Default value = 1)
- uu_flood (int) – Enable/disable unknown unicast flood in the BD. (Default value = 1)
- forward (int) – Enable/disable forwarding on all interfaces in the BD. (Default value = 1)
- learn (int) – Enable/disable learning on all interfaces in the BD. (Default value = 1)
- arp_term (int) – Enable/disable arp termination in the BD. (Default value = 1)
- is_add (int) – Add or delete flag. (Default value = 1)
-
bridge_domain_dump
(bd_id=0)¶ Parameters: bd_id (int) – Bridge domain ID. (Default value = 0 => dump of all existing bridge domains returned) Returns: Dictionary of bridge domain(s) data.
-
bridge_flags
(bd_id, is_set, feature_bitmap)¶ Enable/disable required feature of the bridge domain with defined ID.
Parameters: - bd_id (int) – Bridge domain ID.
- is_set (int) – Set to 1 to enable, set to 0 to disable the feature.
- feature_bitmap (int) – Bitmap value of the feature to be set: - learn (1 << 0), - forward (1 << 1), - flood (1 << 2), - uu-flood (1 << 3) or - arp-term (1 << 4).
-
classify_add_del_session
(is_add, table_index, match, opaque_index=4294967295, hit_next_index=4294967295, advance=0, action=0, metadata=0)¶ Parameters: - is_add –
- table_index –
- match –
- opaque_index – (Default value = 0xFFFFFFFF)
- hit_next_index – (Default value = 0xFFFFFFFF)
- advance – (Default value = 0)
- action – (Default value = 0)
- metadata – (Default value = 0)
-
classify_add_del_table
(is_add, mask, match_n_vectors=1, table_index=4294967295, nbuckets=2, memory_size=2097152, skip_n_vectors=0, next_table_index=4294967295, miss_next_index=4294967295, current_data_flag=0, current_data_offset=0)¶ Parameters: - is_add –
- mask –
- match_n_vectors – (Default value = 1)
- table_index – (Default value = 0xFFFFFFFF)
- nbuckets – (Default value = 2)
- memory_size – (Default value = 2097152)
- skip_n_vectors – (Default value = 0)
- next_table_index – (Default value = 0xFFFFFFFF)
- miss_next_index – (Default value = 0xFFFFFFFF)
- current_data_flag – (Default value = 0)
- current_data_offset – (Default value = 0)
-
cli
(cli)¶ Execute a CLI, calling the before/after hooks appropriately.
Parameters: cli – CLI to execute Returns: CLI output
-
collect_events
()¶ Collect all events from the internal queue and clear the queue.
-
connect
()¶ Connect the API to VPP
-
control_ping
()¶
-
create_loopback
(mac='')¶ Parameters: mac – (Optional)
-
create_subif
(sw_if_index, sub_id, outer_vlan, inner_vlan, no_tags=0, one_tag=0, two_tags=0, dot1ad=0, exact_match=0, default_sub=0, outer_vlan_id_any=0, inner_vlan_id_any=0)¶ Create subinterface from vpe.api: set dot1ad = 0 for dot1q, set dot1ad = 1 for dot1ad
Parameters: - sub_id – param inner_vlan:
- sw_if_index –
- outer_vlan –
- inner_vlan –
- no_tags – (Default value = 0)
- one_tag – (Default value = 0)
- two_tags – (Default value = 0)
- dot1ad – (Default value = 0)
- exact_match – (Default value = 0)
- default_sub – (Default value = 0)
- outer_vlan_id_any – (Default value = 0)
- inner_vlan_id_any – (Default value = 0)
-
create_vlan_subif
(sw_if_index, vlan)¶ Parameters: - vlan –
- sw_if_index –
-
delete_loopback
(sw_if_index)¶
-
delete_subif
(sw_if_index)¶ Delete subinterface
Parameters: sw_if_index –
-
dhcp_proxy_config
(dhcp_server, dhcp_src_address, rx_table_id=0, server_table_id=0, is_add=1, is_ipv6=0)¶
-
dhcp_proxy_set_vss
(table_id, fib_id, oui, is_add=1, is_ip6=0)¶
-
disconnect
()¶ Disconnect the API from VPP
-
expect_negative_api_retval
()¶ Expect API failure
-
expect_zero_api_retval
()¶ Expect API success
-
gre_tunnel_add_del
(src_address, dst_address, outer_fib_id=0, is_teb=0, is_add=1, is_ip6=0)¶ Add a GRE tunnel
Parameters: - src_address –
- dst_address –
- outer_fib_id – (Default value = 0)
- is_add – (Default value = 1)
- is_ipv6 – (Default value = 0)
- is_teb – (Default value = 0)
-
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)
-
ip6_fib_dump
()¶
-
ip6_nd_proxy
(address, sw_if_index, is_del=0)¶
-
ip6_sw_interface_enable_disable
(sw_if_index, enable)¶ Enable/Disable An interface for IPv6
-
ip6_sw_interface_ra_config
(sw_if_index, no, suppress, send_unicast)¶
-
ip6_sw_interface_ra_prefix
(sw_if_index, address, address_length, use_default=0, no_advertise=0, off_link=0, no_autoconfig=0, no_onlink=0, is_no=0, val_lifetime=4294967295, pref_lifetime=4294967295)¶
-
ip_add_del_route
(dst_address, dst_address_length, next_hop_address, next_hop_sw_if_index=4294967295, table_id=0, next_hop_table_id=0, next_hop_weight=1, next_hop_n_out_labels=0, next_hop_out_label_stack=[], next_hop_via_label=1048576, create_vrf_if_needed=0, is_resolve_host=0, is_resolve_attached=0, classify_table_index=4294967295, is_add=1, is_drop=0, is_unreach=0, is_prohibit=0, is_ipv6=0, is_local=0, is_classify=0, is_multipath=0, not_last=0)¶ Parameters: - dst_address_length –
- next_hop_sw_if_index – (Default value = 0xFFFFFFFF)
- dst_address –
- next_hop_address –
- next_hop_sw_if_index – (Default value = 0xFFFFFFFF)
- vrf_id – (Default value = 0)
- lookup_in_vrf – (Default value = 0)
- classify_table_index – (Default value = 0xFFFFFFFF)
- create_vrf_if_needed – (Default value = 0)
- is_add – (Default value = 1)
- is_drop – (Default value = 0)
- is_ipv6 – (Default value = 0)
- is_local – (Default value = 0)
- is_classify – (Default value = 0)
- is_multipath – (Default value = 0)
- is_resolve_host – (Default value = 0)
- is_resolve_attached – (Default value = 0)
- not_last – (Default value = 0)
- next_hop_weight – (Default value = 1)
-
ip_dump
(is_ipv6=0)¶ Return IP dump.
Parameters: is_ipv6 (int) – 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
-
ip_fib_dump
()¶
-
ip_mfib_dump
()¶
-
ip_mroute_add_del
(src_address, grp_address, grp_address_length, e_flags, next_hop_sw_if_index, i_flags, table_id=0, create_vrf_if_needed=0, is_add=1, is_ipv6=0, is_local=0)¶
-
ip_neighbor_add_del
(sw_if_index, mac_address, dst_address, is_add=1, is_ipv6=0, is_static=0, is_no_adj_fib=0)¶ Add neighbor MAC to IPv4 or IPv6 address.
Parameters: - sw_if_index –
- mac_address –
- dst_address –
- is_add – (Default value = 1)
- is_ipv6 – (Default value = 0)
- is_static – (Default value = 0)
- is_no_adj_fib – (Default value = 0)
-
ip_neighbor_dump
(sw_if_index, is_ipv6=0)¶ Return IP neighbor dump.
Parameters: - sw_if_index –
- is_ipv6 (int) – 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
-
l2fib_add_del
(mac, bd_id, sw_if_index, is_add=1, static_mac=0, filter_mac=0, bvi_mac=0)¶ Create/delete L2 FIB entry.
Parameters: - mac (str) – MAC address to create FIB entry for.
- bd_id (int) – Bridge domain index.
- sw_if_index (int) – Software interface index of the interface.
- is_add (int) – Add or delete flag. (Default value = 1)
- static_mac (int) – Set to 1 to create static MAC entry. (Default value = 0)
- filter_mac (int) – Set to 1 to drop packet that’s source or destination MAC address contains defined MAC address. (Default value = 0)
- bvi_mac (int) – Set to 1 to create entry that points to BVI interface. (Default value = 0)
-
lisp_adjacencies_get
(vni=0)¶
-
lisp_adjacency
(leid, reid, leid_len, reid_len, eid_type, is_add=1, vni=0)¶
-
lisp_eid_table_dump
(eid_set=0, prefix_length=0, vni=0, eid_type=0, eid=None, filter_opt=0)¶
-
lisp_enable_disable
(is_enabled)¶
-
lisp_local_mapping
(ls_name, eid_type, eid, prefix_len, vni=0, key_id=0, key='', is_add=1)¶
-
lisp_locator
(ls_name, sw_if_index, priority=1, weight=1, is_add=1)¶
-
lisp_locator_dump
(is_index_set, ls_name=None, ls_index=0)¶
-
lisp_locator_set
(ls_name, is_add=1)¶
-
lisp_locator_set_dump
()¶
-
lisp_remote_mapping
(eid_type, eid, eid_prefix_len=0, vni=0, rlocs=None, rlocs_num=0, is_src_dst=0, is_add=1)¶
-
map_add_domain
(ip6_prefix, ip6_prefix_len, ip6_src, ip6_src_prefix_len, ip4_prefix, ip4_prefix_len, ea_bits_len=0, psid_offset=0, psid_length=0, is_translation=0, mtu=1280)¶
-
mfib_signal_dump
()¶
-
mpls_fib_dump
()¶
-
mpls_ip_bind_unbind
(label, dst_address, dst_address_length, table_id=0, ip_table_id=0, is_ip4=1, create_vrf_if_needed=0, is_bind=1)¶
-
mpls_route_add_del
(label, eos, next_hop_proto_is_ip4, next_hop_address, next_hop_sw_if_index=4294967295, table_id=0, next_hop_table_id=0, next_hop_weight=1, next_hop_n_out_labels=0, next_hop_out_label_stack=[], next_hop_via_label=1048576, create_vrf_if_needed=0, is_resolve_host=0, is_resolve_attached=0, is_add=1, is_drop=0, is_multipath=0, classify_table_index=4294967295, is_classify=0, not_last=0)¶ Parameters: - dst_address_length –
- next_hop_sw_if_index – (Default value = 0xFFFFFFFF)
- dst_address –
- next_hop_address –
- next_hop_sw_if_index – (Default value = 0xFFFFFFFF)
- vrf_id – (Default value = 0)
- lookup_in_vrf – (Default value = 0)
- classify_table_index – (Default value = 0xFFFFFFFF)
- create_vrf_if_needed – (Default value = 0)
- is_add – (Default value = 1)
- is_drop – (Default value = 0)
- is_ipv6 – (Default value = 0)
- is_local – (Default value = 0)
- is_classify – (Default value = 0)
- is_multipath – (Default value = 0)
- is_resolve_host – (Default value = 0)
- is_resolve_attached – (Default value = 0)
- not_last – (Default value = 0)
- next_hop_weight – (Default value = 1)
-
mpls_tunnel_add_del
(tun_sw_if_index, next_hop_proto_is_ip4, next_hop_address, next_hop_sw_if_index=4294967295, next_hop_table_id=0, next_hop_weight=1, next_hop_n_out_labels=0, next_hop_out_label_stack=[], next_hop_via_label=1048576, create_vrf_if_needed=0, is_add=1, l2_only=0)¶ Parameters: - dst_address_length –
- next_hop_sw_if_index – (Default value = 0xFFFFFFFF)
- dst_address –
- next_hop_address –
- next_hop_sw_if_index – (Default value = 0xFFFFFFFF)
- vrf_id – (Default value = 0)
- lookup_in_vrf – (Default value = 0)
- classify_table_index – (Default value = 0xFFFFFFFF)
- create_vrf_if_needed – (Default value = 0)
- is_add – (Default value = 1)
- is_drop – (Default value = 0)
- is_ipv6 – (Default value = 0)
- is_local – (Default value = 0)
- is_classify – (Default value = 0)
- is_multipath – (Default value = 0)
- is_resolve_host – (Default value = 0)
- is_resolve_attached – (Default value = 0)
- not_last – (Default value = 0)
- next_hop_weight – (Default value = 1)
-
pg_create_interface
(pg_index)¶ Parameters: pg_index –
-
ppcli
(cli)¶ Helper method to print CLI command in case of info logging level.
Parameters: cli – CLI to execute Returns: CLI output
-
proxy_arp_add_del
(low_address, hi_address, vrf_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
-
register_hook
(hook)¶ Replace hook registration with new hook
Parameters: hook –
-
reset_fib
(vrf_id, is_ipv6=0)¶ Reset VRF (remove all routes etc.) request.
Parameters: - vrf_id (int) – ID of the FIB table / VRF to reset.
- is_ipv6 (int) – 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
-
reset_vrf
(vrf_id, is_ipv6=0)¶ Reset VRF (remove all routes etc.) request.
Parameters: - vrf_id (int) – ID of the FIB table / VRF to reset.
- is_ipv6 (int) – 1 for IPv6 neighbor, 0 for IPv4. (Default = 0)
-
set_ipfix_exporter
(collector_address, src_address, path_mtu, template_interval, vrf_id=0, collector_port=4739, udp_checksum=0)¶
-
show_version
()¶
-
snat_add_address_range
(first_ip_address, last_ip_address, is_add=1, is_ip4=1, vrf_id=4294967295)¶ Add/del S-NAT address range
Parameters: - first_ip_address – First IP address
- last_ip_address – Last IP address
- vrf_id – VRF id for the address range
- is_add – 1 if add, 0 if delete (Default value = 1)
- is_ip4 – 1 if address type is IPv4 (Default value = 1)
-
snat_add_det_map
(in_addr, in_plen, out_addr, out_plen, is_add=1)¶ Add/delete S-NAT deterministic mapping
:param is_add - 1 if add, 0 if delete :param in_addr - inside IP address :param in_plen - inside IP address prefix length :param out_addr - outside IP address :param out_plen - outside IP address prefix length
-
snat_add_interface_addr
(sw_if_index, is_add=1)¶ Add/del S-NAT address from interface
Parameters: - sw_if_index – Software index of the interface
- is_add – 1 if add, 0 if delete (Default value = 1)
-
snat_add_static_mapping
(local_ip, external_ip=0, external_sw_if_index=4294967295, local_port=0, external_port=0, addr_only=1, vrf_id=0, protocol=0, is_add=1, is_ip4=1)¶ Add/delete S-NAT static mapping
Parameters: - local_ip – Local IP address
- external_ip – External IP address
- external_sw_if_index – External interface instead of IP address
- local_port – Local port number (Default value = 0)
- external_port – External port number (Default value = 0)
- addr_only – 1 if address only mapping, 0 if address and port
- vrf_id – VRF ID
- protocol – IP protocol (Default value = 0)
- is_add – 1 if add, 0 if delete (Default value = 1)
- is_ip4 – 1 if address type is IPv4 (Default value = 1)
-
snat_address_dump
()¶ Dump S-NAT addresses :return: Dictionary of S-NAT addresses
-
snat_det_forward
(in_addr)¶ Get outside address and port range from inside address
:param in_addr - inside IP address
-
snat_det_map_dump
()¶ Dump S-NAT deterministic mappings
Returns: Dictionary of S-NAT deterministic mappings
-
snat_det_reverse
(out_addr, out_port)¶ Get inside address from outside address and port
:param out_addr - outside IP address :param out_port - outside port
-
snat_interface_add_del_feature
(sw_if_index, is_inside=1, is_add=1)¶ Enable/disable S-NAT feature on the interface
Parameters: - sw_if_index – Software index of the interface
- is_inside – 1 if inside, 0 if outside (Default value = 1)
- is_add – 1 if add, 0 if delete (Default value = 1)
-
snat_interface_addr_dump
()¶ Dump S-NAT addresses interfaces :return: Dictionary of S-NAT addresses interfaces
-
snat_interface_dump
()¶ Dump interfaces with S-NAT feature :return: Dictionary of interfaces with S-NAT feature
-
snat_ipfix
(domain_id=1, src_port=4739, enable=1)¶ Enable/disable S-NAT IPFIX logging
Parameters: - domain_id – Observation domain ID (Default value = 1)
- src_port – Source port number (Default value = 4739)
- enable – 1 if enable, 0 if disable (Default value = 1)
-
snat_show_config
()¶ Show S-NAT config :return: S-NAT config parameters
-
snat_static_mapping_dump
()¶ Dump S-NAT static mappings :return: Dictionary of S-NAT static mappings
-
snat_user_dump
()¶ Dump S-NAT users
Returns: Dictionary of S-NAT users
-
snat_user_session_dump
(ip_address, vrf_id, is_ip4=1)¶ Dump S-NAT user’s sessions
Parameters: - ip_address – ip adress of the user to be dumped
- cpu_index – cpu_index on which the user is
- vrf_id – VRF ID
Returns: Dictionary of S-NAT sessions
-
sw_interface_add_del_address
(sw_if_index, addr, addr_len, is_ipv6=0, is_add=1, del_all=0)¶ Parameters: - addr – param is_ipv6: (Default value = 0)
- sw_if_index –
- addr_len –
- is_ipv6 – (Default value = 0)
- is_add – (Default value = 1)
- del_all – (Default value = 0)
-
sw_interface_dump
(filter=None)¶ Parameters: filter – (Default value = None)
-
sw_interface_enable_disable_mpls
(sw_if_index, is_enable=1)¶ Enable/Disable MPLS on the interface :param sw_if_index: :param is_enable: (Default value = 1)
-
sw_interface_ra_suppress
(sw_if_index, suppress=1)¶
-
sw_interface_set_flags
(sw_if_index, admin_up_down, link_up_down=0, deleted=0)¶ Parameters: - admin_up_down –
- sw_if_index –
- link_up_down – (Default value = 0)
- deleted – (Default value = 0)
-
sw_interface_set_l2_bridge
(sw_if_index, bd_id, shg=0, bvi=0, enable=1)¶ Add/remove interface to/from bridge domain.
Parameters: - sw_if_index (int) – Software interface index of the interface.
- bd_id (int) – Bridge domain index.
- shg (int) – Split-horizon group index. (Default value = 0)
- bvi (int) – Set interface as a bridge group virtual interface. (Default value = 0)
- enable (int) – Add or remove interface. (Default value = 1)
-
sw_interface_set_l2_tag_rewrite
(sw_if_index, vtr_oper, push=0, tag1=0, tag2=0)¶ L2 interface vlan tag rewrite configure request :param client_index - opaque cookie to identify the sender :param context - sender context, to match reply w/ request :param sw_if_index - interface the operation is applied to :param vtr_op - Choose from l2_vtr_op_t enum values :param push_dot1q - first pushed flag dot1q id set, else dot1ad :param tag1 - Needed for any push or translate vtr op :param tag2 - Needed for any push 2 or translate x-2 vtr ops
-
sw_interface_set_l2_xconnect
(rx_sw_if_index, tx_sw_if_index, enable)¶ Create or delete unidirectional cross-connect from Tx interface to Rx interface.
Parameters: - rx_sw_if_index (int) – Software interface index of Rx interface.
- tx_sw_if_index (int) – Software interface index of Tx interface.
- enable (int) – Create cross-connect if equal to 1, delete cross-connect if equal to 0.
-
sw_interface_set_table
(sw_if_index, is_ipv6, table_id)¶ Set the IPvX Table-id for the Interface
Parameters: - sw_if_index –
- is_ipv6 –
- table_id –
-
sw_interface_set_unnumbered
(sw_if_index, ip_sw_if_index, is_add=1)¶ Set the Interface to be unnumbered
Parameters: is_add – (Default value = 1) :param sw_if_index - interface That will be unnumbered :param ip_sw_if_index - interface with an IP addres
-
sw_interface_span_enable_disable
(sw_if_index_from, sw_if_index_to, state=1)¶ Parameters: - sw_if_index_from –
- sw_if_index_to –
- state –
-
vxlan_add_del_tunnel
(src_addr, dst_addr, mcast_sw_if_index=4294967295, is_add=1, is_ipv6=0, encap_vrf_id=0, decap_next_index=4294967295, vni=0)¶ Parameters: - dst_addr –
- src_addr –
- is_add – (Default value = 1)
- is_ipv6 – (Default value = 0)
- encap_vrf_id – (Default value = 0)
- decap_next_index – (Default value = 0xFFFFFFFF)
- mcast_sw_if_index – (Default value = 0xFFFFFFFF)
- vni – (Default value = 0)
-
wait_for_event
(timeout, name=None)¶ Wait for and return next event.
-
want_bfd_events
(enable_disable=1)¶
-