Commit 32748e84 authored by Alain Takoudjou's avatar Alain Takoudjou Committed by Tristan Cavelier

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 9282bac3
...@@ -99,6 +99,20 @@ ...@@ -99,6 +99,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": {
...@@ -147,6 +161,15 @@ ...@@ -147,6 +161,15 @@
"description": "Start 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)", "description": "Start 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": 2200 "default": 2200
}] }]
},
"monitor": {
"description": "Define if monitoring instance will be associate to this zope.",
"default": false,
"type": "boolean"
},
"computer-guid": {
"description": "GUID of computer instance must be requested on",
"type": "string"
} }
}, },
"type": "object" "type": "object"
......
...@@ -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": [{
......
...@@ -8,6 +8,14 @@ ...@@ -8,6 +8,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}
...@@ -48,7 +56,7 @@ config-{{ k }} = {{ dumps(v) }} ...@@ -48,7 +56,7 @@ config-{{ k }} = {{ dumps(v) }}
{{ 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}) }}
{{ request('http-monitor', 'http-monitor', 'http-monitor', {}, {'monitor-url': True}) }} {{ request('http-monitor', 'http-monitor', 'http-monitor', {}, {'monitor-url': True}) }}
{# ZODB -#} {# ZODB -#}
...@@ -133,6 +141,12 @@ config-longrequest-logger-interval = {{ dumps(zope_parameter_dict.get('longreque ...@@ -133,6 +141,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)) }}
{% 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. -#}
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,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 -%}
...@@ -32,7 +33,9 @@ recipe = slapos.cookbook:publish.serialised ...@@ -32,7 +33,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
...@@ -233,6 +236,7 @@ command-line = "{{ parameter_dict['bin-directory'] }}/is-local-tcp-port-opened" ...@@ -233,6 +236,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}
...@@ -242,12 +246,16 @@ source = ${directory:log} ...@@ -242,12 +246,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
...@@ -257,7 +265,7 @@ parts += ...@@ -257,7 +265,7 @@ parts +=
resiliency-exclude-file resiliency-exclude-file
resiliency-after-import-script resiliency-after-import-script
promise promise
{% if monitor_port -%}
# Access to mariadb logs # Access to mariadb logs
certificate-authority certificate-authority
cron-entry-monitor cron-entry-monitor
...@@ -270,6 +278,6 @@ parts += ...@@ -270,6 +278,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 ') }}
...@@ -13,6 +13,10 @@ XXX: This template only supports exactly one IPv4 and one IPv6 per ...@@ -13,6 +13,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') }}]
...@@ -98,6 +102,7 @@ recipe = slapos.cookbook:certificate_authority ...@@ -98,6 +102,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}
...@@ -107,7 +112,8 @@ source = ${directory:log} ...@@ -107,7 +112,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] -%}
...@@ -338,7 +344,9 @@ dict toward erp5 partition, violating the DRY principle and making the intent ...@@ -338,7 +344,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
...@@ -353,20 +361,26 @@ bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }} ...@@ -353,20 +361,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