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; +}