diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 0a1794e7c..6431f1a05 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -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 => { diff --git a/xCAT-server/lib/xcat/plugins/destiny.pm b/xCAT-server/lib/xcat/plugins/destiny.pm index f65cc470e..e64a095a0 100644 --- a/xCAT-server/lib/xcat/plugins/destiny.pm +++ b/xCAT-server/lib/xcat/plugins/destiny.pm @@ -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; diff --git a/xCAT-server/lib/xcat/plugins/dhcp.pm b/xCAT-server/lib/xcat/plugins/dhcp.pm index fd02fa82c..61027640d 100644 --- a/xCAT-server/lib/xcat/plugins/dhcp.pm +++ b/xCAT-server/lib/xcat/plugins/dhcp.pm @@ -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}}) diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index ab0028f76..29922d975 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -299,6 +299,10 @@ sub process_request { setstate($_,\%bphash,\%chainhash,\%machash); } } + if ($args[0] ne 'stat') { + $sub_req->({command=>['makedhcp'], + node=>\@nodes},$callback); + } }