diff --git a/templates/410_process-ngcp.yaml.tt2 b/templates/410_process-ngcp.yaml.tt2 index 9eb9b5f..ce17154 100644 --- a/templates/410_process-ngcp.yaml.tt2 +++ b/templates/410_process-ngcp.yaml.tt2 @@ -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); diff --git a/templates/411_process-ngcp-pro.yaml.tt2 b/templates/411_process-ngcp-pro.yaml.tt2 index 6a5e7e9..c4bec43 100644 --- a/templates/411_process-ngcp-pro.yaml.tt2 +++ b/templates/411_process-ngcp-pro.yaml.tt2 @@ -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); diff --git a/templates/510_init-daemons-ngcp.yaml.tt2 b/templates/510_init-daemons-ngcp.yaml.tt2 index 2b46d57..c7dbff6 100644 --- a/templates/510_init-daemons-ngcp.yaml.tt2 +++ b/templates/510_init-daemons-ngcp.yaml.tt2 @@ -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' %] diff --git a/templates/615_kernel-modules.yaml.tt2 b/templates/615_kernel-modules.yaml.tt2 index 6d2bcad..ad070ac 100644 --- a/templates/615_kernel-modules.yaml.tt2 +++ b/templates/615_kernel-modules.yaml.tt2 @@ -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 -%] \ No newline at end of file +[% END -%] diff --git a/templates/821_network-ports-ngcp.yaml.tt2 b/templates/821_network-ports-ngcp.yaml.tt2 index c43de17..fb93b70 100644 --- a/templates/821_network-ports-ngcp.yaml.tt2 +++ b/templates/821_network-ports-ngcp.yaml.tt2 @@ -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'; diff --git a/templates/900_service-ngcp-api.yaml.tt2 b/templates/900_service-ngcp-api.yaml.tt2 index d9f7390..49ee390 100644 --- a/templates/900_service-ngcp-api.yaml.tt2 +++ b/templates/900_service-ngcp-api.yaml.tt2 @@ -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: diff --git a/templates/911_service-grafana.yaml.tt2 b/templates/911_service-grafana.yaml.tt2 index 15be558..4a8ced4 100644 --- a/templates/911_service-grafana.yaml.tt2 +++ b/templates/911_service-grafana.yaml.tt2 @@ -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: diff --git a/templates/920_service-asterisk-odbc-pro.yaml.tt2 b/templates/920_service-asterisk-odbc-pro.yaml.tt2 index 478ffbe..65c4c88 100644 --- a/templates/920_service-asterisk-odbc-pro.yaml.tt2 +++ b/templates/920_service-asterisk-odbc-pro.yaml.tt2 @@ -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 -%] \ No newline at end of file +[% END -%]