From bd87aa9ed9884ae9d69054769d7414377ae02df4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Thu, 20 Aug 2026 16:34:16 -0300 Subject: [PATCH] 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. --- xCAT-server/lib/xcat/plugins/nodediscover.pm | 40 +++++++++++++++----- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/nodediscover.pm b/xCAT-server/lib/xcat/plugins/nodediscover.pm index d7f4fef1e..8e9b77fb0 100644 --- a/xCAT-server/lib/xcat/plugins/nodediscover.pm +++ b/xCAT-server/lib/xcat/plugins/nodediscover.pm @@ -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 }); } }