TT#43306 NGCP::Template::Object: Only match li_dist exactly

This partially reverts commit bc8ae9e795.

We should not match li_dist with regexes as then we would trap cases
that we should not be covering by the li_dist mapping logic. Just do
exact matches.

This also fixes the hypothetical case with other regexes that are not
the wrongly specified '*'.

Change-Id: I9d9d850969e03fa9dc587f2d47a688bc0359e63c
changes/64/23264/1
Guillem Jover 8 years ago
parent 8e43bf3ade
commit 236b56d990

@ -21,19 +21,14 @@ sub has_role
{
my ($self, $hostname, $role) = @_;
my $li_check = 1;
if ($role eq '*') {
$role = '.+';
$li_check = 0;
}
if (not defined $self->{config}{hosts}{$hostname}) {
$hostname = 'self';
}
# The LI role has a virtual role counterpart, which is active only in
# distributed mode.
if ($li_check && 'li_dist' =~ m/^$role$/) {
# distributed mode. We only check for exact matches, as we do not want
# to grab a regex that would match multiple cases.
if ('li_dist' eq $role) {
if ($self->{config}{cluster_sets}{type} eq 'distributed') {
$role = 'li';
} else {
@ -44,7 +39,7 @@ sub has_role
if (any { m/^$role$/ } @{$self->{config}{hosts}{$hostname}{role}}) {
# The LI roles are a bit special, they use additional keys to get
# enabled, so we handle them here.
if ($li_check && 'li' =~ m/^$role$/) {
if ('li' =~ m/^$role$/) {
return $self->{config}{intercept}{enable} eq 'yes';
} else {
# Otherwise, unconditionally enable the role.

Loading…
Cancel
Save