-iSCSI boot changes to take advantage of gPXE if available
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2418 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
ca84dcc4dd
commit
431bbf8509
@ -131,7 +131,7 @@ ipmi => {
|
||||
},
|
||||
},
|
||||
iscsi => {
|
||||
cols => [qw(node server target file userid passwd kernel kcmdline initrd comments disable)],
|
||||
cols => [qw(node server target lun file userid passwd kernel kcmdline initrd comments disable)],
|
||||
keys => [qw(node)],
|
||||
table_desc => 'Contains settings that control how to boot a node from an iSCSI target',
|
||||
descriptions => {
|
||||
|
@ -21,6 +21,7 @@ my $typetab;
|
||||
my $restab;
|
||||
my $sitetab;
|
||||
my $hmtab;
|
||||
my $tftpdir="/tftpboot";
|
||||
|
||||
sub handled_commands {
|
||||
return {
|
||||
@ -73,11 +74,14 @@ sub setdestiny {
|
||||
$callback->({error=>"Unable to open iscsi table to get iscsiboot parameters",errorcode=>[1]});
|
||||
}
|
||||
my $bptab = xCAT::Table->new('bootparams',-create=>1);
|
||||
my $nodetype = xCAT::Table->new('nodetype');
|
||||
my $ntents = $nodetype->getNodesAttribs($req->{node},[qw(os arch profile)]);
|
||||
my $ients = $iscsitab->getNodesAttribs($req->{node},[qw(kernel kcmdline initrd)]);
|
||||
foreach (@{$req->{node}}) {
|
||||
my $ient = $ients->{$_}->[0]; #$iscsitab->getNodeAttribs($_,[qw(kernel kcmdline initrd)]);
|
||||
my $ntent = $ntents->{$_}->[0];
|
||||
unless ($ient and $ient->{kernel}) {
|
||||
$callback->({error=>"$_: No iscsi boot data available",errorcode=>[1]});
|
||||
unless ($ntent and $ntent->{arch} =~ /x86/ and -f "$tftpdir/undionly.kpxe") { $callback->({error=>"$_: No iscsi boot data available",errorcode=>[1]}); } #If x86 node and undionly.kpxe exists, presume they know what they are doing
|
||||
next;
|
||||
}
|
||||
my $hash;
|
||||
|
@ -22,6 +22,9 @@ my $callback;
|
||||
my $restartdhcp;
|
||||
my $nrhash;
|
||||
my $machash;
|
||||
my $iscsients;
|
||||
my $chainents;
|
||||
my $tftpdir='/tftpboot';
|
||||
|
||||
sub handled_commands
|
||||
{
|
||||
@ -110,17 +113,25 @@ sub addnode
|
||||
#up the lease file the way we would want anyway.
|
||||
my $node = shift;
|
||||
my $ent;
|
||||
my $nrent;
|
||||
my $chainent;
|
||||
my $ient;
|
||||
if ($chainents and $chainents->{$node}) {
|
||||
$chainent = $chainents->{$node}->[0];
|
||||
}
|
||||
if ($iscsients and $iscsients->{$node}) {
|
||||
$ient = $iscsients->{$node}->[0];
|
||||
}
|
||||
my $lstatements = $statements;
|
||||
my $guess_next_server = 0;
|
||||
if ($nrhash)
|
||||
{
|
||||
my $ent;
|
||||
$ent = $nrhash->{$node}->[0];
|
||||
if ($ent and $ent->{tftpserver})
|
||||
$nrent = $nrhash->{$node}->[0];
|
||||
if ($nrent and $nrent->{tftpserver})
|
||||
{
|
||||
$lstatements =
|
||||
'next-server '
|
||||
. inet_ntoa(inet_aton($ent->{tftpserver})) . ';'
|
||||
. inet_ntoa(inet_aton($nrent->{tftpserver})) . ';'
|
||||
. $statements;
|
||||
}
|
||||
else
|
||||
@ -129,9 +140,9 @@ sub addnode
|
||||
}
|
||||
|
||||
#else {
|
||||
# $ent = $nrtab->getNodeAttribs($node,['servicenode']);
|
||||
# if ($ent and $ent->{servicenode}) {
|
||||
# $statements = 'next-server = \"'.inet_ntoa(inet_aton($ent->{servicenode})).'\";'.$statements;
|
||||
# $nrent = $nrtab->getNodeAttribs($node,['servicenode']);
|
||||
# if ($nrent and $nrent->{servicenode}) {
|
||||
# $statements = 'next-server = \"'.inet_ntoa(inet_aton($nrent->{servicenode})).'\";'.$statements;
|
||||
# }
|
||||
#}
|
||||
}
|
||||
@ -211,6 +222,25 @@ sub addnode
|
||||
$lstatements = "next-server $nxtsrv;$statements";
|
||||
}
|
||||
}
|
||||
if ($ient and $ient->{server} and $ient->{target}) {
|
||||
if (defined ($ient->{lun})) {
|
||||
$lstatements = 'option root-path \"iscsi:'.$ient->{server}.':::'.$ient->{lun}.':'.$ient->{target}.'\";'.$lstatements;
|
||||
} else {
|
||||
$lstatements = 'option root-path \"iscsi:'.$ient->{server}.':::'.$ient->{lun}.':'.$ient->{target}.'\";'.$lstatements;
|
||||
}
|
||||
if ($nrent and $nrent->{netboot} and $nrent->{netboot} eq 'pxe') {
|
||||
if (-f "$tftpdir/undionly.kpxe") {
|
||||
if ($chainent and $chainent->{currstate} and $chainent->{currstate} eq 'iscsiboot') {
|
||||
$lstatements = 'if exists gpxe.bus-id { filename = \"\"; } else { filename = \"undionly.kpxe\"; } '.$lstatements;
|
||||
} else {
|
||||
$lstatements = 'if exists gpxe.bus-id { filename = \"pxelinux.0\"; } else { filename = \"undionly.kpxe\"; } '.$lstatements;
|
||||
}
|
||||
} #TODO: warn when windows
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#syslog("local4|err", "Setting $node ($hname|$ip) to " . $mac);
|
||||
print $omshell "new host\n";
|
||||
print $omshell
|
||||
@ -469,7 +499,17 @@ sub process_request
|
||||
. $ent->{password} . "\"\n";
|
||||
print $omshell "connect\n";
|
||||
my $nrtab = xCAT::Table->new('noderes');
|
||||
$nrhash = $nrtab->getNodesAttribs($req->{node}, ['tftpserver']);
|
||||
my $chaintab = xCAT::Table->new('chain');
|
||||
if ($chaintab) {
|
||||
$chainents = $chaintab->getNodesAttribs($req->{node},['currstate']);
|
||||
} else {
|
||||
$chainents = undef;
|
||||
}
|
||||
$nrhash = $nrtab->getNodesAttribs($req->{node}, ['tftpserver','netboot']);
|
||||
my $iscsitab = xCAT::Table->new('iscsi');
|
||||
if ($iscsitab) {
|
||||
$iscsients = $iscsitab->getNodesAttribs($req->{node},[qw(server target lun)]);
|
||||
}
|
||||
my $mactab = xCAT::Table->new('mac');
|
||||
$machash = $mactab->getNodesAttribs($req->{node},['mac']);
|
||||
foreach (@{$req->{node}})
|
||||
|
@ -299,6 +299,10 @@ sub process_request {
|
||||
setstate($_,\%bphash,\%chainhash,\%machash);
|
||||
}
|
||||
}
|
||||
if ($args[0] ne 'stat') {
|
||||
$sub_req->({command=>['makedhcp'],
|
||||
node=>\@nodes},$callback);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user