From e452d1d7b00094cc61abc72390b9961634cf8834 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sun, 3 Feb 2008 00:01:35 +0000 Subject: [PATCH] -yaboot configuration requests propogated to all xcatd instances, ignored if not directly reachable -Factor out common broadcast scope to xCAT::Scope git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@380 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT-2.0/xCAT/Scope.pm | 27 +++++++ xCAT-server-2.0/lib/xcat/plugins/yaboot.pm | 83 ++++++++++++---------- 2 files changed, 74 insertions(+), 36 deletions(-) create mode 100644 perl-xCAT-2.0/xCAT/Scope.pm diff --git a/perl-xCAT-2.0/xCAT/Scope.pm b/perl-xCAT-2.0/xCAT/Scope.pm new file mode 100644 index 000000000..24cd31ed0 --- /dev/null +++ b/perl-xCAT-2.0/xCAT/Scope.pm @@ -0,0 +1,27 @@ +package xCAT::Scope; +use xCAT::Utils; +use xCAT::Table; +sub get_broadcast_scope { + my $req = shift; + if ($req =~ /xCAT::Scope/) { + $req = shift; + } + $callback = shift; + if ($req->{_xcatdest}) { return [$req]; } #Exit if the packet has been preprocessed in its history + my @requests = ({%$req}); #Start with a straight copy to reflect 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; +} + +1; diff --git a/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm b/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm index 9cfc7a98b..189b893f7 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm @@ -2,6 +2,7 @@ package xCAT_plugin::yaboot; use Data::Dumper; use Sys::Syslog; +use xCAT::Scope; use Socket; my $request; @@ -127,39 +128,42 @@ sub pass_along { sub preprocess_request { - my $req = shift; - my $callback = shift; - my %localnodehash; - my %dispatchhash; - my $nrtab = xCAT::Table->new('noderes'); - foreach my $node (@{$req->{node}}) { - my $nodeserver; - my $tent = $nrtab->getNodeAttribs($node,['tftpserver']); - if ($tent) { $nodeserver = $tent->{tftpserver} } - unless ($tent and $tent->{tftpserver}) { - $tent = $nrtab->getNodeAttribs($node,['servicenode']); - if ($tent) { $nodeserver = $tent->{servicenode} } - } - if ($nodeserver) { - $dispatchhash{$nodeserver}->{$node} = 1; - } else { - $localnodehash{$node} = 1; - } - } - my @requests; - my $reqc = {%$req}; - $reqc->{node} = [ keys %localnodehash ]; - if (scalar(@{$reqc->{node}})) { push @requests,$reqc } - - foreach my $dtarg (keys %dispatchhash) { #iterate dispatch targets - my $reqcopy = {%$req}; #deep copy - $reqcopy->{'_xcatdest'} = $dtarg; - $reqcopy->{node} = [ keys %{$dispatchhash{$dtarg}}]; - push @requests,$reqcopy; - } - return \@requests; + return xCAT::Scope->get_broadcast_scope(@_); } - +#sub preprocess_request { +# my $req = shift; +# my $callback = shift; +# my %localnodehash; +# my %dispatchhash; +# my $nrtab = xCAT::Table->new('noderes'); +# foreach my $node (@{$req->{node}}) { +# my $nodeserver; +# my $tent = $nrtab->getNodeAttribs($node,['tftpserver']); +# if ($tent) { $nodeserver = $tent->{tftpserver} } +# unless ($tent and $tent->{tftpserver}) { +# $tent = $nrtab->getNodeAttribs($node,['servicenode']); +# if ($tent) { $nodeserver = $tent->{servicenode} } +# } +# if ($nodeserver) { +# $dispatchhash{$nodeserver}->{$node} = 1; +# } else { +# $localnodehash{$node} = 1; +# } +# } +# my @requests; +# my $reqc = {%$req}; +# $reqc->{node} = [ keys %localnodehash ]; +# if (scalar(@{$reqc->{node}})) { push @requests,$reqc } +# +# foreach my $dtarg (keys %dispatchhash) { #iterate dispatch targets +# my $reqcopy = {%$req}; #deep copy +# $reqcopy->{'_xcatdest'} = $dtarg; +# $reqcopy->{node} = [ keys %{$dispatchhash{$dtarg}}]; +# push @requests,$reqcopy; +# } +# return \@requests; +#} +# sub process_request { @@ -168,18 +172,25 @@ sub process_request { $sub_req = shift; my @args; my @nodes; + my @rnodes; if (ref($request->{node})) { - @nodes = @{$request->{node}}; + @rnodes = @{$request->{node}}; } else { - if ($request->{node}) { @nodes = ($request->{node}); } + if ($request->{node}) { @rnodes = ($request->{node}); } } - unless (@nodes) { + unless (@rnodes) { if ($usage{$request->{command}->[0]}) { $callback->({data=>$usage{$request->{command}->[0]}}); } return; } - + @nodes = (); + foreach (@rnodes) { + if (xCAT::Utils->nodeonmynet($_)) { + push @nodes,$_; + } + } + if (ref($request->{arg})) { @args=@{$request->{arg}}; } else {