lib/Kernel/multimachine_topology.pm

NAME

Kernel::multimachine_topology - shared multimachine topology reader for test_data

SYNOPSIS

use Kernel::multimachine_topology qw(get_local_node get_node_by_role get_node_interface);

my $node = get_local_node();    # the node of this job, from ROLE
my $ip = get_node_interface($node, 0)->{ipv4};
my $peer_ip = get_node_interface(get_node_by_role('peer'), 0)->{ipv4};

DESCRIPTION

Reads the multimachine_topology of a multimachine test from the schedule test_data and validates it. The topology describes the machines of a setup: networks, and nodes with a role and interfaces. The schedule includes it from a YAML file:

test_data:
  <<: !include test_data/kernel/multimachine/irq_delivery_2hosts.yaml

See docs/KERNEL_BAREMETAL_MULTIMACHINE.md for the format of the topology, roles and external nodes, and how to write and run a test with it.

This module only reads the topology; it does not change the system.

require_field

my $value = require_field($field, 'field missing');

Return the provided value if it is defined and non-empty. Dies otherwise.

get_topology

my $topology = get_topology();

Return the multimachine_topology hashref from get_test_suite_data(). The structure is validated and indexed on first access.

has_topology

if (has_topology()) { ... }

Return true if the schedule test_data has a multimachine_topology. Use it in modules that also run without a topology, for example with job variables on QEMU.

get_node_by_role

my $node = get_node_by_role('peer');

Return the node hashref for the given role. Dies if no node has this role.

get_local_node

my $node = get_local_node();

Resolve the local node using the ROLE job variable. Dies if that node is external.

get_job_nodes

my $nodes = get_job_nodes();

Return an arrayref of the nodes that run an openQA job, in topology order: all nodes except the external ones. Use it, for example, for the number of tasks of a barrier.

get_peers

my $peers = get_peers('sut');
my $peers = get_peers($node);

Return an arrayref containing all nodes except the selected one.

get_topology_network

my $network = get_topology_network('lab');

Return the network hashref for the given network id. Dies if it is missing.

get_node_interface

my $interface = get_node_interface($node, 0);

Return the interface hashref at the given index for the specified node.