From ddb52b5e48a29daa19d3cb6a6faeb91f46db9938 Mon Sep 17 00:00:00 2001 From: linggao Date: Thu, 1 Jul 2010 19:55:11 +0000 Subject: [PATCH] fix updatenode for service node pool case. Only fixed the -P case, needs more work on other cases git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6634 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/updatenode.pm | 101 +++++++++++++-------- 1 file changed, 61 insertions(+), 40 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index 543f2de65..d1264bed3 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -23,6 +23,8 @@ use xCAT::GlobalDef; use xCAT_monitoring::monitorctrl; use Socket; +my $CALLBACK; +my $RERUNPS4SECURITY; 1; #------------------------------------------------------------------------------- @@ -979,7 +981,7 @@ $AIXnodes_nd, $subreq ) != 0 ) { # do all the nodes for a particular server at once foreach my $snkey (keys %servernodes) { my $nodestring = join(',', @{$servernodes{$snkey}}); - my $cmd; + my $args; my $mode; if ($request->{rerunps4security} && $request->{rerunps4security}->[0] eq "yes") { # for updatenode --security @@ -989,58 +991,50 @@ $AIXnodes_nd, $subreq ) != 0 ) { $mode = "1"; } if ($::SETSERVER) { - $cmd = - "XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -s -e $installdir/postscripts/xcatdsklspost $mode -M $snkey $postscripts 2>&1"; + $args1 = ["-s", "-e", "$installdir/postscripts/xcatdsklspost $mode -M $snkey $postscripts"]; } else { - $cmd = - "XCATBYPASS=Y $::XCATROOT/bin/xdsh $nodestring -s -e $installdir/postscripts/xcatdsklspost $mode -m $snkey $postscripts 2>&1"; + $args1 = ["-s", "-e", "$installdir/postscripts/xcatdsklspost $mode -m $snkey $postscripts"]; } if ($::VERBOSE) { my $rsp = {}; - $rsp->{data}->[0] = " $localhostname: Internal call command: $cmd"; + $rsp->{data}->[0] = " $localhostname: Internal call command: xdsh $nodestring $args1"; $callback->($rsp); } - - if (!open(CMD, "$cmd |")) - { - my $rsp = {}; - $rsp->{data}->[0] = "$localhostname: Cannot run command $cmd"; - $callback->($rsp); - } - else - { - my $rsp = {}; - while () - { - my $output = $_; - chomp($output); - $output =~ s/\\cM//; - if ($output =~ /returned from postscript/) - { - $output =~ - s/returned from postscript/Running of postscripts has completed./; - } - if ($request->{rerunps4security} && $request->{rerunps4security}->[0] eq "yes") { - if ($output =~ /Running of postscripts has completed/) { - $output =~ s/Running of postscripts has completed/Redeliver certificates has completed/; - push @{$rsp->{data}}, $output; - } elsif ($output !~ /Running postscript|Error loading module/) { - push @{$rsp->{data}}, "$output"; - } - } elsif ($output !~ /Error loading module/) { - push @{$rsp->{data}}, "$output"; - } - } - close(CMD); - $callback->($rsp); + + #my $output1 = xCAT::Utils->runxcmd({command => ["xdsh"], + # node => $servernodes{$snkey}, + # arg => $args1, + # _xcatpreprocessed =>[1]}, + # $subreq, 0, 1); + # + + #if ($::RUNCMD_RC != 0) + #{ + # my $rsp; + # push @{$rsp->{data}}, "Could not run postscripts $postscripts on nodes $nodestring \n"; + # xCAT::MsgUtils->message("E", $rsp, $callback); + #} + $CALLBACK=$callback; + if ($request->{rerunps4security}) { + $RERUNPS4SECURITY=$request->{rerunps4security}->[0]; + } else { + $RERUNPS4SECURITY=""; } + $subreq->({command => ["xdsh"], + node => $servernodes{$snkey}, + arg => $args1, + _xcatpreprocessed =>[1]}, + \&getdata); + } - } + } + + if (scalar(@$AIXnodes)) { @@ -1131,6 +1125,33 @@ $AIXnodes_nd, $subreq ) != 0 ) { return 0; } +sub getdata { + my $response = shift; + my $rsp; + foreach my $type (keys %$response) { + foreach my $output (@{$response->{$type}}) { + chomp($output); + $output =~ s/\\cM//; + if ($output =~ /returned from postscript/) + { + $output =~ + s/returned from postscript/Running of postscripts has completed./; + } + if ($RERUNPS4SECURITY && $RERUNPS4SECURITY eq "yes") { + if ($output =~ /Running of postscripts has completed/) { + $output =~ s/Running of postscripts has completed/Redeliver certificates has completed/; + push @{$rsp->{$type}}, $output; + } elsif ($output !~ /Running postscript|Error loading module/) { + push @{$rsp->{$type}}, "$output"; + } + } elsif ($output !~ /Error loading module/) { + push @{$rsp->{$type}}, "$output"; + } + } + } + $CALLBACK->($rsp); +} + #------------------------------------------------------------------------------- =head3 updatenodestat