mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-25 20:02:19 +00:00
test(template): the address mode is answered for the cluster, not for the node
post.sles.common reads MANAGEDADDRESSMODE and, for anything but static, removes the interface configuration and writes a new one with BOOTPROTO=dhcp. managed_address_mode returns site.managedaddressmode, which describes the cluster. An IPv6-only node therefore has the static IPv6 configuration in its AutoYaST profile rewritten to DHCP during the post phase, and comes up with a link-local address only. The node has no IPv4 address to ask a DHCP server for, so the site attribute cannot answer for it. The test renders MANAGEDADDRESSMODE for three nodes with the site attribute set to dhcp: an IPv6-only node, an IPv4 node and a dual-stack node. Only the IPv6-only node is expected to differ, so the other two hold the site behaviour down. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
@@ -117,12 +117,13 @@ local $::XCATSITEVALS{managedaddressmode} = 'dhcp';
|
||||
local $::XCATSITEVALS{xcatdebugmode} = '0';
|
||||
|
||||
sub render_minimal_template {
|
||||
my ($node, $master) = @_;
|
||||
my ($node, $master, $body) = @_;
|
||||
$body //= "#KICKSTARTNET#\n#INSTALL_SOURCES_IN_PRE#\n";
|
||||
my $tmpdir = tempdir(CLEANUP => 1);
|
||||
my $input = "$tmpdir/input.tmpl";
|
||||
my $output = "$tmpdir/output";
|
||||
open(my $template, '>', $input) or die "Unable to write template: $!";
|
||||
print {$template} "#KICKSTARTNET#\n#INSTALL_SOURCES_IN_PRE#\n";
|
||||
print {$template} $body;
|
||||
close($template);
|
||||
|
||||
my $error = xCAT::Template->subvars(
|
||||
@@ -193,4 +194,24 @@ like(
|
||||
);
|
||||
is($ENV{MASTER_IP}, '192.0.2.1', 'IPv4 template keeps legacy master resolution');
|
||||
|
||||
# post.sles.common rewrites the interface configuration with BOOTPROTO=dhcp unless
|
||||
# MANAGEDADDRESSMODE reads static, which undoes the static IPv6 configuration the
|
||||
# AutoYaST profile carries for an IPv6-only node. The site attribute describes the
|
||||
# cluster, so it cannot answer for a node that has no IPv4 address to ask for.
|
||||
{
|
||||
my $v6_mode =
|
||||
render_minimal_template('nodev6', 'master6.example.test', "#MANAGEDADDRESSMODE#\n");
|
||||
like($v6_mode, qr/^static$/m,
|
||||
'an IPv6-only node reports the static address mode whatever the site says');
|
||||
|
||||
my $v4_mode =
|
||||
render_minimal_template('nodev4', 'master4.example.test', "#MANAGEDADDRESSMODE#\n");
|
||||
like($v4_mode, qr/^dhcp$/m, 'an IPv4 node keeps the site address mode');
|
||||
|
||||
my $dual_mode =
|
||||
render_minimal_template('nodedual', 'master4.example.test', "#MANAGEDADDRESSMODE#\n");
|
||||
like($dual_mode, qr/^dhcp$/m,
|
||||
'a dual-stack node keeps the site address mode, since it can still use DHCP');
|
||||
}
|
||||
|
||||
done_testing();
|
||||
|
||||
Reference in New Issue
Block a user