2. Python Library

2.7. Classify suite

Classify utilities library.

class resources.libraries.python.Classify.Classify

Bases: object

Classify utilities.

static add_del_macip_acl_interface(node, interface, action, acl_idx)

Apply/un-apply the MACIP ACL to/from a given interface.

Parameters:
  • node (dict) – VPP node to set MACIP ACL on.
  • interface (str or int) – Interface name or sw_if_index.
  • action (str) – Required action - add or del.
  • acl_idx (str or int) – ACL index to be applied on the interface.
Raises:

RuntimeError – If unable to set MACIP ACL for the interface.

static add_macip_acl(node, ip_ver='ipv4', action='permit', src_ip=None, src_mac=None, src_mac_mask=None)

Add a new MACIP ACL.

Parameters:
  • node (dict) – VPP node to set MACIP ACL on.
  • ip_ver (str) – IP version. (Optional)
  • action (str) – ACL action. (Optional)
  • src_ip (str) – Source IP in format IP/plen. (Optional)
  • src_mac (str) – Source MAC address in format with colons. (Optional)
  • src_mac_mask (str) – Source MAC address mask in format with colons. 00:00:00:00:00:00 is a wildcard mask. (Optional)
Raises:

RuntimeError – If unable to add MACIP ACL.

static add_macip_acl_multi_entries(node, rules=None)

Add a new MACIP ACL.

Parameters:
  • node (dict) – VPP node to set MACIP ACL on.
  • rules (str) – Required MACIP rules. (Optional)
Raises:

RuntimeError – If unable to add MACIP ACL.

static add_replace_acl(node, acl_idx=None, ip_ver='ipv4', action='permit', src=None, dst=None, sport=None, dport=None, proto=None, tcpflg_val=None, tcpflg_mask=None)

Add a new ACL or replace the existing one. To replace an existing ACL, pass the ID of this ACL.

