From e5892fb437671e27b8eac75db04f1f6f5524f916 Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Fri, 5 Jun 2009 10:07:38 +0000 Subject: [PATCH] Fix output issue in getmacs git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3522 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/PPCmac.pm | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/PPCmac.pm b/perl-xCAT/xCAT/PPCmac.pm index f498d0799..638353a5c 100644 --- a/perl-xCAT/xCAT/PPCmac.pm +++ b/perl-xCAT/xCAT/PPCmac.pm @@ -350,7 +350,12 @@ sub getmacs { # A hash to save lpar attributes ######################################### my %nodeatt = (); + + ######################################### + # Cleanup old data + ######################################### my $result = (); + my $data = (); ######################################### # No ping test performed, call lshwres @@ -420,15 +425,14 @@ sub getmacs { my $mtms = @$d[2]; my $id = @$d[0]; my $mac_count = $nodeatt{$mtms}{$id}{'num'}; + my $value = (); my $type; - push @$result,"\n$node:\n"; - ######################################### # Put all the attributes required # together ######################################### - push @$result,"#Type MAC_Address Phys_Port_Loc Adapter Port_Group Phys_Port Logical_Port VLan VSwitch Curr_Conn_Speed\n"; + push @$value,"\n#Type MAC_Address Phys_Port_Loc Adapter Port_Group Phys_Port Logical_Port VLan VSwitch Curr_Conn_Speed\n"; for ( my $num = 1; $num <= $mac_count; $num++ ) { my $mac_addr = $nodeatt{$mtms}{$id}{$num}{'mac_addr'}; @@ -442,9 +446,9 @@ sub getmacs { my $curr_conn_speed = $nodeatt{$mtms}{$port_group}{$logical_port_id}{'curr_conn_speed'}; if ( $phys_port_loc ) { - $type = "virtualio"; + $type = "hea"; } else { - $type = "hea"; + $type = "virtualio"; } my %att = (); @@ -472,20 +476,24 @@ sub getmacs { } } if ( $matched == 1 ) { - push @$result,"$att{'Type'} $att{'MAC_Address'} $att{'Phys_Port_Loc'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; + push @$value,"$att{'Type'} $att{'MAC_Address'} $att{'Phys_Port_Loc'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; } } else { - push @$result,"$att{'Type'} $att{'MAC_Address'} $att{'Phys_Port_Loc'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; + push @$value,"$att{'Type'} $att{'MAC_Address'} $att{'Phys_Port_Loc'} $att{'Adapter'} $att{'Port_Group'} $att{'Phys_Port'} $att{'Logical_Port'} $att{'VLan'} $att{'VSwitch'} $att{'Curr_Conn_Speed'}\n"; } } ######################################### # Write MAC address to database ######################################### - writemac( $node, $result ); + writemac( $node, $value ); + + $data = join /''/,@$value; + + push @$result,[$node,$data,0]; } - return([[join /''/,@$result]]); + return([@$result]); } } else { #########################################