forked from stove/risotto
set_linked_multi_variables
This commit is contained in:
parent
127dba8c52
commit
76a99dc532
2 changed files with 40 additions and 24 deletions
30
bootstrap.py
30
bootstrap.py
|
@ -37,17 +37,21 @@ with open('servers.json', 'r') as server_fh:
|
||||||
MODULES = jsonfile['modules']
|
MODULES = jsonfile['modules']
|
||||||
|
|
||||||
|
|
||||||
async def set_linked_multi_variables(linked_server: str,
|
async def set_linked_multi_variables(value: str,
|
||||||
|
linked_server: str=None,
|
||||||
**kwargs: dict,
|
**kwargs: dict,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
if value is not None and linked_server is not None and 'linked_value_0' not in kwargs:
|
||||||
|
kwargs['linked_value_0'] = value
|
||||||
|
elif linked_server is None:
|
||||||
|
linked_server = value
|
||||||
if linked_server is None:
|
if linked_server is None:
|
||||||
return
|
return
|
||||||
if linked_server not in CONFIGS:
|
if linked_server not in CONFIGS:
|
||||||
warn_explicit(ValueWarning(f'cannot find linked server "{linked_server}"'),
|
warn_explicit(ValueWarning(f'cannot find linked server "{linked_server}"'),
|
||||||
ValueWarning,
|
ValueWarning,
|
||||||
__file__,
|
__file__,
|
||||||
0,
|
3,
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
config = CONFIGS[linked_server][0]
|
config = CONFIGS[linked_server][0]
|
||||||
|
@ -74,14 +78,20 @@ async def set_linked_multi_variables(linked_server: str,
|
||||||
dynamic = None
|
dynamic = None
|
||||||
slave_idx = None
|
slave_idx = None
|
||||||
await config.property.read_write()
|
await config.property.read_write()
|
||||||
|
first_variable = variables[0]['value']
|
||||||
|
if not isinstance(variables[0]['value'], list):
|
||||||
|
variables[0]['value'] = [variables[0]['value']]
|
||||||
try:
|
try:
|
||||||
|
for var_index in range(len(variables[0]['value'])):
|
||||||
|
pass
|
||||||
for index in sorted(list(variables)):
|
for index in sorted(list(variables)):
|
||||||
path = variables[index]['path']
|
path = variables[index]['path']
|
||||||
value = variables[index]['value']
|
if index == 0:
|
||||||
if dynamic:
|
value = variables[index]['value'][var_index]
|
||||||
path = path.replace('{suffix}', dynamic)
|
|
||||||
else:
|
|
||||||
dynamic = normalize_family(value)
|
dynamic = normalize_family(value)
|
||||||
|
else:
|
||||||
|
value = variables[index]['value']
|
||||||
|
path = path.replace('{suffix}', dynamic)
|
||||||
option = config.forcepermissive.option(path, slave_idx)
|
option = config.forcepermissive.option(path, slave_idx)
|
||||||
multi = await option.option.ismulti()
|
multi = await option.option.ismulti()
|
||||||
if multi and await option.option.isfollower():
|
if multi and await option.option.isfollower():
|
||||||
|
@ -94,6 +104,8 @@ async def set_linked_multi_variables(linked_server: str,
|
||||||
if await option.option.isleader():
|
if await option.option.isleader():
|
||||||
slave_idx = values.index(value)
|
slave_idx = values.index(value)
|
||||||
else:
|
else:
|
||||||
|
if isinstance(value, list):
|
||||||
|
value = value[var_index]
|
||||||
await option.value.set(value)
|
await option.value.set(value)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
await config.property.read_only()
|
await config.property.read_only()
|
||||||
|
@ -324,6 +336,8 @@ def build_module(module_name, datas, module_infos):
|
||||||
def calc_depends(appname, added):
|
def calc_depends(appname, added):
|
||||||
if appname in added:
|
if appname in added:
|
||||||
return
|
return
|
||||||
|
if appname not in applications:
|
||||||
|
raise Exception(f'cannot find application dependency "{appname}" in application "{module_name}"')
|
||||||
as_dir = applications[appname]
|
as_dir = applications[appname]
|
||||||
cfg.modules.append(appname)
|
cfg.modules.append(appname)
|
||||||
dictionaries_dir = join(as_dir, 'dictionaries')
|
dictionaries_dir = join(as_dir, 'dictionaries')
|
||||||
|
@ -488,7 +502,7 @@ async def valid_mandatories(server_name, config):
|
||||||
async def templates(server_name, config, cfg, srv, int_idx):
|
async def templates(server_name, config, cfg, srv, int_idx):
|
||||||
values = await config.value.dict()
|
values = await config.value.dict()
|
||||||
engine = RougailSystemdTemplate(config, cfg)
|
engine = RougailSystemdTemplate(config, cfg)
|
||||||
# if server_name == 'revprox.in.silique.fr':
|
# if server_name == 'dovecot.in.silique.fr':
|
||||||
# print()
|
# print()
|
||||||
# print(f'=== Configuration: {server_name} ===')
|
# print(f'=== Configuration: {server_name} ===')
|
||||||
# pprint(values)
|
# pprint(values)
|
||||||
|
|
|
@ -154,6 +154,8 @@ def gen_cert_iter(cn,
|
||||||
if not isfile(cert_ca_name):
|
if not isfile(cert_ca_name):
|
||||||
raise Exception(f'cannot find CA file "{cert_ca_name}"')
|
raise Exception(f'cannot find CA file "{cert_ca_name}"')
|
||||||
if not isfile(cert_name):
|
if not isfile(cert_name):
|
||||||
|
if not isfile(key_ca_name):
|
||||||
|
raise Exception(f"cannot find CA private key (\"{authority_cn}\") to sign certificat for \"{cn}\", is it a Let's Encrypt certification?")
|
||||||
if not isdir(dir_name):
|
if not isdir(dir_name):
|
||||||
makedirs(dir_name)
|
makedirs(dir_name)
|
||||||
if isfile(sn_name):
|
if isfile(sn_name):
|
||||||
|
|
Loading…
Reference in a new issue