2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-10-08 10:32:56 +00:00

feat(netboot): add the ipxe netboot method

xCAT boots x86 nodes through iPXE with netboot=xnba, which names the
xNBA fork that xCAT retires. netboot=ipxe is the method for the upstream
iPXE loaders of the ipxe-xcat package.

The ipxe plugin runs the xnba code, with the boot scripts under
xcat/ipxe/nodes instead of xcat/xnba/nodes. nodeset stat, the osimage
check of nodeset and rinstall, and the install check of Postage accept
the new value. The noderes.netboot description lists it and marks xnba
deprecated. The z/VM and FSM builds of xCAT-server leave the ipxe plugin
out with the xnba and pxe plugins. netboot=xnba does not change, and
makedhcp does not serve the new method yet.
This commit is contained in:
Vinícius Ferrão
2026-09-27 01:54:53 -03:00
parent 9cd1bca4c8
commit 80418f2f73
7 changed files with 89 additions and 13 deletions
+1 -1
View File
@@ -670,7 +670,7 @@ passed as argument rather than by table value',
netboot => 'The type of network booting to use for this node. Valid values:
Arch OS valid netboot options
x86, x86_64 ALL pxe, xnba, grub2
x86, x86_64 ALL pxe, ipxe, xnba (deprecated), grub2
ppc64 <=rhel6, <=sles11.3 yaboot
ppc64 >=rhels7, >=sles11.4 grub2,grub2-http,grub2-tftp
ppc64le NonVirtualize ALL petitboot
+1 -1
View File
@@ -5028,7 +5028,7 @@ sub lookupNetboot {
$ret = "nimol";
} elsif ($imgtype =~ /^Linux$/i) {
if ($osarch =~ /^x86_64$/i) {
$ret = "xnba,pxe,grub2";
$ret = "ipxe,xnba,pxe,grub2";
} elsif ($osarch =~ /^ppc64$/i) {
if (($osv =~ /rh/i and $osn < 7) or ($osv =~ /sles/i and ($osn < 11 or ($osn == 11 and $osm < 4)))) {
$ret = "yaboot";
+4
View File
@@ -2236,6 +2236,10 @@ sub getPostScripts
{
$nodecfg = "$tftpdir/xcat/xnba/nodes/$node";
} elsif ($netboot eq "ipxe")
{
$nodecfg = "$tftpdir/xcat/ipxe/nodes/$node";
} elsif ($netboot eq "pxe")
{
$nodecfg = "$tftpdir/pxelinux.cfg/$node";
+24
View File
@@ -52,6 +52,7 @@ sub getNodesetStates
my @pxenodes = ();
my @yabootnodes = ();
my @xnbanodes = ();
my @ipxenodes = ();
my @grub2nodes = ();
my @petitbootnodes = ();
my $tabdata = $tab->getNodesAttribs(\@nodes, [ 'node', 'netboot' ]);
@@ -68,6 +69,10 @@ sub getNodesetStates
{
push(@xnbanodes, $node);
}
elsif ($nb eq "ipxe")
{
push(@ipxenodes, $node);
}
elsif ($nb eq "pxe")
{
push(@pxenodes, $node);
@@ -127,6 +132,18 @@ sub getNodesetStates
xCAT::MsgUtils->message('E', $retarray[1]);
}
}
if (@ipxenodes > 0)
{
require xCAT_plugin::ipxe;
@retarray =
xCAT_plugin::ipxe::getNodesetStates(\@ipxenodes, $hashref);
if ($retarray[0])
{
$retcode = $retarray[0];
$errormsg .= $retarray[1];
xCAT::MsgUtils->message('E', $retarray[1]);
}
}
if (@aixnodes > 0)
{
@@ -242,6 +259,13 @@ sub get_nodeset_state
my @a = split(' ', $tmp);
$state = $a[0];
}
elsif ($boottype eq "ipxe")
{
require xCAT_plugin::ipxe;
my $tmp = xCAT_plugin::ipxe::getstate($node, $tftpdir);
my @a = split(' ', $tmp);
$state = $a[0];
}
elsif ($boottype eq "yaboot")
{
require xCAT_plugin::yaboot;
+43
View File
@@ -0,0 +1,43 @@
package xCAT_plugin::ipxe;
# netboot=ipxe boots x86 nodes with the upstream iPXE loaders of the ipxe-xcat package. It runs the
# boot scripts of the xnba method, which it keeps under xcat/ipxe instead of xcat/xnba.
use strict;
use warnings;
sub handled_commands {
return { nodeset => 'noderes:netboot' };
}
# xcatd loads xnba.pm from the plugin directory, so load it here only when it is not there yet.
sub _xnba {
require xCAT_plugin::xnba unless defined &xCAT_plugin::xnba::process_request;
return;
}
sub preprocess_request {
_xnba();
local $xCAT_plugin::xnba::SCRIPTS = 'xcat/ipxe';
return xCAT_plugin::xnba::preprocess_request(@_);
}
sub process_request {
_xnba();
local $xCAT_plugin::xnba::SCRIPTS = 'xcat/ipxe';
return xCAT_plugin::xnba::process_request(@_);
}
sub getstate {
_xnba();
local $xCAT_plugin::xnba::SCRIPTS = 'xcat/ipxe';
return xCAT_plugin::xnba::getstate(@_);
}
sub getNodesetStates {
_xnba();
local $xCAT_plugin::xnba::SCRIPTS = 'xcat/ipxe';
return xCAT_plugin::xnba::getNodesetStates(@_);
}
1;
+14 -11
View File
@@ -19,6 +19,9 @@ my $dhcpconf = "/etc/dhcpd.conf";
#my $tftpdir = "/tftpboot";
my $globaltftpdir = xCAT::TableUtils->getTftpDir();
# The directory of the boot scripts under the TFTP root. The ipxe method sets it to xcat/ipxe.
our $SCRIPTS = 'xcat/xnba';
#my $dhcpver = 3;
my %usage = (
@@ -65,9 +68,9 @@ sub getstate {
my $tftpdir = shift;
unless ($tftpdir) { $tftpdir = _slow_get_tftpdir($node); }
if (check_dhcp($node)) {
if (-r $tftpdir . "/xcat/xnba/nodes/" . $node) {
if (-r "$tftpdir/$SCRIPTS/nodes/$node") {
my $fhand;
open($fhand, $tftpdir . "/xcat/xnba/nodes/" . $node);
open($fhand, "$tftpdir/$SCRIPTS/nodes/$node");
my $headline = <$fhand>;
$headline = <$fhand>; #second line is the comment now...
close $fhand;
@@ -251,7 +254,7 @@ sub setstate {
}
}
my $bootloader_root = "$tftpdir/xcat/xnba/nodes";
my $bootloader_root = "$tftpdir/$SCRIPTS/nodes";
unless (-d "$bootloader_root") {
mkpath("$bootloader_root");
}
@@ -291,24 +294,24 @@ sub setstate {
my $hypervisor;
my $kernel;
($kernel, $hypervisor) = split /!/, $kern->{kernel};
print $pcfg " set 209:string xcat/xnba/nodes/$node.pxelinux\n";
print $pcfg " set 209:string $SCRIPTS/nodes/$node.pxelinux\n";
print $pcfg " set 210:string http://" . '${next-server}' . $portsuffix . "/tftpboot/\n";
print $pcfg " imgfetch -n pxelinux.0 http://" . '${next-server}' . $portsuffix . "/tftpboot/xcat/pxelinux.0\n";
print $pcfg " imgload pxelinux.0\n";
print $pcfg " imgexec pxelinux.0\n";
close($pcfg);
open($pcfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".pxelinux");
open($pcfg, '>', "$bootloader_root/$node.pxelinux");
print $pcfg "DEFAULT xCAT\nLABEL xCAT\n KERNEL mboot.c32\n";
print $pcfg " APPEND $hypervisor --- $kernel " . $pxelinuxkcmdline . " --- " . $kern->{initrd} . "\n";
} else {
if ($kern->{kernel} =~ /\.c32\z/ or $kern->{kernel} =~ /memdisk\z/) { #gPXE comboot support seems insufficient, chain pxelinux instead
print $pcfg " set 209:string xcat/xnba/nodes/$node.pxelinux\n";
print $pcfg " set 209:string $SCRIPTS/nodes/$node.pxelinux\n";
print $pcfg " set 210:string http://" . '${next-server}' . $portsuffix . "/tftpboot/\n";
print $pcfg " imgfetch -n pxelinux.0 http://" . '${next-server}' . $portsuffix . "/tftpboot/xcat/pxelinux.0\n";
print $pcfg " imgload pxelinux.0\n";
print $pcfg " imgexec pxelinux.0\n";
close($pcfg);
open($pcfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".pxelinux");
open($pcfg, '>', "$bootloader_root/$node.pxelinux");
#It's time to set pxelinux for this node to boot the kernel..
print $pcfg "DEFAULT xCAT\nLABEL xCAT\n";
@@ -327,7 +330,7 @@ sub setstate {
print $pcfg "IPAPPEND 2\n";
if ($kern->{kernel} =~ /esxi[56]/) { #Make uefi boot provisions
my $ucfg;
open($ucfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".uefi");
open($ucfg, '>', "$bootloader_root/$node.uefi");
if ($kern->{kcmdline} =~ /xcat\/netboot/) {
$kern->{kcmdline} =~ s/xcat\/netboot/\/tftpboot\/xcat\/netboot/;
}
@@ -349,7 +352,7 @@ sub setstate {
print $pcfg "imgexec kernel\n";
if ($kern->{kcmdline} and $kern->{initrd}) { #only a linux kernel/initrd pair should land here, write elilo config and uefi variant of xnba config file
my $ucfg;
open($ucfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".uefi");
open($ucfg, '>', "$bootloader_root/$node.uefi");
if (_use_efistub_for_uefi($kern)) {
print $ucfg "#!gpxe\n";
print $ucfg "imgfetch -n kernel http://" . '${next-server}' . $portsuffix.'/tftpboot/' . $kern->{kernel} . "\n";
@@ -364,9 +367,9 @@ sub setstate {
close($ucfg);
} else {
print $ucfg "#!gpxe\n";
print $ucfg 'chain http://${next-server}'.$portsuffix.'/tftpboot/xcat/elilo-x64.efi -C /tftpboot/xcat/xnba/nodes/' . $node . ".elilo\n";
print $ucfg 'chain http://${next-server}'.$portsuffix.'/tftpboot/xcat/elilo-x64.efi -C /tftpboot/' . "$SCRIPTS/nodes/$node.elilo\n";
close($ucfg);
open($ucfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".elilo");
open($ucfg, '>', "$bootloader_root/$node.elilo");
print $ucfg 'default="xCAT"' . "\n";
print $ucfg "delay=0\n\n";
print $ucfg "image=/tftpboot/" . $kern->{kernel} . "\n";
+2
View File
@@ -297,6 +297,7 @@ rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/windows.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/xcat2nim.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/rhevm.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/xnba.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/ipxe.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/IPMI.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/SSHInteract.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/MellanoxIB.pm
@@ -365,6 +366,7 @@ rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/pxe.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/toolscenter.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/xcat2nim.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/xnba.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT_plugin/ipxe.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/IPMI.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/SSHInteract.pm
rm $RPM_BUILD_ROOT/%{prefix}/lib/perl/xCAT/MellanoxIB.pm