more on node status updates
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2372 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		@@ -5562,7 +5562,6 @@ sub process_request {
 | 
			
		||||
 | 
			
		||||
  #get new node status
 | 
			
		||||
  my %nodestat=();
 | 
			
		||||
  my $errornodes={};
 | 
			
		||||
  my $check=0;
 | 
			
		||||
  my $newstat;
 | 
			
		||||
  if ($command eq 'rpower') {
 | 
			
		||||
@@ -5596,7 +5595,14 @@ sub process_request {
 | 
			
		||||
    $SIG{CHLD} = sub {my $kpid; do { $kpid = waitpid(-1, WNOHANG); if ($kpid > 0) { delete $bmc_comm_pids{$kpid}; $children--; } } while $kpid > 0; };
 | 
			
		||||
    my $sub_fds = new IO::Select;
 | 
			
		||||
    foreach (@donargs) {
 | 
			
		||||
      while ($children > $ipmimaxp) { forward_data($callback,$sub_fds, $errornodes); }
 | 
			
		||||
      while ($children > $ipmimaxp) { 
 | 
			
		||||
        my $errornodes={};
 | 
			
		||||
        forward_data($callback,$sub_fds,$errornodes);
 | 
			
		||||
        #update the node status to the nodelist.status table
 | 
			
		||||
        if ($check) {
 | 
			
		||||
          updateNodeStatus(\%nodestat, $errornodes);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
      $children++;
 | 
			
		||||
      my $cfd;
 | 
			
		||||
      my $pfd;
 | 
			
		||||
@@ -5616,34 +5622,46 @@ sub process_request {
 | 
			
		||||
      $sub_fds->add($cfd)
 | 
			
		||||
	}
 | 
			
		||||
    while ($sub_fds->count > 0 and $children > 0) {
 | 
			
		||||
      my $errornodes={};
 | 
			
		||||
      forward_data($callback,$sub_fds,$errornodes);
 | 
			
		||||
    }
 | 
			
		||||
    while (forward_data($callback,$sub_fds, $errornodes)) {} #Make sure they get drained, this probably is overkill but shouldn't hurt
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  #update the node status to the nodelist.status table
 | 
			
		||||
  if ($check) {
 | 
			
		||||
    my %node_status=();
 | 
			
		||||
    foreach (keys(%$errornodes)) { $nodestat{$_}="no-op"; } 
 | 
			
		||||
 | 
			
		||||
    #foreach (keys %nodestat) { print "node=$_,status=" . $nodestat{$_} ."\n"; } #Ling:remove
 | 
			
		||||
 | 
			
		||||
    foreach my $node (keys %nodestat) {
 | 
			
		||||
      my $stat=$nodestat{$node};
 | 
			
		||||
      if ($stat eq "no-op") { next; }
 | 
			
		||||
      if (exists($node_status{$stat})) {
 | 
			
		||||
        my $pa=$node_status{$stat};
 | 
			
		||||
        push(@$pa, $node);
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        $node_status{$stat}=[$node];
 | 
			
		||||
      #update the node status to the nodelist.status table
 | 
			
		||||
      if ($check) {
 | 
			
		||||
        updateNodeStatus(\%nodestat, $errornodes);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
    #Make sure they get drained, this probably is overkill but shouldn't hurt
 | 
			
		||||
    my $rc=1;
 | 
			
		||||
    while ( $rc>0 ) {
 | 
			
		||||
      my $errornodes={};
 | 
			
		||||
      $rc=forward_data($callback,$sub_fds,$errornodes);
 | 
			
		||||
      #update the node status to the nodelist.status table
 | 
			
		||||
      if ($check) {
 | 
			
		||||
        updateNodeStatus(\%nodestat, $errornodes);
 | 
			
		||||
      }
 | 
			
		||||
    }   
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub updateNodeStatus {
 | 
			
		||||
  my $nodestat=shift;
 | 
			
		||||
  my $errornodes=shift;
 | 
			
		||||
  my %node_status=();
 | 
			
		||||
  foreach my $node (keys(%$errornodes)) {
 | 
			
		||||
    if ($errornodes->{$node} == -1) { next;} #has error, not updating status
 | 
			
		||||
    my $stat=$nodestat->{$node};
 | 
			
		||||
    if (exists($node_status{$stat})) {
 | 
			
		||||
      my $pa=$node_status{$stat};
 | 
			
		||||
      push(@$pa, $node);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
      $node_status{$stat}=[$node];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
sub forward_data { #unserialize data from pipe, chunk at a time, use magic to determine end of data structure
 | 
			
		||||
  my $callback = shift;
 | 
			
		||||
  my $fds = shift;
 | 
			
		||||
@@ -5675,6 +5693,8 @@ sub forward_data { #unserialize data from pipe, chunk at a time, use magic to de
 | 
			
		||||
        }  
 | 
			
		||||
	#print "data:". $_->{node}->[0]->{data}->[0]->{contents}->[0] . "\n";
 | 
			
		||||
        if ($no_op) {
 | 
			
		||||
          if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=-1; } 
 | 
			
		||||
        } else {
 | 
			
		||||
          if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=1; } 
 | 
			
		||||
        }
 | 
			
		||||
        $callback->($_);
 | 
			
		||||
 
 | 
			
		||||
@@ -542,7 +542,6 @@ sub process_request {
 | 
			
		||||
 | 
			
		||||
  #get new node status
 | 
			
		||||
  my %nodestat=();
 | 
			
		||||
  my $errornodes={};
 | 
			
		||||
  my $check=0;
 | 
			
		||||
  my $newstat;
 | 
			
		||||
  if ($command eq 'rpower') {
 | 
			
		||||
@@ -574,7 +573,14 @@ sub process_request {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  foreach $hyp (sort (keys %hyphash)) {
 | 
			
		||||
    while ($children > $vmmaxp) { forward_data($callback,$sub_fds,$errornodes); }
 | 
			
		||||
    while ($children > $vmmaxp) { 
 | 
			
		||||
      my $errornodes={};
 | 
			
		||||
      forward_data($callback,$sub_fds,$errornodes);
 | 
			
		||||
      #update the node status to the nodelist.status table
 | 
			
		||||
      if ($check) {
 | 
			
		||||
        updateNodeStatus(\%nodestat, $errornodes);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    $children++;
 | 
			
		||||
    my $cfd;
 | 
			
		||||
    my $pfd;
 | 
			
		||||
@@ -593,33 +599,46 @@ sub process_request {
 | 
			
		||||
    $sub_fds->add($cfd);
 | 
			
		||||
  }
 | 
			
		||||
  while ($sub_fds->count > 0 or $children > 0) {
 | 
			
		||||
    my $errornodes={};
 | 
			
		||||
    forward_data($callback,$sub_fds,$errornodes);
 | 
			
		||||
  }
 | 
			
		||||
  while (forward_data($callback,$sub_fds,$errornodes)) {}
 | 
			
		||||
 | 
			
		||||
  #update the node status to the nodelist.status table
 | 
			
		||||
  if ($check) {
 | 
			
		||||
    my %node_status=();
 | 
			
		||||
    foreach (keys(%$errornodes)) { $nodestat{$_}="no-op"; } 
 | 
			
		||||
 | 
			
		||||
    #foreach (keys %nodestat) { print "node=$_,status=" . $nodestat{$_} ."\n"; } #Ling:remove
 | 
			
		||||
 | 
			
		||||
    foreach my $node (keys %nodestat) {
 | 
			
		||||
      my $stat=$nodestat{$node};
 | 
			
		||||
      if ($stat eq "no-op") { next; }
 | 
			
		||||
      if (exists($node_status{$stat})) {
 | 
			
		||||
        my $pa=$node_status{$stat};
 | 
			
		||||
        push(@$pa, $node);
 | 
			
		||||
      }
 | 
			
		||||
      else {
 | 
			
		||||
        $node_status{$stat}=[$node];
 | 
			
		||||
      }
 | 
			
		||||
    #update the node status to the nodelist.status table
 | 
			
		||||
    if ($check) {
 | 
			
		||||
      updateNodeStatus(\%nodestat, $errornodes);
 | 
			
		||||
    }
 | 
			
		||||
    xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  #Make sure they get drained, this probably is overkill but shouldn't hurt
 | 
			
		||||
  my $rc=1;
 | 
			
		||||
  while ( $rc>0 ) {
 | 
			
		||||
    my $errornodes={};
 | 
			
		||||
    $rc=forward_data($callback,$sub_fds,$errornodes);
 | 
			
		||||
    #update the node status to the nodelist.status table
 | 
			
		||||
    if ($check) {
 | 
			
		||||
      updateNodeStatus(\%nodestat, $errornodes);
 | 
			
		||||
    }
 | 
			
		||||
  }   
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
sub updateNodeStatus {
 | 
			
		||||
  my $nodestat=shift;
 | 
			
		||||
  my $errornodes=shift;
 | 
			
		||||
  my %node_status=();
 | 
			
		||||
  foreach my $node (keys(%$errornodes)) {
 | 
			
		||||
    if ($errornodes->{$node} == -1) { next;} #has error, not updating status
 | 
			
		||||
    my $stat=$nodestat->{$node};
 | 
			
		||||
    if (exists($node_status{$stat})) {
 | 
			
		||||
      my $pa=$node_status{$stat};
 | 
			
		||||
      push(@$pa, $node);
 | 
			
		||||
    }
 | 
			
		||||
    else {
 | 
			
		||||
      $node_status{$stat}=[$node];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  xCAT_monitoring::monitorctrl::setNodeStatusAttributes(\%node_status, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
sub forward_data {
 | 
			
		||||
  my $callback = shift;
 | 
			
		||||
  my $fds = shift;
 | 
			
		||||
@@ -650,8 +669,10 @@ sub forward_data {
 | 
			
		||||
        }  
 | 
			
		||||
	#print "data:". $_->{node}->[0]->{data}->[0]->{contents}->[0] . "\n";
 | 
			
		||||
        if ($no_op) {
 | 
			
		||||
          if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=-1; } 
 | 
			
		||||
      } else {
 | 
			
		||||
          if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=1; } 
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
        $callback->($_);
 | 
			
		||||
      }
 | 
			
		||||
    } else {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user