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 = ngcp.get_hostname();
hostname = out;
is_proxy = ngcp.has_role(hostname, 'proxy');
argv.host = hostname; is_lb = ngcp.has_role(hostname, 'lb');
argv.role = 'proxy'; is_mgmt = ngcp.has_role(hostname, 'mgmt');
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role'; is_db = ngcp.has_role(hostname, 'db');
is_proxy = out; is_rtp = ngcp.has_role(hostname, 'rtp');
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;
-%] -%]
[% PERL -%] [% PERL -%]
my $node_state = qx(ngcp-check-active -v); my $node_state = qx(ngcp-check-active -v);

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

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

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

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

@ -1,6 +1,5 @@
[% [%
PROCESS '/usr/lib/ngcp-ngcpcfg/get_hostname'; hostname = ngcp.get_hostname();
hostname = out;
argv.host = hostname; argv.host = hostname;
argv.type = 'web_ext'; argv.type = 'web_ext';
@ -34,14 +33,9 @@
PROCESS '/usr/lib/ngcp-ngcpcfg/get_all_ips_for_host'; PROCESS '/usr/lib/ngcp-ngcpcfg/get_all_ips_for_host';
api_int_ips = out.merge(api_int_ips); api_int_ips = out.merge(api_int_ips);
argv.role = 'mgmt'; is_mgmt = ngcp.has_role(hostname, 'mgmt');
PROCESS '/usr/lib/ngcp-ngcpcfg/has_role'; is_li = ngcp.has_role(hostname, 'li');
is_mgmt = out; is_li_dist = is_li && cluster_sets.type == 'distributed' && intercept.enable == 'yes';
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';
-%] -%]
[% PERL -%] [% PERL -%]
my $node_state = qx(ngcp-check-active -v); my $node_state = qx(ngcp-check-active -v);
@ -171,7 +165,7 @@ command:
timeout: 30000 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/": "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 exit-status: 0
stdout: stdout:

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

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

Loading…
Cancel
Save