BaseTunnelRecipe class

class lnst.Recipes.ENRT.BaseTunnelRecipe.BaseTunnelRecipe(**kwargs)

Bases: PacketAssertTestAndEvaluate, BaremetalEnrtRecipe

This base class extends the BaseEnrtRecipe class and defines a common API for implementation of baremetal tunnel recipes.

The ping_test() method is overridden to include a test that the ping packets are properly tunnelled. This is implemented with PacketAssert test module. Each child class needs to implement get_packet_assert_config() so that the correct filters are passed to the module. After the ping test finishes, the minimum expected packet count of the assert is adjusted to the number of pings reported as received by the ping test, so that the evaluation checks that all of the completed pings travelled through the tunnel.

The class inheriting from this base class need to implement following methods:

test_wide_configuration(config) → EnrtConfiguration

The base class defines common steps to create the test wide configuration of a tunnel recipe.

First, an underlying network that will be the transport layer for the tunnel is configured in configure_underlying_network(), then the tunnel is created between the specified endpoints in create_tunnel().

configure_underlying_network(config: EnrtConfiguration) → tuple[RemoteDevice, RemoteDevice]

This method must be implemented by the child class.

The child class should configure the network stack that will be the transport layer for the tunnel configured in create_tunnel().

That usually includes configuring the IP addresses, creating additional network devices such as bonding or vlans, creating network namespaces, etc.

The method must also update the tunnel_endpoints attribute of the config object with a tuple of two Device objects that will be used as tunnel endpoints in create_tunnel()

Parameters:

config (EnrtConfiguration) – Used to configure IP addresses and store them inside the config

Returns:

returns a tuple of two Device objects that will be used as tunnel endpoints in create_tunnel()

Return type:

tuple[RemoteDevice, RemoteDevice]

create_tunnel(config: EnrtConfiguration, tunnel_endpoints: tuple[RemoteDevice, RemoteDevice]) → tuple[RemoteDevice, RemoteDevice]

This method must be implemented by the child class.

The child class should create a network tunnel between the provided endpoints. That usually includes creating tunnel devices such as GreDevice, VxlanDevice, etc. and configuring the IP addresses.

Parameters:
  • config (EnrtConfiguration) – Configuration object useful for assigning IP addresses to devices

  • tunnel_endpoints (tuple[RemoteDevice, RemoteDevice]) – A tuple of the tunnel endpoints.

Returns:

A tuple of the configured tunnel devices.

Return type:

`tuple[RemoteDevice, RemoteDevice]

generate_test_wide_description(config: EnrtConfiguration)

Test wide description is extended with the configured addresses of the underlying network devices and the configured tunnel devices

get_packet_assert_config(ping_config)

This method must be implemented by the child class.

Parameters:

ping_config (PingConfig) – Ping configuration generated by BaseEnrtRecipe.generate_ping_configurations()

Returns:

returns a PacketAssert configuration

Return type:

PacketAssertConf

generate_perf_endpoints(config: EnrtConfiguration) → list[Collection[EndpointPair[IPEndpoint]]]

The perf endpoints for recipes derived from this class are usually the tunnel endpoints. The derived class can override the endpoints if needed.