Commit 9ad09a63 authored by Alain Takoudjou's avatar Alain Takoudjou

stack erp5: Allow to enable or desable monitor, and to define custom port for monitoring instance

We can set a specific port-base to use for monitor instance. We can also activate
or desactivate monitor by using parameter "monitor": true in zope or mariadb parameters.
parent f4e8b42f
...@@ -81,6 +81,20 @@ ...@@ -81,6 +81,20 @@
}, },
"type": "object" "type": "object"
}, },
"monitor": {
"description": "Monitoring instance request parameters",
"properties": {
"port-base": {
"allOf": [{
"$ref": "#/definitions/tcpv4port"
}, {
"description": "Start monitor allocating ports at this value. Useful if one needs to make several partitions share the same port range (ie, several partitions bound to a single address)",
"default": 2600
}]
}
},
"type": "object"
},
"zope-partition-dict": { "zope-partition-dict": {
"description": "Zope layout definition", "description": "Zope layout definition",
"patternProperties": { "patternProperties": {
...@@ -130,6 +144,11 @@ ...@@ -130,6 +144,11 @@
"default": 2200 "default": 2200
}] }]
}, },
"monitor": {
"description": "Define if monitoring instance will be associate to this zope.",
"default": false,
"type": "boolean"
},
"computer-guid": { "computer-guid": {
"description": "GUID of computer instance must be requested on", "description": "GUID of computer instance must be requested on",
"type": "string" "type": "string"
......
...@@ -10,6 +10,11 @@ ...@@ -10,6 +10,11 @@
"description": "Start allocating ports at this value, going downward" "description": "Start allocating ports at this value, going downward"
}] }]
}, },
"monitor": {
"description": "Define if monitor instance will be associate to this instance of mariadb.",
"default": false,
"type": "boolean"
},
"database-list": { "database-list": {
"description": "Databases to create and respective user credentials getting all privileges on it", "description": "Databases to create and respective user credentials getting all privileges on it",
"default": [{ "default": [{
......
...@@ -166,7 +166,7 @@ md5sum = 6598e036c140f65571f3f9e3faa5d008 ...@@ -166,7 +166,7 @@ md5sum = 6598e036c140f65571f3f9e3faa5d008
[template-mariadb] [template-mariadb]
< = download-base < = download-base
filename = instance-mariadb.cfg.in filename = instance-mariadb.cfg.in
md5sum = d42f6a8b11e5908b6a44ce2c3dae0367 md5sum = c7038bb76157cc256d73afb98e1634f9
link-binary = link-binary =
${coreutils:location}/bin/basename ${coreutils:location}/bin/basename
${coreutils:location}/bin/cat ${coreutils:location}/bin/cat
...@@ -297,7 +297,7 @@ extra-context = ...@@ -297,7 +297,7 @@ extra-context =
[template-erp5] [template-erp5]
< = download-base < = download-base
filename = instance-erp5.cfg.in filename = instance-erp5.cfg.in
md5sum = 6d36be642a5891624fae767adf68639e md5sum = 7abb03ec5e17e12ef8c9693befb5cee3
[template-zeo] [template-zeo]
< = download-base < = download-base
...@@ -307,7 +307,7 @@ md5sum = 651fa2ec2feb768e339936b7855774ca ...@@ -307,7 +307,7 @@ md5sum = 651fa2ec2feb768e339936b7855774ca
[template-zope] [template-zope]
< = download-base < = download-base
filename = instance-zope.cfg.in filename = instance-zope.cfg.in
md5sum = 044fea3d2d13783a5509cbcffc2d197b md5sum = 4a860576075559453f4227e0649281a0
link-binary = link-binary =
${aspell:location}/bin/aspell ${aspell:location}/bin/aspell
${coreutils:location}/bin/basename ${coreutils:location}/bin/basename
......
...@@ -3,6 +3,14 @@ ...@@ -3,6 +3,14 @@
{% set site_id = slapparameter_dict.get('site-id', 'erp5') -%} {% set site_id = slapparameter_dict.get('site-id', 'erp5') -%}
{% set inituser_login = slapparameter_dict.get('inituser-login', 'zope') -%} {% set inituser_login = slapparameter_dict.get('inituser-login', 'zope') -%}
{% set publish_dict = {'site-id': site_id, 'inituser-login': inituser_login} -%} {% set publish_dict = {'site-id': site_id, 'inituser-login': inituser_login} -%}
{% set mariadb_request_dict = {'tcpv4-port': 2099} -%}
{% set monitor_dict = slapparameter_dict.get('monitor', {}) %}
{% set monitor_port = monitor_dict.get('port-base', 2600) %}
{% set monitor_count = 1 -%}
{% if mariadb_dict.get('monitor', False) -%}
{% do mariadb_request_dict.__setitem__('monitor-port', mariadb_dict.get('monitor-port', monitor_port)) -%}
{% endif -%}
[request-common] [request-common]
recipe = slapos.cookbook:request.serialised recipe = slapos.cookbook:request.serialised
software-url = ${slap-connection:software-release-url} software-url = ${slap-connection:software-release-url}
...@@ -35,7 +43,7 @@ config-{{ option }} = {{ dumps(value) }} ...@@ -35,7 +43,7 @@ config-{{ option }} = {{ dumps(value) }}
{{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}) }} {{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}) }}
{{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}) }} {{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}) }}
{{ request('cloudooo', 'cloudooo', 'cloudooo', {'tcpv4-port': 2020}) }} {{ request('cloudooo', 'cloudooo', 'cloudooo', {'tcpv4-port': 2020}) }}
{{ request('mariadb', 'mariadb', 'mariadb', {'tcpv4-port': 2099}, {'database-list': True, 'test-database-list': True}) }} {{ request('mariadb', 'mariadb', 'mariadb', mariadb_request_dict, {'database-list': True, 'test-database-list': True}) }}
{# Fail early if an unexpected value is provided -#} {# Fail early if an unexpected value is provided -#}
{% set zodb_type = slapparameter_dict.get('zodb-software-type') -%} {% set zodb_type = slapparameter_dict.get('zodb-software-type') -%}
{% set zodb_extern = slapparameter_dict.get('zodb-extern') -%} {% set zodb_extern = slapparameter_dict.get('zodb-extern') -%}
...@@ -109,7 +117,12 @@ config-longrequest-logger-interval = {{ dumps(zope_parameter_dict.get('longreque ...@@ -109,7 +117,12 @@ config-longrequest-logger-interval = {{ dumps(zope_parameter_dict.get('longreque
config-longrequest-logger-timeout = {{ dumps(zope_parameter_dict.get('longrequest-logger-timeout', 1)) }} config-longrequest-logger-timeout = {{ dumps(zope_parameter_dict.get('longrequest-logger-timeout', 1)) }}
config-port-base = {{ dumps(zope_parameter_dict.get('port-base', 2200)) }} config-port-base = {{ dumps(zope_parameter_dict.get('port-base', 2200)) }}
config-webdav = {{ dumps(zope_parameter_dict.get('webdav', False)) }} config-webdav = {{ dumps(zope_parameter_dict.get('webdav', False)) }}
config-monitor = {{ dumps(zope_parameter_dict.get('monitor', False)) }}
{% if zope_parameter_dict.get('monitor', False) -%}
config-monitor-port = {{ zope_parameter_dict.get('monitor-port', monitor_port + monitor_count) }}
{% endif -%}
sla-computer_guid = {{ dumps(zope_parameter_dict.get('computer-guid', computer_id)) }} sla-computer_guid = {{ dumps(zope_parameter_dict.get('computer-guid', computer_id)) }}
{% set monitor_count = monitor_count + 1 -%}
{% endfor -%} {% endfor -%}
{# We need to concatenate lists that we cannot read as lists, so this gets hairy. -#} {# We need to concatenate lists that we cannot read as lists, so this gets hairy. -#}
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
{% set full_backup_retention_days = catalog_backup.get('full-retention-days', 7) -%} {% set full_backup_retention_days = catalog_backup.get('full-retention-days', 7) -%}
{% set incremental_backup_retention_days = catalog_backup.get('incremental-retention-days', full_backup_retention_days) -%} {% set incremental_backup_retention_days = catalog_backup.get('incremental-retention-days', full_backup_retention_days) -%}
{% set port = slapparameter_dict['tcpv4-port'] %} {% set port = slapparameter_dict['tcpv4-port'] %}
{% set monitor_port = slapparameter_dict.get('monitor-port', 0) -%}
{% if use_ipv6 -%} {% if use_ipv6 -%}
{% set ip = (ipv6_set | list)[0] -%} {% set ip = (ipv6_set | list)[0] -%}
{% else -%} {% else -%}
...@@ -31,7 +32,9 @@ recipe = slapos.cookbook:publish.serialised ...@@ -31,7 +32,9 @@ recipe = slapos.cookbook:publish.serialised
{% endmacro -%} {% endmacro -%}
database-list = {{ render_database_list(database_list) }} database-list = {{ render_database_list(database_list) }}
test-database-list = {{ render_database_list(test_database_list) }} test-database-list = {{ render_database_list(test_database_list) }}
{% if monitor_port -%}
monitor-url = ${publish-connection-informations:monitor_url} monitor-url = ${publish-connection-informations:monitor_url}
{% endif %}
[simplefile] [simplefile]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
...@@ -218,6 +221,7 @@ command-line = "{{ parameter_dict['bin-directory'] }}/is-local-tcp-port-opened" ...@@ -218,6 +221,7 @@ command-line = "{{ parameter_dict['bin-directory'] }}/is-local-tcp-port-opened"
wrapper-path = ${directory:promise}/mariadb wrapper-path = ${directory:promise}/mariadb
parameters-extra = true parameters-extra = true
{% if monitor_port -%}
[{{ section('monitor-current-log-access') }}] [{{ section('monitor-current-log-access') }}]
< = monitor-directory-access < = monitor-directory-access
source = ${directory:log} source = ${directory:log}
...@@ -227,12 +231,16 @@ source = ${directory:log} ...@@ -227,12 +231,16 @@ source = ${directory:log}
source = ${logrotate-entry-mariadb:backup} source = ${logrotate-entry-mariadb:backup}
[monitor-parameters] [monitor-parameters]
port = 3380 port = {{ monitor_port }}
{% endif -%}
[buildout] [buildout]
extends = extends =
{{ logrotate_cfg }} {{ logrotate_cfg }}
{% if monitor_port -%}
# Extends template for monitor
{{ parameter_dict['template-monitor'] }} {{ parameter_dict['template-monitor'] }}
{% endif -%}
parts += parts +=
publish-mariadb-url publish-mariadb-url
logrotate-entry-mariadb logrotate-entry-mariadb
...@@ -240,7 +248,7 @@ parts += ...@@ -240,7 +248,7 @@ parts +=
update-mysql update-mysql
mysqld mysqld
promise promise
{% if monitor_port -%}
# Access to mariadb logs # Access to mariadb logs
certificate-authority certificate-authority
cron-entry-monitor cron-entry-monitor
...@@ -253,6 +261,6 @@ parts += ...@@ -253,6 +261,6 @@ parts +=
cgi-httpd-graceful-wrapper cgi-httpd-graceful-wrapper
monitor-promise monitor-promise
monitor-instance-log-access monitor-instance-log-access
{% endif -%}
# Complete parts with sections # Complete parts with sections
{{ part_list | join('\n ') }} {{ part_list | join('\n ') }}
...@@ -14,6 +14,10 @@ XXX: This template only supports exactly one IPv4 and one IPv6 per ...@@ -14,6 +14,10 @@ XXX: This template only supports exactly one IPv4 and one IPv6 per
partition. No more (undefined result), no less (IndexError). partition. No more (undefined result), no less (IndexError).
-#} -#}
{% set ipv4 = (ipv4_set | list)[0] -%} {% set ipv4 = (ipv4_set | list)[0] -%}
{% set monitor = slapparameter_dict['monitor'] -%}
{% if monitor -%}
{% set monitor_port = slapparameter_dict['monitor-port'] %}
{% endif -%}
{% if slapparameter_dict['mysql-test-url-list'] -%} {% if slapparameter_dict['mysql-test-url-list'] -%}
[{{ section('test-runner') }}] [{{ section('test-runner') }}]
...@@ -99,6 +103,7 @@ recipe = slapos.cookbook:certificate_authority ...@@ -99,6 +103,7 @@ recipe = slapos.cookbook:certificate_authority
openssl-binary = ${binary-link:target-directory}/openssl openssl-binary = ${binary-link:target-directory}/openssl
wrapper = ${directory:services}/ca wrapper = ${directory:services}/ca
{% if monitor -%}
[{{ section('monitor-current-log-access') }}] [{{ section('monitor-current-log-access') }}]
< = monitor-directory-access < = monitor-directory-access
source = ${directory:log} source = ${directory:log}
...@@ -108,7 +113,8 @@ source = ${directory:log} ...@@ -108,7 +113,8 @@ source = ${directory:log}
source = ${directory:logrotate-backup} source = ${directory:logrotate-backup}
[monitor-parameters] [monitor-parameters]
port = {{ slapparameter_dict['port-base'] + 5000 }} port = {{ slapparameter_dict['monitor-port'] }}
{% endif -%}
{% if use_ipv6 -%} {% if use_ipv6 -%}
{% set ipv6 = (ipv6_set | list)[0] -%} {% set ipv6 = (ipv6_set | list)[0] -%}
...@@ -375,7 +381,9 @@ dict toward erp5 partition, violating the DRY principle and making the intent ...@@ -375,7 +381,9 @@ dict toward erp5 partition, violating the DRY principle and making the intent
hard to guess. hard to guess.
-#} -#}
hosts-dict = {{ dumps(hosts_dict) }} hosts-dict = {{ dumps(hosts_dict) }}
{% if monitor -%}
monitor-url = ${monitor-parameters:url} monitor-url = ${monitor-parameters:url}
{% endif -%}
[erp5-promise] [erp5-promise]
recipe = slapos.cookbook:erp5.promise recipe = slapos.cookbook:erp5.promise
...@@ -390,20 +398,26 @@ bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }} ...@@ -390,20 +398,26 @@ bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }}
[buildout] [buildout]
extends = extends =
{{ logrotate_cfg }} {{ logrotate_cfg }}
{% if monitor -%}
# Extends template for monitor
{{ parameter_dict['template-monitor'] }} {{ parameter_dict['template-monitor'] }}
{% endif -%}
parts += parts +=
erp5-promise erp5-promise
{% if monitor -%}
# Access to zope logs
certificate-authority certificate-authority
cron-entry-monitor cron-entry-monitor
cron-entry-rss cron-entry-rss
deploy-index deploy-index
setup-static-files setup-static-files
certificate-authority
public-symlink public-symlink
cgi-httpd-wrapper cgi-httpd-wrapper
cgi-httpd-graceful-wrapper cgi-httpd-graceful-wrapper
monitor-promise monitor-promise
monitor-instance-log-access monitor-instance-log-access
{% endif -%}
# Complete parts with sections
{{ part_list | join('\n ') }} {{ part_list | join('\n ') }}
publish-zope publish-zope
versions = versions versions = versions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment