add -E hierarchy and --fanout support

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15094 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
lissav 2013-02-07 12:44:15 +00:00
parent 8c58adf552
commit 4a241ef34e
2 changed files with 165 additions and 103 deletions

View File

@ -224,6 +224,8 @@ sub preprocess_updatenode
'P|scripts:s' => \$::RERUNPS,
'k|security' => \$::SECURITY,
'o|os:s' => \$::OS,
'fanout=i' => \$::fanout,
)
)
{
@ -925,12 +927,14 @@ sub updatenode
'v|version' => \$::VERSION,
'V|verbose' => \$::VERBOSE,
'F|sync' => \$::FILESYNC,
'l|user:s' => \$::USER,
'f|snsync' => \$::SNFILESYNC,
'S|sw' => \$::SWMAINTENANCE,
's|sn' => \$::SETSERVER,
'P|scripts:s' => \$::RERUNPS,
'k|security' => \$::SECURITY,
'o|os:s' => \$::OS,
'fanout=i' => \$::fanout,
)
)
{
@ -1133,6 +1137,7 @@ sub updatenode
#-----------------------------------------------------------------------------
sub updatenoderunps
{
my $request = shift;
my $subreq = shift;
@ -1168,11 +1173,15 @@ sub updatenoderunps
# it's possible that the nodes could have diff server names
# do all the nodes for a particular server at once
foreach my $snkey (keys %servernodes)
{
my $nodestring = join(',', @{$servernodes{$snkey}});
my $args;
my $mode;
#now build the actual updatenode command
if ( $request->{rerunps4security}
&& $request->{rerunps4security}->[0] eq "yes")
{
@ -1192,35 +1201,25 @@ sub updatenoderunps
my $runpscmd;
if ($::SETSERVER){
$runpscmd =
"$installdir/postscripts/xcatdsklspost $mode -M $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c ";
"$installdir/postscripts/xcatdsklspost $mode -M $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c";
} else {
$runpscmd =
"$installdir/postscripts/xcatdsklspost $mode -m $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"
"$installdir/postscripts/xcatdsklspost $mode -m $snkey '$postscripts' --tftp $tftpdir --installdir $installdir --nfsv4 $nfsv4 -c"
}
# if non-root userid ask xdsh to use sudo
if (defined($::USER)){ # non-root user
$args1 = [
"--nodestatus",
"--sudo",
"-s",
"-v",
"-e",
"$runpscmd"
];
} else { # running as root
$args1 = [
"--nodestatus",
"-s",
"-v",
"-e",
"$runpscmd"
];
}
# if -l username input
if (defined($::USER)){ # need to add the -l username
unshift(@$args1, "$::USER");
unshift(@$args1, "-l");
push @$args1,"--nodestatus"; # return nodestatus
if (defined($::fanout)) { # fanout
push @$args1,"-f" ;
push @$args1,$::fanout;
}
if (defined($::USER)) { # -l contains sudo user
push @$args1,"--sudo" ;
push @$args1,"-l" ;
push @$args1,"$::USER" ;
}
push @$args1,"-s"; # streaming
push @$args1,"-v"; # streaming
push @$args1,"-e"; # execute
push @$args1,"$runpscmd"; # the command
if ($::VERBOSE)
@ -1331,33 +1330,39 @@ sub updatenodesyncfiles
foreach my $synclist (keys %syncfile_node)
{
$numberofsynclists++;
my $args;
my $env;
if ($request->{FileSyncing}->[0] ne "yes") { # sync SN only
push @$args,"-s" ;
$env = ["DSH_RSYNC_FILE=$synclist", "RSYNCSNONLY=1"];
} else {
$env = ["DSH_RSYNC_FILE=$synclist"];
}
push @$args,"--nodestatus" ;
if (defined($::fanout)) { # fanout
push @$args,"-f" ;
push @$args,$::fanout;
}
# if (defined($::USER)) { # -l contains sudo (TODO SUPPORT?)
# push @$args,"--sudo" ;
# push @$args,"-l" ;
# push @$args,"$::USER" ;
# }
push @$args,"-F" ;
push @$args,"$synclist" ;
my $nodestring = join(',', @{$syncfile_node{$synclist}});
if ($::VERBOSE)
{
my $rsp = {};
if ($request->{FileSyncing}->[0] eq "yes")
{ # sync nodes
$rsp->{data}->[0] =
" $localhostname: Internal call command: xdcp ". join(" ",@{$syncfile_node{$synclist}})." -F $synclist";
}
else
{ # sync SN
$rsp->{data}->[0] =
" $localhostname: Internal call command: xdcp ".join(" ",@{$syncfile_node{$synclist}})." -s -F $synclist";
}
$rsp->{data}->[0] =
" $localhostname: Internal call command: xdcp $nodestring " . join(' ', @$args);
$callback->($rsp);
}
my $args;
my $env;
if ($request->{FileSyncing}->[0] eq "yes")
{ # sync nodes
$args = ["--nodestatus","-F", "$synclist"];
$env = ["DSH_RSYNC_FILE=$synclist"];
}
else
{ # sync SN only
$args = ["-s", "--nodestatus","-F", "$synclist"];
$env = ["DSH_RSYNC_FILE=$synclist", "RSYNCSNONLY=1"];
}
$CALLBACK = $callback;
$output =
xCAT::Utils->runxcmd(
{
@ -1521,30 +1526,24 @@ sub updatenodesoftware
$cmd =
"$installdir/postscripts/xcatdsklspost 2 -m $snkey 'ospkgs,otherpkgs' --tftp $tftpdir";
}
# build xdsh command
if (defined($::USER)){ # non-root user
$args1 = [
"--nodestatus",
"--sudo",
"-s",
"-v",
"-e",
"$cmd"
];
} else { # root
$args1 = [
"--nodestatus",
"-s",
"-v",
"-e",
"$cmd"
];
push @$args1,"--nodestatus"; # return nodestatus
if (defined($::fanout)) { # fanout
push @$args1,"-f" ;
push @$args1,$::fanout;
}
# if -l username input
if (defined($::USER)){ # need to add the -l username
unshift(@$args1, "$::USER");
unshift(@$args1, "-l");
if (defined($::USER)) { # -l contains sudo user
push @$args1,"--sudo" ;
push @$args1,"-l" ;
push @$args1,"$::USER" ;
}
push @$args1,"-s"; # streaming
push @$args1,"-v"; # streaming
push @$args1,"-e"; # execute
push @$args1,"$cmd"; # the command
if ($::VERBOSE)
{
@ -2558,12 +2557,18 @@ sub updateAIXsoftware
}
else
{ # if server is remote then use xdsh
my $args;
if (defined($::fanout)) { # fanout input
push @$args,"-f" ;
push @$args,$::fanout;
}
push @$args,"$chmcmd";
my $output =
xCAT::Utils->runxcmd(
{
command => ["xdsh"],
node => [$serv],
arg => [$chmcmd]
arg => $args
},
$subreq, -1, 1
);
@ -2598,10 +2603,16 @@ sub updateAIXsoftware
push @{$rsp->{data}}, "Running command: $mcmd\n";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $args;
if (defined($::fanout)) { # fanout input
push @$args,"-f" ;
push @$args,$::fanout;
}
push @$args,"$mcmd";
my $output =
xCAT::Utils->runxcmd(
{command => ["xdsh"], node => \@nodes, arg => [$mcmd]},
{command => ["xdsh"], node => \@nodes, arg => $args},
$subreq, -1, 1);
if ($::RUNCMD_RC != 0)
@ -2695,20 +2706,21 @@ sub updateAIXsoftware
# installp - UNLESS the flags don't need filesets
if ($noinstallp == 0)
{
if ($::VERBOSE)
{
my $rsp;
push @{$rsp->{data}}, "Running: xdsh -s -v \'$inpcmd\'.\n";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $args1 = [
"--nodestatus",
"-s",
"-v",
"$inpcmd"
];
my $args1;
push @$args1,"--nodestatus";
push @$args1,"-s";
push @$args1,"-v";
if (defined($::fanout)) { # fanout input
push @$args1,"-f" ;
push @$args1,$::fanout;
}
push @$args1,"$inpcmd";
$subreq->(
{
@ -2734,12 +2746,18 @@ sub updateAIXsoftware
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $args;
if (defined($::fanout)) { # fanout input
push @$args,"-f" ;
push @$args,$::fanout;
}
push @$args,"$upcmd";
my $output =
xCAT::Utils->runxcmd(
{
command => ["xdsh"],
node => \@nodes,
arg => [$upcmd]
arg => $args
},
$subreq, -1, 1
);
@ -2805,13 +2823,19 @@ sub updateAIXsoftware
push @{$rsp->{data}}, "Running: \'$emgrcmd\'.\n";
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $args;
if (defined($::fanout)) { # fanout input
push @$args,"-f" ;
push @$args,$::fanout;
}
push @$args,"$emgrcmd";
my $output =
xCAT::Utils->runxcmd(
{
command => ["xdsh"],
node => \@nodes,
arg => [$emgrcmd]
arg => $args
},
$subreq, -1, 1
);
@ -2906,12 +2930,15 @@ sub updateAIXsoftware
xCAT::MsgUtils->message("I", $rsp, $callback);
}
# install the rpms
my $args1 = [
"--nodestatus",
"-s",
"-v",
"$rcmd"
];
my $args1;
push @$args1,"--nodestatus";
push @$args1,"-s";
push @$args1,"-v";
if (defined($::fanout)) { # fanout input
push @$args1,"-f" ;
push @$args1,$::fanout;
}
push @$args1,"$rcmd";
$subreq->(
{
@ -2938,12 +2965,18 @@ sub updateAIXsoftware
xCAT::MsgUtils->message("I", $rsp, $callback);
}
my $args1;
if (defined($::fanout)) { # fanout input
push @$args1,"-f" ;
push @$args1,$::fanout;
}
push @$args1,"$ucmd";
my $output =
xCAT::Utils->runxcmd(
{
command => ["xdsh"],
node => \@nodes,
arg => [$ucmd]
arg => $args1
},
$subreq, -1, 1
);

View File

@ -101,6 +101,10 @@ sub preprocess_request
my @cmd = split(/ /, $value); # split off args, if any
$::dshexecute = $cmd[0]; # This is the executable file
}
if ($var eq "DSH_ENVIRONMENT") # from xdsh -E flag
{
$::dshenvfile = $value; # Name of file with env variables
}
}
# if xdcp need to make sure request has full path to input files
if ($command eq "xdcp") {
@ -154,8 +158,9 @@ sub preprocess_request
if (@snodes) # service nodes
{
# if xdcp and not pull function or xdsh -e
if ((($command eq "xdcp") && ($::dcppull == 0)) or ($::dshexecute))
# if xdcp and not pull function or xdsh -e or xdsh -E
if ((($command eq "xdcp") && ($::dcppull == 0)) or (($::dshexecute)
or ($::dshenvfile)))
{
# get the directory on the servicenode to put the files in
@ -181,7 +186,7 @@ sub preprocess_request
{
return;
}
} else { # xdsh -e
} else { # xdsh -e or -E
$rc =
&process_servicenodes_xdsh($req, $cb, $sub_req, \@snodes,
\@snoderange, $synfiledir);
@ -704,10 +709,12 @@ sub process_servicenodes_xdcp
#-------------------------------------------------------
=head3 process_servicenodes_xdsh
Build the xdsh command to send the -e file
The executable must be copied into /var/xcat/syncfiles, and then
the command modified so that the xdsh running on the SN will cp the file
from /var/xcat/syncfiles to the compute node /tmp directory and run it.
Build the xdsh command to sync the -e file or the -E file
to the servicenodes.
The executable (-e) or the environment file (-E)
must be copied into /var/xcat/syncfiles (SNsyncfiledir attribute), and then
the command modified so that the xdsh running on the SN will use the file
from /var/xcat/syncfiles (default) for the compute nodes.
Return an array of servicenodes that do not have errors
Returns error code:
if = 0, good return continue to process the
@ -732,30 +739,52 @@ sub process_servicenodes_xdsh
$::RUNCMD_RC = 0;
my $cmd = $req->{command}->[0];
# if xdsh -e <executable> command, service nodes first need
# to be rsync with the executable file to the $synfiledir
if ($::dshexecute)
# if xdsh -e <executable> command or xdsh -E <environment file>
# service nodes first need
# to be rsync with the executable or environment file to the $synfiledir
if (($::dshexecute) or ($::dshenvfile))
{
if (!-f $::dshexecute)
if (defined($::dshexecute) && (!-f $::dshexecute))
{ # -e file does not exist, quit
my $rsp = {};
$rsp->{error}->[0] = "File:$::dshexecute does not exist.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return (1); # process no service nodes
}
if (defined($::dshenvfile) && (!-f $::dshenvfile))
{ # -E file does not exist, quit
my $rsp = {};
$rsp->{error}->[0] = "File:$::dshenvfile does not exist.";
xCAT::MsgUtils->message("E", $rsp, $callback, 1);
return (1); # process no service nodes
}
# xdcp the executable from the xdsh -e to the service node first
# xdcp (-F) the executable from the xdsh -e and/or
# xdcp (-F) the environment file from the xdsh -E
# to the service node
# change noderange to the service nodes
# sync to each SN and check for error
# if error do not add to good_SN array, add to bad_SN
# /.../excutable -> $syncdir/..../executable
# /.../envfile -> $syncdir/...../envfile
# build a tmp syncfile with
# $::dshexecute -> $synfiledir . $::dshexecute
# $::dshenvfile -> $synfiledir . $::dshenvfile
my $tmpsyncfile = POSIX::tmpnam . ".dsh";
my $destination=$synfiledir . $::dshexecute;
# if -E option
my $envfile;
my $execfile;
open(TMPFILE, "> $tmpsyncfile")
or die "can not open file $tmpsyncfile";
print TMPFILE "$::dshexecute -> $destination\n";
if (defined($::dshenvfile)) {
$envfile=$synfiledir . $::dshenvfile;
print TMPFILE "$::dshenvfile -> $envfile\n";
}
if (defined($::dshexecute)) {
$execfile=$synfiledir . $::dshexecute;
print TMPFILE "$::dshexecute -> $execfile\n";
}
close TMPFILE;
chmod 0755, $tmpsyncfile;
@ -815,7 +844,7 @@ sub process_servicenodes_xdsh
# remove the tmp syncfile
`/bin/rm $tmpsyncfile`;
} # end xdsh -E
} # end xdsh -e or -E
# report bad service nodes]
if (@::bad_SN)