1.corrected defect 3053 2.update nodelist.updatestatus during 'updatenode -P/-S/-k';2.support nodelist.updatestatus update during 'updatenode -P/-S/-K';3.fix defect #3124 Postage.pm writes error message in /xcatpost/mypostscript: only write <data> field of getpostscript response to mypostscript, complain and terminate when getpostscript failed
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@13981 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
628806fd81
commit
beb47bb0f3
@ -33,6 +33,12 @@ $::NODETYPE_PPC="ppc";
|
||||
$::NODETYPE_ZVM="zvm";
|
||||
$::NODETYPE_MP="mp";
|
||||
|
||||
#valid values for nodelist.updatestatus
|
||||
$::STATUS_SYNCING="syncing";
|
||||
$::STATUS_OUT_OF_SYNC="out-of-sync";
|
||||
$::STATUS_SYNCED="synced";
|
||||
|
||||
|
||||
# valid values for nodelist.status columns or other status
|
||||
$::STATUS_ACTIVE="alive";
|
||||
$::STATUS_INACTIVE="unreachable";
|
||||
@ -65,6 +71,10 @@ $::STATUS_FAILED="failed";
|
||||
$::STATUS_DEFINED=>1,
|
||||
$::STATUS_UNKNOWN=>1,
|
||||
$::STATUS_FAILED=>1,
|
||||
|
||||
$::STATUS_SYNCING=>1,
|
||||
$::STATUS_OUT_OF_SYNC=>1,
|
||||
$::STATUS_SYNCED=>1,
|
||||
);
|
||||
|
||||
#defined->[discovering]->[configuring]->[standingby]->installing->[installed]->booting->alive, defined->[discovering]->[configuring]-[standingby]->netbooting->booted->alive, alive/unreachable->booting->alive, powering-off->unreachable, alive->unreachable
|
||||
|
@ -854,6 +854,70 @@ sub setAppStatus
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 setUpdateStatus
|
||||
Description:
|
||||
Set the updatestatus attribute for a list of nodes during "updatenode"
|
||||
Arguments:
|
||||
@nodes
|
||||
$status
|
||||
Returns:
|
||||
none
|
||||
|
||||
Globals:
|
||||
none
|
||||
Error:
|
||||
none
|
||||
Example:
|
||||
xCAT::TableUtils->setUpdateStatus(\@nodes,$status);
|
||||
Comments:
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
sub setUpdateStatus
|
||||
{
|
||||
require xCAT::Table;
|
||||
|
||||
|
||||
my ($class, $nodes_ref, $status) = @_;
|
||||
my @nodes = @$nodes_ref;
|
||||
|
||||
|
||||
|
||||
#get current local time to set in Updatestatustime attribute
|
||||
my (
|
||||
$sec, $min, $hour, $mday, $mon,
|
||||
$year, $wday, $yday, $isdst
|
||||
)
|
||||
= localtime(time);
|
||||
my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d",
|
||||
$mon + 1, $mday, $year + 1900,
|
||||
$hour, $min, $sec);
|
||||
|
||||
my $nltab = xCAT::Table->new('nodelist');
|
||||
if($nltab){
|
||||
if(@nodes>0){
|
||||
my %updates;
|
||||
|
||||
$updates{'updatestatus'} = $status;
|
||||
$updates{'updatestatustime'} = $currtime;
|
||||
my $where_clause;
|
||||
my $dbname=xCAT::Utils->get_DBName() ;
|
||||
if ($dbname eq 'DB2') {
|
||||
$where_clause="\"node\" in ('" . join("','", @nodes) . "')";
|
||||
} else {
|
||||
$where_clause="node in ('" . join("','", @nodes) . "')";
|
||||
}
|
||||
print "$where_clause";
|
||||
$nltab->setAttribsWhere($where_clause, \%updates );
|
||||
}
|
||||
$nltab->close;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
@ -60,7 +60,8 @@ sub handled_commands
|
||||
updatenode => "updatenode",
|
||||
updatenodestat => "updatenode",
|
||||
updatemynodestat => "updatenode",
|
||||
updatenodeappstat => "updatenode"
|
||||
updatenodeappstat => "updatenode",
|
||||
updatenodeupdatestat => "updatenode"
|
||||
};
|
||||
}
|
||||
|
||||
@ -101,6 +102,10 @@ sub preprocess_request
|
||||
{
|
||||
return [$request];
|
||||
}
|
||||
elsif ($command eq "updatenodeupdatestat")
|
||||
{
|
||||
return [$request];
|
||||
}
|
||||
else
|
||||
{
|
||||
my $rsp = {};
|
||||
@ -154,6 +159,10 @@ sub process_request
|
||||
{
|
||||
return updatenodeappstat($request, $callback);
|
||||
}
|
||||
elsif ($command eq "updatenodeupdatestat")
|
||||
{
|
||||
return updatenodeupdatestat($request, $callback);
|
||||
}
|
||||
else
|
||||
{
|
||||
my $rsp = {};
|
||||
@ -341,6 +350,8 @@ sub preprocess_updatenode
|
||||
}
|
||||
|
||||
my $nodes = $request->{node};
|
||||
|
||||
|
||||
if (!$nodes)
|
||||
{
|
||||
my $rsp = {};
|
||||
@ -495,6 +506,7 @@ sub preprocess_updatenode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# if not -S or -P or --security
|
||||
unless (defined($::SWMAINTENANCE) || defined($::RERUNPS) || $::SECURITY)
|
||||
{
|
||||
@ -884,7 +896,7 @@ sub updatenode
|
||||
#print Dumper($request);
|
||||
my $nodes = $request->{node};
|
||||
my $localhostname = hostname();
|
||||
|
||||
#xCAT::TableUtils->setUpdateStatus($nodes,$::STATUS_SYNCING);
|
||||
# in a mixed cluster we could potentially have both AIX and Linux
|
||||
# nodes provided on the command line ????
|
||||
my ($rc, $AIXnodes, $Linuxnodes) = xCAT::InstUtils->getOSnodes($nodes);
|
||||
@ -1333,7 +1345,6 @@ sub updatenode
|
||||
},
|
||||
\&getdata
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1620,6 +1631,64 @@ sub updatenodestat
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 updatenodeupdatestat
|
||||
|
||||
update the nodelist.updatestatus and nodelist.updatestatustime during updatenode
|
||||
|
||||
Arguments:
|
||||
Returns:
|
||||
0 - for success.
|
||||
1 - for error.
|
||||
|
||||
=cut
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
sub updatenodeupdatestat
|
||||
{
|
||||
my $request = shift;
|
||||
my $callback = shift;
|
||||
my @nodes = ();
|
||||
my @args = ();
|
||||
if (ref($request->{node}))
|
||||
{
|
||||
@nodes = @{$request->{node}};
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($request->{node}) { @nodes = ($request->{node}); }
|
||||
else
|
||||
{ #client asking to update its own status...
|
||||
unless (ref $request->{username})
|
||||
{
|
||||
return;
|
||||
} #TODO: log an attempt without credentials?
|
||||
@nodes = @{$request->{username}};
|
||||
}
|
||||
}
|
||||
if (ref($request->{arg}))
|
||||
{
|
||||
@args = @{$request->{arg}};
|
||||
}
|
||||
else
|
||||
{
|
||||
@args = ($request->{arg});
|
||||
}
|
||||
|
||||
if ((@nodes > 0) && (@args > 0))
|
||||
{
|
||||
my $stat = $args[0];
|
||||
unless ($::VALID_STATUS_VALUES{$stat})
|
||||
{
|
||||
return;
|
||||
} #don't accept just any string, see GlobalDef for updates
|
||||
|
||||
xCAT::TableUtils->setUpdateStatus(\@nodes,$stat);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
=head3 doAIXcopy
|
||||
|
||||
Copy software update files to SNs - if needed.
|
||||
|
@ -369,6 +369,24 @@ if ($inet6support) {
|
||||
#}
|
||||
}
|
||||
close($conn);
|
||||
} elsif ($text =~ /updatestatus/) {
|
||||
#update nodelist.updatestatus according to the message from cn
|
||||
my @tmpa=split(' ', $text);
|
||||
for (my $i = 1; $i <= @tmpa-1; $i++) {
|
||||
my $newstat=$tmpa[$i];
|
||||
my %request = (
|
||||
command => [ 'updatenodeupdatestat' ],
|
||||
node => [ $node ],
|
||||
arg => [ "$newstat" ],
|
||||
);
|
||||
#node should be blocked, race condition may occur otherwise
|
||||
#my $pid=xCAT::Utils->xfork();
|
||||
#unless ($pid) { #fork off the nodeset and potential slowness
|
||||
plugin_command(\%request,undef,\&build_response);
|
||||
# exit(0);
|
||||
#}
|
||||
}
|
||||
close($conn);
|
||||
} elsif ($text =~ /^unlocktftpdir/) { #TODO: only nodes in install state should be allowed
|
||||
mkpath("$tftpdir/xcat/$node");
|
||||
chmod 01777,"$tftpdir/xcat/$node";
|
||||
|
@ -269,7 +269,7 @@ if [ -x /usr/bin/openssl ]; then
|
||||
export USEOPENSSLFORXCAT
|
||||
fi
|
||||
|
||||
/xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript;
|
||||
/xcatpost/getpostscript.awk | egrep '<data>' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript;
|
||||
MYCONT=`grep MASTER /xcatpost/mypostscript`
|
||||
#echo "MYCONT=$MYCONT"
|
||||
#if getpostscript.awk fails, the postscript will fall into infinit loop
|
||||
@ -280,14 +280,17 @@ while [ -z "$MYCONT" ]; do
|
||||
RETRY=$(($RETRY+1))
|
||||
if [ $RETRY -eq $MAX_RETRIES ]
|
||||
then
|
||||
break
|
||||
# break
|
||||
echo "xcatdsklspost: failed to getpostscript from $XCATSERVER"
|
||||
logger -t xcat -p local4.err "xcatdsklspost: failed to getpostscript from $XCATSERVER"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#SLI=$(awk 'BEGIN{srand(); printf("%d\n",rand()*10)}')
|
||||
#SLI=$((10 + $SLI))
|
||||
#sleep $SLI
|
||||
|
||||
/xcatpost/getpostscript.awk | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript;
|
||||
/xcatpost/getpostscript.awk | egrep '<data>' | sed -e 's/<[^>]*>//g'|egrep -v '^ *$'|sed -e 's/^ *//' > /xcatpost/mypostscript;
|
||||
MYCONT=`grep MASTER /xcatpost/mypostscript`
|
||||
if [ ! -z "$MYCONT" ]; then
|
||||
break;
|
||||
@ -339,6 +342,9 @@ if [ "$MODE" = "6" ]; then
|
||||
#remove all the postscripts
|
||||
TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript`
|
||||
echo "$TMP" > /xcatpost/mypostscript
|
||||
|
||||
#TMP=`sed "/postbootscripts-start-here/,/postbootscripts-end-here/ d" /xcatpost/mypostscript.post`
|
||||
#echo "$TMP" > /xcatpost/mypostscript.post
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -354,6 +360,9 @@ if [ "XX$POSTSCRIPTS" != "XX" ]; then
|
||||
#add requested postscripts in
|
||||
echo "$POSTSCRIPTS" | tr "," "\n" >> /xcatpost/mypostscript
|
||||
echo "# postscripts-end-here" >> /xcatpost/mypostscript
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
#ADDSITEYUM is set by post.rh and post.rh.iscsi for full installtion
|
||||
@ -386,6 +395,7 @@ run_ps () {
|
||||
if [ \"\$ret_local\" -ne \"0\" ]; then
|
||||
return_value=\$ret_local
|
||||
fi
|
||||
echo \"Postscript: \$@ exited with code \$ret_local\"
|
||||
else
|
||||
echo \"\`date\` Postscript \$1 does NOT exist.\" | tee -a \$logfile
|
||||
return_value=-1
|
||||
@ -426,9 +436,28 @@ if [ "$CLEANUPXCATPOST" = "'1'" ] || [ "$CLEANUPXCATPOST" = "'yes'" ]; then
|
||||
echo "rm -rf /xcatpost/*" >> /xcatpost/mypostscript
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "5" ]; then
|
||||
#notify the server that we are done with updatenode
|
||||
CNS=`grep NODESTATUS= /xcatpost/mypostscript |awk -F = '{print $2}'`
|
||||
if [ -z "$CNS" ] || [ "$CNS" != "'0'" -a "$CNS" != "'N'" -a "$CNS" != "'n'" ]; then
|
||||
echo "
|
||||
if [ \"\$return_value\" -eq \"0\" ]; then
|
||||
updateflag.awk \$MASTER 3002 \"updatestatus synced\"
|
||||
else
|
||||
updateflag.awk \$MASTER 3002 \"updatestatus out-of-sync\"
|
||||
fi
|
||||
" >> /xcatpost/mypostscript
|
||||
fi
|
||||
|
||||
echo "exit \$return_value" >> /xcatpost/mypostscript
|
||||
fi
|
||||
|
||||
chmod +x /xcatpost/mypostscript
|
||||
if [ -x /xcatpost/mypostscript ];then
|
||||
/xcatpost/mypostscript
|
||||
VRET_POST=$?
|
||||
fi
|
||||
#rm -f /xcatpost/mypostscript
|
||||
|
||||
@ -437,3 +466,4 @@ if [ "$MODE" = "1" ] || [ "$MODE" = "2" ] || [ "$MODE" = "5" ]; then
|
||||
echo "returned from postscript"
|
||||
fi
|
||||
|
||||
exit $VRET_POST
|
||||
|
Loading…
Reference in New Issue
Block a user