From ae25a37bade2ab43df235698c37a17ce128c8cc5 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 13 Jun 2018 01:16:52 +0200 Subject: [PATCH] TT#38200 Add support for virtual LI distributed role This adds an additional virtual li_dist role on top of the existing li role. The difference is that li is the cluster simpli acting in central mode, while li_dist is the cluster acting in distributed mode. Change-Id: I930c93380a0e88649c325b7faf3c0fb86d78e5ff --- lib/NGCP/Template/Object.pm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/NGCP/Template/Object.pm b/lib/NGCP/Template/Object.pm index cd21aa48..74479b81 100644 --- a/lib/NGCP/Template/Object.pm +++ b/lib/NGCP/Template/Object.pm @@ -25,8 +25,25 @@ sub has_role $hostname = 'self'; } + # The LI role has a virtual role counterpart, which is active only in + # distributed mode. + if ('li_dist' =~ m/^$role$/) { + if ($self->{config}{cluster_sets}{type} eq 'distributed') { + $role = 'li'; + } else { + return 0; + } + } + if (any { m/^$role$/ } @{$self->{config}{hosts}{$hostname}{role}}) { - return 1; + # The LI roles are a bit special, they use additional keys to get + # enabled, so we handle them here. + if ('li' =~ m/^$role$/) { + return $self->{config}{intercept}{enable} eq 'yes'; + } else { + # Otherwise, unconditionally enable the role. + return 1; + } } return 0;