diff --git a/xCAT-server/lib/xcat/plugins/tabutils.pm b/xCAT-server/lib/xcat/plugins/tabutils.pm index 2cfa931c8..b77c6c464 100644 --- a/xCAT-server/lib/xcat/plugins/tabutils.pm +++ b/xCAT-server/lib/xcat/plugins/tabutils.pm @@ -1742,11 +1742,14 @@ sub nodech if ($cent) { $curval = $cent->{$key}; } } if ($curval) { - my @vals = split(/,/, $curval); - unless (grep /^$val$/, @vals) { - unshift @vals, $val; - my $newval = join(',', @vals); - $uhsh{$key} = $newval; + foreach my $subval (split /,/, $val) { + my @vals = split(/,/, $curval); + unless (grep /^$subval$/, @vals) { + unshift @vals, $subval; + my $newval = join(',', @vals); + $uhsh{$key} = $newval; + $curval = $newval; + } } } else { $uhsh{$key} = $val; @@ -1762,11 +1765,14 @@ sub nodech if ($cent) { $curval = $cent->{$key}; } } if ($curval) { - my @vals = split(/,/, $curval); - if (grep /^$val$/, @vals) { #only bother if there - @vals = grep(!/^$val$/, @vals); - my $newval = join(',', @vals); - $uhsh{$key} = $newval; + foreach my $subval (split /,/, $val) { + my @vals = split(/,/, $curval); + if (grep /^$subval$/, @vals) { #only bother if there + @vals = grep(!/^$subval$/, @vals); + my $newval = join(',', @vals); + $uhsh{$key} = $newval; + $curval = $newval; + } } } #else, what they asked for is the case alredy } diff --git a/xCAT-test/autotest/testcase/nodech/cases0 b/xCAT-test/autotest/testcase/nodech/cases0 index 10db2ffa9..1583ded28 100644 --- a/xCAT-test/autotest/testcase/nodech/cases0 +++ b/xCAT-test/autotest/testcase/nodech/cases0 @@ -14,26 +14,27 @@ end start:nodech_noderange_table_comma -description:nodech testnode groups,=rhels5.5.Check nodech command with ,=. +description:Append multiple comma-delimited groups without duplicating an existing group. label:mn_only,ci_test,db -cmd:chdef -t node -o testnode groups=all +cmd:chdef -t node -o testnode groups=all,rhels5.5 check:rc==0 -cmd:nodech testnode groups,=rhels5.5 +cmd:nodech testnode groups,=rhels5.5,rhels5.6 check:rc==0 cmd:lsdef -t node -i groups testnode -check:output=~groups=rhels5.5,all +check:output=~groups=rhels5.6,all,rhels5.5 cmd:rmdef -t node testnode end start:nodech_noderange_table_arrow +description:Remove multiple comma-delimited groups while ignoring a group that is absent. label:mn_only,ci_test,db -cmd:chdef -t node -o testnode groups=all,rhels5.5 +cmd:chdef -t node -o testnode groups=all,rhels5.5,rhels5.6 check:rc==0 -cmd:nodech testnode groups^=rhels5.5 +cmd:nodech testnode groups^=rhels5.4,rhels5.5 check:rc==0 cmd:lsdef -t node -i groups testnode -check:output!=rhels5.5 +check:output=~groups=all,rhels5.6 cmd:rmdef -t node testnode end