From c95f5dfe03b80f4e31d7af215d08d5e5346fe6f0 Mon Sep 17 00:00:00 2001 From: linggao Date: Fri, 18 Apr 2008 20:33:19 +0000 Subject: [PATCH] use right way in monctrlcmds.pm to support hierarchy for monstart and monstop commands git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1126 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../lib/xcat/plugins/monctrlcmds.pm | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm b/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm index 5db8080b8..7688a374a 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/monctrlcmds.pm @@ -13,8 +13,11 @@ use xCAT::MsgUtils; use xCAT_monitoring::monitorctrl; use xCAT::Utils; +my $callback; 1; + + #------------------------------------------------------------------------------- =head1 xCAT_plugin:monctrlcmds =head2 Package Description @@ -64,12 +67,13 @@ sub process_request { $Getopt::Long::ignorecase=0; my $request = shift; - my $callback = shift; + $callback = shift; my $command = $request->{command}->[0]; my $args=$request->{arg}; + my $doreq = shift; if ($command eq "monstart") { - my ($ret, $msg) = monstart($args, $callback); + my ($ret, $msg) = monstart($args, $callback, $doreq); if ($msg) { my %rsp=(); $rsp->{dara}->[0]= $msg; @@ -78,7 +82,7 @@ sub process_request { return $ret; } elsif ($command eq "monstop") { - my ($ret, $msg) = monstop($args, $callback); + my ($ret, $msg) = monstop($args, $callback, $doreq); if ($msg) { my %rsp=(); $rsp->{data}->[0]= $msg; @@ -124,6 +128,11 @@ sub process_request { } } +sub take_answer { + my $resp = shift; + $callback->($resp); +} + #-------------------------------------------------------------------------------- =head3 monstart @@ -151,6 +160,7 @@ sub process_request { sub monstart { my $args=shift; my $callback=shift; + my $doreq = shift; my $VERSION; my $HELP; @@ -302,11 +312,15 @@ sub monstart { my %rsp2; $rsp2->{data}->[0]="sending request to $_..."; $callback->($rsp2); - my $result=`psh --nonodecheck $_ monupdate 2>1&`; - if ($result) { - $rsp2->{data}->[0]="$result"; - $callback->($rsp2); - } +# my $result=`psh --nonodecheck $_ monupdate 2>1&`; +# if ($result) { +# $rsp2->{data}->[0]="$result"; +# $callback->($rsp2); +# } + my %req=(); + push @{$req{command}}, "monupdate"; + $req{'_xcatdest'}=$_; + $doreq->(\%req,\&take_answer); } } @@ -339,6 +353,7 @@ sub monstart { sub monstop { my $args=shift; my $callback=shift; + my $doreq = shift; my $VERSION; my $HELP; @@ -443,11 +458,15 @@ sub monstop { my %rsp2; $rsp2->{data}->[0]="sending request to $_..."; $callback->($rsp2); - my $result=`psh --nonodecheck $_ monupdate 2>1&`; - if ($result) { - $rsp2->{data}->[0]="$result"; - $callback->($rsp2); - } + # my $result=`psh --nonodecheck $_ monupdate 2>1&`; + # if ($result) { + # $rsp2->{data}->[0]="$result"; + # $callback->($rsp2); + #} + my %req=(); + push @{$req{command}}, "monupdate"; + $req{'_xcatdest'}=$_; + $doreq->(\%req,\&take_answer); } }