Commit 7ba3ff9e authored by Julien Muchembled's avatar Julien Muchembled

NEO: new schema for node parameters

parent 0b049372
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
# not need these here). # not need these here).
[instance-common] [instance-common]
filename = instance-common.cfg.in filename = instance-common.cfg.in
md5sum = 0a3a54fcc7be0bbd63cbd64f006ceebc md5sum = 80599fcc6e5d07270d7900aebfd62139
[root-common] [root-common]
filename = root-common.cfg.in filename = root-common.cfg.in
md5sum = ccc6e33412259415ec6c3452d37b77cc md5sum = c03fbfc9df9edc1ef60be970e0627c5e
[instance-neo-admin] [instance-neo-admin]
filename = instance-neo-admin.cfg.in filename = instance-neo-admin.cfg.in
...@@ -38,7 +38,7 @@ md5sum = 9f6f8f2b5f4cb0d97d50ffc1d3837e2f ...@@ -38,7 +38,7 @@ md5sum = 9f6f8f2b5f4cb0d97d50ffc1d3837e2f
[template-neo] [template-neo]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 83dc9faca482b2ddbd3d5fa968af7c33 md5sum = 9e63e16eda75e73ad4ffb50afde0505d
[cluster] [cluster]
filename = cluster.cfg.in filename = cluster.cfg.in
......
...@@ -15,7 +15,9 @@ cert = ${slap-connection:cert-file} ...@@ -15,7 +15,9 @@ cert = ${slap-connection:cert-file}
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
filename = ${:_buildout_section_name_}.cfg filename = ${:_buildout_section_name_}.cfg
rendered = ${buildout:parts-directory}/${:_buildout_section_name_}/${:filename} rendered = ${buildout:parts-directory}/${:_buildout_section_name_}/${:filename}
extensions = jinja2.ext.do extensions =
jinja2.ext.do
jinja2.ext.loopcontrols
extra-context = extra-context =
context = context =
key ipv4_set slap-configuration:ipv4 key ipv4_set slap-configuration:ipv4
......
{ {
"$schema": "http://json-schema.org/draft-04/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"description": "Parameters to instantiate a NEO cluster. See https://lab.nexedi.com/nexedi/neoppod/blob/master/neo.conf for more information.", "description": "Parameters to instantiate a NEO cluster. See https://lab.nexedi.com/nexedi/neoppod/blob/master/neo.conf for more information.",
"additionalProperties": false, "additionalProperties": false,
"required": [ "required": [
...@@ -72,71 +72,95 @@ ...@@ -72,71 +72,95 @@
"_key": { "_key": {
"type": "string" "type": "string"
}, },
"node-list": { "node-count": {
"description": "List of dictionaries containing parameters for each node.", "description": "Number of nodes to deploy.",
"items": { "default": 1,
"description": "Dictionary containing parameters required to configure individual nodes.", "type": "integer"
"default": {}, },
"additionalProperties": false, "node": {
"properties": { "description": "Default node parameters.",
"admin": { "default": {},
"description": "Port of admin node. 0 to disable.", "additionalProperties": false,
"default": 2050, "properties": {
"type": "integer" "admin": {
}, "description": "Port of admin node. 0 to disable.",
"master": { "default": 2050,
"description": "Port of master node. 0 to disable.", "type": "integer"
"default": 2051, },
"type": "integer" "master": {
}, "description": "Port of master node. 0 to disable.",
"storage-count": { "default": 2051,
"description": "Number of storage nodes to deploy. One master and one admin node is deployed with each storage.", "type": "integer"
"default": 1, },
"type": "integer" "storage-count": {
}, "description": "Number of storage nodes to deploy. One master and one admin node is deployed with each storage.",
"data-deduplication": { "default": 1,
"description": "Set the --dedup option for storage nodes.", "type": "integer"
"default": false,
"type": "boolean"
},
"disable-drop-partitions": {
"description": "Set the --disable-drop-partitions option for storage nodes.",
"default": false,
"type": "boolean"
},
"storage-type": {
"description": "Storage type. Defaults to MySQL if available, else SQLite.",
"enum": [
"MySQL",
"SQLite"
],
"type": "string"
},
"mysql": {
"description": "Dictionary containing parameters for MySQL.",
"default": {},
"properties": {
"relaxed-writes": {
"description": "When enabled, sets innodb_flush_log_at_trx_commit = 0, innodb_flush_method = nosync, innodb_doublewrite = 0 and sync_frm = 0 - RTFM, those options are dangerous",
"default": false,
"type": "boolean"
}
}, },
"additionalProperties": { "data-deduplication": {
"description": "To configure important parameters like innodb_buffer_pool_size, tokudb_cache_size, etc.", "description": "Set the --dedup option for storage nodes.",
"default": false,
"type": "boolean"
},
"disable-drop-partitions": {
"description": "Set the --disable-drop-partitions option for storage nodes.",
"default": false,
"type": "boolean"
},
"storage-type": {
"description": "Storage type. Defaults to MySQL if available, else SQLite.",
"enum": [
"MySQL",
"SQLite"
],
"type": "string" "type": "string"
}, },
"type": "object" "mysql": {
"description": "Dictionary containing parameters for MySQL.",
"default": {},
"properties": {
"relaxed-writes": {
"description": "When enabled, sets innodb_flush_log_at_trx_commit = 0, innodb_flush_method = nosync, innodb_doublewrite = 0 and sync_frm = 0 - RTFM, those options are dangerous",
"default": false,
"type": "boolean"
}
},
"additionalProperties": {
"description": "To configure important parameters like innodb_buffer_pool_size, tokudb_cache_size, etc.",
"type": "string"
},
"type": "object"
},
"engine": {
"description": "Configures storage engine, currently only InnoDB, RocksDB and TokuDB are supported. Defaults to NEO's default.",
"type": "string"
}
}, },
"engine": { "type": "object"
"description": "Configures storage engine, currently only InnoDB, RocksDB and TokuDB are supported. Defaults to NEO's default.",
"type": "string"
}
}, },
"type": "object" "node!": {
}, "description": "Node parameters are overridden by the value of the first item whose partition reference matches against the pattern.",
"type": "array" "items": {
} "items": [
{
"description": "Override pattern (Python regular expression).",
"type": "string"
},
{
"allOf": [
{
"$ref": "#/properties/node"
},
{
"description": "Override value (parameters for maching nodes)."
}
]
}
],
"type": "array"
},
"type": "array"
}
}, },
"type": "object" "type": "object"
} }
...@@ -8,6 +8,7 @@ rendered = ${buildout:parts-directory}/${:_buildout_section_name_}.cfg ...@@ -8,6 +8,7 @@ rendered = ${buildout:parts-directory}/${:_buildout_section_name_}.cfg
<= jinja2-template-base <= jinja2-template-base
template = {{ cluster }} template = {{ cluster }}
extra-context = extra-context =
import re re
import urlparse urlparse import urlparse urlparse
import-list = import-list =
rawfile root_common {{ root_common }} rawfile root_common {{ root_common }}
......
...@@ -16,6 +16,20 @@ sla-computer_guid = ${slap-connection:computer-id} ...@@ -16,6 +16,20 @@ sla-computer_guid = ${slap-connection:computer-id}
{% endif -%} {% endif -%}
{% endmacro -%} {% endmacro -%}
{% macro apply_overrides(dict_, reference) -%}
{% for key in list(dict_) -%}
{% if key.endswith('!') -%}
{% for pattern, value in dict_.pop(key, ()) -%}
{% set m = re.match(pattern, reference) -%}
{% if m and m.group() == reference %}{# PY3: fullmatch -#}
{% do dict_.__setitem__(key[:-1], value) -%}
{% break -%}
{% endif -%}
{% endfor -%}
{% endif -%}
{% endfor -%}
{% endmacro -%}
{% macro common_section() -%} {% macro common_section() -%}
[request-common-base] [request-common-base]
recipe = slapos.cookbook:request.serialised recipe = slapos.cookbook:request.serialised
...@@ -52,7 +66,22 @@ config-ssl = {{ dumps(( ...@@ -52,7 +66,22 @@ config-ssl = {{ dumps((
config-upstream-cluster = {{ dumps(parameter_dict.get('upstream-cluster', '')) }} config-upstream-cluster = {{ dumps(parameter_dict.get('upstream-cluster', '')) }}
config-upstream-masters = {{ dumps(parameter_dict.get('upstream-masters', '')) }} config-upstream-masters = {{ dumps(parameter_dict.get('upstream-masters', '')) }}
software-type = {{ software_type }} software-type = {{ software_type }}
{% set node_list = parameter_dict.get('node-list', ({},)) -%}
{% set node_list = parameter_dict.get('node-list') -%}
{% if node_list == None -%}
{% set node_list = [] -%}
{% for i in range(parameter_dict.get('node-count', 1)) -%}
{% set x = parameter_dict.copy() -%}
{% do apply_overrides(x, prefix ~ i) -%}
{% do node_list.append(x.get('node', {})) -%}
{% endfor -%}
{% else %}{# BBB -#}
{% do assert('node-count' not in parameter_dict) -%}
{% do assert('node' not in parameter_dict) -%}
{% do assert('node!' not in parameter_dict) -%}
{% endif -%}
{% do assert(node_list) -%}
{% set storage_count = [] -%} {% set storage_count = [] -%}
{% for node in node_list -%} {% for node in node_list -%}
{% do storage_count.append(node.get('storage-count', 1)) -%} {% do storage_count.append(node.get('storage-count', 1)) -%}
......
...@@ -70,7 +70,7 @@ md5sum = cc19560b9400cecbd23064d55c501eec ...@@ -70,7 +70,7 @@ md5sum = cc19560b9400cecbd23064d55c501eec
[template] [template]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = f6c6820f9b3653d0d5c29708606fc591 md5sum = d53a7dbc374374b5c312e3f7e2c0a0ff
[monitor-template-dummy] [monitor-template-dummy]
filename = dummy.cfg filename = dummy.cfg
......
...@@ -46,6 +46,7 @@ extra-context = ...@@ -46,6 +46,7 @@ extra-context =
key jupyter_enable_default dynamic-template-erp5-parameters:jupyter-enable-default key jupyter_enable_default dynamic-template-erp5-parameters:jupyter-enable-default
key local_bt5_repository dynamic-template-erp5-parameters:local-bt5-repository key local_bt5_repository dynamic-template-erp5-parameters:local-bt5-repository
key openssl_location :openssl-location key openssl_location :openssl-location
import re re
import urlparse urlparse import urlparse urlparse
import-list = import-list =
file root_common context:root-common file root_common context:root-common
......
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