From fd83987b667450ca4bf31c9d41a247cced5a8db0 Mon Sep 17 00:00:00 2001 From: yinle Date: Tue, 21 Aug 2012 02:59:32 +0000 Subject: [PATCH] Fix bug 3543531:getAllNodeAttribs take too much time git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.7@13566 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/setup.pm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/setup.pm b/xCAT-server/lib/xcat/plugins/setup.pm index b39369234..28914918b 100644 --- a/xCAT-server/lib/xcat/plugins/setup.pm +++ b/xCAT-server/lib/xcat/plugins/setup.pm @@ -1037,19 +1037,27 @@ sub writelpar { if ($otherint) { # need to replace each ip addr in otherinterfaces with a regex my @ifs = split(/[\s,]+/, $otherint); + my $i = 0; foreach my $if (@ifs) { + $i++; my ($nic, $nicip) = split(/:/, $if); if (!isIP($nicip)) { next; } my ($nicbase, $nic2nd, $nic3rd, $nic4th) = $nicip =~/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; - $if = "$nic:$nicbase.($nic2nd+" . '$1' . "-$primstartnum).($nic3rd+" . '$2' . "-$secstartnum).($nic4th+" . '$3' . "-$thirdstartnum)"; + if ($i == 1) { + $if = "$nic:$nicbase.(($nic2nd+" . '$1' . "-$primstartnum).\'.\'.($nic3rd+" . '$2' . "-$secstartnum).\'.\'.($nic4th+" . '$3' . "-$thirdstartnum).\'"; + } elsif ($i == scalar(@ifs)) { + $if = "$nic:$nicbase.\'.($nic2nd+" . '$1' . "-$primstartnum).\'.\'.($nic3rd+" . '$2' . "-$secstartnum).\'.\'.($nic4th+" . '$3' . "-$thirdstartnum))"; + } else { + $if = "$nic:$nicbase.\'.($nic2nd+" . '$1' . "-$primstartnum).\'.\'.($nic3rd+" . '$2' . "-$secstartnum).\'.\'.($nic4th+" . '$3' . "-$thirdstartnum).\'"; + } } - $regex = '|\D+(\d+)\D+(\d+)\D+(\d+)\D*$|' . join(',', @ifs) . '|'; + $regex = '|\D+(\d+)\D+(\d+)\D+(\d+)\D*$|' . join(',', @ifs) . '|'; #print "regex=$regex\n"; $hash{otherinterfaces} = $regex; if ($serviceip && isIP($serviceip)) { # same as regular lpar value, except prepend the lpar ip as -hf0 my $hf0 = "-hf0:$ipbase.($ip2nd+" . '$1' . "-$primstartnum).($ip3rd+" . '$2' . "-$secstartnum).($ip4th+" . '$3' . "-$thirdstartnum)"; - my $serviceregex = '|\D+(\d+)\D+(\d+)\D+(\d+)\D*$|' . "$hf0," . join(',', @ifs) . '|'; + my $serviceregex = '|\D+(\d+)\D+(\d+)\D+(\d+)\D*$|' . "$hf0," . join(',', @ifs) . '|'; $servicehash{otherinterfaces} = $serviceregex; } }