extra support
This commit is contained in:
parent
4de9bde691
commit
41af2512b5
|
@ -42,7 +42,8 @@ class Risotto(Controller):
|
||||||
release_cache: Dict) -> None:
|
release_cache: Dict) -> None:
|
||||||
as_names = []
|
as_names = []
|
||||||
dest_file = self.get_servermodel_cache(servermodel_id, 'funcs.py')
|
dest_file = self.get_servermodel_cache(servermodel_id, 'funcs.py')
|
||||||
with open(dest_file, 'w') as funcs:
|
with open(dest_file, 'wb') as funcs:
|
||||||
|
funcs.write(b'from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value\n\n')
|
||||||
for applicationservice_id, applicationservice_infos in dependencies.items():
|
for applicationservice_id, applicationservice_infos in dependencies.items():
|
||||||
applicationservice_name, as_release_id = applicationservice_infos
|
applicationservice_name, as_release_id = applicationservice_infos
|
||||||
path = join(self.source_root_path,
|
path = join(self.source_root_path,
|
||||||
|
@ -54,9 +55,13 @@ class Risotto(Controller):
|
||||||
if isdir(path):
|
if isdir(path):
|
||||||
as_names.append(applicationservice_name)
|
as_names.append(applicationservice_name)
|
||||||
for fil in listdir(path):
|
for fil in listdir(path):
|
||||||
with open(join(path, fil), 'r') as fh:
|
if not fil.endswith('.py'):
|
||||||
funcs.write('# {}\n'.format(join(path, fil)))
|
continue
|
||||||
funcs.write(fh.read() + '\n')
|
fil_path = join(path, fil)
|
||||||
|
with open(fil_path, 'rb') as fh:
|
||||||
|
funcs.write(f'# {fil_path}\n'.encode())
|
||||||
|
funcs.write(fh.read())
|
||||||
|
funcs.write(b'\n')
|
||||||
|
|
||||||
as_names_str = '", "'.join(as_names)
|
as_names_str = '", "'.join(as_names)
|
||||||
log.info(_(f'gen funcs for "{servermodel_name}" with application services "{as_names_str}"'))
|
log.info(_(f'gen funcs for "{servermodel_name}" with application services "{as_names_str}"'))
|
||||||
|
@ -68,9 +73,11 @@ class Risotto(Controller):
|
||||||
dependencies: Dict,
|
dependencies: Dict,
|
||||||
release_cache: Dict) -> None:
|
release_cache: Dict) -> None:
|
||||||
paths = []
|
paths = []
|
||||||
as_names = []
|
extras = []
|
||||||
|
as_names = set()
|
||||||
for applicationservice_id, applicationservice_infos in dependencies.items():
|
for applicationservice_id, applicationservice_infos in dependencies.items():
|
||||||
applicationservice_name, as_release_id = applicationservice_infos
|
applicationservice_name, as_release_id = applicationservice_infos
|
||||||
|
# load creole dictionaries
|
||||||
path = join(self.source_root_path,
|
path = join(self.source_root_path,
|
||||||
release_cache[as_release_id]['source_name'],
|
release_cache[as_release_id]['source_name'],
|
||||||
release_cache[as_release_id]['release_name'],
|
release_cache[as_release_id]['release_name'],
|
||||||
|
@ -78,12 +85,29 @@ class Risotto(Controller):
|
||||||
applicationservice_name,
|
applicationservice_name,
|
||||||
'dictionaries')
|
'dictionaries')
|
||||||
if isdir(path):
|
if isdir(path):
|
||||||
as_names.append(applicationservice_name)
|
as_names.add(applicationservice_name)
|
||||||
paths.append(path)
|
paths.append(path)
|
||||||
|
|
||||||
|
# load extra dictionaries
|
||||||
|
path = join(self.source_root_path,
|
||||||
|
release_cache[as_release_id]['source_name'],
|
||||||
|
release_cache[as_release_id]['release_name'],
|
||||||
|
'applicationservice',
|
||||||
|
applicationservice_name,
|
||||||
|
'extras')
|
||||||
|
if isdir(path):
|
||||||
|
for namespace in listdir(path):
|
||||||
|
extra_dir = join(path, namespace)
|
||||||
|
if not isdir(extra_dir):
|
||||||
|
continue
|
||||||
|
as_names.add(applicationservice_name)
|
||||||
|
extras.append((namespace, [extra_dir]))
|
||||||
eolobj = CreoleObjSpace(dtdfilename)
|
eolobj = CreoleObjSpace(dtdfilename)
|
||||||
as_names_str = '", "'.join(as_names)
|
as_names_str = '", "'.join(as_names)
|
||||||
log.info(_(f'gen schema for "{servermodel_name}" with application services "{as_names_str}"'))
|
log.info(_(f'gen schema for "{servermodel_name}" with application services "{as_names_str}"'))
|
||||||
eolobj.create_or_populate_from_xml('creole', paths)
|
eolobj.create_or_populate_from_xml('creole', paths)
|
||||||
|
for extra in extras:
|
||||||
|
eolobj.create_or_populate_from_xml(extra[0], extra[1])
|
||||||
# FIXME extra
|
# FIXME extra
|
||||||
funcs_file = self.get_servermodel_cache(servermodel_id, 'funcs.py')
|
funcs_file = self.get_servermodel_cache(servermodel_id, 'funcs.py')
|
||||||
eolobj.space_visitor(funcs_file)
|
eolobj.space_visitor(funcs_file)
|
||||||
|
|
|
@ -84,11 +84,12 @@ class Risotto(Controller):
|
||||||
|
|
||||||
# check if a session already exists
|
# check if a session already exists
|
||||||
sessions = storage.get_sessions()
|
sessions = storage.get_sessions()
|
||||||
for session in sessions.values():
|
for sess_id, session in sessions.items():
|
||||||
if sess['id'] == id:
|
if session['id'] == id:
|
||||||
if sess['username'] == risotto_context.username:
|
if session['username'] == risotto_context.username:
|
||||||
# same user so returns it
|
# same user so returns it
|
||||||
return self.format_session(session['session_id'], session)
|
return self.format_session(sess_id,
|
||||||
|
session)
|
||||||
else:
|
else:
|
||||||
raise Exception(_(f'{username} already edits this configuration'))
|
raise Exception(_(f'{username} already edits this configuration'))
|
||||||
|
|
||||||
|
@ -157,11 +158,13 @@ class Risotto(Controller):
|
||||||
session_id,
|
session_id,
|
||||||
type)
|
type)
|
||||||
# if multi and not follower the value is in fact in value_multi
|
# if multi and not follower the value is in fact in value_multi
|
||||||
option = session['option'].option(name).option
|
# FIXME option = session['option'].option(name).option
|
||||||
|
option = session['config'].option(name).option
|
||||||
if option.ismulti() and not option.isfollower():
|
if option.ismulti() and not option.isfollower():
|
||||||
value = value_multi
|
value = value_multi
|
||||||
namespace = session['namespace']
|
#FIXME namespace = session['namespace']
|
||||||
update = {'name': f'{namespace}.{name}',
|
#FIXME update = {'name': f'{namespace}.{name}',
|
||||||
|
update = {'name': name,
|
||||||
'action': action,
|
'action': action,
|
||||||
'value': value}
|
'value': value}
|
||||||
if index is not None:
|
if index is not None:
|
||||||
|
@ -196,12 +199,13 @@ class Risotto(Controller):
|
||||||
mandatories = list(config.value.mandatory())
|
mandatories = list(config.value.mandatory())
|
||||||
config.property.read_write()
|
config.property.read_write()
|
||||||
if mandatories:
|
if mandatories:
|
||||||
|
# FIXME mandatories = [mandatory.split('.', 1)[1] for mandatory in mandatories]
|
||||||
if len(mandatories) == 1:
|
if len(mandatories) == 1:
|
||||||
mandatories = mandatories[0]
|
mandatories = mandatories[0]
|
||||||
msg = _('the parameter "--{mandatories}" is mandatory')
|
msg = _(f'the parameter "--{mandatories}" is mandatory')
|
||||||
else:
|
else:
|
||||||
mandatories = '", "--'.join(mandatories)
|
mandatories = '", "--'.join(mandatories)
|
||||||
msg = _('parameters "{mandatories}" are mandatories')
|
msg = _(f'parameters "--{mandatories}" are mandatories')
|
||||||
raise Exception(msg)
|
raise Exception(msg)
|
||||||
return self.format_session(session_id,
|
return self.format_session(session_id,
|
||||||
session)
|
session)
|
||||||
|
@ -219,7 +223,7 @@ class Risotto(Controller):
|
||||||
if name is not None:
|
if name is not None:
|
||||||
info['content'] = {name: session['option'].option(name).value.get()}
|
info['content'] = {name: session['option'].option(name).value.get()}
|
||||||
else:
|
else:
|
||||||
info['content'] = session['option'].value.dict()
|
info['content'] = session['option'].value.dict(fullpath=True)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
@register(['v1.session.server.stop', 'v1.session.servermodel.stop'], None)
|
@register(['v1.session.server.stop', 'v1.session.servermodel.stop'], None)
|
||||||
|
|
|
@ -97,7 +97,7 @@ class Storage(object):
|
||||||
session_id: int,
|
session_id: int,
|
||||||
username: str) -> Dict:
|
username: str) -> Dict:
|
||||||
if session_id not in self.sessions:
|
if session_id not in self.sessions:
|
||||||
raise Exception(f'the session {session_id} not exists')
|
raise Exception(f'the session "{session_id}" not exists')
|
||||||
session = self.sessions[session_id]
|
session = self.sessions[session_id]
|
||||||
if username != session['username']:
|
if username != session['username']:
|
||||||
raise NotAllowedError()
|
raise NotAllowedError()
|
||||||
|
|
Loading…
Reference in New Issue