From 6a492166e4ae8d4f1cdf9c97da48dff24ff43865 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Sun, 27 Jan 2008 20:45:31 +0000 Subject: [PATCH] Add hierarchical intelligence to pxe and paboot plugins git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@333 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/lib/xcat/plugins/pxe.pm | 33 +++++++++++++++++++++ xCAT-server-2.0/lib/xcat/plugins/yaboot.pm | 34 ++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/xCAT-server-2.0/lib/xcat/plugins/pxe.pm b/xCAT-server-2.0/lib/xcat/plugins/pxe.pm index 3d59a7a8c..702e741c6 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/pxe.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/pxe.pm @@ -124,6 +124,39 @@ 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; +} sub process_request { $request = shift; diff --git a/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm b/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm index 758ebcaca..7ac5eb59a 100644 --- a/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server-2.0/lib/xcat/plugins/yaboot.pm @@ -124,6 +124,40 @@ 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; +}