From 5ea143c734d2aaa3a389b26a3ced075327ed0fbc Mon Sep 17 00:00:00 2001 From: creativezj Date: Mon, 1 Apr 2013 07:17:34 +0000 Subject: [PATCH] fix multiple nic error while all nics in same network git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15752 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index ff650f532..8a7b62d95 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -1494,15 +1494,9 @@ sub gen_new_hostinfo_string{ # compose the stanza string for hostinfo file. my $hostsinfostr = ""; foreach my $item (keys %hostinfo_dict){ - # Generate IPs for all interfaces. + # Generate IPs for other interfaces defined in MAC file. my %ipshash; - foreach (keys %netprofileattr){ - my $netname = $netprofileattr{$_}{'network'}; - my $freeipsref; - if ($netname){ - $freeipsref = $freeipshash{$netname}; - } - + foreach (keys %netprofileattr){ # Not generate IP if exists other nics if (exists $allothernics{$item}->{$_}) { my $avaiableip = $allothernics{$item}->{$_}; @@ -1511,10 +1505,21 @@ sub gen_new_hostinfo_string{ }else{ $ipshash{$_} = $avaiableip; $allips{$avaiableip} = 0; - next; } } - + } + + # Generate IPs for not defined interfaces. + foreach (keys %netprofileattr){ + my $netname = $netprofileattr{$_}{'network'}; + my $freeipsref; + if ($netname){ + $freeipsref = $freeipshash{$netname}; + } + + if (exists $allothernics{$item}->{$_}) { + next; + } # If generated IP is already used, re-generate free ip my $nextip = shift @$freeipsref; while (exists $allips{$nextip}){