From dd8ba073e38f0fcabf4032cd125ab0cb22d9feae Mon Sep 17 00:00:00 2001 From: wanghuaz Date: Tue, 6 Sep 2011 14:14:14 +0000 Subject: [PATCH] Fixed the issue that makehosts failed with host.ip empty but otherinterfaces are valid git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10447 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/hosts.pm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index a2eb58692..398eaa70a 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -117,9 +117,11 @@ sub addotherinterfaces { my @itf_pairs=split(/,/, $otherinterfaces); foreach (@itf_pairs) { my ($itf,$ip)=split(/:/, $_); - if ($itf =~ /^-/ ) { - $itf = $node.$itf }; - addnode $itf,$ip,'',$domain; + if ( $ip && xCAT::Utils->isIpaddr($ip) ) { + if ($itf =~ /^-/ ) { + $itf = $node.$itf }; + addnode $itf,$ip,'',$domain; + } } } @@ -227,10 +229,10 @@ sub process_request { } else { if ( xCAT::Utils->isIpaddr($ref->{ip}) ) { addnode $ref->{node},$ref->{ip},$ref->{hostnames},$domain; - if (defined($ref->{otherinterfaces})){ - addotherinterfaces $ref->{node},$ref->{otherinterfaces},$domain; - } - } + } + if (defined($ref->{otherinterfaces})){ + addotherinterfaces $ref->{node},$ref->{otherinterfaces},$domain; + } } } #end foreach } # end else @@ -242,9 +244,9 @@ sub process_request { foreach (@hostents) { if ( xCAT::Utils->isIpaddr($_->{ip}) ) { addnode $_->{node},$_->{ip},$_->{hostnames},$domain; - if (defined($_->{otherinterfaces})){ - addotherinterfaces $_->{node},$_->{otherinterfaces},$domain; - } + } + if (defined($_->{otherinterfaces})){ + addotherinterfaces $_->{node},$_->{otherinterfaces},$domain; } } }