From 60d9b5fd9ea706e1212a977dc5c766aee47100a4 Mon Sep 17 00:00:00 2001 From: Yuan Bai Date: Wed, 19 Oct 2016 17:17:40 +0800 Subject: [PATCH] fix always get one adapter in array. (#1991) --- xCAT-server/lib/xcat/plugins/localrest.pm | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/localrest.pm b/xCAT-server/lib/xcat/plugins/localrest.pm index 24e5a6b4f..1d58e95a7 100644 --- a/xCAT-server/lib/xcat/plugins/localrest.pm +++ b/xCAT-server/lib/xcat/plugins/localrest.pm @@ -143,7 +143,7 @@ sub handle_rest_request { #------------------------------------------------------- sub list_adapters { - my ($rsp, $cmd, $tmpres, $vline); + my ($rsp, $cmd, $vline); my ($mac, $ip, $adapter, $preadapter, $samenic); my (@cmdres, @origin, @eachline, @line, @result); $cmd = "ip -o addr"; @@ -174,29 +174,31 @@ sub list_adapters { } } # get net ip and mac + my $i=0; foreach my $key (keys %{$samenic}){ $vline=${$samenic}{$key}; @line = split(' ',$vline); - $tmpres->{'name'} = $key; + my %tmpres = (); + $tmpres{'name'} = $key; for (my $i=0; $i<@line; $i++) { if ( $line[$i] =~ /^inet$/ ) { $ip = $line[$i+1]; - $tmpres->{'ip'} = $ip; + $tmpres{'ip'} = $ip; } if ( $line[$i] =~ 'ether' ) { $mac = $line[$i+1]; - $tmpres->{'mac'} = $mac; + $tmpres{'mac'} = $mac; } } - push (@result, $tmpres); + push (@result, \%tmpres); + } return \@result; } - #------------------------------------------------------- =head3 handler to download credential files