2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-29 17:23:08 +00:00

Merge pull request #6772 from jjohnson42/skipelilo

Skip elilo if possible
This commit is contained in:
cxhong 2020-07-20 21:20:08 -04:00 committed by GitHub
commit 1352a5cfa0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -91,6 +91,25 @@ sub getstate {
}
}
my %efistubcache;
sub has_efistub {
my $kern = shift;
my $node = shift;
my $filename = $globaltftpdir . "/" . $kern;
if (defined $efistubcache{$filename}) {
return $efistubcache{$filename};
}
open my $kernel, '<:raw', $filename;
read $kernel, my $bytes, 512;
my $match = pack 'H*', '504500006486';
if ($bytes =~ m/$match/) {
$efistubcache{$filename} = 1;
return 1;
} else {
$efistubcache{$filename} = 0;
return 0;
}
}
sub setstate {
=pod
@ -304,23 +323,36 @@ sub setstate {
print $pcfg "imgargs kernel BOOTIF=" . '${netX/mac}' . "\n";
}
if ($kern->{initrd}) {
print $pcfg "imgfetch http://" . '${next-server}:' . "$httpport/tftpboot/" . $kern->{initrd} . "\n";
print $pcfg "imgfetch -n initrd http://" . '${next-server}:' . "$httpport/tftpboot/" . $kern->{initrd} . "\n";
}
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");
print $ucfg "#!gpxe\n";
print $ucfg 'chain http://${next-server}:'.$httpport.'/tftpboot/xcat/elilo-x64.efi -C /tftpboot/xcat/xnba/nodes/' . $node . ".elilo\n";
close($ucfg);
open($ucfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".elilo");
print $ucfg 'default="xCAT"' . "\n";
print $ucfg "delay=0\n\n";
print $ucfg "image=/tftpboot/" . $kern->{kernel} . "\n";
print $ucfg " label=\"xCAT\"\n";
print $ucfg " initrd=/tftpboot/" . $kern->{initrd} . "\n";
print $ucfg " append=\"" . $elilokcmdline . ' BOOTIF=%B"' . "\n";
close($ucfg);
if (has_efistub($kern->{kernel}, $node)) {
print $ucfg "#!gpxe\n";
print $ucfg "imgfetch -n kernel http://" . '${next-server}:' . $httpport.'/tftpboot/' . $kern->{kernel} . "\n";
print $ucfg "imgload kernel\n";
if ($kern->{kcmdline}) {
print $ucfg "imgargs kernel " . $kern->{kcmdline} . ' BOOTIF=01-${netX/mac:hexhyp} initrd=initrd' . "\n";
} else {
print $ucfg "imgargs kernel BOOTIF=" . '${netX/mac} initrd=initrd' . "\n";
}
print $ucfg "imgfetch -n initrd http://" . '${next-server}:' . "$httpport/tftpboot/" . $kern->{initrd} . "\n";
print $ucfg "imgexec kernel\n";
close($ucfg);
} else {
print $ucfg "#!gpxe\n";
print $ucfg 'chain http://${next-server}:'.$httpport.'/tftpboot/xcat/elilo-x64.efi -C /tftpboot/xcat/xnba/nodes/' . $node . ".elilo\n";
close($ucfg);
open($ucfg, '>', $tftpdir . "/xcat/xnba/nodes/" . $node . ".elilo");
print $ucfg 'default="xCAT"' . "\n";
print $ucfg "delay=0\n\n";
print $ucfg "image=/tftpboot/" . $kern->{kernel} . "\n";
print $ucfg " label=\"xCAT\"\n";
print $ucfg " initrd=/tftpboot/" . $kern->{initrd} . "\n";
print $ucfg " append=\"" . $elilokcmdline . ' BOOTIF=%B"' . "\n";
}
}
}
}