TT#43306 Workaround argv.role='*' case in ngcp.has_role()

Otherwise it matches on 'li/li_dist' cases and the library get_all_ips
returns no IPs if called like:
>   argv.role='*';
>   argv.type='*';
>   PROCESS '/usr/lib/ngcp-ngcpcfg/get_all_ips';
>   all_ips = out;

This is a hotfix commit for backporting into mr6.4.1 while the "proper" fix
should be re-considered and committed for mr6.5+

P.S we have 3 tt2 templates where we have * in argv parameters.
P.P.S. The code is from Andreas, tnx for the fix!

Change-Id: I119a687389075d2ebdcd824ed457f768b5fb2123
changes/87/23087/1
Alexander Lutay 8 years ago
parent ffedf0a0a2
commit bc8ae9e795

@ -21,13 +21,19 @@ 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_dist' =~ m/^$role$/) {
if ($li_check && 'li_dist' =~ m/^$role$/) {
if ($self->{config}{cluster_sets}{type} eq 'distributed') {
$role = 'li';
} else {
@ -38,7 +44,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' =~ m/^$role$/) {
if ($li_check && 'li' =~ m/^$role$/) {
return $self->{config}{intercept}{enable} eq 'yes';
} else {
# Otherwise, unconditionally enable the role.

Loading…
Cancel
Save