2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-04 12:07:56 +00:00

feat(nodediscover): default discovered riscv64 nodes to grub2

Discovery left noderes.netboot untouched for any architecture outside
x86, ppc and armv7l, so a discovered riscv64 node had no boot method and
nodeset failed to find a plugin for it.

Move the default-netboot ladder into _default_netboot(), which returns
the method to set or undef, and teach it that riscv64 nodes boot through
UEFI and grub2. The existing x86, PowerNV, ppc and onie rules are
unchanged; aarch64 is deliberately left as it was. The platform of the
discovery request is only read when the request carries it, so a node
that reports none does not gain the key, which would end up stored as
discovery data.
This commit is contained in:
Vinícius Ferrão
2026-08-20 16:34:16 -03:00
parent d64366a30a
commit bd87aa9ed9
+31 -9
View File
@@ -137,6 +137,31 @@ sub handled_commands {
};
}
# Pick the noderes.netboot method a freshly discovered node should use when
# the admin has not already chosen one that fits its architecture. Returns the
# method to set, or undef to leave noderes.netboot alone.
sub _default_netboot {
my ($arch, $platform, $currboot) = @_;
$arch = '' unless defined $arch;
$platform = '' unless defined $platform;
$currboot = '' unless defined $currboot;
if ($arch =~ /x86/ and $currboot !~ /pxe/ and $currboot !~ /xnba/) {
return 'xnba';
} elsif ($arch =~ /ppc/ and $platform =~ /PowerNV/) {
return 'petitboot';
} elsif ($arch =~ /ppc/ and $currboot !~ /yaboot/) {
return 'yaboot';
} elsif ($arch =~ /armv7l/ and $currboot !~ /onie/) {
#for onie switch, the netboot should be "onie"
return 'onie';
} elsif ($arch =~ /^riscv64$/ and $currboot !~ /grub2/) {
#riscv64 nodes boot through UEFI and grub2 only
return 'grub2';
}
return;
}
sub process_request {
my $request = shift;
my $callback = shift;
@@ -230,15 +255,12 @@ sub process_request {
$currboot = $rent->{'netboot'};
}
if ($request->{arch}->[0] =~ /x86/ and $currboot !~ /pxe/ and $currboot !~ /xnba/) {
$nrtab->setNodeAttribs($node, { netboot => 'xnba' });
} elsif ($request->{arch}->[0] =~ /ppc/ and $request->{platform}->[0] =~ /PowerNV/) {
$nrtab->setNodeAttribs($node, { netboot => 'petitboot' });
} elsif ($request->{arch}->[0] =~ /ppc/ and $currboot !~ /yaboot/) {
$nrtab->setNodeAttribs($node, { netboot => 'yaboot' });
} elsif($request->{arch}->[0] =~ /armv7l/ and $currboot !~ /onie/) {
#for onie switch, the netboot should be "onie"
$nrtab->setNodeAttribs($node, { netboot => 'onie' });
# do not dereference platform unless the request carries it: the key would be
# autovivified into the request hash and later stored as discovery data
my $platform = exists $request->{platform} ? $request->{platform}->[0] : undef;
my $netboot = _default_netboot($request->{arch}->[0], $platform, $currboot);
if (defined $netboot) {
$nrtab->setNodeAttribs($node, { netboot => $netboot });
}
}