From b5448dc6f87098f3f1071bd66960064254763c7e Mon Sep 17 00:00:00 2001 From: chenglch Date: Mon, 15 May 2017 09:57:12 +0800 Subject: [PATCH] Fix regular expression issue while listing group object Group object should not be translate with the object name even if the attribute contains regular expression. Fix-issue: #3047 --- perl-xCAT/xCAT/DBobjUtils.pm | 10 ++++++---- xCAT-server/lib/xcat/plugins/DBobjectdefs.pm | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 0bc7e2286..fe4864e54 100755 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -2503,6 +2503,7 @@ sub judge_node nicsattr value, like niccsips=eth0!1.1.1.1|2.1.1.1,eth1!3.1.1.1|4.1.1.1 node name, like frame10node10 nicnames: only return the value for specific nics, like "eth0,eth1" + is_group: bool value indicates whether the type of object is group Returns: expanded format, like: nicsips.eth0=1.1.1.1|2.1.1.1 @@ -2524,8 +2525,7 @@ sub expandnicsattr() if (($nicstr) && ($nicstr =~ /xCAT::/)) { $nicstr = shift; } - my $node = shift; - my $nicnames = shift; + my ($node, $nicnames, $is_group) = @_; my $ret; $nicstr =~ /^(.*?)=(.*?)$/; @@ -2574,8 +2574,10 @@ sub expandnicsattr() } } } - - $nicv[1]= xCAT::Table::transRegexAttrs($node, $nicv[1]); + # print group attributes in original format + if (!$is_group) { + $nicv[1]= xCAT::Table::transRegexAttrs($node, $nicv[1]); + } # ignore the line that does not have nicname or value if ($nicv[0] && $nicv[1]) { $ret .= " $nicattr.$nicv[0]=$nicv[1]\n"; diff --git a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm index 973f1d4c0..8faed0d4f 100755 --- a/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm +++ b/xCAT-server/lib/xcat/plugins/DBobjectdefs.pm @@ -3862,13 +3862,14 @@ sub defls $nicnames = join(',', @{ $::NicsAttrHash{$showattr} }); } my $nicsstr; + my $is_group = $defhash{$obj}{'objtype'} eq 'group'; if ($nicnames) { - $nicsstr = xCAT::DBobjUtils->expandnicsattr($nicval, $obj, $nicnames); + $nicsstr = xCAT::DBobjUtils->expandnicsattr($nicval, $obj, $nicnames, $is_group); } else { - $nicsstr = xCAT::DBobjUtils->expandnicsattr($nicval, $obj); + $nicsstr = xCAT::DBobjUtils->expandnicsattr($nicval, $obj, undef, $is_group); } # Compress mode, format the output @@ -3921,7 +3922,8 @@ sub defls if ($showattr =~ /^nic/) { my $nicval = "$showattr=$attrval"; - my $nicsstr = xCAT::DBobjUtils->expandnicsattr($nicval, $obj); + my $is_group = $defhash{$obj}{'objtype'} eq 'group'; + my $nicsstr = xCAT::DBobjUtils->expandnicsattr($nicval, $obj, undef, $is_group); if ($nicsstr) { push(@{ $rsp_info->{data} }, "$nicsstr");