From d83a06c0c37dfefec4c22f26d62fcb5608d16ae7 Mon Sep 17 00:00:00 2001 From: nott Date: Fri, 29 Mar 2013 13:19:19 +0000 Subject: [PATCH] add default for nichostnamesuffixes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15728 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/hosts.pm | 30 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 2f5223ef7..5af80b787 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -459,13 +459,8 @@ sub donics ] ); - if ( - !( - $et->{nicips} - && $et->{'nichostnamesuffixes'} - ) - ) - { + # only require IP for nic + if ( !($et->{nicips}) ) { next; } @@ -474,6 +469,7 @@ sub donics # new $et->{nicips} looks like # "eth0!11.10.1.1,eth1!60.0.0.5|60.0.0.250..." my @nicandiplist = split(',', $et->{'nicips'}); + foreach (@nicandiplist) { my ($nicname, $nicip); @@ -504,6 +500,7 @@ sub donics } my @nicandsufx = split(',', $et->{'nichostnamesuffixes'}); + foreach (@nicandsufx) { my ($nicname, $nicsufx); @@ -513,10 +510,6 @@ sub donics ($nicname, $nicsufx) = split(':', $_); } - if (!$nicsufx) { - next; - } - if ( $nicsufx =~ /\|/) { my @sufs = split( /\|/, $nicsufx); my $index=0; @@ -529,6 +522,18 @@ sub donics } } + # see if we need to fill in a default suffix + # nich has all the valid nics - ie. that have IPs provided! + foreach my $nic (keys %{$nich}) { + for (my $i = 0; $i < $nicindex{$nic}; $i++ ){ + if (!$nich->{$nic}->{nicsufx}->[$i]) { + # then we have no suffix at all for this + # so set a default + $nich->{$nic}->{nicsufx}->[$i] = "-$nic"; + } + } + } + my @nicandnetwrk = split(',', $et->{'nicnetworks'}); foreach (@nicandnetwrk) { @@ -538,6 +543,7 @@ sub donics } else { ($nicname, $netwrk) = split(':', $_); } + if (!$netwrk) { next; } @@ -553,7 +559,7 @@ sub donics $nich->{$nicname}->{netwrk}->[0] = $netwrk; } } - + my @nicandnicalias = split(',', $et->{'nicaliases'}); foreach (@nicandnicalias) {