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']
|
||||
|
||||
|
||||
async def set_linked_multi_variables(linked_server: str,
|
||||
async def set_linked_multi_variables(value: str,
|
||||
linked_server: str=None,
|
||||
**kwargs: dict,
|
||||
) -> 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:
|
||||
return
|
||||
if linked_server not in CONFIGS:
|
||||
warn_explicit(ValueWarning(f'cannot find linked server "{linked_server}"'),
|
||||
ValueWarning,
|
||||
__file__,
|
||||
0,
|
||||
3,
|
||||
)
|
||||
return
|
||||
config = CONFIGS[linked_server][0]
|
||||
|
@ -74,14 +78,20 @@ async def set_linked_multi_variables(linked_server: str,
|
|||
dynamic = None
|
||||
slave_idx = None
|
||||
await config.property.read_write()
|
||||
first_variable = variables[0]['value']
|
||||
if not isinstance(variables[0]['value'], list):
|
||||
variables[0]['value'] = [variables[0]['value']]
|
||||
try:
|
||||
for var_index in range(len(variables[0]['value'])):
|
||||
pass
|
||||
for index in sorted(list(variables)):
|
||||
path = variables[index]['path']
|
||||
value = variables[index]['value']
|
||||
if dynamic:
|
||||
path = path.replace('{suffix}', dynamic)
|
||||
else:
|
||||
if index == 0:
|
||||
value = variables[index]['value'][var_index]
|
||||
dynamic = normalize_family(value)
|
||||
else:
|
||||
value = variables[index]['value']
|
||||
path = path.replace('{suffix}', dynamic)
|
||||
option = config.forcepermissive.option(path, slave_idx)
|
||||
multi = await option.option.ismulti()
|
||||
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():
|
||||
slave_idx = values.index(value)
|
||||
else:
|
||||
if isinstance(value, list):
|
||||
value = value[var_index]
|
||||
await option.value.set(value)
|
||||
except Exception as err:
|
||||
await config.property.read_only()
|
||||
|
@ -324,6 +336,8 @@ def build_module(module_name, datas, module_infos):
|
|||
def calc_depends(appname, added):
|
||||
if appname in added:
|
||||
return
|
||||
if appname not in applications:
|
||||
raise Exception(f'cannot find application dependency "{appname}" in application "{module_name}"')
|
||||
as_dir = applications[appname]
|
||||
cfg.modules.append(appname)
|
||||
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):
|
||||
values = await config.value.dict()
|
||||
engine = RougailSystemdTemplate(config, cfg)
|
||||
# if server_name == 'revprox.in.silique.fr':
|
||||
# if server_name == 'dovecot.in.silique.fr':
|
||||
# print()
|
||||
# print(f'=== Configuration: {server_name} ===')
|
||||
# pprint(values)
|
||||
|
|
|
@ -154,6 +154,8 @@ def gen_cert_iter(cn,
|
|||
if not isfile(cert_ca_name):
|
||||
raise Exception(f'cannot find CA file "{cert_ca_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):
|
||||
makedirs(dir_name)
|
||||
if isfile(sn_name):
|
||||
|
|
Loading…
Reference in a new issue