TT#38200 Switch to use new ngcp object with methods

This simplifies the pseudo-function calls into proper ones.

Reaname the confusing is_li_enabled into the more descriptive name
is_li_dist.

Change-Id: I42b079945c100aafa37eab9f44307fac940f42a8
changes/86/22186/3
Guillem Jover 7 years ago
parent b995e51194
commit e656d74486

@ -1,31 +1,11 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
argv.host = hostname;
argv.role = 'proxy';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_proxy = out;
argv.host = hostname;
argv.role = 'lb';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_lb = out;
argv.host = hostname;
argv.role = 'mgmt';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_mgmt = out;
argv.host = hostname;
argv.role = 'db';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_db = out;
argv.host = hostname;
argv.role = 'rtp';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_rtp = out;
hostname = ngcp.get_hostname();
is_proxy = ngcp.has_role(hostname, 'proxy');
is_lb = ngcp.has_role(hostname, 'lb');
is_mgmt = ngcp.has_role(hostname, 'mgmt');
is_db = ngcp.has_role(hostname, 'db');
is_rtp = ngcp.has_role(hostname, 'rtp');
-%]
[% PERL -%]
my $node_state = qx(ngcp-check-active -v);

@ -1,21 +1,9 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
argv.host = hostname;
argv.role = 'proxy';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_proxy = out;
argv.host = hostname;
argv.role = 'lb';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_lb = out;
argv.host = hostname;
argv.role = 'rtp';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_rtp = out;
hostname = ngcp.get_hostname();
is_proxy = ngcp.has_role(hostname, 'proxy');
is_lb = ngcp.has_role(hostname, 'lb');
is_rtp = ngcp.has_role(hostname, 'rtp');
-%]
[% PERL -%]
my $node_state = qx(ngcp-check-active -v);

@ -1,36 +1,13 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
argv.host = hostname;
argv.role = 'proxy';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_proxy = out;
argv.host = hostname;
argv.role = 'lb';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_lb = out;
argv.host = hostname;
argv.role = 'mgmt';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_mgmt = out;
argv.host = hostname;
argv.role = 'db';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_db = out;
argv.host = hostname;
argv.role = 'rtp';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_rtp = out;
argv.role = 'li';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_li = out;
is_li_enabled = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
hostname = ngcp.get_hostname();
is_proxy = ngcp.has_role(hostname, 'proxy');
is_lb = ngcp.has_role(hostname, 'lb');
is_mgmt = ngcp.has_role(hostname, 'mgmt');
is_db = ngcp.has_role(hostname, 'db');
is_rtp = ngcp.has_role(hostname, 'rtp');
is_li = ngcp.has_role(hostname, 'li');
is_li_dist = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
-%]
[% PERL -%]
my $node_state = qx(ngcp-check-active -v);
@ -102,7 +79,7 @@ service:
nginx.service:
enabled: [% nginx.enable == 'yes' ? 'true' : 'false' %]
running: [% (is_mgmt || is_li_enabled) && nginx.enable == 'yes' ? 'true' : 'false' %]
running: [% (is_mgmt || is_li_dist) && nginx.enable == 'yes' ? 'true' : 'false' %]
prosody.service:
enabled: [% general.process_handler == 'none' && prosody.enable == 'yes' ? 'true' : 'false' %]

@ -1,11 +1,7 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
hostname = ngcp.get_hostname();
argv.host = hostname;
argv.role = 'proxy';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_proxy = out;
is_proxy = ngcp.has_role(hostname, 'proxy');
-%]
[% PERL -%]
my $node_state = qx(ngcp-check-active -v);
@ -27,4 +23,4 @@ command:
stdout:
- '/^2$/'
stderr: []
[% END -%]
[% END -%]

@ -1,31 +1,11 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
hostname = ngcp.get_hostname();
argv.host = hostname;
argv.role = 'proxy';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_proxy = out;
argv.host = hostname;
argv.role = 'lb';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_lb = out;
argv.host = hostname;
argv.role = 'mgmt';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_mgmt = out;
argv.host = hostname;
argv.role = 'db';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_db = out;
argv.host = hostname;
argv.role = 'rtp';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_rtp = out;
is_proxy = ngcp.has_role(hostname, 'proxy');
is_lb = ngcp.has_role(hostname, 'lb');
is_mgmt = ngcp.has_role(hostname, 'mgmt');
is_db = ngcp.has_role(hostname, 'db');
is_rtp = ngcp.has_role(hostname, 'rtp');
argv.host = hostname;
argv.type = 'sip_ext';

@ -1,6 +1,5 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
hostname = ngcp.get_hostname();
argv.host = hostname;
argv.type = 'web_ext';
@ -34,14 +33,9 @@
PROCESS '/usr/lib/ngcp-ngcpcfg/get_all_ips_for_host';
api_int_ips = out.merge(api_int_ips);
argv.role = 'mgmt';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_mgmt = out;
argv.role = 'li';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_li = out;
is_li_enabled = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
is_mgmt = ngcp.has_role(hostname, 'mgmt');
is_li = ngcp.has_role(hostname, 'li');
is_li_dist = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
-%]
[% PERL -%]
my $node_state = qx(ngcp-check-active -v);
@ -171,7 +165,7 @@ command:
timeout: 30000
[% IF www_admin.enable == 'yes' && (is_mgmt || is_li_enabled) && node_state == 'active' -%]
[% IF www_admin.enable == 'yes' && (is_mgmt || is_li_dist) && node_state == 'active' -%]
"curl -H 'NGCP-UserAgent: NGCP::API::Client' --insecure -L https://[% credentials.rest_api.auth_system.u %]:[% credentials.rest_api.auth_system.p %]@[% api_int_ips.0 -%]:[% www_admin.http_system.port %]/api/":
exit-status: 0
stdout:

@ -1,16 +1,8 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
hostname = ngcp.get_hostname();
argv.host = hostname;
argv.role = 'mgmt';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_mgmt = out;
argv.role = 'li';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_li = out;
is_li_enabled = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
is_mgmt = ngcp.has_role(hostname, 'mgmt');
is_li_dist = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
-%]
file:
@ -23,7 +15,7 @@ file:
command:
[% IF grafana.enable == 'yes' && (is_mgmt || is_li_enabled) -%]
[% IF grafana.enable == 'yes' && (is_mgmt || is_li_dist) -%]
sqlite3 /var/lib/grafana/grafana.db "select name from data_source":
exit-status: 0
stdout:

@ -1,11 +1,7 @@
[%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname';
hostname = out;
hostname = ngcp.get_hostname();
argv.host = hostname;
argv.role = 'proxy';
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role';
is_proxy = out;
is_proxy = ngcp.has_role(hostname, 'proxy');
-%]
[% PERL -%]
my $node_state = qx(ngcp-check-active -v);
@ -31,4 +27,4 @@ command:
stderr: []
timeout: 10000
[% END -%]
[% END -%]

Loading…
Cancel
Save