Parameters:
  • node (dict) – VPP node to set ACL on.
  • acl_idx (int) – ID of ACL. (Optional)
  • ip_ver (str) – IP version. (Optional)
  • action (str) – ACL action. (Optional)
  • src (str) – Source IP in format IP/plen. (Optional)
  • dst (str) – Destination IP in format IP/plen. (Optional)
  • sport (str or int) – Source port or ICMP4/6 type - range format X-Y allowed. (Optional)
  • dport (str or int) – Destination port or ICMP4/6 code - range format X-Y allowed. (Optional)
  • proto (int) – L4 protocol (http://www.iana.org/assignments/protocol- numbers/protocol-numbers.xhtml). (Optional)
  • tcpflg_val (int) – TCP flags value. (Optional)
  • tcpflg_mask (int) – TCP flags mask. (Optional)
Raises:

RuntimeError – If unable to add or replace ACL.

static add_replace_acl_multi_entries(node, acl_idx=None, rules=None)

Add a new ACL or replace the existing one. To replace an existing ACL, pass the ID of this ACL.

Parameters:
  • node (dict) – VPP node to set ACL on.
  • acl_idx (int) – ID of ACL. (Optional)
  • rules (str) – Required rules. (Optional)
Raises:

RuntimeError – If unable to add or replace ACL.

static cli_show_acl(node, acl_idx=None)

Show ACLs.

Parameters:
  • node (dict) – VPP node to show ACL on.
  • acl_idx (int or str) – Index of ACL to be shown.
Raises:

RuntimeError – If unable to delete ACL.

static compute_classify_hex_mask(ip_version, protocol, direction)

Compute classify hex mask for TCP or UDP packet matching.

Parameters:
  • ip_version (str) – Version of IP protocol.
  • protocol (str) – Type of protocol.
  • direction (str) – Traffic direction.
Returns:

Classify hex mask.

:rtype : str :raises ValueError: If protocol is not TCP or UDP. :raises ValueError: If direction is not source or destination or

source + destination.
static compute_classify_hex_value(hex_mask, source_port, destination_port)

Compute classify hex value for TCP or UDP packet matching.

Parameters:
  • hex_mask (str) – Classify hex mask.
  • source_port (str) – Source TCP/UDP port.
  • destination_port (str) – Destination TCP/UDP port.
Returns:

Classify hex value.

Return type:

str

static delete_acl(node, idx)

Delete required ACL.

Parameters:
  • node (dict) – VPP node to delete ACL on.
  • idx (int or str) – Index of ACL to be deleted.
Raises:

RuntimeError – If unable to delete ACL.

static delete_macip_acl(node, idx)

Delete required MACIP ACL.

Parameters:
  • node (dict) – VPP node to delete MACIP ACL on.
  • idx (int or str) – Index of ACL to be deleted.
Raises:

RuntimeError – If unable to delete MACIP ACL.

static get_classify_session_data(node, table_index, session_index=None)

Retrieve settings for all classify sessions in a table, or for a specific classify session.

Parameters:
  • node (dict) – VPP node to retrieve classify data from.
  • table_index (int) – Index of a classify table.
  • session_index (int) – Index of a specific classify session. (Optional)
Returns:

List of classify session settings, or a dictionary of settings for a specific classify session.

Return type:

list or dict

static get_classify_table_data(node, table_index)

Retrieve settings for classify table by ID.

Parameters:
  • node (dict) – VPP node to retrieve classify data from.
  • table_index (int) – Index of a specific classify table.
Returns:

Classify table settings.

Return type:

dict

static set_acl_list_for_interface(node, interface, acl_type, acl_idx=None)

Set the list of input or output ACLs applied to the interface. It unapplies any previously applied ACLs.

Parameters:
  • node (dict) – VPP node to set ACL on.
  • interface (str or int) – Interface name or sw_if_index.
  • acl_type (str) – Type of ACL(s) - input or output.
  • acl_idx (list) – Index(ies) of ACLs to be applied on the interface.
Raises:

RuntimeError – If unable to set ACL list for the interface.

static vpp_configures_classify_session_generic(node, session_type, table_index, skip_n, match_n, match, match2='')

Configuration of classify session.

Parameters:
  • node – VPP node to setup classify session.
  • session_type – Session type - hit-next, l2-hit-next, acl-hit-next

or policer-hit-next, and their respective parameters. :param table_index: Classify table index. :param skip_n: Number of skip vectors based on mask. :param match_n: Number of match vectors based on mask. :param match: Match value - l2, l3, l4 or hex, and their respective parameters. :param match2: Additional match values, to avoid using overly long variables in RobotFramework. :type node: dict :type session_type: str :type table_index: int :type skip_n: int :type match_n: int :type match: str :type match2: str

static vpp_configures_classify_session_hex(node, acl_method, table_index, skip_n, match_n, hex_value)

Configuration of classify session with hex value.

Parameters:
  • node (dict) – VPP node to setup classify session.
  • acl_method (str) – ACL method - deny/permit.
  • table_index (int) – Classify table index.
  • skip_n (int) – Number of skip vectors based on mask.
  • match_n (int) – Number of match vectors based on mask.
  • hex_value (str) – Classify hex value.
static vpp_configures_classify_session_l2(node, acl_method, table_index, skip_n, match_n, direction, address)

Configuration of classify session for MAC address filtering.

Parameters:
  • node (dict) – VPP node to setup classify session.
  • acl_method (str) – ACL method - deny/permit.
  • table_index (int) – Classify table index.
  • skip_n (int) – Number of skip vectors based on mask.
  • match_n (int) – Number of match vectors based on mask.
  • direction (str) – Direction of traffic - src/dst.
  • address (str) – IPv4 or IPv6 address.
static vpp_configures_classify_session_l3(node, acl_method, table_index, skip_n, match_n, ip_version, direction, address)

Configuration of classify session for IP address filtering.

Parameters:
  • node (dict) – VPP node to setup classify session.
  • acl_method (str) – ACL method - deny/permit.
  • table_index (int) – Classify table index.
  • skip_n (int) – Number of skip vectors based on mask.
  • match_n (int) – Number of match vectors based on mask.
  • ip_version (str) – Version of IP protocol.
  • direction (str) – Direction of traffic - src/dst.
  • address (str) – IPv4 or IPv6 address.
static vpp_creates_classify_table_hex(node, hex_mask)

Create classify table with hex mask.

Parameters:
  • node (dict) – VPP node to create classify table based on hex mask.
  • hex_mask (str) – Classify hex mask.

:returns (table_index, skip_n, match_n) table_index: Classify table index. skip_n: Number of skip vectors. match_n: Number of match vectors. :rtype: tuple(int, int, int) :raises RuntimeError: If VPP can’t create table.

static vpp_creates_classify_table_l2(node, direction)

Create classify table for MAC address filtering.

Parameters:
  • node (dict) – VPP node to create classify table.
  • direction (str) – Direction of traffic - src/dst.

:returns (table_index, skip_n, match_n) table_index: Classify table index. skip_n: Number of skip vectors. match_n: Number of match vectors. :rtype: tuple(int, int, int) :raises RuntimeError: If VPP can’t create table.

static vpp_creates_classify_table_l3(node, ip_version, direction)

Create classify table for IP address filtering.

Parameters:
  • node (dict) – VPP node to create classify table.
  • ip_version (str) – Version of IP protocol.
  • direction (str) – Direction of traffic - src/dst.

:returns (table_index, skip_n, match_n) table_index: Classify table index. skip_n: Number of skip vectors. match_n: Number of match vectors. :rtype: tuple(int, int, int) :raises RuntimeError: If VPP can’t create table.

static vpp_log_macip_acl_interface_assignment(node)

Get interface list and associated MACIP ACLs and write to robot log.

Parameters:node (dict) – VPP node.
static vpp_log_macip_acl_settings(node)
Retrieve configured MACIP settings from the ACL plugin
and write to robot log.
Parameters:node (dict) – VPP node.
static vpp_log_plugin_acl_interface_assignment(node)

Retrieve interface assignment from the ACL plugin and write to robot log.

Parameters:node (dict) – VPP node.
static vpp_log_plugin_acl_settings(node)
Retrieve configured settings from the ACL plugin
and write to robot log.
Parameters:node (dict) – VPP node.

2.8. ContainerUtils suite

Library to manipulate Containers.

class resources.libraries.python.ContainerUtils.ContainerManager(engine)

Bases: object

Container lifecycle management class.

acquire_all_containers()

Acquire all containers.

build_all_containers()

Build all containers.

configure_vpp_in_all_containers(vat_template_file)

Configure VPP in all containers.

Parameters:vat_template_file (str) – Template file name of a VAT script.
construct_container(**kwargs)

Construct container object on node with specified parameters.

Parameters:
  • kwargs – Key-value pairs used to construct container.
  • kwargs – dict
construct_containers(**kwargs)

Construct 1..N container(s) on node with specified name.

Ordinal number is automatically added to the name of container as suffix.

Parameters:
  • kwargs – Named parameters.
  • kwargs – dict
create_all_containers()

Create all containers.

destroy_all_containers()

Destroy all containers.

execute_on_all_containers(command)

Execute command on all containers.

Parameters:command (str) – Command to execute.
execute_on_container(name, command)

Execute command on container with name.

Parameters:
  • name (str) – Container name.
  • command (str) – Command to execute.
get_container_by_name(name)

Get container instance.

Parameters:name (str) – Container name.
Returns:Container instance.
Return type:Container
Raises:RuntimeError – If failed to get container with name.
install_vpp_in_all_containers()

Install VPP into all containers.

stop_all_containers()

Stop all containers.

class resources.libraries.python.ContainerUtils.ContainerEngine

Bases: object

Abstract class for container engine.

acquire(force)

Acquire/download container.

Parameters:force (bool) – Destroy a container if exists and create.
build()

Build container (compile).

create()

Create/deploy container.

create_vpp_exec_config(vat_template_file, **kwargs)

Create VPP exec configuration on container.

Parameters:
  • vat_template_file (str) – File name of a VAT template script.
  • kwargs (dict) – Parameters for VAT script.
create_vpp_startup_config(config_filename='/etc/vpp/startup.conf')

Create base startup configuration of VPP on container.

Parameters:config_filename (str) – Startup configuration file name.
destroy()

Destroy/remove container.

execute(command)

Execute process inside container.

Parameters:command (str) – Command to run inside container.
info()

Info about container.

initialize()

Initialize container object.

install_supervisor()

Install supervisord inside a container.

install_vpp(install_dkms=False)

Install VPP inside a container.

Parameters:install_dkms – If install dkms package. This will impact install

time. Dkms is required for installation of vpp-dpdk-dkms. Default is false. :type install_dkms: bool

is_container_present()

Check if container is present.

is_container_running()

Check if container is running.

restart_vpp()

Restart VPP service inside a container.

stop()

Stop container.

system_info()

System info.

class resources.libraries.python.ContainerUtils.LXC

Bases: resources.libraries.python.ContainerUtils.ContainerEngine

LXC implementation.

acquire(force=True)

Acquire a privileged system object where configuration is stored.

Parameters:force – If a container exists, destroy it and create a new

container. :type force: bool :raises RuntimeError: If creating the container or writing the container config fails.

create()

Create/deploy an application inside a container on system.

Raises:RuntimeError – If creating the container fails.
destroy()

Destroy a container.

Raises:RuntimeError – If destroying container failed.
execute(command)

Start a process inside a running container.

Runs the specified command inside the container specified by name. The container has to be running already.

Parameters:command (str) – Command to run inside container.
Raises:RuntimeError – If running the command failed.
info()

Query and shows information about a container.

Raises:RuntimeError – If getting info about a container failed.
is_container_present()

Check if container is existing on node.

Returns:True if container is present.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
is_container_running()

Check if container is running on node.

Returns:True if container is running.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
stop()

Stop a container.

Raises:RuntimeError – If stopping the container failed.
system_info()

Check the current kernel for LXC support.

Raises:RuntimeError – If checking LXC support failed.
class resources.libraries.python.ContainerUtils.Docker

Bases: resources.libraries.python.ContainerUtils.ContainerEngine

Docker implementation.

acquire(force=True)

Pull an image or a repository from a registry.

Parameters:force (bool) – Destroy a container if exists.
Raises:RuntimeError – If pulling a container failed.
create()

Create/deploy container.

Raises:RuntimeError – If creating a container failed.
destroy()

Remove a container.

Raises:RuntimeError – If removing a container failed.
execute(command)

Start a process inside a running container.

Runs the specified command inside the container specified by name. The container has to be running already.

Parameters:command (str) – Command to run inside container.
Raises:RuntimeError – If runnig the command in a container failed.
info()

Return low-level information on Docker objects.

Raises:RuntimeError – If getting info about a container failed.
is_container_present()

Check if container is present on node.

Returns:True if container is present.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
is_container_running()

Check if container is running on node.

Returns:True if container is running.
Return type:bool
Raises:RuntimeError – If getting info about a container failed.
stop()

Stop running container.

Raises:RuntimeError – If stopping a container failed.
system_info()

Display the docker system-wide information.

Raises:RuntimeError – If displaying system information failed.
class resources.libraries.python.ContainerUtils.Container

Bases: object

Container class.

2.9. Cop suite

COP utilities library.

class resources.libraries.python.Cop.Cop

Bases: object

COP utilities.

static cop_add_whitelist_entry(node, interface, ip_format, fib_id)

Add cop whitelisted entry.

Parameters:
  • node (dict) – Node to add COP whitelist on.
  • interface (str) – Interface of the node where the COP is added.
  • ip_format (str) – IP format : ip4 or ip6 are valid formats.
  • fib_id (int) – Specify the fib table ID.
static cop_interface_enable_or_disable(node, interface, state)

Enable or disable COP on the interface.

Parameters:
  • node (dict) – Node to add COP whitelist on.
  • interface (str) – Interface of the node where the COP is added.
  • state (str) – disable/enable COP on the interface.

2.10. CpuUtils suite

CPU utilities library.

class resources.libraries.python.CpuUtils.CpuUtils

Bases: object

CPU utilities

NR_OF_THREADS = 2
static cpu_list_per_node(node, cpu_node, smt_used=False)

Return node related list of CPU numbers.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

List of cpu numbers related to numa from argument.

Return type:

list of int

Raises:

RuntimeError – If node cpuinfo is not available or if SMT is not

enabled.

static cpu_list_per_node_str(node, cpu_node, skip_cnt=0, cpu_cnt=0, sep=', ', smt_used=False)

Return string of node related list of CPU numbers.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_cnt (int) – Count of cpus to return, if 0 then return all.
  • sep (str) – Separator, default: 1,2,3,4,....
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

Cpu numbers related to numa from argument.

Return type:

str

static cpu_node_count(node)

Return count of numa nodes.

Parameters:node (dict) – Targeted node.
Returns:Count of numa nodes.
Return type:int
Raises:RuntimeError – If node cpuinfo is not available.
static cpu_range_per_node_str(node, cpu_node, skip_cnt=0, cpu_cnt=0, sep='-', smt_used=False)

Return string of node related range of CPU numbers, e.g. 0-4.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_cnt (int) – Count of cpus to return, if 0 then return all.
  • sep (str) – Separator, default: “-”.
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

String of node related range of CPU numbers.

Return type:

str

static cpu_slice_of_list_per_node(node, cpu_node, skip_cnt=0, cpu_cnt=0, smt_used=False)

Return string of node related list of CPU numbers.

Parameters:
  • node (dict) – Node dictionary with cpuinfo.
  • cpu_node (int) – Numa node number.
  • skip_cnt (int) – Skip first “skip_cnt” CPUs.
  • cpu_cnt (int) – Count of cpus to return, if 0 then return all.
  • smt_used (bool) – True - we want to use SMT, otherwise false.
Returns:

Cpu numbers related to numa from argument.

Return type:

list

Raises:

RuntimeError – If we require more cpus than available.

static get_cpu_layout_from_all_nodes(nodes)
Retrieve cpu layout from all nodes, assuming all nodes
are Linux nodes.
Parameters:nodes (dict) – DICT__nodes from Topology.DICT__nodes.
Raises:RuntimeError – If the ssh command “lscpu -p” fails.
static is_smt_enabled(cpu_info)

Uses CPU mapping to find out if SMT is enabled or not. If SMT is enabled, the L1d,L1i,L2,L3 setting is the same for two processors. These two processors are two threads of one core.

Parameters:cpu_info (list) – CPU info, the output of “lscpu -p”.
Returns:True if SMT is enabled, False if SMT is disabled.
Return type:bool

2.11. DUTSetup suite

DUT setup library.

class resources.libraries.python.DUTSetup.DUTSetup

Bases: object

Contains methods for setting up DUTs.

static crypto_device_init(node, numvfs)

Init Crypto QAT device virtual functions on DUT.

Parameters:
  • node (dict) – DUT node.
  • numvfs (int) – Number of VFs to initialize, 0 - disable the VFs.
Returns:

nothing

Raises:

RuntimeError – If failed to stop VPP or QAT failed to initialize.

static crypto_device_verify(node, force_init=False, numvfs=32)

Verify if Crypto QAT device virtual functions are initialized on all DUTs. If parameter force initialization is set to True, then try to initialize or disable QAT.

Parameters:
  • node (dict) – DUT node.
  • force_init (bool) – If True then try to initialize to specific value.
  • numvfs (int) – Number of VFs to initialize, 0 - disable the VFs.
Returns:

nothing

Raises:

RuntimeError – If QAT is not initialized or failed to initialize.

static get_pci_dev_driver(node, pci_addr)

Get current PCI device driver on node.

Parameters:
  • node (dict) – DUT node.
  • pci_addr (str) – PCI device address.
Returns:

Driver or None

Raises:

RuntimeError – If PCI rescan or lspci command execution failed.

static get_vpp_pid(node)

Get PID of running VPP process.

Parameters:node (dict) – DUT node.
Returns:PID
Return type:int

:raises RuntimeError if it is not possible to get the PID.

static get_vpp_pids(nodes)

Get PID of running VPP process on all DUTs.

Parameters:nodes (dict) – DUT nodes.
Returns:PIDs
Return type:dict
static kernel_module_load(node, module)

Load kernel module on node.

Parameters:
  • node (dict) – DUT node.
  • module (str) – Module to load.
Returns:

nothing

Raises:

RuntimeError – If loading failed.

static kernel_module_verify(node, module, force_load=False)

Verify if kernel module is loaded on all DUTs. If parameter force load is set to True, then try to load the modules.

Parameters:
  • node (dict) – DUT node.
  • module (str) – Module to verify.
  • force_load (bool) – If True then try to load module.
Returns:

nothing

Raises:

RuntimeError – If module is not loaded or failed to load.

static pci_driver_bind(node, pci_addr, driver)

Bind PCI device to driver on node.

Parameters:
  • node (dict) – DUT node.
  • pci_addr (str) – PCI device address.
  • driver (str) – Driver to bind.
Returns:

nothing

Raises:

RuntimeError – If PCI device bind failed.

static pci_driver_unbind(node, pci_addr)

Unbind PCI device from current driver on node.

Parameters:
  • node (dict) – DUT node.
  • pci_addr (str) – PCI device address.
Returns:

nothing

Raises:

RuntimeError – If PCI device unbind failed.

static setup_all_duts(nodes)

Prepare all DUTs in given topology for test execution.

static setup_dut(node)

Run script over SSH to setup the DUT node.

Parameters:node (dict) – DUT node to set up.
Raises:Exception – If the DUT setup fails.
static show_vpp_version_on_all_duts(nodes)

Show VPP version verbose on all DUTs.

Parameters:nodes (dict) – VPP nodes
static start_vpp_service_on_all_duts(nodes)

Start up the VPP service on all nodes.

Parameters:nodes (dict) – Nodes in the topology.
static vpp_api_trace_dump(node)

Run “api trace custom-dump” CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_api_trace_save(node)

Run “api trace save” CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_enable_traces_on_all_duts(nodes)

Enable vpp packet traces on all DUTs in the given topology.

Parameters:nodes (dict) – Nodes in the topology.
static vpp_enable_traces_on_dut(node)

Enable vpp packet traces on the DUT node.

Parameters:node (dict) – DUT node to set up.
static vpp_show_crypto_device_mapping(node)

Run “show crypto device mapping” CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_show_version_verbose(node)

Run “show version verbose” CLI command.

Parameters:node (dict) – Node to run command on.

2.12. Dhcp suite

DHCP utilities for VPP.

class resources.libraries.python.Dhcp.DhcpClient

Bases: object

DHCP Client utilities.

static set_dhcp_client_on_interface(vpp_node, interface, hostname=None)

Set DHCP client on interface.

Parameters:
  • vpp_node (dict) – VPP node to set DHCP client on.
  • interface (str) – Interface name to set DHCP client on.
  • hostname (str) – Hostname used in DHCP DISCOVER.
Raises:

RuntimeError – If unable to set DHCP client on interface.

class resources.libraries.python.Dhcp.DhcpProxy

Bases: object

DHCP Proxy utilities.

static dhcp_proxy_config(vpp_node, server_address, source_address)

Set DHCP proxy.

Parameters:
  • vpp_node (dict) – VPP node to set DHCP proxy.
  • server_address (str) – DHCP server IP address.
  • source_address (str) – DHCP proxy address.
Raises:

RuntimeError – If unable to set DHCP proxy.

static vpp_get_dhcp_proxy(node, ip_version)

Retrieve DHCP relay configuration.

Parameters:
  • node (dict) – VPP node.
  • ip_version (str) – IP protocol version: ipv4 or ipv6.
Returns:

DHCP relay data.

Return type:

list

2.13. DpdkUtil suite

Dpdk Utilities Library.

class resources.libraries.python.DpdkUtil.DpdkUtil

Bases: object

Utilities for DPDK.

static dpdk_testpmd_start(node, **args)

Start DPDK testpmd app on VM node.

Parameters:
  • node (dict) – VM Node to start testpmd on.
  • args (dict) – List of testpmd parameters.
Returns:

nothing

static dpdk_testpmd_stop(node)

Stop DPDK testpmd app on node.

Parameters:node (dict) – Node to stop testpmd on.
Returns:nothing
static get_eal_options(**args)

Create EAL parameters string.

Parameters:args (dict) – List of testpmd parameters.
Returns:EAL parameters string.
Return type:str
static get_pmd_options(**args)

Create PMD parameters string.

Parameters:args (dict) – List of testpmd parameters.
Returns:PMD parameters string.
Return type:str

2.14. DropRateSearch suite

Drop rate search algorithms

class resources.libraries.python.DropRateSearch.DropRateSearch

Bases: object

Abstract class with search algorithm implementation.

Binary search of rate with loss below acceptance criteria.

Parameters:
  • b_min (float) – Min range rate.
  • b_max (float) – Max range rate.
  • traffic_type (str) – Traffic profile.
  • skip_max_rate (bool) – Start with max rate first
Returns:

nothing

Raises:

ValueError if input values are not valid

Combined search of rate with loss below acceptance criteria.

Parameters:
  • start_rate (float) – Initial rate.
  • traffic_type (str) – Traffic profile.
Returns:

nothing

Raises:

RuntimeError if linear search failed

static floats_are_close_equal(num_a, num_b, rel_tol=1e-09, abs_tol=0.0)

Compares two float numbers for close equality.

Parameters:
  • num_a (float) – First number to compare.
  • num_b (float) – Second number to compare.
  • rel_tol=1e-9 – The relative tolerance.
  • abs_tol=0.0 – The minimum absolute tolerance level.
Returns:

Returns True if num_a is close in value to num_b or equal. False otherwise.

Return type:

boolean

Raises:

ValueError if input values are not valid

get_binary_convergence_threshold()

Get convergence for binary search.

Returns:Treshold value number.
Return type:float
get_duration()

Return configured duration of single traffic run.

Returns:Number of seconds for traffic to run.
Return type:int
get_latency()

Return min/avg/max latency.

Returns:Latency stats.
Return type:list
get_loss_acceptance()

Return configured loss acceptance treshold.

Returns:Loss acceptance treshold.
Return type:float
get_max_attempts()

Return maximum number of traffic runs during one rate step.

Returns:Number of traffic runs.
Return type:int
get_rate_type_str()

Return rate type representation.

Returns:String representation of rate type.
Return type:str
Raises:ValueError if rate type is unknown

Linear search of rate with loss below acceptance criteria.

Parameters:
  • start_rate (float) – Initial rate.
  • traffic_type (str) – Traffic profile.
Returns:

nothing

Raises:

ValueError if start rate is not in range

loss_acceptance_type_is_percentage()
Return true if loss acceptance treshold type is percentage,
false otherwise.
Returns:True if loss acceptance treshold type is percentage.
Return type:boolean
measure_loss(rate, frame_size, loss_acceptance, loss_acceptance_type, traffic_type)

Send traffic from TG and measure count of dropped frames.

Parameters:
  • rate (int) – Offered traffic load.
  • frame_size (str) – Size of frame.
  • loss_acceptance (float) – Permitted drop ratio or frames count.
  • loss_acceptance_type (LossAcceptanceType) – Type of permitted loss.
  • traffic_type (str) – Traffic profile ([2,3]-node-L[2,3], ...).
Returns:

Drop threshold exceeded? (True/False)

:rtype bool

set_binary_convergence_threshold(convergence)

Set convergence for binary search.

Parameters:convergence (float) – Treshold value number.
Returns:nothing
set_duration(duration)

Set the duration of single traffic run.

Parameters:duration (int) – Number of seconds for traffic to run.
Returns:nothing
set_loss_acceptance(loss_acceptance)

Set loss acceptance treshold for PDR search.

Parameters:loss_acceptance (str) – Loss acceptance treshold for PDR search.
Returns:nothing
Raises:ValueError if loss acceptance is lower than zero
set_loss_acceptance_type_frames()

Set loss acceptance treshold type to frames.

Returns:nothing
set_loss_acceptance_type_percentage()

Set loss acceptance treshold type to percentage.

Returns:nothing
set_max_attempts(max_attempts)

Set maximum number of traffic runs during one rate step.

Parameters:max_attempts (int) – Number of traffic runs.
Returns:nothing
Raises:ValueError if max attempts is lower than zero
set_search_frame_size(frame_size)

Set size of frames to send.

Parameters:frame_size (str) – Size of frames.
Returns:nothing
set_search_linear_step(step_rate)

Set step size for linear search.

Parameters:step_rate (float) – Linear search step size.
Returns:nothing
set_search_rate_boundaries(max_rate, min_rate)

Set search boundaries: min,max.

Parameters:
  • max_rate (float) – Upper value of search boundaries.
  • min_rate (float) – Lower value of search boundaries.
Returns:

nothing

Raises:

ValueError if min rate is lower than 0 and higher than max rate

set_search_rate_type_bps()

Set rate type to bits per second.

Returns:nothing
set_search_rate_type_percentage()

Set rate type to percentage of linerate.

Returns:nothing
set_search_rate_type_pps()

Set rate type to packets per second.

Returns:nothing
set_search_result_type_best_of_n()

Set type of search result evaluation to Best of N.

Returns:nothing
set_search_result_type_worst_of_n()

Set type of search result evaluation to Worst of N.

Returns:nothing
verify_search_result()

Fail if search was not successful.

Returns:Result rate and latency stats.
Return type:tuple
Raises:Exception if search failed
class resources.libraries.python.DropRateSearch.LossAcceptanceType

Bases: enum.Enum

Type of the loss acceptance criteria.

FRAMES = 1
PERCENTAGE = 2
class resources.libraries.python.DropRateSearch.RateType

Bases: enum.Enum

Type of rate units.

BITS_PER_SECOND = 3
PACKETS_PER_SECOND = 2
PERCENTAGE = 1
class resources.libraries.python.DropRateSearch.SearchDirection

Bases: enum.Enum

Direction of linear search.

BOTTOM_UP = 2
TOP_DOWN = 1
class resources.libraries.python.DropRateSearch.SearchResultType

Bases: enum.Enum

Type of search result evaluation.

BEST_OF_N = 1
WORST_OF_N = 2
class resources.libraries.python.DropRateSearch.SearchResults

Bases: enum.Enum

Result of the drop rate search.

FAILURE = 2
SUCCESS = 1
SUSPICIOUS = 3

2.15. HTTPRequest suite

Implementation of HTTP requests GET, PUT, POST and DELETE used in communication with Honeycomb.

The HTTP requests are implemented in the class HTTPRequest which uses requests.request.

class resources.libraries.python.HTTPRequest.HTTPCodes

Bases: enum.IntEnum

HTTP status codes

ACCEPTED = 201
CONFLICT = 409
FORBIDDEN = 403
INTERNAL_SERVER_ERROR = 500
NOT_FOUND = 404
OK = 200
SERVICE_UNAVAILABLE = 503
UNAUTHORIZED = 401
class resources.libraries.python.HTTPRequest.HTTPRequest

Bases: object

A class implementing HTTP requests GET, PUT, POST and DELETE used in communication with Honeycomb.

The communication with Honeycomb and processing of all exceptions is done in the method _http_request which uses requests.request to send requests and receive responses. The received status code and content of response are logged on the debug level. All possible exceptions raised by requests.request are also processed there.

The other methods (get, put, post and delete) use _http_request to send corresponding request.

These methods must not be used as keywords in tests. Use keywords implemented in the module HoneycombAPIKeywords instead.

static create_full_url(ip_addr, port, path)

Creates full url including host, port, and path to data.

Parameters:
  • ip_addr (str) – Server IP.
  • port (str or int) – Communication port.
  • path (str) – Path to data.
Returns:

Full url.

Return type:

str

static delete(node, path, timeout=15)

Sends a DELETE request and returns the response and status code.

Parameters:
  • node – Honeycomb node.
  • path – URL path, e.g. /index.html.
  • timeout – How long to wait for the server to send data before

giving up, as a float, or a (connect timeout, read timeout) tuple. :type node: dict :type path: str :type timeout: float or tuple :return: Status code and content of response. :rtype: tuple

static get(node, path, headers=None, timeout=15, enable_logging=True)

Sends a GET request and returns the response and status code.

Parameters:
  • node – Honeycomb node.
  • path – URL path, e.g. /index.html.
  • headers – Dictionary of HTTP Headers to send with the Request.
  • timeout – How long to wait for the server to send data before

giving up, as a float, or a (connect timeout, read timeout) tuple. :param enable_logging: Used to suppress errors when checking Honeycomb state during suite setup and teardown. When True, logging is enabled, otherwise logging is disabled. :type node: dict :type path: str :type headers: dict :type timeout: float or tuple :type enable_logging: bool :return: Status code and content of response. :rtype: tuple

static post(node, path, headers=None, payload=None, json=None, timeout=15, enable_logging=True)

Sends a POST request and returns the response and status code.

Parameters:
  • node – Honeycomb node.
  • path – URL path, e.g. /index.html.
  • headers – Dictionary of HTTP Headers to send with the Request.
  • payload – Dictionary, bytes, or file-like object to send in

the body of the Request. :param json: JSON formatted string to send in the body of the Request. :param timeout: How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple. :param enable_logging: Used to suppress errors when checking ODL state during suite setup and teardown. When True, logging is enabled, otherwise logging is disabled. :type node: dict :type path: str :type headers: dict :type payload: dict, bytes, or file-like object :type json: str :type timeout: float or tuple :type enable_logging: bool :return: Status code and content of response. :rtype: tuple

static put(node, path, headers=None, payload=None, json=None, timeout=15)

Sends a PUT request and returns the response and status code.

Parameters:
  • node – Honeycomb node.
  • path – URL path, e.g. /index.html.
  • headers – Dictionary of HTTP Headers to send with the Request.
  • payload – Dictionary, bytes, or file-like object to send in

the body of the Request. :param json: JSON formatted string to send in the body of the Request. :param timeout: How long to wait for the server to send data before giving up, as a float, or a (connect timeout, read timeout) tuple. :type node: dict :type path: str :type headers: dict :type payload: dict, bytes, or file-like object :type json: str :type timeout: float or tuple :return: Status code and content of response. :rtype: tuple

exception resources.libraries.python.HTTPRequest.HTTPRequestError(msg, details='', enable_logging=True)

Bases: exceptions.Exception

Exception raised by HTTPRequest objects.

When raising this exception, put this information to the message in this order: - short description of the encountered problem, - relevant messages if there are any collected, e.g., from caught

exception,
  • relevant data if there are any collected.

The logging is performed on two levels: 1. error - short description of the problem; 2. debug - detailed information.

2.16. IPUtil suite

Common IP utilities library.

class resources.libraries.python.IPUtil.IPUtil

Bases: object

Common IP utilities

static get_linux_interface_name(node, pci_addr)

Get the interface name.

Parameters:
  • node (dict) – Node where to execute command.
  • pci_addr (str) – PCI address
Returns:

Interface name

Return type:

str

Raises:

RuntimeError – If cannot get the information about interfaces.

static int_to_ip(ip_int)

Convert IP address from integer representation (e.g. 167772161) to string format (10.0.0.1).

Parameters:ip_int (int) – IP address in integer representation.
Returns:String representation of IP address.
Return type:str
static ip_addresses_should_be_equal(ip1, ip2)

Fails if the given IP addresses are unequal.

Parameters:
  • ip1 (str) – IPv4 or IPv6 address.
  • ip2 (str) – IPv4 or IPv6 address.
static ip_to_int(ip_str)

Convert IP address from string format (e.g. 10.0.0.1) to integer representation (167772161).

Parameters:ip_str (str) – IP address in string representation.
Returns:Integer representation of IP address.
Return type:int
static linux_enable_forwarding(node, ip_ver='ipv4')

Enable forwarding on a Linux node, e.g. VM.

Parameters:
  • node (dict) – Node to enable forwarding on.
  • ip_ver (str) – IP version, ‘ipv4’ or ‘ipv6’.
static set_linux_interface_ip(node, interface, ip_addr, prefix, namespace=None)

Set IP address to interface in linux.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
  • ip_addr (str) – IP to be set on interface.
  • prefix (int) – IP prefix.
  • namespace (str) – Execute command in namespace. Optional
Raises:

RuntimeError – IP could not be set.

static set_linux_interface_route(node, interface, route, namespace=None)

Set route via interface in linux.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
  • route (str) – Route to be added via interface.
  • namespace (str) – Execute command in namespace. Optional parameter.
static set_linux_interface_up(node, interface)

Set the specified interface up.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
Raises:

RuntimeError – If the interface could not be set up.

static setup_network_namespace(node, namespace_name, interface_name, ip_addr, prefix)

Setup namespace on given node and attach interface and IP to this namespace. Applicable also on TG node.

Parameters:
  • node (dict) – Node to set namespace on.
  • namespace_name (str) – Namespace name.
  • interface_name – Interface name.
  • ip_addr (str) – IP address of namespace’s interface.
  • prefix (int) – IP address prefix length.
static vpp_ip_probe(node, interface, addr, if_type='key')

Run ip probe on VPP node.

Parameters:
  • node (dict) – VPP node.
  • interface (str) – Interface key or name.
  • addr (str) – IPv4/IPv6 address.
  • if_type (str) – Interface type
Raises:
  • ValueError – If the if_type is unknown.
  • Exception – If vpp probe fails.
resources.libraries.python.IPUtil.convert_ipv4_netmask_prefix(network)

Convert network mask to equivalent network prefix length or vice versa.

Example: mask 255.255.0.0 -> prefix length 16 :param network: Network mask or network prefix length. :type network: str or int :returns: Network mask or network prefix length. :rtype: str or int

2.17. IPsecUtil suite

IPsec utilities library.

class resources.libraries.python.IPsecUtil.CryptoAlg(alg_name, scapy_name, key_len)

Bases: enum.Enum

Encryption algorithms.

AES_CBC_128 = ('aes-cbc-128', 'AES-CBC', 16)
AES_CBC_192 = ('aes-cbc-192', 'AES-CBC', 24)
AES_CBC_256 = ('aes-cbc-256', 'AES-CBC', 32)
AES_GCM_128 = ('aes-gcm-128', 'AES-GCM', 20)
class resources.libraries.python.IPsecUtil.IPsecUtil

Bases: object

IPsec utilities.

static crypto_alg_aes_cbc_128()

Return encryption algorithm aes-cbc-128.

Returns:CryptoAlg enum AES_CBC_128 object.
Return type:CryptoAlg
static crypto_alg_aes_cbc_192()

Return encryption algorithm aes-cbc-192.

Returns:CryptoAlg enum AES_CBC_192 objec.
Return type:CryptoAlg
static crypto_alg_aes_cbc_256()

Return encryption algorithm aes-cbc-256.

Returns:CryptoAlg enum AES_CBC_256 object.
Return type:CryptoAlg
static crypto_alg_aes_gcm_128()

Return encryption algorithm aes-gcm-128.

Returns:CryptoAlg enum AES_GCM_128 object.
Return type:CryptoAlg
static get_crypto_alg_key_len(crypto_alg)

Return encryption algorithm key length.

Parameters:crypto_alg (CryptoAlg) – Encryption algorithm.
Returns:Key length.
Return type:int
static get_crypto_alg_scapy_name(crypto_alg)

Return encryption algorithm scapy name.

Parameters:crypto_alg (CryptoAlg) – Encryption algorithm.
Returns:Algorithm scapy name.
Return type:str
static get_integ_alg_key_len(integ_alg)

Return integrity algorithm key length.

Parameters:integ_alg (IntegAlg) – Integrity algorithm.
Returns:Key length.
Return type:int
static get_integ_alg_scapy_name(integ_alg)

Return integrity algorithm scapy name.

Parameters:integ_alg (IntegAlg) – Integrity algorithm.
Returns:Algorithm scapy name.
Return type:str
static integ_alg_aes_gcm_128()

Return integrity algorithm AES-GCM-128.

Returns:IntegAlg enum AES_GCM_128 object.
Return type:IntegAlg
static integ_alg_sha1_96()

Return integrity algorithm SHA1-96.

Returns:IntegAlg enum SHA1_96 object.
Return type:IntegAlg
static integ_alg_sha_256_128()

Return integrity algorithm SHA-256-128.

Returns:IntegAlg enum SHA_256_128 object.
Return type:IntegAlg
static integ_alg_sha_384_192()

Return integrity algorithm SHA-384-192.

Returns:IntegAlg enum SHA_384_192 object.
Return type:IntegAlg
static integ_alg_sha_512_256()

Return integrity algorithm SHA-512-256.

Returns:IntegAlg enum SHA_512_256 object.
Return type:IntegAlg
static policy_action_bypass()

Return policy action bypass.

Returns:PolicyAction enum BYPASS object.
Return type:PolicyAction
static policy_action_discard()

Return policy action discard.

Returns:PolicyAction enum DISCARD object.
Return type:PolicyAction
static policy_action_protect()

Return policy action protect.

Returns:PolicyAction enum PROTECT object.
Return type:PolicyAction
static vpp_ipsec_add_multiple_tunnels(node1, node2, interface1, interface2, n_tunnels, crypto_alg, crypto_key, integ_alg, integ_key, tunnel_ip1, tunnel_ip2, raddr_ip1, raddr_ip2, raddr_range)

Create multiple IPsec tunnels between two VPP nodes.

Parameters:
  • node1 – VPP node 1 to create tunnels.
  • node2 – VPP node 2 to create tunnels.
  • interface1 – Interface name or sw_if_index on node 1.
  • interface2 – Interface name or sw_if_index on node 2.
  • n_tunnels – Number of tunnels to create.
  • crypto_alg – The encryption algorithm name.
  • crypto_key – The encryption key string.
  • integ_alg – The integrity algorithm name.
  • integ_key – The integrity key string.
  • tunnel_ip1 – Tunnel node1 IPv4 address.
  • tunnel_ip2 – Tunnel node2 IPv4 address.
  • raddr_ip1 – Policy selector remote IPv4 start address for the

first tunnel in direction node1->node2. :param raddr_ip2: Policy selector remote IPv4 start address for the first tunnel in direction node2->node1. :param raddr_range: Mask specifying range of Policy selector Remote IPv4 addresses. Valid values are from 1 to 32. :type node1: dict :type node2: dict :type interface1: str or int :type interface2: str or int :type n_tunnels: int :type crypto_alg: CryptoAlg :type crypto_key: str :type integ_alg: str :type integ_key: str :type tunnel_ip1: str :type tunnel_ip2: str :type raddr_ip1: string :type raddr_ip2: string :type raddr_range: int

static vpp_ipsec_add_sad_entries(node, n_entries, sad_id, spi, crypto_alg, crypto_key, integ_alg, integ_key, tunnel_src=None, tunnel_dst=None)

Create multiple Security Association Database entries on VPP node.

Parameters:
  • node – VPP node to add SAD entry on.
  • n_entries – Number of SAD entries to be created.
  • sad_id – First SAD entry ID. All subsequent SAD entries will have

id incremented by 1. :param spi: Security Parameter Index of first SAD entry. All subsequent SAD entries will have spi incremented by 1. :param crypto_alg: The encryption algorithm name. :param crypto_key: The encryption key string. :param integ_alg: The integrity algorithm name. :param integ_key: The integrity key string. :param tunnel_src: Tunnel header source IPv4 or IPv6 address. If not specified ESP transport mode is used. :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If not specified ESP transport mode is used. :type node: dict :type n_entries: int :type sad_id: int :type spi: int :type crypto_alg: CryptoAlg :type crypto_key: str :type integ_alg: IntegAlg :type integ_key: str :type tunnel_src: str :type tunnel_dst: str

static vpp_ipsec_add_sad_entry(node, sad_id, spi, crypto_alg, crypto_key, integ_alg, integ_key, tunnel_src=None, tunnel_dst=None)

Create Security Association Database entry on the VPP node.

Parameters:
  • node – VPP node to add SAD entry on.
  • sad_id – SAD entry ID.
  • spi – Security Parameter Index of this SAD entry.
  • crypto_alg – The encryption algorithm name.
  • crypto_key – The encryption key string.
  • integ_alg – The integrity algorithm name.
  • integ_key – The integrity key string.
  • tunnel_src – Tunnel header source IPv4 or IPv6 address. If not

specified ESP transport mode is used. :param tunnel_dst: Tunnel header destination IPv4 or IPv6 address. If not specified ESP transport mode is used. :type node: dict :type sad_id: int :type spi: int :type crypto_alg: CryptoAlg :type crypto_key: str :type integ_alg: str :type integ_key: str :type tunnel_src: str :type tunnel_dst: str

static vpp_ipsec_add_spd(node, spd_id)

Create Security Policy Database on the VPP node.

Parameters:
  • node (dict) – VPP node to add SPD on.
  • spd_id (int) – SPD ID.
static vpp_ipsec_create_tunnel_interfaces(node1, node2, if1_ip_addr, if2_ip_addr, if1_key, if2_key, n_tunnels, crypto_alg, crypto_key, integ_alg, integ_key, raddr_ip1, raddr_ip2, raddr_range)

Create multiple IPsec tunnel interfaces between two VPP nodes.

Parameters:
  • node1 – VPP node 1 to create tunnel interfaces.
  • node2 – VPP node 2 to create tunnel interfaces.
  • if1_ip_addr – VPP node 1 interface IP4 address.
  • if2_ip_addr – VPP node 2 interface IP4 address.
  • if1_key – VPP node 1 interface key from topology file.
  • if2_key – VPP node 2 interface key from topology file.
  • n_tunnels – Number of tunnell interfaces to create.
  • crypto_alg – The encryption algorithm name.
  • crypto_key – The encryption key string.
  • integ_alg – The integrity algorithm name.
  • integ_key – The integrity key string.
  • raddr_ip1 – Policy selector remote IPv4 start address for the

first tunnel in direction node1->node2. :param raddr_ip2: Policy selector remote IPv4 start address for the first tunnel in direction node2->node1. :param raddr_range: Mask specifying range of Policy selector Remote IPv4 addresses. Valid values are from 1 to 32. :type node1: dict :type node2: dict :type if1_ip_addr: str :type if2_ip_addr: str :type if1_key: str :type if2_key: str :type n_tunnels: int :type crypto_alg: CryptoAlg :type crypto_key: str :type integ_alg: IntegAlg :type integ_key: str :type raddr_ip1: string :type raddr_ip2: string :type raddr_range: int

static vpp_ipsec_sa_set_key(node, sa_id, crypto_key, integ_key)

Update Security Association (SA) keys.

Parameters:
  • node (dict) – VPP node to update SA keys.
  • sa_id (int) – SAD entry ID.
  • crypto_key (str) – The encryption key string.
  • integ_key (str) – The integrity key string.
static vpp_ipsec_show(node)

Run “show ipsec” debug CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_ipsec_spd_add_entries(node, n_entries, spd_id, priority, inbound, sa_id, raddr_ip, raddr_range)

Create multiple Security Policy Database entries on the VPP node.

Parameters:
  • node – VPP node to add SPD entries on.
  • n_entries – Number of SPD entries to be added.
  • spd_id – SPD ID to add entries on.
  • priority – SPD entries priority, higher number = higher priority.
  • inbound – If True policy is for inbound traffic, otherwise

outbound. :param sa_id: SAD entry ID for first entry. Each subsequent entry will SAD entry ID incremented by 1. :param raddr_ip: Policy selector remote IPv4 start address for the first entry. Remote IPv4 end address will be calculated depending on raddr_range parameter. Each subsequent entry will have start address next after IPv4 end address of previous entry. :param raddr_range: Mask specifying range of Policy selector Remote IPv4 addresses. Valid values are from 1 to 32. :type node: dict :type n_entries: int :type spd_id: int :type priority: int :type inbound: bool :type sa_id: int :type raddr_ip: string :type raddr_range: int

static vpp_ipsec_spd_add_entry(node, spd_id, priority, action, inbound=True, sa_id=None, laddr_range=None, raddr_range=None, proto=None, lport_range=None, rport_range=None)

Create Security Policy Database entry on the VPP node.

Parameters:
  • node – VPP node to add SPD entry on.
  • spd_id – SPD ID to add entry on.
  • priority – SPD entry priority, higher number = higher priority.
  • action – Policy action.
  • inbound – If True policy is for inbound traffic, otherwise

outbound. :param sa_id: SAD entry ID for protect action. :param laddr_range: Policy selector local IPv4 or IPv6 address range in format IP/prefix or IP/mask. If no mask is provided, it’s considered to be /32. :param raddr_range: Policy selector remote IPv4 or IPv6 address range in format IP/prefix or IP/mask. If no mask is provided, it’s considered to be /32. :param proto: Policy selector next layer protocol number. :param lport_range: Policy selector local TCP/UDP port range in format <port_start>-<port_end>. :param rport_range: Policy selector remote TCP/UDP port range in format <port_start>-<port_end>. :type node: dict :type spd_id: int :type priority: int :type action: PolicyAction :type inbound: bool :type sa_id: int :type laddr_range: string :type raddr_range: string :type proto: int :type lport_range: string :type rport_range: string

static vpp_ipsec_spd_add_if(node, spd_id, interface)

Add interface to the Security Policy Database.

Parameters:
  • node (dict) – VPP node.
  • spd_id (int) – SPD ID to add interface on.
  • interface (str or int) – Interface name or sw_if_index.
class resources.libraries.python.IPsecUtil.IntegAlg(alg_name, scapy_name, key_len)

Bases: enum.Enum

Integrity algorithm.

AES_GCM_128 = ('aes-gcm-128', 'AES-GCM', 20)
SHA1_96 = ('sha1-96', 'HMAC-SHA1-96', 20)
SHA_256_128 = ('sha-256-128', 'SHA2-256-128', 32)
SHA_384_192 = ('sha-384-192', 'SHA2-384-192', 48)
SHA_512_256 = ('sha-512-256', 'SHA2-512-256', 64)
class resources.libraries.python.IPsecUtil.PolicyAction(string)

Bases: enum.Enum

Policy actions.

BYPASS = 'bypass'
DISCARD = 'discard'
PROTECT = 'protect'

2.18. IPv4NodeAddress suite

Robot framework variable file.

Create dictionary variable nodes_ipv4_addr of IPv4 addresses from available networks.

class resources.libraries.python.IPv4NodeAddress.IPv4NetworkGenerator(networks)

Bases: object

IPv4 network generator.

next_network()
Returns:Next network in form (IPv4Network, subnet).
Raises:StopIteration if there are no more elements.
resources.libraries.python.IPv4NodeAddress.get_variables(nodes, networks=['192.168.1.0/24', '192.168.2.0/24', '192.168.3.0/24', '192.168.4.0/24', '192.168.5.0/24', '192.168.6.0/24', '192.168.7.0/24', '192.168.8.0/24', '192.168.9.0/24', '192.168.10.0/24', '192.168.11.0/24', '192.168.12.0/24', '192.168.13.0/24', '192.168.14.0/24', '192.168.15.0/24', '192.168.16.0/24', '192.168.17.0/24', '192.168.18.0/24', '192.168.19.0/24', '192.168.20.0/24', '192.168.21.0/24', '192.168.22.0/24', '192.168.23.0/24', '192.168.24.0/24', '192.168.25.0/24', '192.168.26.0/24', '192.168.27.0/24', '192.168.28.0/24', '192.168.29.0/24', '192.168.30.0/24', '192.168.31.0/24', '192.168.32.0/24', '192.168.33.0/24', '192.168.34.0/24', '192.168.35.0/24', '192.168.36.0/24', '192.168.37.0/24', '192.168.38.0/24', '192.168.39.0/24', '192.168.40.0/24', '192.168.41.0/24', '192.168.42.0/24', '192.168.43.0/24', '192.168.44.0/24', '192.168.45.0/24', '192.168.46.0/24', '192.168.47.0/24', '192.168.48.0/24', '192.168.49.0/24', '192.168.50.0/24', '192.168.51.0/24', '192.168.52.0/24', '192.168.53.0/24', '192.168.54.0/24', '192.168.55.0/24', '192.168.56.0/24', '192.168.57.0/24', '192.168.58.0/24', '192.168.59.0/24', '192.168.60.0/24', '192.168.61.0/24', '192.168.62.0/24', '192.168.63.0/24', '192.168.64.0/24', '192.168.65.0/24', '192.168.66.0/24', '192.168.67.0/24', '192.168.68.0/24', '192.168.69.0/24', '192.168.70.0/24', '192.168.71.0/24', '192.168.72.0/24', '192.168.73.0/24', '192.168.74.0/24', '192.168.75.0/24', '192.168.76.0/24', '192.168.77.0/24', '192.168.78.0/24', '192.168.79.0/24', '192.168.80.0/24', '192.168.81.0/24', '192.168.82.0/24', '192.168.83.0/24', '192.168.84.0/24', '192.168.85.0/24', '192.168.86.0/24', '192.168.87.0/24', '192.168.88.0/24', '192.168.89.0/24', '192.168.90.0/24', '192.168.91.0/24', '192.168.92.0/24', '192.168.93.0/24', '192.168.94.0/24', '192.168.95.0/24', '192.168.96.0/24', '192.168.97.0/24', '192.168.98.0/24', '192.168.99.0/24'])

Special robot framework method that returns dictionary nodes_ipv4_addr, mapping of node and interface name to IPv4 address.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • networks (list) – List of available IPv4 networks.

Note

Robot framework calls it automatically.

2.19. IPv4Setup suite

IPv4 setup library

class resources.libraries.python.IPv4Setup.Dut(node_info)

Bases: resources.libraries.python.IPv4Setup.IPv4Node

Device under test

arp_ping(destination_address, source_interface)

Does nothing.

exec_vat(script, **args)

Wrapper for VAT executor.

Parameters:
  • script (str) – Script to execute.
  • args (dict) – Parameters to the script.
Returns:

nothing

flush_ip_addresses(interface)
get_sw_if_index(interface)

Get sw_if_index of specified interface from current node.

Parameters:interface (str) – Interface name.
Returns:sw_if_index of the interface or None.
Return type:int
ping(destination_address, source_interface)
set_arp(iface_key, ip_address, mac_address)

Set entry in ARP cache.

Parameters:
  • iface_key (str) – Interface key.
  • ip_address (str) – IP address.
  • mac_address (str) – MAC address.
set_ip(interface, address, prefix_length)
set_route(network, prefix_length, gateway, interface, count=1)
unset_route(network, prefix_length, gateway, interface)
class resources.libraries.python.IPv4Setup.IPv4Node(node_info)

Bases: object

Abstract class of a node in a topology.

flush_ip_addresses(interface)

Flush all IPv4 addresses from specified interface.

Parameters:interface (str) – Interface name.
Returns:nothing
ping(destination_address, source_interface)

Send an ICMP request to destination node.

Parameters:
  • destination_address (str) – Address to send the ICMP request.
  • source_interface (str) – Source interface name.
Returns:

nothing

set_ip(interface, address, prefix_length)

Configure IPv4 address on interface.

Parameters:
  • interface (str) – Interface name.
  • address (str) – IPv4 address.
  • prefix_length (int) – IPv4 prefix length.
Returns:

nothing

set_route(network, prefix_length, gateway, interface, count=1)

Configure IPv4 route.

Parameters:
  • network (str) – Network IPv4 address.
  • prefix_length (int) – IPv4 prefix length.
  • gateway (str) – IPv4 address of the gateway.
  • interface (str) – Interface name.
  • count – Number of consecutive routes to add.
Returns:

nothing

unset_route(network, prefix_length, gateway, interface)

Remove specified IPv4 route.

Parameters:
  • network (str) – Network IPv4 address.
  • prefix_length (int) – IPv4 prefix length.
  • gateway (str) – IPv4 address of the gateway.
  • interface (str) – Interface name.
Returns:

nothing

class resources.libraries.python.IPv4Setup.IPv4Setup

Bases: object

IPv4 setup in topology.

static add_arp_on_dut(node, iface_key, ip_address, mac_address)

Set ARP cache entree on DUT node.

Parameters:
  • node (dict) – VPP Node in the topology.
  • iface_key (str) – Interface key.
  • ip_address (str) – IP address of the interface.
  • mac_address (str) – MAC address of the interface.
static get_ip_addr(node, iface_key, nodes_addr)

Return IPv4 address of the node port.

Parameters:
  • node (dict) – Node in the topology.
  • iface_key (str) – Interface key of the node.
  • nodes_addr (dict) – Nodes IPv4 addresses.
Returns:

IPv4 address.

Return type:

str

static setup_arp_on_all_duts(nodes_info, nodes_addr)

For all DUT nodes extract MAC and IP addresses of adjacent interfaces from topology and use them to setup ARP entries.

Parameters:nodes_info – Dictionary containing information on all nodes

in topology. :param nodes_addr: Nodes IPv4 addresses. :type nodes_info: dict :type nodes_addr: dict

static vpp_nodes_set_ipv4_addresses(nodes, nodes_addr)

Set IPv4 addresses on all VPP nodes in topology.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • nodes_addr (dict) – Available nodes IPv4 addresses.
Returns:

Affected interfaces as list of (node, interface) tuples.

Return type:

list

class resources.libraries.python.IPv4Setup.Tg(node_info)

Bases: resources.libraries.python.IPv4Setup.IPv4Node

Traffic generator node

arp_ping(destination_address, source_interface)

Execute ‘arping’ command to send one ARP packet from the TG node.

Parameters:
  • destination_address (str) – Destination IP address for the ARP packet.
  • source_interface (str) – Name of an interface to send ARP packet from.
flush_ip_addresses(interface)
ping(destination_address, source_interface)
set_ip(interface, address, prefix_length)
set_route(network, prefix_length, gateway, interface, count=1)
unset_route(network, prefix_length, gateway, interface)
resources.libraries.python.IPv4Setup.get_node(node_info)

Creates a class instance derived from Node based on type.

Parameters:node_info (dict) – Dictionary containing information on nodes in topology.
Returns:Class instance that is derived from Node.

2.20. IPv4Util suite

Implements IPv4 RobotFramework keywords

class resources.libraries.python.IPv4Util.IPv4Util

Bases: object

Implements keywords for IPv4 tests.

static arp_ping(node, interface, ip_address)

Send an ARP ping from the specified node.

Parameters:
  • node (dict) – Node in topology.
  • ip_address (str) – Destination IP address for the ARP packet.
  • interface (str) – Name of an interface to send the ARP packet from.
static flush_ip_addresses(port, node)

See IPv4Node.flush_ip_addresses for more information.

Parameters:
  • port
  • node
Returns:

static get_ip_addr_prefix_length(node, port, nodes_addr)

Get IPv4 address prefix for specified interface.

Parameters:
  • node (dict) – Node dictionary.
  • port (str) – Interface name.
  • nodes_addr (dict) – Available nodes IPv4 addresses.
Returns:

IPv4 prefix length.

Return type:

int

static get_ip_addr_subnet(node, port, nodes_addr)

Get IPv4 subnet of specified interface.

Parameters:
  • node (dict) – Node dictionary.
  • port (int) – Interface name.
  • nodes_addr (dict) – Available nodes IPv4 addresses.
Returns:

IPv4 subnet.

Return type:

str

Get link IPv4 address.

Parameters:
  • link (str) – Link name.
  • nodes_addr (dict) – Available nodes IPv4 addresses.
Returns:

Link IPv4 address.

Return type:

str

Get link IPv4 address prefix.

Parameters:
  • link (str) – Link name.
  • nodes_addr (dict) – Available nodes IPv4 addresses.
Returns:

Link IPv4 address prefix.

Return type:

int

static send_ping_from_node_to_dst(node, destination, namespace=None, ping_count=3, interface=None)

Send a ping from node to destination. Optionally, you can define a namespace and interface from where to send a ping.

Parameters:
  • node (dict) – Node to start ping on.
  • destination (str) – IPv4 address where to send ping.
  • namespace (str) – Namespace to send ping from. Optional
  • ping_count (int) – Number of pings to send. Default 3
  • interface (str) – Interface from where to send ping. Optional
Raises:

RuntimeError – If no response for ping, raise error

static set_interface_address(node, interface, address, prefix_length)

See IPv4Node.set_ip for more information.

Parameters:
  • node (dict) – Node where IP address should be set to.
  • interface (str) – Interface name.
  • address (str) – IP address.
  • prefix_length (int) – Prefix length.
static set_linux_interface_arp(node, interface, ip_addr, mac, namespace=None)

Set arp on interface in linux.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
  • ip_addr (str) – IP address for ARP entry.
  • mac (str) – MAC address.
  • namespace (str) – Execute command in namespace. Optional
Raises:

RuntimeError – Could not set ARP properly.

static set_route(node, network, prefix_length, interface, gateway)

See IPv4Node.set_route for more information.

Parameters:
  • node (dict) – Node where IP address should be set to.
  • network (str) – IP network.
  • prefix_length (int) – Prefix length.
  • interface (str) – Interface name.
  • gateway (str) – Gateway.

2.21. IPv6NodesAddr suite

Robot framework variable file.

Create dictionary variable nodes_ipv6_addr with IPv6 addresses from available networks.

resources.libraries.python.IPv6NodesAddr.get_variables(nodes, networks=['3ffe:0001::/64', '3ffe:0002::/64', '3ffe:0003::/64', '3ffe:0004::/64', '3ffe:0005::/64', '3ffe:0006::/64', '3ffe:0007::/64', '3ffe:0008::/64', '3ffe:0009::/64', '3ffe:000a::/64', '3ffe:000b::/64', '3ffe:000c::/64', '3ffe:000d::/64', '3ffe:000e::/64', '3ffe:000f::/64', '3ffe:0010::/64', '3ffe:0011::/64', '3ffe:0012::/64', '3ffe:0013::/64', '3ffe:0014::/64', '3ffe:0015::/64', '3ffe:0016::/64', '3ffe:0017::/64', '3ffe:0018::/64', '3ffe:0019::/64', '3ffe:001a::/64', '3ffe:001b::/64', '3ffe:001c::/64', '3ffe:001d::/64', '3ffe:001e::/64', '3ffe:001f::/64', '3ffe:0020::/64', '3ffe:0021::/64', '3ffe:0022::/64', '3ffe:0023::/64', '3ffe:0024::/64', '3ffe:0025::/64', '3ffe:0026::/64', '3ffe:0027::/64', '3ffe:0028::/64', '3ffe:0029::/64', '3ffe:002a::/64', '3ffe:002b::/64', '3ffe:002c::/64', '3ffe:002d::/64', '3ffe:002e::/64', '3ffe:002f::/64', '3ffe:0030::/64', '3ffe:0031::/64', '3ffe:0032::/64', '3ffe:0033::/64', '3ffe:0034::/64', '3ffe:0035::/64', '3ffe:0036::/64', '3ffe:0037::/64', '3ffe:0038::/64', '3ffe:0039::/64', '3ffe:003a::/64', '3ffe:003b::/64', '3ffe:003c::/64', '3ffe:003d::/64', '3ffe:003e::/64', '3ffe:003f::/64', '3ffe:0040::/64', '3ffe:0041::/64', '3ffe:0042::/64', '3ffe:0043::/64', '3ffe:0044::/64', '3ffe:0045::/64', '3ffe:0046::/64', '3ffe:0047::/64', '3ffe:0048::/64', '3ffe:0049::/64', '3ffe:004a::/64', '3ffe:004b::/64', '3ffe:004c::/64', '3ffe:004d::/64', '3ffe:004e::/64', '3ffe:004f::/64', '3ffe:0050::/64', '3ffe:0051::/64', '3ffe:0052::/64', '3ffe:0053::/64', '3ffe:0054::/64', '3ffe:0055::/64', '3ffe:0056::/64', '3ffe:0057::/64', '3ffe:0058::/64', '3ffe:0059::/64', '3ffe:005a::/64', '3ffe:005b::/64', '3ffe:005c::/64', '3ffe:005d::/64', '3ffe:005e::/64', '3ffe:005f::/64', '3ffe:0060::/64', '3ffe:0061::/64', '3ffe:0062::/64', '3ffe:0063::/64'])

Special robot framework method that returns dictionary nodes_ipv6_addr, mapping of node and interface name to IPv6 address.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • networks (list) – List of available IPv6 networks.

Note

Robot framework calls it automatically.

2.22. IPv6Setup suite

Library to set up IPv6 in topology.

class resources.libraries.python.IPv6Setup.IPv6Networks(networks)

Bases: object

IPv6 network iterator.

Parameters:networks (list) – List of the available IPv6 networks.
next_network()

Get the next element of the iterator.

Returns:IPv6 network.
Return type:IPv6Network object
Raises:StopIteration if there is no more elements.
class resources.libraries.python.IPv6Setup.IPv6Setup

Bases: object

IPv6 setup in topology.

Get link IPv6 address.

Parameters:
  • link (str) – Link name.
  • nodes_addr (dict) – Available nodes IPv6 addresses.
Returns:

Link IPv6 address.

Return type:

str

Get link IPv6 address prefix.

Parameters:
  • link (str) – Link name.
  • nodes_addr (dict) – Available nodes IPv6 addresses.
Returns:

Link IPv6 address prefix.

Return type:

int

static linux_del_if_ipv6_addr(node, interface, addr, prefix)

Delete IPv6 address on linux host.

Parameters:
  • node (dict) – Linux node.
  • interface (str) – Node interface.
  • addr (str) – IPv6 address.
  • prefix (str) – IPv6 address prefix.
static linux_set_if_ipv6_addr(node, interface, addr, prefix)

Set IPv6 address on linux host.

Parameters:
  • node (dict) – Linux node.
  • interface (str) – Node interface.
  • addr (str) – IPv6 address.
  • prefix (str) – IPv6 address prefix.
nodes_clear_ipv6_addresses(nodes, nodes_addr)

Remove IPv6 addresses from all VPP nodes in topology.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • nodes_addr (dict) – Available nodes IPv6 addresses.
nodes_set_ipv6_addresses(nodes, nodes_addr)

Set IPv6 addresses on all VPP nodes in topology.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • nodes_addr (dict) – Available nodes IPv6 addresses.
Returns:

Affected interfaces as list of (node, interface) tuples.

Return type:

list

Suppress ICMPv6 router advertisement message for link scope address on all VPP nodes in the topology.

Parameters:nodes (dict) – Nodes of the test topology.
static vpp_del_if_ipv6_addr(node, interface, addr, prefix)

Delete IPv6 address on VPP.

Parameters:
  • node (dict) – VPP node.
  • interface (str) – Node interface.
  • addr (str) – IPv6 address.
  • prefix (str) – IPv6 address prefix.
static vpp_ra_send_after_interval(node, interface, interval=2)

Setup vpp router advertisement(RA) in such way it sends RA packet after and every interval value.

Parameters:
  • node (dict) – VPP node.
  • interface (str) – Interface name.
  • interval (int) – Interval for RA resend

Suppress ICMPv6 router advertisement message for link scope address.

Parameters:
  • node (dict) – VPP node.
  • interface (str) – Interface name.
static vpp_set_if_ipv6_addr(node, iface_key, addr, prefix)

Set IPv6 address on VPP.

Parameters:
  • node (dict) – VPP node.
  • iface_key (str) – Node interface key.
  • addr (str) – IPv6 address.
  • prefix (str) – IPv6 address prefix.

2.23. IPv6Util suite

IPv6 utilities library.

class resources.libraries.python.IPv6Util.IPv6Util

Bases: object

IPv6 utilities

static add_ip_neighbor(node, interface, ip_address, mac_address)

Add IP neighbor.

Parameters:
  • node (dict) – VPP node to add ip neighbor.
  • interface (str or int) – Interface name or sw_if_index.
  • ip_address (str) – IP address.
  • mac_address (str) – MAC address.
static get_node_port_ipv6_address(node, iface_key, nodes_addr)

Return IPv6 address of the node port.

Parameters:
  • node (dict) – Node in the topology.
  • iface_key (str) – Interface key of the node.
  • nodes_addr (dict) – Nodes IPv6 addresses.
Returns:

IPv6 address string.

Return type:

str

static ipv6_ping(src_node, dst_addr, count=3, data_size=56, timeout=1)

IPv6 ping.

Parameters:
  • src_node (dict) – Node where ping run.
  • dst_addr (str) – Destination IPv6 address.
  • count (int) – Number of echo requests. (Optional)
  • data_size (int) – Number of the data bytes. (Optional)
  • timeout (int) – Time to wait for a response, in seconds. (Optional)
Returns:

Number of lost packets.

Return type:

int

static ipv6_ping_port(nodes_ip, src_node, dst_node, port, cnt=3, size=56, timeout=1)

Send IPv6 ping to the node port.

Parameters:
  • nodes_ip (dict) – Nodes IPv6 addresses.
  • src_node (dict) – Node where ping run.
  • dst_node (dict) – Destination node.
  • port (str) – Port on the destination node.
  • cnt (int) – Number of echo requests. (Optional)
  • size (int) – Number of the data bytes. (Optional)
  • timeout (int) – Time to wait for a response, in seconds. (Optional)
Returns:

Number of lost packets.

Return type:

int

2.24. InterfaceUtil suite

Interface util library

class resources.libraries.python.InterfaceUtil.InterfaceUtil

Bases: object

General utilities for managing interfaces

static all_vpp_interfaces_ready_wait(nodes, timeout=10)

Wait until all interfaces with admin-up are in link-up state for all nodes in the topology.

Parameters:
  • nodes (dict) – Nodes in the topology.
  • timeout (int) – Seconds to wait per node for all interfaces to come up.
Returns:

Nothing.

static assign_interface_to_fib_table(node, interface, table_id, ipv6=False)

Assign VPP interface to specific VRF/FIB table.

Parameters:
  • node (dict) – VPP node where the FIB and interface are located.
  • interface (str or int) – Interface to be assigned to FIB.
  • table_id (int) – VRF table ID.
  • ipv6 (bool) – Assign to IPv6 table. Default False.
static create_gre_tunnel_interface(node, source_ip, destination_ip)

Create GRE tunnel interface on node.

Parameters:
  • node (dict) – VPP node to add tunnel interface.
  • source_ip (str) – Source of the GRE tunnel.
  • destination_ip (str) – Destination of the GRE tunnel.
Returns:

Name and index of created GRE tunnel interface.

Return type:

tuple

Raises:

RuntimeError – If unable to create GRE tunnel interface.

static create_subinterface(node, interface, sub_id, outer_vlan_id=None, inner_vlan_id=None, type_subif=None)

Create sub-interface on node. It is possible to set required sub-interface type and VLAN tag(s).

Parameters:
  • node – Node to add sub-interface.
  • interface – Interface name on which create sub-interface.
  • sub_id – ID of the sub-interface to be created.
  • outer_vlan_id – Optional outer VLAN ID.
  • inner_vlan_id – Optional inner VLAN ID.
  • type_subif – Optional type of sub-interface. Values supported by

VPP: [no_tags] [one_tag] [two_tags] [dot1ad] [exact_match] [default_sub] :type node: dict :type interface: str or int :type sub_id: int :type outer_vlan_id: int :type inner_vlan_id: int :type type_subif: str :returns: Name and index of created sub-interface. :rtype: tuple :raises RuntimeError: If it is not possible to create sub-interface.

static create_vlan_subinterface(node, interface, vlan)

Create VLAN subinterface on node.

Parameters:
  • node (dict) – Node to add VLAN subinterface on.
  • interface (str) – Interface name on which create VLAN subinterface.
  • vlan (int) – VLAN ID of the subinterface to be created.
Returns:

Name and index of created subinterface.

Return type:

tuple

Raises:

RuntimeError – if it is unable to create VLAN subinterface on the

node.

static create_vxlan_interface(node, vni, source_ip, destination_ip)

Create VXLAN interface and return sw if index of created interface.

Executes “vxlan_add_del_tunnel src {src} dst {dst} vni {vni}” VAT command on the node.

Parameters:
  • node (dict) – Node where to create VXLAN interface.
  • vni (int) – VXLAN Network Identifier.
  • source_ip (str) – Source IP of a VXLAN Tunnel End Point.
  • destination_ip (str) – Destination IP of a VXLAN Tunnel End Point.
Returns:

SW IF INDEX of created interface.

Return type:

int

Raises:

RuntimeError – if it is unable to create VxLAN interface on the

node.

static get_interface_classify_table(node, interface)

Get name of classify table for the given interface.

Parameters:
  • node (dict) – VPP node to get data from.
  • interface (str or int) – Name or sw_if_index of a specific interface.
Returns:

Classify table name.

Return type:

str

static get_interface_vrf_table(node, interface)

Get vrf ID for the given interface.

Parameters:
  • node (dict) – VPP node.
  • interface (str or int) – Name or sw_if_index of a specific interface.
Returns:

vrf ID of the specified interface.

Return type:

int

static get_sw_if_index(node, interface_name)

Get sw_if_index for the given interface from actual interface dump.

Parameters:
  • node (dict) – VPP node to get interface data from.
  • interface_name (str) – Name of the specific interface.
Returns:

sw_if_index of the given interface.

Return type:

str

static iface_update_numa_node(node)
For all interfaces from topology file update numa node based on
information from the node.
Parameters:

node (dict) – Node from topology.

Returns:

Nothing.

Raises:
  • ValueError – If numa node ia less than 0.
  • RuntimeError – If update of numa node failes.
static set_default_ethernet_mtu_on_all_interfaces_on_node(node)

Set default Ethernet MTU on all interfaces on node.

Function can be used only for TGs.

Parameters:node (dict) – Node where to set default MTU.
Returns:Nothing.
static set_interface_ethernet_mtu(node, iface_key, mtu)

Set Ethernet MTU for specified interface.

Function can be used only for TGs.

Parameters:
  • node (dict) – Node where the interface is.
  • iface_key (str) – Interface key from topology file.
  • mtu (int) – MTU to set.
Returns:

Nothing.

Raises:
  • ValueError – If the node type is “DUT”.
  • ValueError – If the node has an unknown node type.
static set_interface_state(node, interface, state, if_type='key')

Set interface state on a node.

Function can be used for DUTs as well as for TGs.

Parameters:
  • node (dict) – Node where the interface is.
  • interface (str or int) – Interface key or sw_if_index or name.
  • state (str) – One of ‘up’ or ‘down’.
  • if_type (str) – Interface type
Returns:

Nothing.

Raises:
  • ValueError – If the interface type is unknown.
  • ValueError – If the state of interface is unexpected.
  • ValueError – If the node has an unknown node type.
static set_linux_interface_mac(node, interface, mac, namespace=None)

Set MAC address for interface in linux.

Parameters:
  • node (dict) – Node where to execute command.
  • interface (str) – Interface in namespace.
  • mac (str) – MAC to be assigned to interface.
  • namespace (str) – Execute command in namespace. Optional
static tap_dump(node, name=None)

Get all TAP interface data from the given node, or data about a specific TAP interface.

Parameters:
  • node (dict) – VPP node to get data from.
  • name (str) – Optional name of a specific TAP interface.
Returns:

Dictionary of information about a specific TAP interface, or

a List of dictionaries containing all TAP data for the given node. :rtype: dict or list

static tg_get_interface_driver(node, pci_addr)

Get interface driver from the TG node.

Parameters:
  • node (dict) – Node to get interface driver on (must be TG node).
  • pci_addr (str) – PCI address of the interface.
Returns:

Interface driver or None if not found.

Return type:

str

Raises:

RuntimeError – If it is not possible to get the interface driver

information from the node.

Note

# lspci -vmmks 0000:00:05.0 Slot: 00:05.0 Class: Ethernet controller Vendor: Red Hat, Inc Device: Virtio network device SVendor: Red Hat, Inc SDevice: Device 0001 PhySlot: 5 Driver: virtio-pci

static tg_set_interface_driver(node, pci_addr, driver)

Set interface driver on the TG node.

Parameters:
  • node (dict) – Node to set interface driver on (must be TG node).
  • pci_addr (str) – PCI address of the interface.
  • driver (str) – Driver name.
Returns:

None.

Raises:
  • RuntimeError – If unbinding from the current driver fails.
  • RuntimeError – If binding to the new driver fails.
static tg_set_interfaces_default_driver(node)

Set interfaces default driver specified in topology yaml file.

Parameters:node (dict) – Node to setup interfaces driver on (must be TG node).
static tg_set_interfaces_udev_rules(node)

Set udev rules for interfaces.

Create udev rules file in /etc/udev/rules.d where are rules for each interface used by TG node, based on MAC interface has specific name. So after unbind and bind again to kernel driver interface has same name as before. This must be called after TG has set name for each port in topology dictionary. udev rule example SUBSYSTEM==”net”, ACTION==”add”, ATTR{address}==”52:54:00:e1:8a:0f”, NAME=”eth1”

Parameters:node (dict) – Node to set udev rules on (must be TG node).
Raises:RuntimeError – If setting of udev rules fails.
static update_all_interface_data_on_all_nodes(nodes, skip_tg=False, numa_node=False)

Update interface names on all nodes in DICT__nodes.

This method updates the topology dictionary by querying interface lists of all nodes mentioned in the topology dictionary.

Parameters:
  • nodes (dict) – Nodes in the topology.
  • skip_tg (bool) – Skip TG node
  • numa_node (bool) – Retrieve numa_node location.
static update_all_numa_nodes(nodes, skip_tg=False)

For all nodes and all their interfaces from topology file update numa node information based on information from the node.

Parameters:
  • nodes (dict) – Nodes in the topology.
  • skip_tg (bool) – Skip TG node
Returns:

Nothing.

static update_nic_interface_names(node)

Update interface names based on nic type and PCI address.

This method updates interface names in the same format as VPP does.

Parameters:node (dict) – Node dictionary.
static update_nic_interface_names_on_all_duts(nodes)

Update interface names based on nic type and PCI address on all DUTs.

This method updates interface names in the same format as VPP does.

Parameters:nodes (dict) – Topology nodes.
static update_tg_interface_data_on_node(node)

Update interface name for TG/linux node in DICT__nodes.

Parameters:node (dict) – Node selected from DICT__nodes.
Raises:RuntimeError – If getting of interface name and MAC fails.

Note

# for dev in ls /sys/class/net/; > do echo “”cat /sys/class/net/$dev/address”: “$dev””; done “52:54:00:9f:82:63”: “eth0” “52:54:00:77:ae:a9”: “eth1” “52:54:00:e1:8a:0f”: “eth2” “00:00:00:00:00:00”: “lo”

static update_vpp_interface_data_on_node(node)

Update vpp generated interface data for a given node in DICT__nodes.

Updates interface names, software if index numbers and any other details generated specifically by vpp that are unknown before testcase run. It does this by dumping interface list to JSON output from all devices using vpp_api_test, and pairing known information from topology (mac address/pci address of interface) to state from VPP.

Parameters:node (dict) – Node selected from DICT__nodes.
static vhost_user_dump(node)

Get vhost-user data for the given node.

Parameters:node (dict) – VPP node to get interface data from.
Returns:List of dictionaries with all vhost-user interfaces.
Return type:list
static vpp_create_loopback(node)

Create loopback interface on VPP node.

Parameters:node (dict) – Node to create loopback interface on.
Returns:SW interface index.
Return type:int
Raises:RuntimeError – If it is not possible to create loopback on the

node.

static vpp_enable_input_acl_interface(node, interface, ip_version, table_index)

Enable input acl on interface.

Parameters:
  • node (dict) – VPP node to setup interface for input acl.
  • interface (str or int) – Interface to setup input acl.
  • ip_version (str) – Version of IP protocol.
  • table_index (int) – Classify table index.
static vpp_get_interface_data(node, interface=None)

Get all interface data from a VPP node. If a name or sw_interface_index is provided, return only data for the matching interface.

Parameters:
  • node (dict) – VPP node to get interface data from.
  • interface (int or str) – Numeric index or name string of a specific interface.
Returns:

List of dictionaries containing data for each interface, or a

single dictionary for the specified interface. :rtype: list or dict :raises TypeError: if the data type of interface is neither basestring nor int.

static vpp_get_interface_ip_addresses(node, interface, ip_version)

Get list of IP addresses from an interface on a VPP node.

Parameters:
  • node (dict) – VPP node to get data from.
  • interface (str) – Name of an interface on the VPP node.
  • ip_version (str) – IP protocol version (ipv4 or ipv6).
Returns:

List of dictionaries, each containing IP address, subnet

prefix length and also the subnet mask for ipv4 addresses. Note: A single interface may have multiple IP addresses assigned. :rtype: list

static vpp_get_interface_mac(node, interface=None)

Get MAC address for the given interface from actual interface dump.

Parameters:
  • node (dict) – VPP node to get interface data from.
  • interface (int or str) – Numeric index or name string of a specific interface.
Returns:

MAC address.

Return type:

str

static vpp_get_interface_name(node, sw_if_index)

Get interface name for the given SW interface index from actual interface dump.

Parameters:
  • node (dict) – VPP node to get interface data from.
  • sw_if_index (int) – SW interface index of the specific interface.
Returns:

Name of the given interface.

Return type:

str

static vpp_ip_source_check_setup(node, interface)

Setup Reverse Path Forwarding source check on interface.

Parameters:
  • node (dict) – Node to setup RPF source check.
  • interface (str) – Interface name to setup RPF source check.
static vpp_node_interfaces_ready_wait(node, timeout=10)

Wait until all interfaces with admin-up are in link-up state.

Parameters:
  • node (dict) – Node to wait on.
  • timeout (int) – Waiting timeout in seconds (optional, default 10s).
Returns:

Nothing.

Raises:

RuntimeError if the timeout period value has elapsed.

static vpp_nodes_interfaces_ready_wait(nodes, timeout=10)

Wait until all interfaces with admin-up are in link-up state for listed nodes.

Parameters:
  • nodes (list) – List of nodes to wait on.
  • timeout (int) – Seconds to wait per node for all interfaces to come up.
Returns:

Nothing.

static vpp_proxy_arp_interface_enable(node, interface)

Enable proxy ARP on interface.

Parameters:
  • node (dict) – VPP node to enable proxy ARP on interface.
  • interface (str or int) – Interface to enable proxy ARP.
static vxlan_dump(node, interface=None)

Get VxLAN data for the given interface.

Parameters:
  • node – VPP node to get interface data from.
  • interface – Numeric index or name string of a specific interface.

If None, information about all VxLAN interfaces is returned. :type node: dict :type interface: int or str :returns: Dictionary containing data for the given VxLAN interface or if interface=None, the list of dictionaries with all VxLAN interfaces. :rtype: dict or list :raises TypeError: if the data type of interface is neither basestring nor int.

static vxlan_gpe_dump(node, interface_name=None)

Get VxLAN GPE data for the given interface.

Parameters:
  • node – VPP node to get interface data from.
  • interface_name – Name of the specific interface. If None,

information about all VxLAN GPE interfaces is returned. :type node: dict :type interface_name: str :returns: Dictionary containing data for the given VxLAN GPE interface or if interface=None, the list of dictionaries with all VxLAN GPE interfaces. :rtype: dict or list

2.25. KubernetesUtils suite

Library to control Kubernetes kubectl.

class resources.libraries.python.KubernetesUtils.KubernetesUtils

Bases: object

Kubernetes utilities class.

static apply_kubernetes_resource_on_all_duts(nodes, yaml_file, **kwargs)

Apply Kubernetes resource on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • yaml_file (str) – YAML configuration file.
  • kwargs (dict) – Key-value pairs to replace in YAML template.
static apply_kubernetes_resource_on_node(node, yaml_file, **kwargs)

Apply Kubernetes resource on node.

Parameters:
  • node (dict) – DUT node.
  • yaml_file (str) – YAML configuration file.
  • kwargs (dict) – Key-value pairs to replace in YAML template.
Raises:

RuntimeError – If applying Kubernetes template failed.

static create_kubernetes_cm_from_file_on_all_duts(nodes, nspace, name, **kwargs)

Create Kubernetes ConfigMap from file on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
  • name (str) – ConfigMap name.
  • kwargs – Named parameters.
  • kwargs – dict
static create_kubernetes_cm_from_file_on_node(node, nspace, name, **kwargs)

Create Kubernetes ConfigMap from file on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
  • name (str) – ConfigMap name.
  • kwargs – Named parameters.
  • kwargs – dict
Raises:

RuntimeError – If creating Kubernetes ConfigMap failed.

static create_kubernetes_vnf_startup_config(**kwargs)

Create Kubernetes VNF startup configuration.

Parameters:
  • kwargs – Key-value pairs used to create configuration.
  • kwargs – dict
static create_kubernetes_vswitch_startup_config(**kwargs)

Create Kubernetes VSWITCH startup configuration.

Parameters:
  • kwargs – Key-value pairs used to create configuration.
  • kwargs – dict
static delete_kubernetes_resource_on_all_duts(nodes, nspace, name=None, rtype='po, cm, deploy, rs, rc, svc')

Delete all Kubernetes resource on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
  • rtype (str) – Kubernetes resource type.
  • name (str) – Name of resource.
static delete_kubernetes_resource_on_node(node, nspace, name=None, rtype='po, cm, deploy, rs, rc, svc')

Delete Kubernetes resource on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
  • rtype (str) – Kubernetes resource type.
  • name (str) – Name of resource (Default: all).
Raises:

RuntimeError – If retrieving or deleting Kubernetes resource

failed.

static describe_kubernetes_resource_on_all_duts(nodes, nspace)

Describe all Kubernetes PODs in namespace on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
static describe_kubernetes_resource_on_node(node, nspace)

Describe all Kubernetes PODs in namespace on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
static destroy_kubernetes_on_all_duts(nodes)

Destroy Kubernetes on all DUTs.

Parameters:nodes (dict) – Topology nodes.
static destroy_kubernetes_on_node(node)

Destroy Kubernetes on node.

Parameters:node (dict) – DUT node.
Raises:RuntimeError – If destroying Kubernetes failed.
static get_kubernetes_logs_on_all_duts(nodes, nspace)

Get Kubernetes logs from all PODs in namespace on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
static get_kubernetes_logs_on_node(node, nspace)

Get Kubernetes logs from all PODs in namespace on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
static set_kubernetes_pods_affinity_on_all_duts(nodes)

Set affinity for all Kubernetes PODs except VPP on all DUTs.

Parameters:nodes (dict) – Topology nodes.
static set_kubernetes_pods_affinity_on_node(node)

Set affinity for all Kubernetes PODs except VPP on node.

Parameters:node (dict) – DUT node.
static setup_kubernetes_on_all_duts(nodes)

Set up Kubernetes on all DUTs.

Parameters:nodes (dict) – Topology nodes.
static setup_kubernetes_on_node(node)

Set up Kubernetes on node.

Parameters:node (dict) – DUT node.
Raises:RuntimeError – If Kubernetes setup failed on node.
static wait_for_kubernetes_pods_on_all_duts(nodes, nspace)

Wait for Kubernetes to become ready on all DUTs.

Parameters:
  • nodes (dict) – Topology nodes.
  • nspace (str) – Kubernetes namespace.
static wait_for_kubernetes_pods_on_node(node, nspace)

Wait for Kubernetes PODs to become ready on node.

Parameters:
  • node (dict) – DUT node.
  • nspace (str) – Kubernetes namespace.
Raises:

RuntimeError – If Kubernetes PODs are not in Running state.

2.26. L2Util suite

L2 Utilities Library.

class resources.libraries.python.L2Util.L2Util

Bases: object

Utilities for l2 configuration.

static add_interface_to_l2_bd(node, interface, bd_id, shg=0)

Add a interface to the l2 bridge domain.

Get SW IF ID and add it to the bridge domain.

Parameters:
  • node (dict) – Node where we want to execute the command that does this.
  • interface (str) – Interface name.
  • bd_id (int) – Bridge domain index number to add Interface name to.
  • shg (int) – Split horizon group.
static add_sw_if_index_to_l2_bd(node, sw_if_index, bd_id, shg=0)

Add interface with sw_if_index to l2 bridge domain.

Execute the “sw_interface_set_l2_bridge sw_if_index {sw_if_index} bd_id {bd_id} shg {shg} enable” VAT command on the given node.

Parameters:
  • node (dict) – Node where we want to execute the command that does this.
  • sw_if_index (int) – Interface index.
  • bd_id (int) – Bridge domain index number to add SW IF ID to.
  • shg (int) – Split horizon group.
Returns:

static create_bridge_domain_vat_dict(node, link_names, bd_id)

Create dictionary that can be used in l2 bridge domain template.

The resulting dictionary looks like this: ‘interface1’: interface name of first interface ‘interface2’: interface name of second interface ‘bd_id’: bridge domain index

Parameters:
  • node – Node data dictionary.
  • link_names – List of names of links the bridge domain should be

connecting. :param bd_id: Bridge domain index number. :type node: dict :type link_names: list :return: Dictionary used to generate l2 bridge domain VAT configuration from template file. :rtype: dict

static create_l2_bd(node, bd_id, flood=1, uu_flood=1, forward=1, learn=1, arp_term=0)

Create a l2 bridge domain on the chosen VPP node

Execute “bridge_domain_add_del bd_id {bd_id} flood {flood} uu-flood 1 forward {forward} learn {learn} arp-term {arp_term}” VAT command on the node.

Parameters:
  • node (dict) – Node where we wish to crate the l2 bridge domain.
  • bd_id (int) – Bridge domain index number.
  • flood (bool) – Enable flooding.
  • uu_flood (bool) – Enable uu_flood.
  • forward (bool) – Enable forwarding.
  • learn (bool) – Enable mac address learning to fib.
  • arp_term – Enable arp_termination.

:type arp_term:bool

static delete_bridge_domain_vat(node, bd_id)

Delete the specified bridge domain from the node.

Parameters:
  • node (dict) – VPP node to delete a bridge domain from.
  • bd_id (int) – Bridge domain ID.
static delete_l2_fib_entry(node, bd_id, mac)

Delete the specified L2 FIB entry.

Parameters:
  • node (dict) – VPP node.
  • bd_id (int) – Bridge domain ID.
  • mac (str) – MAC address used as the key in L2 FIB entry.
static get_l2_fib_entry_vat(node, bd_index, mac)

Retrieves the L2 FIB entry specified by MAC address using VAT.

Parameters:
  • node (dict) – VPP node.
  • bd_index (int) – Index of the bridge domain.
  • mac (str) – MAC address used as the key in L2 FIB data structure.
Returns:

L2 FIB entry

Return type:

dict

static get_l2_fib_table_vat(node, bd_index)

Retrieves the L2 FIB table using VAT.

Parameters:
  • node (dict) – VPP node.
  • bd_index (int) – Index of the bridge domain.
Returns:

L2 FIB table.

Return type:

list

static int_to_mac(mac_int)

Convert MAC address from integer representation (e.g. 1108152157446) to string format (01:02:03:04:05:06).

Parameters:mac_int (str) – MAC address in integer representation.
Returns:String representation of MAC address.
Return type:int
static l2_vlan_tag_rewrite(node, interface, tag_rewrite_method, push_dot1q=True, tag1_id=None, tag2_id=None)

Rewrite tags in ethernet frame.

Parameters:
  • node (dict) – Node to rewrite tags.
  • interface (str or int) – Interface on which rewrite tags.
  • tag_rewrite_method (str) – Method of tag rewrite.
  • push_dot1q (bool) – Optional parameter to disable to push dot1q tag instead of dot1ad.
  • tag1_id (int) – Optional tag1 ID for VLAN.
  • tag2_id (int) – Optional tag2 ID for VLAN.
static linux_add_bridge(node, br_name, if_1, if_2, set_up=True)

Bridge two interfaces on linux node.

Parameters:
  • node – Node to add bridge on.
  • br_name – Bridge name.
  • if_1 – First interface to be added to the bridge.
  • if_2 – Second interface to be added to the bridge.
  • set_up – Change bridge interface state to up after create bridge.

Optional. Default: True. :type node: dict :type br_name: str :type if_1: str :type if_2: str :type set_up: bool

static linux_del_bridge(node, br_name, set_down=True)

Delete bridge from linux node.

Parameters:
  • node – Node to delete bridge from.
  • br_name – Bridge name.
  • set_down – Change bridge interface state to down before delbr

command. Optional. Default: True. :type node: str :type br_name: str :type set_down: bool ..note:: The network interface corresponding to the bridge must be down before it can be deleted!

static mac_to_int(mac_str)

Convert MAC address from string format (e.g. 01:02:03:04:05:06) to integer representation (1108152157446).

Parameters:mac_str (str) – MAC address in string representation.
Returns:Integer representation of MAC address.
Return type:int
static vpp_add_l2_bridge_domain(node, bd_id, port_1, port_2, learn=True)

Add L2 bridge domain with 2 interfaces to the VPP node.

Parameters:
  • node (dict) – Node to add L2BD on.
  • bd_id (int) – Bridge domain ID.
  • port_1 (str) – First interface name added to L2BD.
  • port_2 (str) – Second interface name added to L2BD.
  • learn (bool) – Enable/disable MAC learn.
static vpp_add_l2fib_entry(node, mac, interface, bd_id)

Create a static L2FIB entry on a vpp node.

Parameters:
  • node (dict) – Node to add L2FIB entry on.
  • mac (str) – Destination mac address.
  • interface (str or int) – Interface name or sw_if_index.
  • bd_id (int) – Bridge domain id.
static vpp_get_bridge_domain_data(node, bd_id=None)

Get all bridge domain data from a VPP node. If a domain ID number is provided, return only data for the matching bridge domain.

Parameters:
  • node (dict) – VPP node to get bridge domain data from.
  • bd_id (int) – Numeric ID of a specific bridge domain.
Returns:

List of dictionaries containing data for each bridge domain, or a single dictionary for the specified bridge domain.

Return type:

list or dict

static vpp_setup_bidirectional_cross_connect(node, interface1, interface2)

Create bidirectional cross-connect between 2 interfaces on vpp node.

Parameters:
  • node (dict) – Node to add bidirectional cross-connect.
  • interface1 (str or int) – First interface name or sw_if_index.
  • interface2 (str or int) – Second interface name or sw_if_index.

2.27. LXCUtils suite

Library to manipulate LXC.

class resources.libraries.python.LXCUtils.LXCUtils(container_name='slave')

Bases: object

LXC utilities.

container_cpuset_cpus(container_cpu)

Set cpuset.cpus control group associated with a container.

Parameters:container_cpu (str) – Cpuset.cpus string.
Raises:RuntimeError – If failed to set cgroup for a container.
create_container(force_create=True)

Create and start a container.

Parameters:force_create (bool) – Destroy a container if exists and create.
create_vpp_cfg_in_container(vat_template_file, **args)

Create VPP exec config for a container on given node.

Parameters:
  • vat_template_file (str) – Template file name of a VAT script.
  • args (dict) – Parameters for VAT script.
destroy_container()

Stop and destroy a container.

install_vpp_in_container(install_dkms=False)

Install vpp inside a container.

Parameters:install_dkms – If install dkms package. This will impact install

time. Dkms is required for installation of vpp-dpdk-dkms. Default is false. :type install_dkms: bool

is_container_present()

Check if LXC container is existing on node.

is_container_running()

Check if LXC container is running on node.

Raises:RuntimeError – If failed to get info about a container.
lxc_attach(command)

Start a process inside a running container. Runs the specified command inside the container specified by name. The container has to be running already.

Parameters:

command (str) – Command to run inside container.

Raises:
  • RuntimeError – If container is not running.
  • RuntimeError – If failed to run the command.
mount_host_dir_in_container()

Mount shared folder inside container.

Raises:RuntimeError – If failed to mount host dir in a container.
mount_hugepages_in_container()

Mount hugepages inside container.

Raises:RuntimeError – If failed to mount hugepages in a container.
restart_container()

Restart container.

restart_vpp_in_container()

Restart vpp service inside a container.

set_guest_dir(node, guest_dir)

Set mount dir on LXC.

Parameters:
  • node (dict) – Node to control LXC on.
  • guest_dir (str) – Guest dir for mount.
Raises:

RuntimeError – If Node type is not DUT.

set_host_dir(node, host_dir)

Set shared dir on parent node for LXC.

Parameters:node (dict) – Node to control LXC on.
Raises:RuntimeError – If Node type is not DUT.
set_node(node)

Set node for LXC execution.

Parameters:node (dict) – Node to execute LXC on.
Raises:RuntimeError – If Node type is not DUT.
start_container()

Start a container and wait for running state.

stop_container()

Stop a container and wait for stopped state.

2.28. LispSetup suite

Library to set up Lisp in topology.

class resources.libraries.python.LispSetup.LispAdjacency

Bases: object

Class for lisp adjacency API.

static vpp_add_lisp_adjacency(node, vni, deid, deid_prefix, seid, seid_prefix, is_mac=False)

Add lisp adjacency on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • vni (int) – Vni.
  • deid (str) – Destination eid address.
  • deid_prefix (int) – Destination eid address prefix_len.
  • seid (str) – Source eid address.
  • seid_prefix (int) – Source eid address prefix_len.
  • is_mac (bool) – Set to True if the deid/seid is MAC address.
static vpp_del_lisp_adjacency(node, vni, deid, deid_prefix, seid, seid_prefix)

Delete lisp adjacency on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • vni (int) – Vni.
  • deid (str) – Destination eid address.
  • deid_prefix (int) – Destination eid address prefix_len.
  • seid (str) – Source eid address.
  • seid_prefix (int) – Source eid address prefix_len.
class resources.libraries.python.LispSetup.LispEidTableMap

Bases: object

Class for EID table map.

static vpp_lisp_eid_table_mapping(node, vni, bd_id=None, vrf=None)

Map LISP VNI to either bridge domain ID, or VRF ID.

Parameters:
  • node (dict) – VPP node.
  • vni (int) – Lisp VNI.
  • bd_id (int) – Bridge domain ID.
  • vrf (int) – VRF id.
class resources.libraries.python.LispSetup.LispGpeForwardEntry

Bases: object

The functionality needed for these methods is not implemented in VPP (VAT). Bug https://jira.fd.io/browse/VPP-334 was open to cover this issue.

TODO: Implement when VPP-334 is fixed.

static add_lisp_gpe_forward_entry(node, *args)

Not implemented

static del_lisp_gpe_forward_entry(node, *args)

Not implemented

class resources.libraries.python.LispSetup.LispGpeIface

Bases: object

Class for Lisp gpe interface API.

static vpp_lisp_gpe_iface(node, state)

Set lisp gpe interface up or down on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • state (str) – State of the gpe iface, up or down.
class resources.libraries.python.LispSetup.LispGpeStatus

Bases: object

Clas for LISP GPE status manipulation.

static vpp_lisp_gpe_enable_disable(node, state)

Change the state of LISP GPE - enable or disable.

Parameters:
  • node (dict) – VPP node.
  • state (str) – Requested state - enable or disable.
class resources.libraries.python.LispSetup.LispLocalEid

Bases: object

Class for Lisp local eid API.

static vpp_add_lisp_local_eid(node, locator_set_name, vni, eid, prefix_len=None)

Set lisp eid address on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • locator_set_name (str) – Name of the locator_set.
  • vni (int) – vni value.
  • eid (str) – Eid value.
  • prefix_len (int) – prefix len if the eid is IP address.
static vpp_del_lisp_local_eid(node, locator_set_name, vni, eid, prefix_len=None)

Set lisp eid addres on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • locator_set_name (str) – Name of the locator_set.
  • vni (int) – vni value.
  • eid (str) – Eid value.
  • prefix_len (int) – prefix len if the eid is IP address.
class resources.libraries.python.LispSetup.LispLocator

Bases: object

Class for the Lisp Locator API.

static vpp_add_lisp_locator(node, locator_name, sw_if_index, priority, weight)

Set lisp locator on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • locator_name (str) – Name of the locator_set.
  • sw_if_index (int) – sw_if_index if the interface.
  • priority (int) – priority of the locator.
  • weight (int) – weight of the locator.
static vpp_del_lisp_locator(node, locator_name, sw_if_index, priority, weight)

Unset lisp locator on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • locator_name (str) – Name of the locator_set.
  • sw_if_index (int) – sw_if_index if the interface.
  • priority (int) – priority of the locator.
  • weight (int) – weight of the locator.
class resources.libraries.python.LispSetup.LispLocatorSet

Bases: object

Class for Lisp Locator Set API.

static vpp_add_lisp_locator_set(node, name)

Add lisp locator_set on VPP.

Parameters:
  • node (dict) – VPP node.
  • name (str) – VPP locator name.
static vpp_del_lisp_locator_set(node, name)

Del lisp locator_set on VPP.

Parameters:
  • node (dict) – VPP node.
  • name (str) – VPP locator name.
class resources.libraries.python.LispSetup.LispMapResolver

Bases: object

Class for Lisp map resolver API.

static vpp_add_map_resolver(node, map_resolver_ip)

Set lisp map resolver on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • map_resolver_ip (str) – IP address of the map resolver.
static vpp_del_map_resolver(node, map_resolver_ip)

Unset lisp map resolver on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • map_resolver_ip (str) – IP address of the map resolver.
class resources.libraries.python.LispSetup.LispRemoteMapping

Bases: object

Class for lisp remote mapping API.

static vpp_add_lisp_remote_mapping(node, vni, deid, deid_prefix, seid, seid_prefix, rloc, is_mac=False)

Add lisp remote mapping on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • vni (int) – Vni.
  • deid (str) – Destination eid address.
  • deid_prefix (int) – Destination eid address prefix_len.
  • seid (str) – Source eid address.
  • seid_prefix (int) – Source eid address prefix_len.
  • rloc (str) – Receiver locator.
  • is_mac (bool) – Set to True if the deid/seid is MAC address.
static vpp_del_lisp_remote_mapping(node, vni, deid, deid_prefix, seid, seid_prefix, rloc)

Delete lisp remote mapping on the VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • vni (int) – Vni.
  • deid (str) – Destination eid address.
  • deid_prefix (int) – Destination eid address prefix_len.
  • seid (str) – Source eid address.
  • seid_prefix (int) – Source eid address prefix_len.
  • rloc (str) – Receiver locator.
class resources.libraries.python.LispSetup.LispSetup

Bases: object

Lisp setup in topology.

static vpp_lisp_gpe_interface_status(node, state)

Set lisp gpe interface status on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • state (str) – State of the gpe iface, up or down
static vpp_set_lisp_eid_table(node, eid_table)

Set lisp eid tables on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • eid_table (dict) – Dictionary containing information of eid_table.
static vpp_set_lisp_locator_set(node, locator_set_list)

Set lisp locator_sets on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • locator_set_list (list) – List of locator_set.
static vpp_set_lisp_map_resolver(node, map_resolver)

Set lisp map resolvers on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • map_resolver (dict) – Dictionary containing information of map resolver.
static vpp_unset_lisp_eid_table(node, eid_table)

Unset lisp eid tables on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • eid_table (dict) – Dictionary containing information of eid_table.
static vpp_unset_lisp_locator_set(node, locator_set_list)

Unset lisp locator_sets on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • locator_set_list (list) – List of locator_set.
static vpp_unset_lisp_map_resolver(node, map_resolver)

Unset lisp map resolvers on VPP node in topology.

Parameters:
  • node (dict) – VPP node.
  • map_resolver (dict) – Dictionary containing information of map resolver.
class resources.libraries.python.LispSetup.LispStatus

Bases: object

Class for lisp API.

static vpp_lisp_enable_disable(node, state)

Enable/Disable lisp in the VPP node in topology.

Parameters:
  • node (dict) – Node of the test topology.
  • state (str) – State of the lisp, enable or disable.

2.29. LispUtil suite

Lisp utilities library.

class resources.libraries.python.LispUtil.LispUtil

Bases: object

Implements keywords for Lisp tests.

static generate_duplicate_lisp_locator_set_data(node, locator_set_number)

Generate a list of lisp locator_set we want set to VPP and then check if it is set correctly. Some locator_sets are duplicated.

Parameters:
  • node (dict) – VPP node.
  • locator_set_number (str) – Generate n locator_set.
Returns:

list of lisp locator_set, list of lisp locator_set expected

from VAT. :rtype: tuple

static generate_unique_lisp_locator_set_data(node, locator_set_number)

Generate a list of lisp locator_set we want set to VPP and then check if it is set correctly. All locator_sets are unique.

Parameters:
  • node (dict) – VPP node.
  • locator_set_number (str) – Generate n locator_set.
Returns:

list of lisp locator_set, list of lisp locator_set expected

from VAT. :rtype: tuple

lisp_is_empty(lisp_params)

Check if the input param are empty.

Parameters:lisp_params (list) – Should be empty list.
lisp_locator_s_should_be_equal(locator_set1, locator_set2)

Fail if the lisp values are not equal.

Parameters:
  • locator_set1 (list) – Generate lisp value.
  • locator_set2 (list) – Lisp value from VPP.
static lisp_should_be_equal(lisp_val1, lisp_val2)

Fail if the lisp values are not equal.

Parameters:
  • lisp_val1 (list) – First lisp value.
  • lisp_val2 (list) – Second lisp value.
static vpp_show_lisp_eid_table(node)

Get lisp eid table from VPP node.

Parameters:node (dict) – VPP node.
Returns:Lisp eid table as python list.
Return type:list
static vpp_show_lisp_locator_set(node, items_filter)

Get lisp locator_set from VPP node.

Parameters:
  • node – VPP node.
  • items_filter – Filter which specifies which items should be

retrieved - local, remote, empty string = both. :type node: dict :type items_filter: str :returns: Lisp locator_set data as python list. :rtype: list

static vpp_show_lisp_map_register(node)

Get LISP Map Register from VPP node.

Parameters:node (dict) – VPP node.
Returns:LISP Map Register as python list.
Return type:list
static vpp_show_lisp_map_request_mode(node)

Get LISP Map Request mode from VPP node.

Parameters:node (dict) – VPP node.
Returns:LISP Map Request mode as python list.
Return type:list
static vpp_show_lisp_map_resolver(node)

Get lisp map resolver from VPP node.

Parameters:node (dict) – VPP node.
Returns:Lisp map resolver as python list.
Return type:list
static vpp_show_lisp_map_server(node)

Get LISP Map Server from VPP node.

Parameters:node (dict) – VPP node.
Returns:LISP Map Server as python list.
Return type:list
static vpp_show_lisp_petr_config(node)

Get LISP PETR configuration from VPP node.

Parameters:node (dict) – VPP node.
Returns:LISP PETR configuration as python list.
Return type:list
static vpp_show_lisp_pitr(node)

Get Lisp PITR feature config from VPP node.

Parameters:node (dict) – VPP node.
Returns:Lisp PITR config data.
Return type:dict
static vpp_show_lisp_rloc_config(node)

Get LISP RLOC configuration from VPP node.

Parameters:node (dict) – VPP node.
Returns:LISP RLOC configuration as python list.
Return type:list
static vpp_show_lisp_state(node)

Get lisp state from VPP node.

Parameters:node (dict) – VPP node.
Returns:Lisp gpe state.
Return type:list

2.30. MacSwap suite

Macswap sample_plugin util library

class resources.libraries.python.MacSwap.MacSwap

Bases: object

Macswap sample plugin API

static enable_disable_macswap_vat(node, interface)

Enable/Disable macswap on interface.

Function can be used on a VPP node with macswap plugin.

Parameters:
  • node (dict) – Node where the interface is.
  • interface (str or int) – Interface id.
Returns:

nothing

static enable_disable_macswap_vat_exec(node, interface_name)

Enable/Disable macswap on interface.

Function can be used on a VPP node with macswap plugin.

Parameters:
  • node (dict) – Node where the interface is.
  • interface_name (str or int) – Interface name.
Returns:

nothing

2.31. Map suite

Map utilities library.

class resources.libraries.python.Map.Map

Bases: object

Utilities for manipulating MAP feature in VPP.

static compute_ipv6_map_destination_address(ipv4_pfx, ipv6_pfx, ea_bit_len, psid_offset, psid_len, ipv4_dst, dst_port)
Compute IPv6 destination address from IPv4 address for MAP algorithm.
(RFC 7597)
n bits | o bits | s bits | 128-n-o-s bits |
Rule IPv6 prefix EA bits subnet ID interface ID
Rule IPv6 prefix | EA bits |subnet ID| interface ID |
param ipv4_pfx:Domain IPv4 preffix.
param ipv6_pfx:Domain IPv6 preffix.
param ea_bit_len:
 Domain EA bits length.
param psid_offset:
 Domain PSID offset.
param psid_len:Domain PSID length.
param ipv4_dst:Destination IPv4 address.
param dst_port:Destination port number or ICMP ID.
type ipv4_pfx:str
type ipv6_pfx:str
type ea_bit_len:
 int
type psid_offset:
 int
type psid_len:int
type ipv4_dst:str
type dst_port:int
returns:Computed IPv6 address.
rtype:str
static compute_ipv6_map_source_address(ipv6_pfx, ipv4_src)

Compute IPv6 source address from IPv4 address for MAP-T algorithm.

Parameters:
  • ipv6_pfx (str) – 96 bit long IPv6 prefix.
  • ipv4_src (str) – IPv4 source address
Returns:

IPv6 address, combination of IPv6 prefix and IPv4 address.

Return type:

str

static get_psid_from_port(port, psid_len, psid_offset)
Return PSID from port.
0 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5

Ports in | A | PSID | j |

the CE port set | > 0 | | |
Parameters:
  • port (int) – Port to compute PSID from.
  • psid_len (int) – PSID length.
  • psid_offset (int) – PSID offset.
Returns:

PSID.

Return type:

int

static map_add_domain(vpp_node, ip4_pfx, ip6_pfx, ip6_src, ea_bits_len, psid_offset, psid_len, map_t=False)

Add map domain on node.

Parameters:
  • vpp_node – VPP node to add map domain on.
  • ip4_pfx – Rule IPv4 prefix.
  • ip6_pfx – Rule IPv6 prefix.
  • ip6_src – MAP domain IPv6 BR address / Tunnel source.
  • ea_bits_len – Embedded Address bits length.
  • psid_offset – Port Set Identifier (PSID) offset.
  • psid_len – Port Set Identifier (PSID) length.
  • map_t – Mapping using translation instead of encapsulation.

Default False. :type vpp_node: dict :type ip4_pfx: str :type ip6_pfx: str :type ip6_src: str :type ea_bits_len: int :type psid_offset: int :type psid_len: int :type map_t: bool :returns: Index of created map domain. :rtype: int :raises RuntimeError: If unable to add map domain.

static map_add_rule(vpp_node, index, psid, dst, delete=False)

Add or delete map rule on node.

Parameters:
  • vpp_node (dict) – VPP node to add map rule on.
  • index (int) – Map domain index to add rule to.
  • psid (int) – Port Set Identifier.
  • dst (str) – MAP CE IPv6 address.
  • delete (bool) – If set to True, delete rule. Default False.
Raises:

RuntimeError – If unable to add map rule.

static map_del_domain(vpp_node, index)

Delete map domain on node.

Parameters:
  • vpp_node (dict) – VPP node to delete map domain on.
  • index (int) – Index of the map domain.
Raises:

RuntimeError – If unable to delete map domain.

2.32. Memif suite

Memif interface library.

class resources.libraries.python.Memif.Memif

Bases: object

Memif interface class.

static clear_memif_socks(node, *socks)

Clear Memif sockets for the given node.

Parameters:
  • node (dict) – Given node to clear Memif sockets on.
  • socks (list) – Memif sockets.
static create_memif_interface(node, socket, mid, role='master')

Create Memif interface on the given node.

Parameters:
  • node (dict) – Given node to create Memif interface on.
  • socket (str) – Memif interface socket path.
  • mid (str) – Memif interface ID.
  • role (str) – Memif interface role [master|slave]. Default is master.
Returns:

SW interface index.

Return type:

int

Raises:

ValueError – If command ‘create memif’ fails.

static parse_memif_dump_data(memif_data)

Convert Memif data to dictionary.

Parameters:memif_data (str) – Dump of Memif interfaces data.
Returns:Memif interfaces data in dictionary.
Return type:dict
Raises:RuntimeError – If there is no memif interface name found in provided data.
static show_memif(node)

Show Memif data for the given node.

Parameters:node (dict) – Given node to show Memif data on.
static vpp_get_memif_interface_id(node, sw_if_idx)

Get Memif interface ID from Memif interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

Memif interface ID.

Return type:

int

static vpp_get_memif_interface_mac(node, sw_if_idx)

Get Memif interface MAC address from Memif interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

Memif interface MAC address.

Return type:

str

static vpp_get_memif_interface_name(node, sw_if_idx)

Get Memif interface name from Memif interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

Memif interface name.

Return type:

str

static vpp_get_memif_interface_role(node, sw_if_idx)

Get Memif interface role from Memif interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

Memif interface role.

Return type:

int

static vpp_get_memif_interface_socket(node, sw_if_idx)

Get Memif interface socket path from Memif interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

Memif interface socket path.

Return type:

str

2.33. NATUtil suite

NAT utilities library.

class resources.libraries.python.NATUtil.NATUtil

Bases: object

This class defines the methods to set NAT.

static get_nat_interfaces(node)

Get list of interfaces configured with NAT from VPP node.

Parameters:node (dict) – VPP node.
Returns:List of interfaces on the node that are configured with NAT.
Return type:list
Raises:RuntimeError – If the output is not as expected.
static get_nat_static_mappings(node)

Get NAT static mappings from VPP node.

Parameters:node (dict) – VPP node.
Returns:List of static mappings.
Return type:list
Raises:RuntimeError – If the output is not as expected.
static set_nat44_deterministic(node, ip_in, subnet_in, ip_out, subnet_out)

Set deterministic behaviour of NAT44.

Parameters:
  • node (dict) – DUT node.
  • ip_in (str) – Inside IP.
  • subnet_in (str or int) – Inside IP subnet.
  • ip_out (str) – Outside IP.
  • subnet_out (str or int) – Outside IP subnet.
Returns:

Response of the command.

Return type:

str

Raises:

RuntimeError – If setting of deterministic behaviour of NAT44

fails.

static set_nat44_interfaces(node, int_in, int_out)

Set inside and outside interfaces for NAT44.

Parameters:
  • node (dict) – DUT node.
  • int_in (str) – Inside interface.
  • int_out (str) – Outside interface.
Returns:

Response of the command.

Return type:

str

Raises:

RuntimeError – If setting of inside and outside interfaces for

NAT44 fails.

static set_nat_workers(node, lcores)

Set NAT workers.

Parameters:
  • node – DUT node.
  • lcores – list of cores, format: range e.g. 1-5 or list of ranges

e.g.: 1-5,18-22. :type node: dict :type lcores: str :returns: Response of the command. :rtype: str :raises RuntimeError: If setting of NAT workers fails.

static show_nat(node)

Show the NAT settings.

Parameters:node (dict) – DUT node.
Returns:Response of the command.
Return type:str
Raises:RuntimeError – If getting of NAT settings fails.
static show_nat44_deterministic_forward(node, ip_addr)

Show forward IP address and port(s).

Parameters:
  • node (dict) – DUT node.
  • ip_addr (str) – IP address.
Returns:

Response of the command.

Return type:

str

Raises:

RuntimeError – If command ‘exec snat deterministic forward’

fails.

static show_nat44_deterministic_reverse(node, ip_addr, port)

Show reverse IP address.

Parameters:
  • node (dict) – DUT node.
  • ip_addr (str) – IP address.
  • port (str or int) – Port.
Returns:

Response of the command.

Return type:

str

Raises:

RuntimeError – If command ‘exec snat deterministic reverse’

fails.

2.34. Namespaces suite

Linux namespace utilities library.

class resources.libraries.python.Namespaces.Namespaces

Bases: object

Linux namespace utilities.

static attach_interface_to_namespace(node, namespace, interface)

Attach specific interface to namespace.

Parameters:
  • node (dict) – Node where to execute command.
  • namespace (str) – Namespace to execute command on.
  • interface (str) – Interface in namespace.
Raises:

RuntimeError – Interface could not be attached.

clean_up_namespaces(node)

Remove all old namespaces.

Parameters:node (dict) – Node where to execute command.
Raises:RuntimeError – Namespaces could not be cleaned properly.
static create_bridge_for_int_in_namespace(node, namespace, bridge_name, *interfaces)

Setup bridge domain and add interfaces to it.

Parameters:
  • node (dict) – Node where to execute command.
  • namespace (str) – Namespace to execute command on.
  • bridge_name (str) – Name of the bridge to be created.
  • interfaces (list) – List of interfaces to add to the namespace.
create_namespace(node, namespace_name)

Create namespace and add the name to the list for later clean-up.

Parameters:
  • node (dict) – Where to create namespace.
  • namespace_name (str) – Name for namespace.

2.35. NodePath suite

Path utilities library for nodes in the topology.

class resources.libraries.python.NodePath.NodePath

Bases: object

Path utilities for nodes in the topology.

Example:

node1–link1–>node2–link2–>node3–link3–>node2–link4–>node1 RobotFramework: | Library | resources/libraries/python/NodePath.py

Path test
| [Arguments] | ${node1} | ${node2} | ${node3}
| Append Node | ${nodes1}
| Append Node | ${nodes2}
| Append Nodes | ${nodes3} | ${nodes2}
| Append Node | ${nodes1}
| Compute Path | ${FALSE}
| ${first_int} | ${node}= | First Interface
| ${last_int} | ${node}= | Last Interface
| ${first_ingress} | ${node}= | First Ingress Interface
| ${last_egress} | ${node}= | Last Egress Interface
| ${next} | ${node}= | Next Interface

Python: >>> from NodePath import NodePath >>> path = NodePath() >>> path.append_node(node1) >>> path.append_node(node2) >>> path.append_nodes(node3, node2) >>> path.append_node(node1) >>> path.compute_path() >>> (interface, node) = path.first_interface() >>> (interface, node) = path.last_interface() >>> (interface, node) = path.first_ingress_interface() >>> (interface, node) = path.last_egress_interface() >>> (interface, node) = path.next_interface()

append_node(node, filter_list=None)

Append node to the path.

Parameters:
  • node (dict) – Node to append to the path.
  • filter_list (list of strings) – Filter criteria list.
append_nodes(*nodes)

Append nodes to the path.

Parameters:nodes (dict) – Nodes to append to the path.

Note

Node order does matter.

clear_path()

Clear path.

compute_path(always_same_link=True)

Compute path for added nodes.

Parameters:always_same_link – If True use always same link between two nodes

in path. If False use different link (if available) between two nodes if one link was used before. :type always_same_link: bool

Note

First add at least two nodes to the topology.

first_ingress_interface()

Return first ingress interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

first_interface()

Return first interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

last_egress_interface()

Return last egress interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

last_interface()

Return last interface on the path.

Returns:Interface and node.
Return type:tuple (str, dict)

Note

Call compute_path before.

next_interface()

Path interface iterator.

Returns:Interface and node or None if not next interface.
Return type:tuple (str, dict)

Note

Call compute_path before.

2.36. PacketVerifier suite

PacketVerifier module.

Example:
>>> from scapy.all import *
>>> from PacketVerifier import *
>>> rxq = RxQueue('eth1')
>>> txq = TxQueue('eth1')
>>> src_mac = "AA:BB:CC:DD:EE:FF"
>>> dst_mac = "52:54:00:ca:5d:0b"
>>> src_ip = "11.11.11.10"
>>> dst_ip = "11.11.11.11"
>>> sent_packets = []
>>> pkt_send = Ether(src=src_mac, dst=dst_mac) /
... IP(src=src_ip, dst=dst_ip) /
... ICMP()
>>> sent_packets.append(pkt_send)
>>> txq.send(pkt_send)
>>> pkt_send = Ether(src=src_mac, dst=dst_mac) /
... ARP(hwsrc=src_mac, psrc=src_ip, hwdst=dst_mac, pdst=dst_ip, op=2)
>>> sent_packets.append(pkt_send)
>>> txq.send(pkt_send)
>>> rxq.recv(100, sent_packets).show()
###[ Ethernet ]###
  dst       = aa:bb:cc:dd:ee:ff
  src       = 52:54:00:ca:5d:0b
  type      = 0x800
###[ IP ]###
  version   = 4L
  ihl       = 5L
  tos       = 0x0
  len       = 28
  id        = 43183
  flags     =
  frag      = 0L
  ttl       = 64
  proto     = icmp
  chksum    = 0xa607
  src       = 11.11.11.11
  dst       = 11.11.11.10
  options
###[ ICMP ]###
  type      = echo-reply
  code      = 0
  chksum    = 0xffff
  id        = 0x0
  seq       = 0x0
###[ Padding ]###
  load = 'RTÊ]

ª»ÌÝîÿ’

class resources.libraries.python.PacketVerifier.RxQueue(interface_name)

Bases: resources.libraries.python.PacketVerifier.PacketVerifier

Receive queue object.

This object creates raw socket, reads packets from it and provides function to access them.

Parameters:interface_name (str) – Which interface to bind to.
recv(timeout=3, ignore=None, verbose=True)

Read next received packet.

Returns scapy’s Ether() object created from next packet in the queue. Queue is being filled in parallel in subprocess. If no packet arrives in given timeout queue.Empty exception will be risen.

Parameters:
  • timeout (int) – How many seconds to wait for next packet.
  • ignore (list) – List of packets that should be ignored.
  • verbose (bool) – Used to suppress detailed logging of received packets.
Returns:

Ether() initialized object from packet data.

Return type:

scapy.Ether

class resources.libraries.python.PacketVerifier.TxQueue(interface_name)

Bases: resources.libraries.python.PacketVerifier.PacketVerifier

Transmission queue object.

This object is used to send packets over RAW socket on a interface.

Parameters:interface_name (str) – Which interface to send packets from.
send(pkt, verbose=True)

Send packet out of the bound interface.

Parameters:
  • pkt (string or scapy Packet derivative.) – Packet to send.
  • verbose (bool) – Used to supress detailed logging of sent packets.
class resources.libraries.python.PacketVerifier.Interface(if_name)

Bases: object

Class for network interfaces. Contains methods for sending and receiving packets.

recv_pkt(timeout=3)

Read one packet from the interface’s receive queue.

Parameters:timeout (int) – Timeout value in seconds.
Returns:Ether() initialized object from packet data.
Return type:scapy.Ether
send_pkt(pkt)

Send the provided packet out the interface.

resources.libraries.python.PacketVerifier.create_gratuitous_arp_request(src_mac, src_ip)

Creates scapy representation of gratuitous ARP request.

resources.libraries.python.PacketVerifier.auto_pad(packet)

Pads zeroes at the end of the packet if the total len < 60 bytes.

resources.libraries.python.PacketVerifier.checksum_equal(chksum1, chksum2)

Compares two checksums in one’s complement notation.

Checksums to be compared are calculated as 16 bit one’s complement of the one’s complement sum of 16 bit words of some buffer. In one’s complement notation 0x0000 (positive zero) and 0xFFFF (negative zero) are equivalent.

Parameters:
  • chksum1 (uint16) – First checksum.
  • chksum2 (uint16) – Second checksum.
Returns:

True if checksums are equivalent, False otherwise.

Return type:

boolean

2.37. Policer suite

Policer utilities library.

class resources.libraries.python.Policer.DSCP(string, num)

Bases: enum.Enum

DSCP for mark-and-transmit action.

AF11 = ('AF11', 10)
AF12 = ('AF12', 12)
AF13 = ('AF13', 14)
AF21 = ('AF21', 18)
AF22 = ('AF22', 20)
AF23 = ('AF23', 22)
AF31 = ('AF31', 26)
AF32 = ('AF32', 28)
AF33 = ('AF33', 30)
CS0 = ('CS0', 0)
CS1 = ('CS1', 8)
CS2 = ('CS2', 16)
CS3 = ('CS3', 24)
CS4 = ('CS4', 32)
CS5 = ('CS5', 40)
CS6 = ('CS6', 48)
CS7 = ('CS7', 56)
EF = ('EF', 46)
class resources.libraries.python.Policer.Policer

Bases: object

Policer utilities.

static dscp_af11()

Return DSCP AF11.

Returns:DSCP enum AF11 object.
Return type:DSCP
static dscp_af12()

Return DSCP AF12.

Returns:DSCP enum AF12 object.
Return type:DSCP
static dscp_af13()

Return DSCP AF13.

Returns:DSCP enum AF13 object.
Return type:DSCP
static dscp_af21()

Return DSCP AF21.

Returns:DSCP enum AF21 object.
Return type:DSCP
static dscp_af22()

Return DSCP AF22.

Returns:DSCP enum AF22 object.
Return type:DSCP
static dscp_af23()

Return DSCP AF23.

Returns:DSCP enum AF23 object.
Return type:DSCP
static dscp_af31()

Return DSCP AF31.

Returns:DSCP enum AF31 object.
Return type:DSCP
static dscp_af32()

Return DSCP AF32.

Returns:DSCP enum AF32 object.
Return type:DSCP
static dscp_af33()

Return DSCP AF33.

Returns:DSCP enum AF33 object.
Return type:DSCP
static dscp_cs0()

Return DSCP CS0.

Returns:DSCP enum CS0 object.
Return type:DSCP
static dscp_cs1()

Return DSCP CS1.

Returns:DSCP enum CS1 object.
Return type:DSCP
static dscp_cs2()

Return DSCP CS2.

Returns:DSCP enum CS2 object.
Return type:DSCP
static dscp_cs3()

Return DSCP CS3.

Returns:DSCP enum CS3 object.
Return type:DSCP
static dscp_cs4()

Return DSCP CS4.

Returns:DSCP enum CS4 object.
Return type:DSCP
static dscp_cs5()

Return DSCP CS5.

Returns:DSCP enum CS5 object.
Return type:DSCP
static dscp_cs6()

Return DSCP CS6.

Returns:DSCP enum CS6 object.
Return type:DSCP
static dscp_cs7()

Return DSCP CS7.

Returns:DSCP enum CS7 object.
Return type:DSCP
static dscp_ef()

Return DSCP EF.

Returns:DSCP enum EF object.
Return type:DSCP
static get_dscp_num_value(dscp)

Return DSCP numeric value.

Parameters:dscp (DSCP) – DSCP enum object.
Returns:DSCP numeric value.
Return type:int
policer_classify_set_interface(interface)

Set policer classify interface.

Parameters:interface (str or int) – Interface name or sw_if_index.

Note

First set node with policer_set_node.

policer_classify_set_match_ip(ip, is_src=True)

Set policer classify match source IP address.

Parameters:
  • ip (str) – IPv4 or IPv6 address.
  • is_src (bool) – Match src IP if True otherwise match dst IP.
policer_classify_set_precolor_conform()

Set policer classify pre-color to conform-color.

policer_classify_set_precolor_exceed()

Set policer classify pre-color to exceeed-color.

policer_clear_settings()

Clear policer settings.

policer_enable_color_aware()

Enable color-aware mode for policer.

policer_set_cb(cb)

Set policer CB.

Parameters:cb (int) – Committed Burst size.
policer_set_cir(cir)

Set policer CIR.

Parameters:cir (int) – Committed Information Rate.
policer_set_configuration()

Configure policer on VPP node.

...note:: First set all required parameters.

policer_set_conform_action_drop()

Set policer conform-action to drop.

policer_set_conform_action_mark_and_transmit(dscp)

Set policer conform-action to mark-and-transmit.

Parameters:dscp (DSCP) – DSCP value to mark.
policer_set_conform_action_transmit()

Set policer conform-action to transmit.

policer_set_eb(eb)

Set policer EB.

Parameters:eb (int) – Excess Burst size.
policer_set_eir(eir)

Set polcier EIR.

Parameters:eir (int) – Excess Information Rate.
policer_set_exceed_action_drop()

Set policer exceed-action to drop.

policer_set_exceed_action_mark_and_transmit(dscp)

Set policer exceed-action to mark-and-transmit.

Parameters:dscp (DSCP) – DSCP value to mark.
policer_set_exceed_action_transmit()

Set policer exceed-action to transmit.

policer_set_name(name)

Set policer name.

Parameters:name (str) – Policer name.
policer_set_node(node)

Set node to setup policer on.

Parameters:node (dict) – VPP node.
policer_set_rate_type_kbps()

Set policer rate type to kbps.

policer_set_rate_type_pps()

Set policer rate type to pps.

policer_set_round_type_closest()

Set policer round type to closest.

policer_set_round_type_down()

Set policer round type to down.

policer_set_round_type_up()

Set policer round type to up.

policer_set_type_1r2c()

Set policer type to 1r2c.

policer_set_type_1r3c()

Set policer type to 1r3c RFC2697.

policer_set_type_2r3c_2698()

Set policer type to 2r3c RFC2698.

policer_set_type_2r3c_4115()

Set policer type to 2r3c RFC4115.

policer_set_type_2r3c_mef5cf1()

Set policer type to 2r3c MEF5CF1.

policer_set_violate_action_drop()

Set policer violate-action to drop.

policer_set_violate_action_mark_and_transmit(dscp)

Set policer violate-action to mark-and-transmit.

Parameters:dscp (DSCP) – DSCP value to mark.
policer_set_violate_action_transmit()

Set policer violate-action to transmit.

class resources.libraries.python.Policer.PolicerAction(string)

Bases: enum.Enum

Policer action.

DROP = 'drop'
MARK_AND_TRANSMIT = 'mark-and-transmit'
TRANSMIT = 'transmit'
class resources.libraries.python.Policer.PolicerClassifyPreColor(string)

Bases: enum.Enum

Policer classify precolor.

CONFORM_COLOR = 'conform-color'
EXCEED_COLOR = 'exceed-color'
class resources.libraries.python.Policer.PolicerClassifyTableType(string)

Bases: enum.Enum

Policer classify table type.

IP4_TABLE = 'ip4-table'
IP6_TABLE = 'ip6-table'
L2_TABLE = 'l2-table'
class resources.libraries.python.Policer.PolicerRateType(string)

Bases: enum.Enum

Policer rate types.

KBPS = 'kbps'
PPS = 'pps'
class resources.libraries.python.Policer.PolicerRoundType(string)

Bases: enum.Enum

Policer round types.

CLOSEST = 'closest'
DOWN = 'down'
UP = 'up'
class resources.libraries.python.Policer.PolicerType(string)

Bases: enum.Enum

Policer type.

P_1R2C = '1r2c'
P_1R3C = '1r3c'
P_2R3C_2698 = '2r3c-2698'
P_2R3C_4115 = '2r3c-4115'
P_2R3C_MEF5CF1 = '2r3c-mef5cf1'

2.38. ProxyArp suite

Proxy ARP library

class resources.libraries.python.ProxyArp.ProxyArp

Bases: object

Proxy ARP utilities.

static vpp_add_proxy_arp(node, lo_ip4_addr, hi_ip4_addr)

Enable proxy ARP for a range of IP addresses.

Parameters:
  • node (dict) – VPP node to enable proxy ARP.
  • lo_ip4_addr (str) – The lower limit of the IP addresses.
  • hi_ip4_addr (str) – The upper limit of the IP addresses.

2.39. QemuUtils suite

QEMU utilities library.

class resources.libraries.python.QemuUtils.QemuUtils(qemu_id=1)

Bases: object

QEMU utilities.

static build_qemu(node, force_install=False, apply_patch=False)

Build QEMU from sources.

Parameters:
  • node (dict) – Node to build QEMU on.
  • force_install (bool) – If True, then remove previous build.
  • apply_patch (bool) – If True, then apply patches from qemu_patches dir.
Raises:

RuntimeError if building QEMU failed.

qemu_add_vhost_user_if(socket, server=True, mac=None)

Add Vhost-user interface.

Parameters:
  • socket (str) – Path of the unix socket.
  • server (bool) – If True the socket shall be a listening socket.
  • mac (str) – Vhost-user interface MAC address (optional, otherwise is used auto-generated MAC 52:54:00:00:xx:yy).
qemu_clear_socks()

Remove all sockets created by QEMU.

qemu_kill()

Kill qemu process.

qemu_kill_all(node=None)

Kill all qemu processes on DUT node if specified.

Parameters:node (dict) – Node to kill all QEMU processes on.
qemu_quit()

Quit the QEMU emulator.

qemu_set_affinity(*host_cpus)

Set qemu affinity by getting thread PIDs via QMP and taskset to list of CPU cores.

Parameters:host_cpus (list) – List of CPU cores.
qemu_set_bin(path)

Set binary path for QEMU.

Parameters:path (str) – Absolute path in filesystem.
qemu_set_disk_image(disk_image)

Set disk image.

Parameters:disk_image (str) – Path of the disk image.
qemu_set_huge_allocate()

Set flag to allocate more huge pages if needed.

qemu_set_huge_mnt(huge_mnt)

Set hugefile mount point.

Parameters:huge_mnt (int) – System hugefile mount point.
qemu_set_mem_size(mem_size)

Set virtual RAM size.

Parameters:mem_size (int) – RAM size in Mega Bytes.
qemu_set_node(node)

Set node to run QEMU on.

Parameters:node (dict) – Node to run QEMU on.
qemu_set_scheduler_policy()
Set scheduler policy to SCHED_RR with priority 1 for all Qemu CPU
processes.
Raises:RuntimeError – Set scheduler policy failed.
qemu_set_serial_port(port)

Set serial console port.

Parameters:port (int) – Serial console port.
qemu_set_smp(cpus, cores, threads, sockets)

Set SMP option for QEMU.

Parameters:
  • cpus (int) – Number of CPUs.
  • cores (int) – Number of CPU cores on one socket.
  • threads (int) – Number of threads on one CPU core.
  • sockets (int) – Number of discrete sockets in the system.
qemu_set_ssh_fwd_port(fwd_port)

Set host port for guest SSH forwarding.

Parameters:fwd_port (int) – Port number on host for guest SSH forwarding.
qemu_start()

Start QEMU and wait until VM boot.

Returns:VM node info.
Return type:dict

Note

First set at least node to run QEMU on.

Warning

Starts only one VM on the node.

qemu_system_powerdown()

Power down the system (if supported).

qemu_system_reset()

Reset the system.

qemu_system_status()

Return current VM status.

VM should be in following status:

  • debug: QEMU running on a debugger
  • finish-migrate: paused to finish the migration process
  • inmigrate: waiting for an incoming migration
  • internal-error: internal error has occurred
  • io-error: the last IOP has failed
  • paused: paused
  • postmigrate: paused following a successful migrate
  • prelaunch: QEMU was started with -S and guest has not started
  • restore-vm: paused to restore VM state
  • running: actively running
  • save-vm: paused to save the VM state
  • shutdown: shut down (and -no-shutdown is in use)
  • suspended: suspended (ACPI S3)
  • watchdog: watchdog action has been triggered
  • guest-panicked: panicked as a result of guest OS panic
Returns:VM status.
Return type:str

2.40. Routing suite

Routing utilities library.

class resources.libraries.python.Routing.Routing

Bases: object

Routing utilities.

static add_fib_table(node, table_id, ipv6=False)

Create new FIB table according to ID.

Parameters:
  • node (dict) – Node to add FIB on.
  • table_id (int) – FIB table ID.
  • ipv6 (bool) – Is this an IPv6 table
static add_route(node, ip_addr, prefix, gateway, namespace=None)

Add route in namespace.

Parameters:
  • node (dict) – Node where to execute command.
  • ip_addr (str) – Route destination IP address.
  • prefix (int) – IP prefix.
  • namespace (str) – Execute command in namespace. Optional.
  • gateway (str) – Gateway address.
static vpp_route_add(node, network, prefix_len, gateway=None, interface=None, use_sw_index=True, resolve_attempts=10, count=1, vrf=None, lookup_vrf=None, multipath=False, weight=None, local=False)

Add route to the VPP node.

Parameters:
  • node – Node to add route on.
  • network – Route destination network address.
  • prefix_len – Route destination network prefix length.
  • gateway – Route gateway address.
  • interface – Route interface.
  • vrf – VRF table ID (Optional).
  • use_sw_index – Use sw_if_index in VAT command.
  • resolve_attempts – Resolve attempts IP route add parameter.
  • count – number of IP addresses to add starting from network IP
  • local – The route is local

with same prefix (increment is 1). If None, then is not used. :param lookup_vrf: VRF table ID for lookup. :param multipath: Enable multipath routing. :param weight: Weight value for unequal cost multipath routing. :type node: dict :type network: str :type prefix_len: int :type gateway: str :type interface: str :type use_sw_index: bool :type resolve_attempts: int :type count: int :type vrf: int :type lookup_vrf: int :type multipath: bool :type weight: int :type local: bool

2.41. SRv6 suite

Segment Routing over IPv6 dataplane utilities library.

class resources.libraries.python.SRv6.SRv6

Bases: object

SRv6 class.

static configure_sr_localsid(node, local_sid, behavior, interface=None, next_hop=None, fib_table=None)

Create SRv6 LocalSID and binds it to a particular behaviour on the given node.

Parameters:
  • node (dict) – Given node to create localSID on.
  • local_sid (str) – LocalSID IPv6 address.
  • behavior (str) – SRv6 LocalSID function.
  • interface (str) – Interface name (Optional, required for L2/L3 xconnects).
  • next_hop (int) – Next hop IPv4/IPv6 address (Optional, required for L3 xconnects).
  • fib_table (str) – FIB table for IPv4/IPv6 lookup (Optional, required for L3 routing).
Raises:

ValueError – If unsupported SRv6 LocalSID function used or required parameter is missing.

static configure_sr_policy(node, bsid, sid_list, mode='encap')

Create SRv6 policy on the given node.

Parameters:
  • node (dict) – Given node to create SRv6 policy on.
  • bsid (str) – BindingSID - local SID IPv6 address.
  • sid_list (list) – SID list.
  • mode (str) – Encapsulation / insertion mode.
static configure_sr_steer(node, mode, bsid, interface=None, ip_addr=None, prefix=None)

Create SRv6 steering policy on the given node.

Parameters:
  • node (dict) – Given node to create steering policy on.
  • mode (str) – Mode of operation - L2 or L3.
  • bsid (str) – BindingSID - local SID IPv6 address.
  • interface (str) – Interface name (Optional, required in case of L2 mode).
  • ip_addr (str) – IPv4/IPv6 address (Optional, required in case of L3 mode).
  • prefix (int) – IP address prefix (Optional, required in case of L3 mode).
Raises:

ValueError – If unsupported mode used or required parameter is missing.

static delete_sr_localsid(node, local_sid)

Delete SRv6 LocalSID on the given node.

Parameters:
  • node (dict) – Given node to delete localSID on.
  • local_sid (str) – LocalSID IPv6 address.
static delete_sr_policy(node, bsid)

Delete SRv6 policy on the given node.

Parameters:
  • node (dict) – Given node to delete SRv6 policy on.
  • bsid (str) – BindingSID IPv6 address.
static delete_sr_steer(node, mode, bsid, interface=None, ip_addr=None, mask=None)

Delete SRv6 steering policy on the given node.

Parameters:
  • node (dict) – Given node to delete steering policy on.
  • mode (str) – Mode of operation - L2 or L3.
  • bsid (str) – BindingSID - local SID IPv6 address.
  • interface (str) – Interface name (Optional, required in case of L2 mode).
  • ip_addr (int) – IPv4/IPv6 address (Optional, required in case of L3 mode).
  • mask (int) – IP address mask (Optional, required in case of L3 mode).
Raises:

ValueError – If unsupported mode used or required parameter is missing.

static set_sr_encaps_source_address(node, ip6_addr)

Set SRv6 encapsulation source address on the given node.

Parameters:
  • node (dict) – Given node to set SRv6 encapsulation source address on.
  • ip6_addr (str) – Local SID IPv6 address.
static show_sr_localsids(node)

Show SRv6 LocalSIDs on the given node.

Parameters:node (dict) – Given node to show localSIDs on.
static show_sr_policies(node)

Show SRv6 policies on the given node.

Parameters:node (dict) – Given node to show SRv6 policies on.
static show_sr_steering_policies(node)

Show SRv6 steering policies on the given node.

Parameters:node (dict) – Given node to show SRv6 steering policies on.

2.42. SchedUtils suite

Linux scheduler util library

class resources.libraries.python.SchedUtils.SchedUtils

Bases: object

General class for any linux scheduler related methods/functions.

static set_proc_scheduling_other(node, pid)

Set normal scheduling of a process to SCHED_OTHER for specified PID.

Parameters:
  • node (dict) – Node where to apply scheduling changes.
  • pid (int) – Process ID.
Raises:
  • ValueError – Parameters out of allowed ranges.
  • RuntimeError – Failed to set policy for PID.
static set_proc_scheduling_rr(node, pid, priority=1)

Set real-time scheduling of a process to SCHED_RR with priority for specified PID.

Parameters:
  • node (dict) – Node where to apply scheduling changes.
  • pid (int) – Process ID.
  • priority (int) – Realtime priority in range 1-99. Default is 1.
Raises:
  • ValueError – Parameters out of allowed ranges.
  • RuntimeError – Failed to set policy for PID.
static set_vpp_scheduling_rr(node)

Set real-time scheduling attributes of VPP worker threads to SCHED_RR with priority 1.

Parameters:node (dict) – DUT node with running VPP.
Raises:RuntimeError – Failed to retrieve PID for VPP worker threads.

2.43. SetupFramework suite

This module exists to provide setup utilities for the framework on topology nodes. All tasks required to be run before the actual tests are started is supposed to end up here.

class resources.libraries.python.SetupFramework.SetupFramework

Bases: object

Setup suite run on topology nodes.

Many VAT/CLI based tests need the scripts at remote hosts before executing them. This class packs the whole testing directory and copies it over to all nodes in topology under /tmp/

static setup_framework(nodes)

Pack the whole directory and extract in temp on each node.

Parameters:nodes (dict) – Topology nodes.

2.44. TGSetup suite

TG Setup library.

class resources.libraries.python.TGSetup.TGSetup

Bases: object

TG setup before test.

static all_tgs_set_interface_default_driver(nodes)

Setup interfaces default driver for all TGs in given topology.

Parameters:nodes (dict) – Nodes in topology.

2.45. Tap suite

Tap utilities library.

class resources.libraries.python.Tap.Tap

Bases: object

Tap utilities.

static add_tap_interface(node, tap_name, mac=None)

Add tap interface with name and optionally with MAC.

Parameters:
  • node (dict) – Node to add tap on.
  • tap_name (str) – Tap interface name for linux tap.
  • mac (str) – Optional MAC address for VPP tap.
Returns:

Returns a interface index.

Return type:

int

static check_tap_present(node, tap_name)

Check whether specific tap interface exists.

Parameters:
  • node (dict) – Node to check tap on.
  • tap_name (str) – Tap interface name for linux tap.
Raises:

RuntimeError – Specified interface was not found.

static delete_tap_interface(node, if_index)

Delete tap interface.

Parameters:
  • node (dict) – Node to delete tap on.
  • if_index (int) – Index of tap interface to be deleted.
Raises:

RuntimeError – Deletion was not successful.

static modify_tap_interface(node, if_index, tap_name, mac=None)

Modify tap interface like linux interface name or VPP MAC.

Parameters:
  • node (dict) – Node to modify tap on.
  • if_index (int) – Index of tap interface to be modified.
  • tap_name (str) – Tap interface name for linux tap.
  • mac (str) – Optional MAC address for VPP tap.
Returns:

Returns a interface index.

Return type:

int

static vpp_get_tap_interface_mac(node, sw_if_idx)

Get tap interface MAC address from hardware interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

Tap interface MAC address.

Return type:

str

static vpp_get_tap_interface_name(node, sw_if_idx)

Get VPP tap interface name from hardware interfaces dump.

Parameters:
  • node (dict) – DUT node.
  • sw_if_idx (int) – DUT node.
Returns:

VPP tap interface name.

Return type:

str

2.46. Trace suite

Packet trace library.

class resources.libraries.python.Trace.Trace

Bases: object

This class provides methods to manipulate the VPP packet trace.

static clear_packet_trace_on_all_duts(nodes)

Clear VPP packet trace.

Parameters:nodes (list) – Nodes where the packet trace will be cleared.
static show_packet_trace_on_all_duts(nodes)

Show VPP packet trace.

Parameters:nodes (list) – Nodes from which the packet trace will be displayed.

2.47. TrafficGenerator suite

Performance testing traffic generator library.

class resources.libraries.python.TrafficGenerator.TrafficGenerator

Bases: object

Traffic Generator.

ROBOT_LIBRARY_SCOPE = 'TEST SUITE'
get_latency_int()

Return rounded min/avg/max latency.

Returns:Latency stats.
Return type:list
get_loss()

Return number of lost packets.

Returns:Number of lost packets.
Return type:str
get_received()

Return number of received packets.

Returns:Number of received packets.
Return type:str
get_sent()

Return number of sent packets.

Returns:Number of sent packets.
Return type:str
initialize_traffic_generator(tg_node, tg_if1, tg_if2, tg_if1_adj_node, tg_if1_adj_if, tg_if2_adj_node, tg_if2_adj_if, test_type, tg_if1_dst_mac=None, tg_if2_dst_mac=None)

TG initialization.

Parameters:
  • tg_node (dict) – Traffic generator node.
  • tg_if1 (str) – TG - name of first interface.
  • tg_if2 (str) – TG - name of second interface.
  • tg_if1_adj_node (dict) – TG if1 adjecent node.
  • tg_if1_adj_if (str) – TG if1 adjecent interface.
  • tg_if2_adj_node (dict) – TG if2 adjecent node.
  • tg_if2_adj_if (str) – TG if2 adjecent interface.
  • test_type (str) – ‘L2’, ‘L3’ or ‘L7’ - OSI Layer testing type.
  • tg_if1_dst_mac (str) – Interface 1 destination MAC address.
  • tg_if2_dst_mac (str) – Interface 2 destination MAC address.
Returns:

nothing

Raises:

RuntimeError in case of issue during initialization.

static is_trex_running(node)

Check if TRex is running using pidof.

Parameters:node (dict) – Traffic generator node.
Returns:True if TRex is running otherwise False.
Return type:bool
Raises:RuntimeError if node type is not a TG.
no_traffic_loss_occurred()

Fail if loss occurred in traffic run.

Returns:nothing
Raises:Exception if loss occured.
node

Getter.

Returns:Traffic generator node.
Return type:dict
partial_traffic_loss_accepted(loss_acceptance, loss_acceptance_type)

Fail if loss is higher then accepted in traffic run.

Parameters:
  • loss_acceptance (float) – Permitted drop ratio or frames count.
  • loss_acceptance_type (LossAcceptanceType) – Type of permitted loss.
Returns:

nothing

Raises:

Exception if loss is above acceptance criteria.

send_traffic_on_tg(duration, rate, framesize, traffic_type, warmup_time=5, async_call=False, latency=True)

Send traffic from all configured interfaces on TG.

Parameters:
  • duration (str) – Duration of test traffic generation in seconds.
  • rate (str) – Offered load per interface (e.g. 1%, 3gbps, 4mpps, ...).
  • framesize (str) – Frame size (L2) in Bytes.
  • traffic_type (str) – Traffic profile.
  • warmup_time (int) – Warmup phase in seconds.
  • async_call (bool) – Async mode.
  • latency (bool) – With latency measurement.
Returns:

TG output.

Return type:

str

Raises:

RuntimeError if TG is not set.

Raises:

RuntimeError if node is not TG or subtype is not specified.

Raises:

NotImplementedError if TG is not supported.

stop_traffic_on_tg()

Stop all traffic on TG.

Returns:Nothing
Raises:RuntimeError if TG is not set.
static teardown_traffic_generator(node)

TG teardown.

Parameters:node (dict) – Traffic generator node.
Returns:nothing
Raises:RuntimeError if TRex teardown failed.
Raises:RuntimeError if node type is not a TG.
trex_stl_start_remote_exec(duration, rate, framesize, traffic_type, async_call=False, latency=True, warmup_time=5)

Execute script on remote node over ssh to start traffic.

Parameters:
  • duration (int) – Time expresed in seconds for how long to send traffic.
  • rate (str) – Traffic rate expressed with units (pps, %)
  • framesize (str) – L2 frame size to send (without padding and IPG).
  • traffic_type (str) – Traffic profile.
  • async_call (bool) – If enabled then don’t wait for all incomming trafic.
  • latency (bool) – With latency measurement.
  • warmup_time (int) – Warmup time period.
Returns:

Nothing

Raises:

RuntimeError in case of TG driver issue.

static trex_stl_stop_remote_exec(node)

Execute script on remote node over ssh to stop running traffic.

Parameters:node (dict) – TRex generator node.
Returns:Nothing
Raises:RuntimeError if stop traffic script fails.
class resources.libraries.python.TrafficGenerator.TGDropRateSearchImpl

Bases: resources.libraries.python.DropRateSearch.DropRateSearch

Drop Rate Search implementation.

get_latency()

Returns min/avg/max latency.

Returns:Latency stats.
Return type:list
measure_loss(rate, frame_size, loss_acceptance, loss_acceptance_type, traffic_type)

Runs the traffic and evaluate the measured results.

Parameters:
  • rate (int) – Offered traffic load.
  • frame_size (str) – Size of frame.
  • loss_acceptance (float) – Permitted drop ratio or frames count.
  • loss_acceptance_type (LossAcceptanceType) – Type of permitted loss.
  • traffic_type (str) – Traffic profile ([2,3]-node-L[2,3], ...).
Returns:

Drop threshold exceeded? (True/False)

Return type:

bool

Raises:

NotImplementedError if TG is not supported.

Raises:

RuntimeError if TG is not specified.

2.48. TrafficScriptArg suite

Traffic scripts argument parser library.

class resources.libraries.python.TrafficScriptArg.TrafficScriptArg(more_args=None, opt_args=None)

Bases: object

Traffic scripts argument parser.

Parse arguments for traffic script. Default has two arguments ‘–tx_if’ and ‘–rx_if’. You can provide more arguments. All arguments have string representation of the value. You can add also optional arguments. Default value for optional arguments is empty string.

Parameters:
  • more_args (list) – List of additional arguments (optional).
  • opt_args (list) – List of optional arguments (optional).
Example:
>>> from TrafficScriptArg import TrafficScriptArg
>>> args = TrafficScriptArg(['src_mac', 'dst_mac', 'src_ip', 'dst_ip'])
get_arg(arg_name)

Get argument value.

Parameters:arg_name (str) – Argument name.
Returns:Argument value.
Return type:str

2.49. TrafficScriptExecutor suite

Traffic script executor library.

class resources.libraries.python.TrafficScriptExecutor.TrafficScriptExecutor

Bases: object

Traffic script executor utilities.

static run_traffic_script_on_node(script_file_name, node, script_args, timeout=60)

Run traffic script on the TG node.

Parameters:
  • script_file_name (str) – Traffic script name.
  • node (dict) – Node to run traffic script on.
  • script_args (str) – Traffic scripts arguments.
  • timeout (int) – Timeout (optional).
Raises:
  • RuntimeError – ICMP echo Rx timeout.
  • RuntimeError – DHCP REQUEST Rx timeout.
  • RuntimeError – DHCP DISCOVER Rx timeout.
  • RuntimeError – TCP/UDP Rx timeout.
  • RuntimeError – ARP reply timeout.
  • RuntimeError – Traffic script execution failed.
static traffic_script_gen_arg(rx_if, tx_if, src_mac, dst_mac, src_ip, dst_ip)

Generate traffic script basic arguments string.

Parameters:
  • rx_if (str) – Interface that receives traffic.
  • tx_if (str) – Interface that sends traffic.
  • src_mac (str) – Source MAC address.
  • dst_mac (str) – Destination MAC address.
  • src_ip (str) – Source IP address.
  • dst_ip (str) – Destination IP address.
Returns:

Traffic script arguments string.

Return type:

str

2.50. VPPUtil suite

VPP util library

class resources.libraries.python.VPPUtil.VPPUtil

Bases: object

General class for any VPP related methods/functions.

static show_vpp_settings(node, *additional_cmds)

Print default VPP settings. In case others are needed, can be accepted as next parameters (each setting one parameter), preferably in form of a string.

Parameters:
  • node – VPP node.
  • additional_cmds – Additional commands that the vpp should print

settings for. :type node: dict :type additional_cmds: tuple

static start_vpp_service(node)

start VPP service on the specified node.

Parameters:node (dict) – VPP node.
Raises:RuntimeError – If VPP fails to start.
static stop_vpp_service(node)

Stop VPP service on the specified node.

Parameters:node (dict) – VPP node.
Raises:RuntimeError – If VPP fails to stop.

2.51. VatExecutor suite

VAT executor library.

class resources.libraries.python.VatExecutor.VatExecutor

Bases: object

Contains methods for executing VAT commands on DUTs.

static cmd_from_template(node, vat_template_file, **vat_args)

Execute VAT script on specified node. This method supports script templates with parameters.

Parameters:
  • node – Node in topology on witch the script is executed.
  • vat_template_file – Template file of VAT script.
  • vat_args – Arguments to the template file.
Returns:

List of JSON objects returned by VAT.

execute_script(vat_name, node, timeout=15, json_out=True)

Copy local_path script to node, execute it and return result.

Parameters:vat_name – Name of the vat script file. Only the file name of

the script is required, the resources path is prepended automatically. :param node: Node to execute the VAT script on. :param timeout: Seconds to allow the script to run. :param json_out: Require JSON output. :type vat_name: str :type node: dict :type timeout: int :type json_out: bool :returns: Status code, stdout and stderr of executed VAT script. :rtype: tuple :raises RuntimeError: If VAT script execution failed.

execute_script_json_out(vat_name, node, timeout=15)

Pass all arguments to ‘execute_script’ method, then cleanup returned json output.

param vat_name:Name of the vat script file. Only the file name of

the script is required, the resources path is prepended automatically. :param node: Node to execute the VAT script on. :param timeout: Seconds to allow the script to run. :type vat_name: str :type node: dict :type timeout: int

get_script_stderr()

Returns value of stderr from last executed script.

get_script_stdout()

Returns value of stdout from last executed script.

scp_and_execute_cli_script(fname, node, timeout=15, json_out=True)

Copy vat_name script to node, execute it and return result.

Parameters:fname – Name of the VPP script file.

Full path and name of the script is required. :param node: Node to execute the VPP script on. :param timeout: Seconds to allow the script to run. :param json_out: Require JSON output. :type fname: str :type node: dict :type timeout: int :type json_out: bool :returns: Status code, stdout and stderr of executed CLI script. :rtype: tuple :raises RuntimeError: If CLI script execution failed.

scp_and_execute_script(vat_name, node, timeout=15, json_out=True)

Copy vat_name script to node, execute it and return result.

Parameters:vat_name – Name of the vat script file.

Full path and name of the script is required. :param node: Node to execute the VAT script on. :param timeout: Seconds to allow the script to run. :param json_out: Require JSON output. :type vat_name: str :type node: dict :type timeout: int :type json_out: bool :returns: Status code, stdout and stderr of executed VAT script. :rtype: tuple :raises RuntimeError: If VAT script execution failed.

script_should_have_failed()

Read return code from last executed script and raise exception if the script didn’t fail.

script_should_have_passed()

Read return code from last executed script and raise exception if the script failed.

2.52. VatHistory suite

DUT VAT command history setup library.

class resources.libraries.python.VatHistory.VatHistory

Bases: object

Contains methods to set up DUT VAT command history.

static add_to_vat_history(node, cmd)

Add command to VAT command history on DUT node.

Parameters:
  • node (dict) – DUT node to add command to VAT command history for.
  • cmd (str) – Command to be added to VAT command history.
static reset_vat_history(node)

Reset VAT command history for DUT node.

Parameters:node (dict) – DUT node to reset VAT command history for.
static reset_vat_history_on_all_duts(nodes)

Reset VAT command history for all DUT nodes.

Parameters:nodes (dict) – Nodes to reset VAT command history for.
static show_vat_history(node)

Show VAT command history for DUT node.

Parameters:node (dict) – DUT node to show VAT command history for.
static show_vat_history_on_all_duts(nodes)

Show VAT command history for all DUT nodes.

Parameters:nodes (dict) – Nodes to show VAT command history for.

2.53. VatJsonUtil suite

Utilities to work with JSON data format from VAT.

class resources.libraries.python.VatJsonUtil.VatJsonUtil

Bases: object

Utilities to work with JSON data format from VAT.

static get_interface_name_from_json(interface_dump_json, sw_if_index)

Get interface name from given JSON output by sw_if_index.

Parameters:interface_dump_json – JSON output from dump_interface_list VAT

command. :param sw_if_index: SW interface index. :type interface_dump_json: str :type sw_if_index: int :return: Interface name. :rtype: str :raises ValueError: If interface not found in interface_dump_json.

static get_interface_sw_index_from_json(interface_dump_json, interface_name)

Get sw_if_index from given JSON output by interface name.

Parameters:interface_dump_json – JSON output from dump_interface_list VAT

command. :param interface_name: Interface name. :type interface_dump_json: str :type interface_name: str :return: SW interface index. :rtype: int :raises ValueError: If interface not found in interface_dump_json.

static get_vpp_interface_by_mac(interfaces_list, mac_address)

Return interface dictionary from interface_list by MAC address.

Extracts interface dictionary from all of the interfaces in interfaces list parsed from JSON according to mac_address of the interface.

Parameters:
  • interfaces_list (dict) – Interfaces parsed from JSON.
  • mac_address (str) – MAC address of interface we are looking for.
Returns:

Interface from JSON.

Return type:

dict

static update_vpp_interface_data_from_json(node, interface_dump_json)

Update vpp node data in node__DICT from JSON interface dump.

This method updates vpp interface names and sw if indexes according to interface MAC addresses found in interface_dump_json.

Parameters:
  • node – Node dictionary.
  • interface_dump_json – JSON output from dump_interface_list VAT

command. :type node: dict :type interface_dump_json: str

static verify_vat_retval(vat_out, exp_retval=0, err_msg='VAT cmd failed')

Verify return value of VAT command.

VAT command JSON output should be object (dict in python) or array. We are looking for something like this: { “retval”: 0 }. Verification is skipped if VAT output does not contain return value element or root elemet is array.

Parameters:
  • vat_out (dict or list) – VAT command output in python representation of JSON.
  • exp_retval (int) – Expected return value (default 0).
Err_msg:

Message to be displayed in case of error (optional).

Raises:

RuntimeError – If VAT command return value is incorrect.

2.54. VhostUser suite

Vhost-user interfaces library.

class resources.libraries.python.VhostUser.VhostUser

Bases: object

Vhost-user interfaces

static get_vhost_user_if_name_by_sock(node, socket)

Get Vhost-user interface name by socket.

Parameters:
  • node (dict) – Node to get Vhost-user interface name on.
  • socket (str) – Vhost-user interface socket path.
Returns:

Interface name or None if not found.

Return type:

str

static get_vhost_user_mac_by_sw_index(node, sw_if_index)

Get Vhost-user l2_address for the given interface from actual interface dump.

Parameters:
  • node (dict) – VPP node to get interface data from.
  • sw_if_index (str) – Idx of the specific interface.
Returns:

l2_address of the given interface.

Return type:

str

static show_vpp_vhost_on_all_duts(nodes)

Show Vhost User on all DUTs.

Parameters:nodes (dict) – VPP nodes.
static vpp_create_vhost_user_interface(node, socket)

Create Vhost-user interface on VPP node.

Parameters:
  • node (dict) – Node to create Vhost-user interface on.
  • socket (str) – Vhost-user interface socket path.
Returns:

SW interface index.

Return type:

int

Raises:

RuntimeError – If Vhost-user interface creation failed.

static vpp_show_vhost(node)

Get vhost-user data for the given node.

Parameters:node (dict) – VPP node to get interface data from.
Returns:nothing

2.55. VppConfigGenerator suite

VPP Configuration File Generator library.

class resources.libraries.python.VppConfigGenerator.VppConfigGenerator

Bases: object

VPP Configuration File Generator.

add_api_segment_api_size(value)

Add API-SEGMENT api-size configuration.

Parameters:value (str) – API size.
add_api_segment_gid(value='vpp')

Add API-SEGMENT gid configuration.

Parameters:value (str) – Gid.
add_api_segment_global_size(value)

Add API-SEGMENT global-size configuration.

Parameters:value (str) – Global size.
add_api_trace()

Add API trace configuration.

add_config_item(config, value, path)

Add startup configuration item.

Parameters:
  • config (dict) – Startup configuration of node.
  • value (str) – Value to insert.
  • path (list) – Path where to insert item.
add_cpu_corelist_workers(value)

Add CPU corelist-workers configuration.

Parameters:value (str) – Corelist-workers option.
add_cpu_main_core(value)

Add CPU main core configuration.

Parameters:value (str) – Main core option.
add_dpdk_cryptodev(count)

Add DPDK Crypto PCI device configuration.

Parameters:count (int) – Number of HW crypto devices to add.
add_dpdk_dev(*devices)

Add DPDK PCI device configuration.

Parameters:devices (tuple) – PCI device(s) (format xxxx:xx:xx.x)
Raises:ValueError – If PCI address format is not valid.
add_dpdk_dev_default_rxd(value)

Add DPDK dev default rxd configuration.

Parameters:value (str) – Default number of rxds.
add_dpdk_dev_default_rxq(value)

Add DPDK dev default rxq configuration.

Parameters:value (str) – Default number of rxqs.
add_dpdk_dev_default_txd(value)

Add DPDK dev default txd configuration.

Parameters:value (str) – Default number of txds.
add_dpdk_dev_default_txq(value)

Add DPDK dev default txq configuration.

Parameters:value (str) – Default number of txqs.
add_dpdk_no_multi_seg()

Add DPDK no-multi-seg configuration.

add_dpdk_no_tx_checksum_offload()

Add DPDK no-tx-checksum-offload configuration.

add_dpdk_socketmem(value)

Add DPDK socket memory configuration.

Parameters:value (str) – Socket memory size.
add_dpdk_sw_cryptodev(sw_pmd_type, socket_id, count)

Add DPDK SW Crypto device configuration.

Parameters:
  • sw_pmd_type (str) – Type of SW crypto device PMD to add.
  • socket_id (int) – Socket ID.
  • count (int) – Number of SW crypto devices to add.
add_dpdk_uio_driver(value)

Add DPDK uio-driver configuration.

Parameters:value (str) – DPDK uio-driver configuration.
add_heapsize(value)

Add Heapsize configuration.

Parameters:value (str) – Amount of heapsize.
add_ip6_hash_buckets(value)

Add IP6 hash buckets configuration.

Parameters:value (str) – Number of IP6 hash buckets.
add_ip6_heap_size(value)

Add IP6 heap-size configuration.

Parameters:value (str) – IP6 Heapsize amount.
add_ip_heap_size(value)

Add IP heap-size configuration.

Parameters:value (str) – IP Heapsize amount.
add_nat(value='deterministic')

Add NAT configuration.

Parameters:value (str) – NAT mode.
add_plugin_disable(*plugins)

Add plugin disable for specific plugin.

Parameters:plugins (list) – Plugin(s) to disable.
add_session_event_queue_length(value)

Add session event queue length.

Parameters:value (int) – Session event queue length.
add_session_local_endpoints_table_buckets(value)

Add the number of local endpoints table buckets.

Parameters:value (int) – Number of local endpoints table buckets.
add_session_local_endpoints_table_memory(value)

Add the size of local endpoints table memory.

Parameters:value (str) – Size of local endpoints table memory.
add_session_preallocated_sessions(value)

Add the number of pre-allocated sessions.

Parameters:value (int) – Number of pre-allocated sessions.
add_session_v4_halfopen_table_buckets(value)

Add the number of v4 halfopen table buckets.

Parameters:value (int) – Number of v4 halfopen table buckets.
add_session_v4_halfopen_table_memory(value)

Add the size of v4 halfopen table memory.

Parameters:value (str) – Size of v4 halfopen table memory.
add_session_v4_session_table_buckets(value)

Add number of v4 session table buckets to the config.

Parameters:value (int) – Number of v4 session table buckets.
add_session_v4_session_table_memory(value)

Add the size of v4 session table memory.

Parameters:value (str) – Size of v4 session table memory.
add_tcp_preallocated_connections(value)

Add TCP pre-allocated connections.

Parameters:value (int) – The number of pre-allocated connections.
add_tcp_preallocated_half_open_connections(value)

Add TCP pre-allocated half open connections.

Parameters:value (int) – The number of pre-allocated half open connections.
add_unix_cli_listen(value='localhost:5002')

Add UNIX cli-listen configuration.

Parameters:value (str) – CLI listen address and port or path to CLI socket.
add_unix_coredump()

Add UNIX full-coredump configuration.

add_unix_exec(value)

Add UNIX exec configuration.

add_unix_gid(value='vpp')

Add UNIX gid configuration.

Parameters:value (str) – Gid.
add_unix_log(value=None)

Add UNIX log configuration.

Parameters:value (str) – Log file.
add_unix_nodaemon()

Add UNIX nodaemon configuration.

apply_config(filename=None, waittime=5, retries=12, restart_vpp=True)

Generate and apply VPP configuration for node.

Use data from calls to this class to form a startup.conf file and replace /etc/vpp/startup.conf with it on node.

Parameters:
  • filename (str) – Startup configuration file name.
  • waittime (int) – Time to wait for VPP to restart (default 5 seconds).
  • retries (int) – Number of times (default 12) to re-try waiting.
  • restart_vpp (bool.) – Whether to restart VPP.
Raises:

RuntimeError – If writing config file failed or restart of VPP failed or backup of VPP startup.conf failed.

dump_config(obj, level=-1)

Dump the startup configuration in VPP config format.

Parameters:
  • obj (Obj) – Python Object to print.
  • level (int) – Nested level for indentation.
Returns:

nothing

get_config_str()

Get dumped startup configuration in VPP config format.

Returns:Startup configuration in VPP config format.
Return type:str
restore_config()

Restore VPP startup.conf from backup.

Raises:RuntimeError – When restoration of startup.conf file failed.
set_node(node)

Set DUT node.

Parameters:node (dict) – Node to store configuration on.
Raises:RuntimeError – If Node type is not DUT.
set_vpp_logfile(logfile)

Set VPP logfile location.

Parameters:logfile (str) – VPP logfile location.
set_vpp_startup_conf_backup(backup='/etc/vpp/startup.backup')

Set VPP startup configuration backup.

Parameters:backup (str) – VPP logfile location.

2.56. VppCounters suite

VPP counters utilities library.

class resources.libraries.python.VppCounters.VppCounters

Bases: object

VPP counters utilities.

static clear_error_counters_on_all_duts(nodes)

Clear VPP errors counters on all DUTs.

Parameters:nodes (dict) – VPP nodes.
static clear_hardware_counters_on_all_duts(nodes)

Clear hardware counters on all DUTs.

Parameters:nodes (dict) – VPP nodes.
static clear_interface_counters_on_all_duts(nodes)

Clear interface counters on all DUTs.

Parameters:nodes (dict) – VPP nodes.
static clear_runtime_counters_on_all_duts(nodes)

Run “clear runtime” CLI command on all DUTs.

Parameters:nodes (dict) – VPP nodes.
static show_runtime_counters_on_all_duts(nodes)

Clear VPP runtime counters on all DUTs.

Parameters:nodes (dict) – VPP nodes.
static show_statistics_on_all_duts(nodes, sleeptime=5)

Show VPP statistics on all DUTs.

Parameters:
  • nodes (dict) – VPP nodes.
  • sleeptime (int) – Time to wait for traffic to arrive back to TG.
static show_vpp_statistics(node)

Show [error, hardware, interface] stats.

Parameters:node (dict) – VPP node.
static vpp_clear_errors_counters(node)

Clear errors counters on VPP node.

Parameters:node (dict) – Node to clear errors counters on.
static vpp_clear_hardware_counters(node)

Clear interface hardware counters on VPP node.

Parameters:node (dict) – Node to clear hardware counters on.
static vpp_clear_interface_counters(node)

Clear interface counters on VPP node.

Parameters:node (dict) – Node to clear interface counters on.
static vpp_clear_runtime(node)

Run “clear runtime” CLI command.

Parameters:node (dict) – Node to run command on.
vpp_dump_stats_table(node)

Dump stats table on VPP node.

Parameters:node (dict) – Node to dump stats table on.
Returns:Stats table.
vpp_get_ipv46_interface_counter(node, interface, is_ipv6=True)

Return interface IPv4/IPv6 counter.

Parameters:
  • node (dict) – Node to get interface IPv4/IPv6 counter on.
  • interface (str) – Interface name.
  • is_ipv6 (bool) – Specify IP version.
Returns:

Interface IPv4/IPv6 counter.

Return type:

int

vpp_get_ipv4_interface_counter(node, interface)
Parameters:
  • node (dict) – Node to get interface IPv4 counter on.
  • interface (str) – Interface name.
Returns:

Interface IPv4 counter.

Return type:

int

vpp_get_ipv6_interface_counter(node, interface)
Parameters:
  • node (dict) – Node to get interface IPv6 counter on.
  • interface (str) – Interface name.
Returns:

Interface IPv6 counter.

Return type:

int

vpp_nodes_clear_interface_counters(nodes)

Clear interface counters on all VPP nodes in topology.

Parameters:nodes (dict) – Nodes in topology.
static vpp_show_errors(node)

Run “show errors” debug CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_show_errors_on_all_duts(nodes, verbose=False)

Show errors on all DUTs.

Parameters:
  • nodes (dict) – VPP nodes.
  • verbose (bool) – If True show verbose output.
static vpp_show_errors_verbose(node)

Run “show errors verbose” debug CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_show_hardware_detail(node)

Run “show hardware-interfaces detail” debug CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_show_runtime(node)

Run “show runtime” CLI command.

Parameters:node (dict) – Node to run command on.
static vpp_show_runtime_verbose(node)

Run “show runtime verbose” CLI command.

Parameters:node (dict) – Node to run command on.

2.57. constants suite

Constants used in CSIT.

class resources.libraries.python.constants.Constants

Bases: object

Constants used in CSIT.

ODL_PORT = 8181
QEMU_INSTALL_DIR = '/opt/qemu-2.5.0'
QEMU_INSTALL_VERSION = 'qemu-2.5.0'
REMOTE_FW_DIR = '/tmp/openvpp-testing'
REMOTE_HC_DIR = '/opt/honeycomb'
REMOTE_HC_LOG = '/var/log/honeycomb/honeycomb.log'
REMOTE_HC_PERSIST = '/var/lib/honeycomb/persist'
RESOURCES_LIB_SH = 'resources/libraries/bash'
RESOURCES_TPL_HC = 'resources/templates/honeycomb'
RESOURCES_TPL_K8S = 'resources/templates/kubernetes'
RESOURCES_TPL_VAT = 'resources/templates/vat'
TREX_INSTALL_DIR = '/opt/trex-core-2.35'
TREX_INSTALL_VERSION = '2.35'
VAT_BIN_NAME = 'vpp_api_test'

2.58. ssh suite

Library for SSH connection management.

resources.libraries.python.ssh.exec_cmd(node, cmd, timeout=600, sudo=False)

Convenience function to ssh/exec/return rc, out & err.

Returns (rc, stdout, stderr).

resources.libraries.python.ssh.exec_cmd_no_error(node, cmd, timeout=600, sudo=False)

Convenience function to ssh/exec/return out & err.

Verifies that return code is zero.

Returns (stdout, stderr).

2.59. tcp suite

TCP util library.

class resources.libraries.python.tcp.TCPUtils

Bases: object

Implementation of the TCP utilities.

static start_http_server(node)

Start HTTP server on the given node.

Parameters:node (dict) – Node to start HTTP server on.
static start_http_server_params(node, prealloc_fifos, fifo_size, private_segment_size)

Start HTTP server on the given node.

test http server static prealloc-fifos <N> fifo-size <size in kB> private-segment-size <seg_size expressed as number + unit, e.g. 100m>

Where N is the max number of connections you expect to handle at one time and <size> should be small if you test for CPS and exchange few bytes, say 4, if each connection just exchanges few packets. Or it should be much larger, up to 1024/4096 (i.e. 1-4MB) if you have only one connection and exchange a lot of packets, i.e., when you test for RPS. If you need to allocate lots of FIFOs, so you test for CPS, make private-segment-size something like 4g.

Example:

For CPS test http server static prealloc-fifos 10000 fifo-size 64 private-segment-size 4000m

For RPS test http server static prealloc-fifos 500000 fifo-size 4 test http server static prealloc-fifos 500000 fifo-size 4 private-segment-size 4000m

Parameters:
  • node – Node to start HTTP server on.
  • prealloc_fifos – Max number of connections you expect to handle at

one time. :param fifo_size: FIFO size in kB. :param private_segment_size: Private segment size. Number + unit. :type node: dict :type prealloc_fifos: str :type fifo_size: str :type private_segment_size: str

2.60. topology suite

Defines nodes and topology structure.

class resources.libraries.python.topology.Topology

Bases: object

Topology data manipulation and extraction methods.

Defines methods used for manipulation and extraction of data from the active topology.

“Active topology” contains initially data from the topology file and can be extended with additional data from the DUTs like internal interface indexes or names. Additional data which can be filled to the active topology are

  • additional internal representation (index, name, ...)
  • operational data (dynamic ports)

To access the port data it is recommended to use a port key because the key does not rely on the data retrieved from nodes, this allows to call most of the methods without having filled active topology with internal nodes data.

static add_new_port(node, ptype)

Add new port to the node to active topology.

Parameters:
  • node (dict) – Node to add new port on.
  • ptype (str) – Port type, used as key prefix.
Returns:

Port key or None

Return type:

string or None

static convert_interface_reference(node, interface, wanted_format)

Takes interface reference in any format (name, link name, topology key or sw_if_index) and returns its equivalent in the desired format.

Parameters:
  • node – Node in topology.
  • interface – Name, sw_if_index, link name or key of an interface

on the node. :param wanted_format: Format of return value wanted. Valid options are: sw_if_index, key, name. :type node: dict :type interface: str or int :type wanted_format: str

Returns:

Interface name, interface key or sw_if_index.

Return type:

str or int

Raises:
  • TypeError, ValueError – If provided with invalid arguments.
  • RuntimeError – If the interface does not exist in topology.
static convert_interface_reference_to_key(node, interface)

Takes interface reference in any format (name, link name, interface key or sw_if_index) and converts to interface key using Topology methods.

Parameters:
  • node – Node in topology.
  • interface – Name, sw_if_index, link name or key of an interface

on the node. Valid formats are: sw_if_index, key, name. :type node: dict :type interface: str or int

Returns:

Interface key.

Return type:

str

Raises:
  • TypeError – If provided with invalid interface argument.
  • RuntimeError – If the interface does not exist in topology.

Return list of link names that connect together node1 and node2.

Parameters:
  • node1 (dict) – Node topology dictionary.
  • node2 (dict) – Node topology dictionary.
  • filter_list_node1 (list of strings) – Link filter criteria for node1.
  • filter_list_node2 (list of strings) – Link filter criteria for node2.
Returns:

List of strings that represent connecting link names.

Return type:

list

static get_adjacent_node_and_interface(nodes_info, node, iface_key)

Get node and interface adjacent to specified interface on local network.

Parameters:nodes_info – Dictionary containing information on all nodes

in topology. :param node: Node that contains specified interface. :param iface_key: Interface key from topology file. :type nodes_info: dict :type node: dict :type iface_key: str :returns: Return (node, interface_key) tuple or None if not found. :rtype: (dict, str)

static get_cryptodev(node)

Return Crytodev configuration of the node.

Parameters:node (dict) – Node created from topology.
Returns:Cryptodev configuration string.
Return type:str
get_egress_interfaces_name_for_nodes(node1, node2)

Get egress interfaces on node1 for link with node2.

Parameters:
  • node1 (dict) – First node, node to get egress interface on.
  • node2 (dict) – Second node.
Returns:

Egress interfaces.

Return type:

list

Parameters:
  • node1 (dict) – Connected node.
  • node2 (dict) – Connected node.
Returns:

Name of link connecting the two nodes together.

Return type:

str

Raises:

RuntimeError

get_first_egress_interface_for_nodes(node1, node2)

Get first egress interface on node1 for link with node2.

Parameters:
  • node1 (dict) – First node, node to get egress interface name on.
  • node2 (dict) – Second node.
Returns:

Egress interface name.

Return type:

str

Return interface key of link on node.

This method returns the interface name associated with a given link for a given node.

Parameters:
  • node (dict) – The node topology dictionary.
  • link_name (string) – Name of the link that a interface is connected to.
Returns:

Interface key of the interface connected to the given link.

Return type:

str

static get_interface_by_name(node, iface_name)

Return interface key based on name from DUT/TG.

This method returns interface key based on interface name retrieved from the DUT, or TG.

Parameters:
  • node (dict) – The node topology dictionary.
  • iface_name (string) – Interface name (string form).
Returns:

Interface key.

Return type:

str

static get_interface_by_sw_index(node, sw_index)

Return interface name of link on node.

This method returns the interface name associated with a software interface index assigned to the interface by vpp for a given node.

Parameters:
  • node (dict) – The node topology dictionary.
  • sw_index (int) – Sw_index of the link that a interface is connected to.
Returns:

Interface name of the interface connected to the given link.

Return type:

str

static get_interface_driver(node, iface_key)

Get interface driver.

Parameters:
  • node (dict) – Node to get interface driver on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return interface driver or None if not found.

static get_interface_ip4(node, iface_key)

Get IP4 address for the interface.

Parameters:
  • node (dict) – Node to get interface mac on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return IP4 or None if not found.

static get_interface_mac(node, iface_key)

Get MAC address for the interface.

Parameters:
  • node (dict) – Node to get interface mac on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return MAC or None if not found.

static get_interface_mtu(node, iface_key)

Get interface MTU.

Returns physical layer MTU (max. size of Ethernet frame). :param node: Node to get interface MTU on. :param iface_key: Interface key from topology file. :type node: dict :type iface_key: str :returns: MTU or None if not found. :rtype: int

static get_interface_name(node, iface_key)

Get interface name (retrieved from DUT/TG).

Returns name in string format, retrieved from the node. :param node: Node to get interface name on. :param iface_key: Interface key from topology file. :type node: dict :type iface_key: str :returns: Interface name or None if not found. :rtype: str

static get_interface_numa_node(node, iface_key)

Get interface numa node.

Returns physical relation to numa node, numa_id.

Parameters:
  • node (dict) – Node to get numa id on.
  • iface_key (str) – Interface key from topology file.
Returns:

numa node id, None if not available.

Return type:

int

static get_interface_pci_addr(node, iface_key)

Get interface PCI address.

Parameters:
  • node (dict) – Node to get interface PCI address on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return PCI address or None if not found.

static get_interface_sw_index(node, iface_key)

Get VPP sw_if_index for the interface using interface key.

Parameters:
  • node (dict) – Node to get interface sw_if_index on.
  • iface_key (str/int) – Interface key from topology file, or sw_index.
Returns:

Return sw_if_index or None if not found.

static get_interface_sw_index_by_name(node, iface_name)

Get VPP sw_if_index for the interface using interface name.

Parameters:
  • node (dict) – Node to get interface sw_if_index on.
  • iface_name (str) – Interface name.
Returns:

Return sw_if_index or None if not found.

Raises:

TypeError – If provided interface name is not a string.

Return dictionary of dictionaries {“interfaceN”, interface name}.

This method returns the interface names associated with given links for a given node.

Parameters:
  • node – The node topology directory.
  • link_names – List of names of the link that a interface is

connected to. :type node: dict :type link_names: list :returns: Dictionary of interface names that are connected to the given links. :rtype: dict

static get_interfaces_numa_node(node, *iface_keys)

Get numa node on which are located most of the interfaces.

Return numa node with highest count of interfaces provided as arguments. Return 0 if the interface does not have numa_node information available. If all interfaces have unknown location (-1), then return 0. If most of interfaces have unknown location (-1), but there are some interfaces with known location, then return the second most location of the provided interfaces.

Parameters:
  • node (dict) – Node from DICT__nodes.
  • iface_keys (strings) – Interface keys for lookup.

Get list of links(networks) in the topology.

Parameters:nodes (dict) – Nodes of the test topology.
Returns:Links in the topology.
Return type:list

Return link combinations used in tests in circular topology.

For the time being it returns links from the Node path: TG->DUT1->DUT2->TG The naming convention until changed to something more general is implemented is this: DUT1_DUT2_LINK: link name between DUT! and DUT2 DUT1_TG_LINK: link name between DUT1 and TG DUT2_TG_LINK: link name between DUT2 and TG TG_TRAFFIC_LINKS: list of link names that generated traffic is sent to and from DUT1_BD_LINKS: list of link names that will be connected by the bridge domain on DUT1 DUT2_BD_LINKS: list of link names that will be connected by the bridge domain on DUT2

Parameters:
  • tgen (dict) – Traffic generator node data.
  • dut1 (dict) – DUT1 node data.
  • dut2 (dict) – DUT2 node data.
Returns:

Dictionary of possible link combinations.

Return type:

dict

static get_node_arch(node)
Return arch of the node.
Default to x86_64 if no arch present
Parameters:node (dict) – Node created from topology.
Returns:Node architecture
Return type:str
static get_node_by_hostname(nodes, hostname)

Get node from nodes of the topology by hostname.

Parameters:
  • nodes (dict) – Nodes of the test topology.
  • hostname (str) – Host name.
Returns:

Node dictionary or None if not found.

static get_node_hostname(node)

Return host (hostname/ip address) of the node.

Parameters:node (dict) – Node created from topology.
Returns:Hostname or IP address.
Return type:str
static get_node_interfaces(node)

Get all node interfaces.

Parameters:node (dict) – Node to get list of interfaces from.
Returns:Return list of keys of all interfaces.
Return type:list

Return interface mac address by link name.

Parameters:
  • node (dict) – Node to get interface sw_index on.
  • link_name (str) – Link name.
Returns:

MAC address string.

Return type:

str

static get_uio_driver(node)

Return uio-driver configuration of the node.

Parameters:node (dict) – Node created from topology.
Returns:uio-driver configuration string.
Return type:str
static is_tg_node(node)

Find out whether the node is TG.

Parameters:node (dict) – Node to examine.
Returns:True if node is type of TG, otherwise False.
Return type:bool
static remove_all_added_ports_on_all_duts_from_topology(nodes)

Remove all added ports on all DUT nodes in the topology.

Parameters:nodes (dict) – Nodes in the topology.
Returns:Nothing
static remove_all_ports(node, ptype)

Remove all ports with ptype as prefix.

Parameters:node (dict) – Node to remove ports on.
Param:ptype: Port type, used as key prefix.
Returns:Nothing
static remove_port(node, iface_key)

Remove required port from active topology.

Parameters:node (dict) – Node to remove port on.
Param:iface_key: Topology key of the interface.
Returns:Nothing
static set_interface_numa_node(node, iface_key, numa_node_id)

Set interface numa_node location.

Parameters:
  • node (dict) – Node to set numa_node on.
  • iface_key (str) – Interface key from topology file.
Returns:

Return iface_key or None if not found.

static update_interface_mac_address(node, iface_key, mac_address)

Update mac_address on the interface from the node.

Parameters:
  • node (dict) – Node to update MAC on.
  • iface_key (str) – Topology key of the interface.
  • mac_address (str) – MAC address.
static update_interface_memif_id(node, iface_key, memif_id)

Update memif ID on the interface from the node.

Parameters:
  • node (dict) – Node to update memif ID on.
  • iface_key (str) – Topology key of the interface.
  • memif_id (str) – Memif interface ID.
static update_interface_memif_role(node, iface_key, memif_role)

Update memif role on the interface from the node.

Parameters:
  • node (dict) – Node to update memif role on.
  • iface_key (str) – Topology key of the interface.
  • memif_role (str) – Memif role.
static update_interface_memif_socket(node, iface_key, memif_socket)

Update memif socket name on the interface from the node.

Parameters:
  • node (dict) – Node to update socket name on.
  • iface_key (str) – Topology key of the interface.
  • memif_socket (str) – Path to named socket on node.
static update_interface_name(node, iface_key, name)

Update name on the interface from the node.

Parameters:
  • node (dict) – Node to update name on.
  • iface_key (str) – Topology key of the interface.
  • name (str) – Interface name to store.
static update_interface_sw_if_index(node, iface_key, sw_if_index)

Update sw_if_index on the interface from the node.

Parameters:
  • node (dict) – Node to update sw_if_index on.
  • iface_key (str) – Topology key of the interface.
  • sw_if_index (int) – Internal index to store.
static update_interface_tap_dev_name(node, iface_key, dev_name)

Update device name on the tap interface from the node.

Parameters:
  • node (dict) – Node to update tap device name on.
  • iface_key (str) – Topology key of the interface.
  • dev_name (str) – Device name of the tap interface.
Returns:

Nothing

static update_interface_vhost_socket(node, iface_key, vhost_socket)

Update vhost socket name on the interface from the node.

Parameters:
  • node (dict) – Node to update socket name on.
  • iface_key (str) – Topology key of the interface.
  • vhost_socket (str) – Path to named socket on node.
class resources.libraries.python.topology.NodeType

Bases: object

Defines node types used in topology dictionaries.

DUT = 'DUT'
TG = 'TG'
VM = 'VM'