diff --git a/perl-xCAT-2.0/xCAT/Postage.pm b/perl-xCAT-2.0/xCAT/Postage.pm index fd66c40d3..415f163af 100644 --- a/perl-xCAT-2.0/xCAT/Postage.pm +++ b/perl-xCAT-2.0/xCAT/Postage.pm @@ -1,6 +1,7 @@ # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html package xCAT::Postage; use xCAT::Table; +use xCAT::MsgUtils; use xCAT::NodeRange; use Data::Dumper; #------------------------------------------------------------------------------- @@ -155,10 +156,10 @@ sub makescript { push @scriptd, "export SVLOGLOCAL\n"; } - if ($nodesetstate) { - push @scriptd, "NODESETSTATE=".$nodesetstate."\n"; - push @scriptd, "export NODESETSTATE\n"; - } + if (!$nodesetstate) { $nodesetstate=getnodesetstate($node);} + push @scriptd, "NODESETSTATE=".$nodesetstate."\n"; + push @scriptd, "export NODESETSTATE\n"; + # see if this is a service or compute node? if (xCAT::Utils->isSN($node) ) { @@ -189,4 +190,54 @@ sub makescript { return @scriptd; } +#---------------------------------------------------------------------------- + +=head3 getnodesetstate + + Determine the nodeset stat. +=cut + +#----------------------------------------------------------------------------- +sub getnodesetstate { + my $node=shift; + my $state="undefined"; + + #get boot type (pxe or yaboot) for the node + my $noderestab=xCAT::Table->new('noderes',-create=>0); + my $ent=$noderestab->getNodeAttribs($node,[qw(netboot)]); + if ($ent->{netboot}) { + my $boottype=$ent->{netboot}; + + #get nodeset state from corresponding files + my $bootfilename; + if ($boottype eq "pxe") { $bootfilename="/tftpboot/pxelinux.cfg/$node";} + elsif ($boottype eq "yaboot") { $bootfilename="/tftpboot/etc/$node";} + else { $bootfilename="/tftpboot/pxelinux.cfg/$node"; } + + if (-r $bootfilename) { + my $fhand; + open ($fhand, $bootfilename); + my $headline = <$fhand>; + close $fhand; + $headline =~ s/^#//; + chomp($headline); + @a=split(' ', $headline); + $state = $a[0]; + } else { + xCAT::MsgUtils->message('S', "getpostscripts: file $bootfilename cannot be accessed."); + } + } else { + xCAT::MsgUtils->message('S', "getpostscripts: noderes.netboot for node $node not defined."); + } + + #get the nodeset state from the chain table as a backup. + if ($state eq "undefined") { + my $chaintab = xCAT::Table->new('chain'); + my $stref = $chaintab->getNodeAttribs($node,['currstate']); + if ($stref and $stref->{currstate}) { $state=$stref->{currstate}; } + } + + return $state; +} + 1; diff --git a/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm b/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm index dbc4afdc5..d76b0abff 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm @@ -41,7 +41,6 @@ sub handled_commands #------------------------------------------------------- sub process_request { - my $request = shift; my $callback = shift; my $nodes = $request->{node}; @@ -57,14 +56,13 @@ sub process_request if ($request->{'_xcat_clienthost'}) { $client = $request->{'_xcat_clienthost'}->[0]; } + if ($client) { ($client) = noderange($client) }; unless ($client) { #Not able to do identify the host in question return; } - my $state = $request->{scripttype}->[0]; - unless ($state) { - return; - } + my $state; + if ($request->{scripttype}) { $state = $request->{scripttype}->[0];} my @scriptcontents = xCAT::Postage::makescript($client,$state,$callback); if (scalar(@scriptcontents)) { diff --git a/xCAT/postscripts/getpostscript.awk b/xCAT/postscripts/getpostscript.awk index 039b98511..f6ea24b96 100755 --- a/xCAT/postscripts/getpostscript.awk +++ b/xCAT/postscripts/getpostscript.awk @@ -6,7 +6,6 @@ BEGIN { print "" |& server print " getpostscript" |& server - print " install" |& server print "" |& server while (server |& getline) {