Kernel::multimachine_topology - shared multimachine topology reader for test_data
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};
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.
my $value = require_field($field, 'field missing');
Return the provided value if it is defined and non-empty. Dies otherwise.
my $topology = get_topology();
Return the multimachine_topology hashref from get_test_suite_data(). The structure is validated and indexed on first access.
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.
my $node = get_node_by_role('peer');
Return the node hashref for the given role. Dies if no node has this role.
my $node = get_local_node();
Resolve the local node using the ROLE job variable. Dies if that node is external.
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.
my $peers = get_peers('sut');
my $peers = get_peers($node);
Return an arrayref containing all nodes except the selected one.
my $network = get_topology_network('lab');
Return the network hashref for the given network id. Dies if it is missing.
my $interface = get_node_interface($node, 0);
Return the interface hashref at the given index for the specified node.