fix NODESETSTATE env variable value in posrscripts

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1395 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
linggao 2008-05-14 19:14:32 +00:00
parent f7eb37cf56
commit b9d4932178
3 changed files with 58 additions and 10 deletions

View File

@ -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;

View File

@ -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)) {

View File

@ -6,7 +6,6 @@ BEGIN {
print "<xcatrequest>" |& server
print " <command>getpostscript</command>" |& server
print " <scripttype>install</scripttype>" |& server
print "</xcatrequest>" |& server
while (server |& getline) {