Make ipmi requests fan out to service nodes, fix problem where serverdone flags were erroneously propogated to client from a dispatched request
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@326 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -4316,6 +4316,40 @@ sub loadsdrcache {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
sub preprocess_request { 
 | 
			
		||||
  my $request = shift;
 | 
			
		||||
  my @requests;
 | 
			
		||||
  my %servicenodehash;
 | 
			
		||||
  my %noservicenodehash;
 | 
			
		||||
  my $nrtab = xCAT::Table->new('noderes');
 | 
			
		||||
  foreach my $node (@{$request->{node}}) {
 | 
			
		||||
     my $tent  = $nrtab->getNodeAttribs($node,['servicenode']);
 | 
			
		||||
     if ($tent and $tent->{servicenode}) {
 | 
			
		||||
       $servicenodehash{$tent->{servicenode}}->{$node} = 1;
 | 
			
		||||
     } else {
 | 
			
		||||
       $noservicenodehash{$node} = 1;
 | 
			
		||||
      }
 | 
			
		||||
   }
 | 
			
		||||
   foreach my $smaster (keys %servicenodehash) {
 | 
			
		||||
  	   my $reqcopy = {%$request};
 | 
			
		||||
	   $reqcopy->{'_xcatdest'} = $smaster;
 | 
			
		||||
	   $reqcopy->{node} = [ keys %{$servicenodehash{$smaster}} ];
 | 
			
		||||
	   push @requests,$reqcopy;
 | 
			
		||||
   }
 | 
			
		||||
   my $reqcopy = {%$request};
 | 
			
		||||
   $reqcopy->{node} = [ keys %noservicenodehash ];
 | 
			
		||||
   if ($reqcopy->{node}) {
 | 
			
		||||
      push @requests,$reqcopy;
 | 
			
		||||
   }
 | 
			
		||||
   return \@requests;
 | 
			
		||||
}
 | 
			
		||||
    
 | 
			
		||||
     
 | 
			
		||||
 | 
			
		||||
     
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   
 | 
			
		||||
sub process_request {
 | 
			
		||||
    my $request = shift;
 | 
			
		||||
    my $callback = shift;
 | 
			
		||||
 
 | 
			
		||||
@@ -562,10 +562,16 @@ sub plugin_command {
 | 
			
		||||
  if ($sock) { print $sock XMLout(\%done,RootName => 'xcatresponse',NoAttr=>1); }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
my $dispatch_cb;
 | 
			
		||||
sub dispatch_callback {
 | 
			
		||||
   my $rsp = shift;
 | 
			
		||||
   delete $rsp->{serverdone};
 | 
			
		||||
   $dispatch_cb->($rsp);
 | 
			
		||||
}
 | 
			
		||||
sub dispatch_request {
 | 
			
		||||
  my $req = shift;
 | 
			
		||||
  my $callback = shift;
 | 
			
		||||
  $dispatch_cb = shift;
 | 
			
		||||
 | 
			
		||||
  my $modname = shift;
 | 
			
		||||
  my $reqs = [];
 | 
			
		||||
  no strict  "refs";
 | 
			
		||||
@@ -591,15 +597,15 @@ sub dispatch_request {
 | 
			
		||||
        $ENV{XCATHOST} =  ( $_->{'_xcatdest'} =~ /:/ ? $_->{'_xcatdest'} : $_->{'_xcatdest'}.":3001" );
 | 
			
		||||
        eval {
 | 
			
		||||
        undef $_->{'_xcatdest'};
 | 
			
		||||
        xCAT::Client::submit_request($_,$callback,$xcatdir."/cert/server-key.pem",$xcatdir."/cert/server-cert.pem",$xcatdir."/cert/ca.pem"); 
 | 
			
		||||
        xCAT::Client::submit_request($_,\&dispatch_callback,$xcatdir."/cert/server-key.pem",$xcatdir."/cert/server-cert.pem",$xcatdir."/cert/ca.pem"); 
 | 
			
		||||
        };
 | 
			
		||||
        if ($@) {
 | 
			
		||||
	   $callback->({error=>["Error dispatching command to ".$ENV{XCATHOST}.""],errorcode=>[1]}); 
 | 
			
		||||
	   $dispatch_cb->({error=>["Error dispatching command to ".$ENV{XCATHOST}.""],errorcode=>[1]}); 
 | 
			
		||||
	   syslog("local4|err","Error dispatching request: ".$@);
 | 
			
		||||
	}
 | 
			
		||||
        $ENV{XCATHOST} = $oldenv;
 | 
			
		||||
     } else {
 | 
			
		||||
        ${"xCAT_plugin::".$modname."::"}{process_request}->($_,$callback,\&do_request);
 | 
			
		||||
        ${"xCAT_plugin::".$modname."::"}{process_request}->($_,$dispatch_cb,\&do_request);
 | 
			
		||||
     }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user