diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index 7f087887a..9f4eb03bc 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -868,7 +868,8 @@ sub handle_response { #print "printing node\n"; my $nodes=($rsp->{node}); my $node; - foreach $node (@$nodes) { + my @nodelist = sort {$a cmp $b} @$nodes; + foreach $node (@nodelist) { my $desc=$node->{name}->[0]; if ($node->{errorcode}) { if (ref($node->{errorcode}) eq 'ARRAY') { foreach my $ecode (@{$node->{errorcode}}) { $xCAT::Client::EXITCODE |= $ecode; } } diff --git a/perl-xCAT/xCAT/PPCscan.pm b/perl-xCAT/xCAT/PPCscan.pm index 6b5d5aa80..35e0e0436 100644 --- a/perl-xCAT/xCAT/PPCscan.pm +++ b/perl-xCAT/xCAT/PPCscan.pm @@ -430,15 +430,19 @@ sub format_output { ####################################### # Get longest name for formatting ####################################### + my $nodehash; + my @errmsg; foreach ( @$values ) { - ################################### - # Skip error message - ################################### + ############################################## + # Skip error message after saving it for last + ############################################## if ( /^#.*: ERROR / ) { + push @errmsg, $_; next; } - /[^\,]+,([^\,]+),/; - my $length = length( $1 ); + /([^\,]+),([^\,]+),/; + $nodehash->{$1.$2} = $_; + my $length = length( $2 ); $max_length = ($length > $max_length) ? $length : $max_length; } my $format = sprintf( "%%-%ds", ($max_length + 2 )); @@ -453,18 +457,10 @@ sub format_output { ####################################### # Add node information ####################################### - my @errmsg; - foreach ( @$values ) { - my @data = split /,/; + foreach ( sort keys %$nodehash ) { + my @data = split /,/, $nodehash->{$_}; my $i = 0; - ################################### - # Save error messages for last - ################################### - if ( /^#.*: ERROR / ) { - push @errmsg, $_; - next; - } foreach ( @header ) { my $d = $data[$i++]; @@ -502,23 +498,29 @@ sub format_stanza { my $values = shift; my $result; + my $nodehash; ##################################### # Skip hardware control point ##################################### shift(@$values); - foreach ( sort @$values ) { - my @data = split /,/; + foreach ( @$values ) { + ################################### + # Skip error message + ################################### + if ( /^#.*: ERROR / ) { + next; + } + /[^\,]+,([^\,]+),/; + $nodehash->{$1} = $_; + } + + foreach ( sort keys %$nodehash ) { + my @data = split /,/, $nodehash->{$_}; my $type = $data[0]; my $i = 0; - ################################# - # Skip error message - ################################# - if ( /^#.*: ERROR / ) { - next; - } ################################# # Node attributes ################################# @@ -565,26 +567,31 @@ sub format_xml { my $hwtype = shift; my $values = shift; my $xml; + my $nodehash; ##################################### # Skip hardware control point ##################################### shift(@$values); + foreach ( @$values ) { + ################################### + # Skip error message + ################################### + if ( /^#.*: ERROR / ) { + next; + } + /[^\,]+,([^\,]+),/; + $nodehash->{$1} = $_; + } ##################################### # Create XML formatted attributes ##################################### - foreach ( @$values ) { - my @data = split /,/; + foreach ( sort keys %$nodehash ) { + my @data = split /,/, $nodehash->{$_}; my $type = $data[0]; my $i = 0; - ################################# - # Skip error message - ################################# - if ( /^#.*: ERROR / ) { - next; - } ################################# # Initialize hash reference ################################# diff --git a/xCAT-server/lib/perl/xCAT/PPC.pm b/xCAT-server/lib/perl/xCAT/PPC.pm index 8cd474f48..477e92f6f 100644 --- a/xCAT-server/lib/perl/xCAT/PPC.pm +++ b/xCAT-server/lib/perl/xCAT/PPC.pm @@ -606,15 +606,26 @@ sub child_response { $data .= <$rfh>; } my $responses = thaw($data); - foreach ( @$responses ) { - #save the nodes that has errors for node status monitoring - if ((exists($_->{errorcode})) && ($_->{errorcode} != 0)) { - if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=-1; } - } else { - if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=1; } - } - $callback->( $_ ); - } + my @nodes; + foreach ( @$responses ) { + my $node = $_->{node}->[0]->{name}->[0]; + push (@nodes, $node); + } + + foreach ( sort @nodes ) { + my $nodename = $_; + foreach ( @$responses ) { + if ($nodename eq $_->{node}->[0]->{name}->[0]) { + #save the nodes that has errors for node status monitoring + if ((exists($_->{errorcode})) && ($_->{errorcode} != 0)) { + if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=-1; } + } else { + if ($errornodes) { $errornodes->{$_->{node}->[0]->{name}->[0]}=1; } + } + $callback->( $_ ); + } + } + } next; } ################################# @@ -1434,6 +1445,7 @@ sub preprocess_request { foreach (@$hcps1) { push @nodes, @{$hcp_hash{$_}{nodes}}; } + @nodes = sort @nodes; $reqcopy->{node} = \@nodes; #print "nodes=@nodes\n"; push @requests, $reqcopy; diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 4b269f859..81e35a2bd 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -1353,17 +1353,23 @@ sub nodels { my @attribs = ("node"); my @ents = $nodelisttab->getAllAttribs(@attribs); - foreach (@ents) - { + my @nodes; + foreach (@ents) { + if ($_->{node}) { + push @nodes, $_->{node}; + } + } + @nodes = sort {$a cmp $b} @nodes; + foreach (@nodes) { my $rsp; - if ($_->{node}) - { - $rsp->{node}->[0]->{name}->[0] = ($_->{node}); + #if ($_) + #{ + $rsp->{node}->[0]->{name}->[0] = ($_); # $rsp->{node}->[0]->{data}->[0]->{contents}->[0]="$_->{node} node contents"; # $rsp->{node}->[0]->{data}->[0]->{desc}->[0]="$_->{node} node desc"; $callback->($rsp); - } + #} } } }