2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-21 19:22:05 +00:00

fix always get one adapter in array. (#1991)

This commit is contained in:
Yuan Bai 2016-10-19 17:17:40 +08:00 committed by yangsong
parent 684babe436
commit 60d9b5fd9e

View File

@ -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