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 @@
},
"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": {
"description": "Zope layout definition",
"patternProperties": {
......@@ -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)",
"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"
......
......@@ -10,6 +10,11 @@
"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": {
"description": "Databases to create and respective user credentials getting all privileges on it",
"default": [{
......
......@@ -8,6 +8,14 @@
{% set site_id = slapparameter_dict.get('site-id', 'erp5') -%}
{% set inituser_login = slapparameter_dict.get('inituser-login', 'zope') -%}
{% 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]
recipe = slapos.cookbook:request.serialised
software-url = ${slap-connection:software-release-url}
......@@ -48,7 +56,7 @@ config-{{ k }} = {{ dumps(v) }}
{{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}) }}
{{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}) }}
{{ 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}) }}
{# ZODB -#}
......@@ -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-port-base = {{ dumps(zope_parameter_dict.get('port-base', 2200)) }}
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 -%}
{# We need to concatenate lists that we cannot read as lists, so this gets hairy. -#}
......
......@@ -11,6 +11,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 port = slapparameter_dict['tcpv4-port'] %}
{% set monitor_port = slapparameter_dict.get('monitor-port', 0) -%}
{% if use_ipv6 -%}
{% set ip = (ipv6_set | list)[0] -%}
{% else -%}
......@@ -32,7 +33,9 @@ recipe = slapos.cookbook:publish.serialised
{% endmacro -%}
database-list = {{ render_database_list(database_list) }}
test-database-list = {{ render_database_list(test_database_list) }}
{% if monitor_port -%}
monitor-url = ${publish-connection-informations:monitor_url}
{% endif %}
[simplefile]
recipe = slapos.recipe.template:jinja2
......@@ -233,6 +236,7 @@ command-line = "{{ parameter_dict['bin-directory'] }}/is-local-tcp-port-opened"
wrapper-path = ${directory:promise}/mariadb
parameters-extra = true
{% if monitor_port -%}
[{{ section('monitor-current-log-access') }}]
< = monitor-directory-access
source = ${directory:log}
......@@ -242,12 +246,16 @@ source = ${directory:log}
source = ${logrotate-entry-mariadb:backup}
[monitor-parameters]
port = 3380
port = {{ monitor_port }}
{% endif -%}
[buildout]
extends =
{{ logrotate_cfg }}
{% if monitor_port -%}
# Extends template for monitor
{{ parameter_dict['template-monitor'] }}
{% endif -%}
parts +=
publish-mariadb-url
logrotate-entry-mariadb
......@@ -257,7 +265,7 @@ parts +=
resiliency-exclude-file
resiliency-after-import-script
promise
{% if monitor_port -%}
# Access to mariadb logs
certificate-authority
cron-entry-monitor
......@@ -270,6 +278,6 @@ parts +=
cgi-httpd-graceful-wrapper
monitor-promise
monitor-instance-log-access
{% endif -%}
# Complete parts with sections
{{ part_list | join('\n ') }}
......@@ -13,6 +13,10 @@ XXX: This template only supports exactly one IPv4 and one IPv6 per
partition. No more (undefined result), no less (IndexError).
-#}
{% 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'] -%}
[{{ section('test-runner') }}]
......@@ -98,6 +102,7 @@ recipe = slapos.cookbook:certificate_authority
openssl-binary = ${binary-link:target-directory}/openssl
wrapper = ${directory:services}/ca
{% if monitor -%}
[{{ section('monitor-current-log-access') }}]
< = monitor-directory-access
source = ${directory:log}
......@@ -107,7 +112,8 @@ source = ${directory:log}
source = ${directory:logrotate-backup}
[monitor-parameters]
port = {{ slapparameter_dict['port-base'] + 5000 }}
port = {{ slapparameter_dict['monitor-port'] }}
{% endif -%}
{% if use_ipv6 -%}
{% set ipv6 = (ipv6_set | list)[0] -%}
......@@ -338,7 +344,9 @@ dict toward erp5 partition, violating the DRY principle and making the intent
hard to guess.
-#}
hosts-dict = {{ dumps(hosts_dict) }}
{% if monitor -%}
monitor-url = ${monitor-parameters:url}
{% endif -%}
[erp5-promise]
recipe = slapos.cookbook:erp5.promise
......@@ -353,20 +361,26 @@ bt5-repository-url = {{ dumps(slapparameter_dict['bt5-repository-url']) }}
[buildout]
extends =
{{ logrotate_cfg }}
{% if monitor -%}
# Extends template for monitor
{{ parameter_dict['template-monitor'] }}
{% endif -%}
parts +=
erp5-promise
{% if monitor -%}
# Access to zope logs
certificate-authority
cron-entry-monitor
cron-entry-rss
deploy-index
setup-static-files
certificate-authority
public-symlink
cgi-httpd-wrapper
cgi-httpd-graceful-wrapper
monitor-promise
monitor-instance-log-access
{% endif -%}
# Complete parts with sections
{{ part_list | join('\n ') }}
publish-zope
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