From 175c3937b05aed6c58f7740ef0d47c2425777074 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 10 Mar 2008 18:25:22 +0000 Subject: [PATCH] Add hierarchical support to plugin (preprocess_request). git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@745 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/xdsh.pm | 33 +++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/xCAT-server-2.0/lib/xcat/plugins/xdsh.pm b/xCAT-server-2.0/lib/xcat/plugins/xdsh.pm index d91c861aa..8307ace05 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/xdsh.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/xdsh.pm @@ -39,6 +39,36 @@ sub handled_commands }; } +#------------------------------------------------------- + +=head3 preprocess_request + + Check and setup for hierarchy + +=cut + +#------------------------------------------------------- +sub preprocess_request { + my $req = shift; + my $cb = shift; + if ($req->{_xcatdest}) { return [$req]; } #exit if preprocessed + my @requests = ({%$req}); #first element is local instance + my $sitetab = xCAT::Table->new('site'); + (my $ent) = $sitetab->getAttribs({key=>'xcatservers'},'value'); + $sitetab->close; + if ($ent and $ent->{value}) { + foreach (split /,/,$ent->{value}) { + if (xCAT::Utils->thishostisnot($_)) { + my $reqcopy = {%$req}; + $reqcopy->{'_xcatdest'} = $_; + push @requests,$reqcopy; + } + } + } + return \@requests; +} + + #------------------------------------------------------- =head3 process_request @@ -99,6 +129,7 @@ sub process_request sub xdsh { my ($nodes, $args, $callback, $command, $noderange) = @_; + #`touch /tmp/lissadebug`; # parse dsh input @local_results = @@ -124,7 +155,7 @@ sub xdsh sub xdcp { my ($nodes, $args, $callback, $command, $noderange) = @_; - + #`touch /tmp/lissadebug`; # parse dcp input @local_results = xCAT::DSHCLI->parse_and_run_dcp($nodes, $args, $callback,