2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

Merge pull request #3050 from chenglch/nicgroup

Fix regular expression issue while listing group object
This commit is contained in:
zet809 2017-05-15 14:55:42 +08:00 committed by GitHub
commit fd8587f8a4
2 changed files with 11 additions and 7 deletions

View File

@ -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";

View File

@ -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");