Commit 1bd2e9d0 authored by Łukasz Nowak's avatar Łukasz Nowak

XXX refix defaults

parent 63227759
......@@ -14,7 +14,7 @@
# not need these here).
[template]
filename = instance.cfg.in
md5sum = 31821067c5f1586863c8c64c2143a51c
md5sum = 173312288efa2070611a6ba50120c952
[profile-common]
filename = instance-common.cfg.in
......@@ -22,11 +22,11 @@ md5sum = 5784bea3bd608913769ff9a8afcccb68
[profile-frontend]
filename = instance-frontend.cfg.in
md5sum = a0b28604769b1fe3fd745ef9683984e7
md5sum = 628a3d2dfb493b9834a23b9c02304f8d
[profile-master]
filename = instance-master.cfg.in
md5sum = c8103be1781b3289e52c863921e9436a
md5sum = bddf84b27d403fb6d5c3a969e78c43cb
[profile-slave-list]
filename = instance-slave-list.cfg.in
......@@ -98,7 +98,7 @@ md5sum = 04bc664aa0159acaafec49a6bc36e84b
[software-py]
filename = software.py
md5sum = 487233af12c5b41d636a44a21a9daa64
md5sum = 2fef3ad7fb2f367045e6977f422f3bb0
[profile-kedifa]
filename = instance-kedifa.cfg.in
......
{% import "caucase" as caucase with context %}
{%- set configuration = instance_parameter_dict['configuration'] %}
{%- do software_module.merge_dict(configuration['user'], FRONTEND_USER_DEFAULTS) %}
{%- do software_module.merge_defaults(configuration['user'], FRONTEND_USER_DEFAULTS) %}
{%- set HTTP3_PORT = configuration['user']['global']['expert']['advertised-http3-port'] %}
{%- set FRONTEND_HTTP3 = configuration['user']['global']['enable-http3'] %}
{%- if FRONTEND_HTTP3 %}
......
{%- import "caucase" as CAUCASE with context %}
{#- BEGIN: Definition of global variables of the profile #}
{%- set configuration = instance_parameter_dict['configuration'].copy() %}
{%- do software_module.merge_dict(configuration, CLUSTER_DEFAULTS) %}
{%- do software_module.merge_defaults(configuration, CLUSTER_DEFAULTS) %}
{%- set SLAVE_TRUE_VALUES = ['y', 'yes', '1', 'true'] -%}
{#- List of keys which shall pass buildout before sending in request to parse ${...:...} #}
{%- set NEED_BUILDOUT_PASS_REQUEST_KEY_LIST = [
......
......@@ -68,8 +68,9 @@ init =
default_dict[property] = value_dict['default']
elif 'properties' in value_dict:
default_dict[property] = fetchLevel(value_dict)
#else: # XXX -- then merge_dict can't work nicely...
# default_dict[property] = None
else:
# None means no default
default_dict[property] = None
return default_dict
options['defaults'] = fetchLevel(input_json)
......
......@@ -124,12 +124,13 @@ def caucase_csr_sign_check():
print('OK No CSR to sign on %s' % (ca_url,))
def merge_dict(d, u):
def merge_defaults(d, u):
# inspired https://stackoverflow.com/a/3233356
for k, v in u.items():
if isinstance(v, collections.abc.Mapping):
d[k] = merge_dict(d.get(k, {}), v)
d[k] = merge_defaults(d.get(k, {}), v)
else:
if k not in d:
# None means no default defined
if k not in d and v is not None:
d[k] = v
return d
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