From 5a09a9b34abfe726de6ddc51552d79c61179cd62 Mon Sep 17 00:00:00 2001 From: lissav Date: Thu, 29 Aug 2013 13:45:24 -0400 Subject: [PATCH] add timeout support to updatenode to pass into xdsh --- perl-xCAT/xCAT/Usage.pm | 7 ++++-- xCAT-client/bin/updatenode | 3 ++- xCAT-server/lib/xcat/plugins/updatenode.pm | 29 +++++++++++++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 242104d2e..62ce7f9fe 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -345,9 +345,9 @@ my %usage = ( "Usage: updatenode [-h|--help|-v|--version | -g|--genmypost] or - updatenode [-V|--verbose] [-k|--security] [-s|--sn] + updatenode [-V|--verbose] [-k|--security] [-s|--sn] [-t ] or - updatenode [-V|--verbose] [-F|--sync | -f|--snsync] [-l|--user[username]] [--fanout=[fanout value]] [-S|--sw] + updatenode [-V|--verbose] [-F|--sync | -f|--snsync] [-l|--user[username]] [--fanout=[fanout value]] [-S|--sw] [-t ] [-P|--scripts [script1,script2,...]] [-s|--sn] [-A|--updateallsw] [-c|--cmdlineonly] [-d alt_source_dir] [attr=val [attr=val...]] @@ -384,6 +384,9 @@ Options: [-s|--sn] Set the server information stored on the nodes. + [-t|--timeout] Time out in seconds to allow the command to run. Default is no timeout, + except for updatenode -k which has a 10 second default timeout. + [-A|--updateallsw] Install or update all software contained in the source directory. (AIX only) diff --git a/xCAT-client/bin/updatenode b/xCAT-client/bin/updatenode index 35e7efd99..c2c2e2a73 100755 --- a/xCAT-client/bin/updatenode +++ b/xCAT-client/bin/updatenode @@ -88,7 +88,7 @@ if ( 'v|version' => \$::VERSION, 'V|verbose' => \$::VERBOSE, 'F|sync' => \$::FILESYNC, - 'g|genmypost' => \$::GENMYPOST, + 'g|genmypost' => \$::GENMYPOST, 'f|snsync' => \$::SNFILESYNC, 'l|user:s' => \$::USER, 'S|sw' => \$::SWMAINTENANCE, @@ -97,6 +97,7 @@ if ( 'k|security' => \$::SECURITY, 'o|os:s' => \$::OS, 'fanout=i' => \$::fanout, + 't|timetout=i' => \$::timeout, ) ) { &updatenode_usage(); diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index a8e03b1ad..6e427786e 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -227,6 +227,7 @@ sub preprocess_updatenode 'k|security' => \$::SECURITY, 'o|os:s' => \$::OS, 'fanout=i' => \$::fanout, + 't|timetout=i' => \$::timeout, ) ) @@ -832,13 +833,18 @@ sub security_update_sshkeys # call the xdsh -K to set up the ssh keys my @envs = @{$request->{environment}}; - my @args = ("-K"); + my $args; + push @$args,"-K"; + if (defined($::timeout)) { # timeout + push @$args,"-t" ; + push @$args,$::timeout; + } my $res = xCAT::Utils->runxcmd( { command => ['xdsh'], node => \@$nodes, - arg => \@args, + arg => $args, env => \@envs, }, $subreq, 0, 1 @@ -849,7 +855,7 @@ sub security_update_sshkeys my $rsp = {}; # not display password in verbose mode. $rsp->{data}->[0] = - " $localhostname: Internal call command: xdsh -K. nodes = @$nodes, arguments = @args, env = xxxxxx"; + " $localhostname: Internal call command: xdsh @$nodes " . join(' ', @$args); $rsp->{data}->[1] = " $localhostname: return messages of last command: @$res"; $callback->($rsp); @@ -1006,6 +1012,7 @@ sub updatenode 'k|security' => \$::SECURITY, 'o|os:s' => \$::OS, 'fanout=i' => \$::fanout, + 't|timetout=i' => \$::timeout, ) ) { @@ -1318,6 +1325,10 @@ sub updatenoderunps push @$args1,"-f" ; push @$args1,$::fanout; } + if (defined($::timeout)) { # timeout + push @$args1,"-t" ; + push @$args1,$::timeout; + } if (defined($::USER)) { # -l contains sudo user push @$args1,"--sudo" ; push @$args1,"-l" ; @@ -1450,6 +1461,10 @@ sub updatenodesyncfiles push @$args,"-f" ; push @$args,$::fanout; } + if (defined($::timeout)) { # timeout + push @$args,"-t" ; + push @$args,$::timeout; + } if (defined($::USER)) { # -l must sudo push @$args,"--sudo" ; push @$args,"-l" ; @@ -1646,6 +1661,10 @@ sub updatenodesoftware push @$args1,"-f" ; push @$args1,$::fanout; } + if (defined($::timeout)) { # timeout + push @$args1,"-t" ; + push @$args1,$::timeout; + } if (defined($::USER)) { # -l contains sudo user push @$args1,"--sudo" ; push @$args1,"-l" ; @@ -2622,6 +2641,10 @@ sub updateAIXsoftware push @$args1,"-f" ; push @$args1,$::fanout; } + if (defined($::timeout)) { # timeout + push @$args1,"-t" ; + push @$args1,$::timeout; + } push @$args1,"$installcmd"; $subreq->(