add setting prefix (name of the module)
This commit is contained in:
parent
5ac9ec72f8
commit
2655e03172
|
@ -1,32 +1,31 @@
|
||||||
MESSAGE_ROOT_PATH = 'messages'
|
|
||||||
INTERNAL_USER = 'internal'
|
|
||||||
CONFIGURATION_DIR = 'configurations'
|
|
||||||
TEMPLATE_DIR = 'templates'
|
|
||||||
TMP_DIR = 'tmp'
|
|
||||||
DEFAULT_USER = 'Anonymous'
|
|
||||||
DEFAULT_DSN = 'postgres:///risotto?host=/var/run/postgresql/&user=risotto'
|
|
||||||
DEFAULT_TIRAMISU_DSN = 'postgres:///tiramisu?host=/var/run/postgresql/&user=tiramisu'
|
|
||||||
|
|
||||||
from os import environ
|
from os import environ
|
||||||
from pathlib import PurePosixPath
|
|
||||||
CURRENT_PATH = PurePosixPath(__file__)
|
|
||||||
|
CONFIGURATION_DIR = 'configurations'
|
||||||
|
TMP_DIR = 'tmp'
|
||||||
|
DEFAULT_USER = environ.get('DEFAULT_USER', 'Anonymous')
|
||||||
|
DEFAULT_DSN = environ.get('RISOTTO_DSN', 'postgres:///risotto?host=/var/run/postgresql/&user=risotto')
|
||||||
|
DEFAULT_TIRAMISU_DSN = environ.get('DEFAULT_TIRAMISU_DSN', 'postgres:///tiramisu?host=/var/run/postgresql/&user=tiramisu')
|
||||||
|
MESSAGE_PATH = environ.get('MESSAGE_PATH', '/root/risotto-message/messages')
|
||||||
|
MODULE_NAME = environ.get('MODULE_NAME', 'test')
|
||||||
|
|
||||||
|
|
||||||
def get_config():
|
def get_config():
|
||||||
return {'database': {'dsn': environ.get('RISOTTO_DSN', DEFAULT_DSN),
|
return {'database': {'dsn': DEFAULT_DSN,
|
||||||
'tiramisu_dsn': environ.get('RISOTTO_TIRAMISU_DSN', DEFAULT_TIRAMISU_DSN),
|
'tiramisu_dsn': DEFAULT_TIRAMISU_DSN,
|
||||||
},
|
},
|
||||||
'http_server': {'port': 8080,
|
'http_server': {'port': 8080,
|
||||||
#'default_user': "gnunux"},
|
|
||||||
'default_user': DEFAULT_USER},
|
'default_user': DEFAULT_USER},
|
||||||
'global': {'message_root_path': CURRENT_PATH.parents[2] / 'messages',
|
'global': {'message_root_path': MESSAGE_PATH,
|
||||||
'debug': True,
|
'debug': True,
|
||||||
'internal_user': 'internal',
|
'internal_user': 'internal',
|
||||||
'check_role': True,
|
'check_role': True,
|
||||||
'admin_user': DEFAULT_USER},
|
'admin_user': DEFAULT_USER,
|
||||||
|
'module_name': MODULE_NAME,
|
||||||
|
'version': 'v1'},
|
||||||
'source': {'root_path': '/srv/seed'},
|
'source': {'root_path': '/srv/seed'},
|
||||||
'cache': {'root_path': '/var/cache/risotto'},
|
'cache': {'root_path': '/var/cache/risotto'},
|
||||||
'servermodel': {'internal_source': 'internal',
|
'servermodel': {'internal_source': 'internal',
|
||||||
'internal_distribution': 'last',
|
'internal_distribution': 'last',
|
||||||
'internal_release_name': 'none'},
|
'internal_release_name': 'none'},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,7 +102,8 @@ async def api(request, risotto_context):
|
||||||
WHERE RoleURI.URIId = URI.URIId
|
WHERE RoleURI.URIId = URI.URIId
|
||||||
'''
|
'''
|
||||||
uris = [uri['uriname'] for uri in await connection.fetch(sql)]
|
uris = [uri['uriname'] for uri in await connection.fetch(sql)]
|
||||||
async with await Config(get_messages(load_shortarg=True, uris=uris)[1]) as config:
|
async with await Config(get_messages(load_shortarg=True,
|
||||||
|
uris=uris)[1]) as config:
|
||||||
await config.property.read_write()
|
await config.property.read_write()
|
||||||
tiramisu = await config.option.dict(remotable='none')
|
tiramisu = await config.option.dict(remotable='none')
|
||||||
return tiramisu
|
return tiramisu
|
||||||
|
|
|
@ -12,7 +12,9 @@ from os.path import isfile
|
||||||
from ..config import get_config
|
from ..config import get_config
|
||||||
from ..utils import _
|
from ..utils import _
|
||||||
|
|
||||||
MESSAGE_ROOT_PATH = get_config().get('global').get('message_root_path')
|
MESSAGE_ROOT_PATH = get_config()['global']['message_root_path']
|
||||||
|
MODULE_NAME = get_config()['global']['module_name']
|
||||||
|
CUSTOMTYPES = {}
|
||||||
|
|
||||||
groups.addgroup('message')
|
groups.addgroup('message')
|
||||||
|
|
||||||
|
@ -56,18 +58,21 @@ class MessageDefinition:
|
||||||
self.errors = []
|
self.errors = []
|
||||||
self.related = []
|
self.related = []
|
||||||
self.response = None
|
self.response = None
|
||||||
|
self.uri = message
|
||||||
|
|
||||||
# loads yaml information into object
|
# loads yaml information into object
|
||||||
for key, value in raw_def.items():
|
for key, value in raw_def.items():
|
||||||
|
if key == 'uri':
|
||||||
|
raise Exception('uri in not allowed in message')
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
if key == 'pattern':
|
if key == 'pattern':
|
||||||
if value not in ['rpc', 'event', 'error']:
|
if value not in ['rpc', 'event']:
|
||||||
raise Exception(_('unknown pattern {}').format(value))
|
raise Exception(_('unknown pattern {}').format(value))
|
||||||
elif key == 'parameters':
|
elif key == 'parameters':
|
||||||
if 'type' in value and isinstance(value['type'], str):
|
if 'type' in value and isinstance(value['type'], str):
|
||||||
# should be a customtype
|
# should be a customtype
|
||||||
value = customtypes[value['type']].properties
|
value = CUSTOMTYPES[value['type']].properties
|
||||||
else:
|
else:
|
||||||
value = _parse_parameters(value)
|
value = _parse_parameters(value)
|
||||||
elif key == 'response':
|
elif key == 'response':
|
||||||
|
@ -81,8 +86,6 @@ class MessageDefinition:
|
||||||
getattr(self, key)
|
getattr(self, key)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
raise Exception(_('mandatory key not set {} message').format(key))
|
raise Exception(_('mandatory key not set {} message').format(key))
|
||||||
if self.uri != message:
|
|
||||||
raise Exception(_(f'yaml file name "{message}.yml" does not match uri "{self.uri}"'))
|
|
||||||
|
|
||||||
|
|
||||||
class ParameterDefinition:
|
class ParameterDefinition:
|
||||||
|
@ -110,11 +113,11 @@ class ParameterDefinition:
|
||||||
tvalue = value[2:]
|
tvalue = value[2:]
|
||||||
else:
|
else:
|
||||||
tvalue = value
|
tvalue = value
|
||||||
if tvalue in customtypes:
|
if tvalue in CUSTOMTYPES:
|
||||||
if value.startswith('[]'):
|
if value.startswith('[]'):
|
||||||
value = '[]{}'.format(customtypes[tvalue].type)
|
value = '[]{}'.format(CUSTOMTYPES[tvalue].type)
|
||||||
else:
|
else:
|
||||||
value = customtypes[value].type
|
value = CUSTOMTYPES[value].type
|
||||||
else:
|
else:
|
||||||
self._valid_type(value)
|
self._valid_type(value)
|
||||||
#self._valid_type(value)
|
#self._valid_type(value)
|
||||||
|
@ -133,6 +136,7 @@ class ParameterDefinition:
|
||||||
elif typ not in ['Boolean', 'String', 'Number', 'File', 'Dict', 'Any']:
|
elif typ not in ['Boolean', 'String', 'Number', 'File', 'Dict', 'Any']:
|
||||||
raise Exception(_('unknown parameter type: {}').format(typ))
|
raise Exception(_('unknown parameter type: {}').format(typ))
|
||||||
|
|
||||||
|
|
||||||
class ResponseDefinition:
|
class ResponseDefinition:
|
||||||
"""
|
"""
|
||||||
An ResponseDefinition is a representation of a response in the Zephir application messaging context
|
An ResponseDefinition is a representation of a response in the Zephir application messaging context
|
||||||
|
@ -158,13 +162,13 @@ class ResponseDefinition:
|
||||||
self.multi = True
|
self.multi = True
|
||||||
else:
|
else:
|
||||||
tvalue = value
|
tvalue = value
|
||||||
if tvalue in customtypes:
|
if tvalue in CUSTOMTYPES:
|
||||||
self.parameters = customtypes[tvalue].properties
|
self.parameters = CUSTOMTYPES[tvalue].properties
|
||||||
self.required = customtypes[tvalue].required
|
self.required = CUSTOMTYPES[tvalue].required
|
||||||
if value.startswith('[]'):
|
if value.startswith('[]'):
|
||||||
value = '[]{}'.format(customtypes[tvalue].type)
|
value = '[]{}'.format(CUSTOMTYPES[tvalue].type)
|
||||||
else:
|
else:
|
||||||
value = customtypes[value].type
|
value = CUSTOMTYPES[value].type
|
||||||
else:
|
else:
|
||||||
self._valid_type(value)
|
self._valid_type(value)
|
||||||
setattr(self, key, value)
|
setattr(self, key, value)
|
||||||
|
@ -209,14 +213,17 @@ def _parse_parameters(raw_defs):
|
||||||
return parameters
|
return parameters
|
||||||
|
|
||||||
|
|
||||||
def parse_definition(filecontent: bytes, message: str):
|
def parse_definition(filecontent: bytes,
|
||||||
|
message: str):
|
||||||
return MessageDefinition(load(filecontent, Loader=SafeLoader), message)
|
return MessageDefinition(load(filecontent, Loader=SafeLoader), message)
|
||||||
|
|
||||||
|
|
||||||
def is_message_defined(uri):
|
def is_message_defined(uri):
|
||||||
version, message = split_message_uri(uri)
|
version, message = split_message_uri(uri)
|
||||||
path = get_message_file_path(version, message)
|
path = get_message_file_path(version, message)
|
||||||
return isfile(path)
|
return isfile(path)
|
||||||
|
|
||||||
|
|
||||||
def get_message(uri):
|
def get_message(uri):
|
||||||
load_customtypes()
|
load_customtypes()
|
||||||
try:
|
try:
|
||||||
|
@ -231,23 +238,30 @@ def get_message(uri):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
raise Exception(_('cannot parse message {}: {}').format(uri, str(err)))
|
raise Exception(_('cannot parse message {}: {}').format(uri, str(err)))
|
||||||
|
|
||||||
|
|
||||||
def split_message_uri(uri):
|
def split_message_uri(uri):
|
||||||
return uri.split('.', 1)
|
return uri.split('.', 1)
|
||||||
|
|
||||||
|
|
||||||
def get_message_file_path(version, message):
|
def get_message_file_path(version, message):
|
||||||
return join(MESSAGE_ROOT_PATH, version, 'messages', message + '.yml')
|
module_name, filename = message.split('.', 1)
|
||||||
|
if module_name != MODULE_NAME:
|
||||||
|
raise Exception(f'should only load message for {MODULE_NAME}, not {message}')
|
||||||
|
return join(MESSAGE_ROOT_PATH, version, MODULE_NAME, 'messages', filename + '.yml')
|
||||||
|
|
||||||
|
|
||||||
def list_messages(uris):
|
def list_messages(uris):
|
||||||
messages = listdir(MESSAGE_ROOT_PATH)
|
versions = listdir(join(MESSAGE_ROOT_PATH))
|
||||||
messages.sort()
|
versions.sort()
|
||||||
for version in messages:
|
for version in versions:
|
||||||
for message in listdir(join(MESSAGE_ROOT_PATH, version, 'messages')):
|
for message in listdir(join(MESSAGE_ROOT_PATH, version, MODULE_NAME, 'messages')):
|
||||||
if message.endswith('.yml'):
|
if message.endswith('.yml'):
|
||||||
uri = version + '.' + message.rsplit('.', 1)[0]
|
uri = version + '.' + MODULE_NAME + '.' + message.rsplit('.', 1)[0]
|
||||||
if uris is not None and uri not in uris:
|
if uris is not None and uri not in uris:
|
||||||
continue
|
continue
|
||||||
yield uri
|
yield uri
|
||||||
|
|
||||||
|
|
||||||
class CustomParam:
|
class CustomParam:
|
||||||
__slots__ = ('name',
|
__slots__ = ('name',
|
||||||
'type',
|
'type',
|
||||||
|
@ -358,25 +372,24 @@ class CustomType:
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
|
||||||
customtypes = {}
|
|
||||||
def load_customtypes():
|
def load_customtypes():
|
||||||
if not customtypes:
|
if not CUSTOMTYPES:
|
||||||
versions = listdir(MESSAGE_ROOT_PATH)
|
versions = listdir(MESSAGE_ROOT_PATH)
|
||||||
versions.sort()
|
versions.sort()
|
||||||
for version in versions:
|
for version in versions:
|
||||||
for message in listdir(join(MESSAGE_ROOT_PATH, version, 'types')):
|
for message in listdir(join(MESSAGE_ROOT_PATH, version, MODULE_NAME, 'types')):
|
||||||
if message.endswith('.yml'):
|
if message.endswith('.yml'):
|
||||||
path = join(MESSAGE_ROOT_PATH, version, 'types', message)
|
path = join(MESSAGE_ROOT_PATH, version, MODULE_NAME, 'types', message)
|
||||||
message = message.rsplit('.', 1)[0]
|
message = message.rsplit('.', 1)[0]
|
||||||
with open(path, "r") as message_file:
|
with open(path, "r") as message_file:
|
||||||
try:
|
try:
|
||||||
ret = CustomType(load(message_file, Loader=SafeLoader))
|
ret = CustomType(load(message_file, Loader=SafeLoader))
|
||||||
customtypes[ret.getname()] = ret
|
CUSTOMTYPES[ret.getname()] = ret
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
raise Exception('{} for {}'.format(err, message))
|
raise Exception('{} for {}'.format(err, message))
|
||||||
for customtype in customtypes.values():
|
for customtype in CUSTOMTYPES.values():
|
||||||
properties = {}
|
properties = {}
|
||||||
for key, value in customtype.properties.items():
|
for key, value in customtype.properties.items():
|
||||||
type_ = value.type
|
type_ = value.type
|
||||||
|
@ -384,10 +397,10 @@ def load_customtypes():
|
||||||
ttype_ = type_[2:]
|
ttype_ = type_[2:]
|
||||||
else:
|
else:
|
||||||
ttype_ = type_
|
ttype_ = type_
|
||||||
if ttype_ in customtypes:
|
if ttype_ in CUSTOMTYPES:
|
||||||
if type_.startswith('[]'):
|
if type_.startswith('[]'):
|
||||||
raise Exception(_('cannot have []CustomType'))
|
raise Exception(_('cannot have []CustomType'))
|
||||||
properties[key] = customtypes[ttype_]
|
properties[key] = CUSTOMTYPES[ttype_]
|
||||||
else:
|
else:
|
||||||
properties[key] = value
|
properties[key] = value
|
||||||
customtype.properties = properties
|
customtype.properties = properties
|
||||||
|
@ -580,26 +593,18 @@ def get_messages(load_shortarg=False,
|
||||||
uris=None):
|
uris=None):
|
||||||
"""generate description from yml files
|
"""generate description from yml files
|
||||||
"""
|
"""
|
||||||
optiondescriptions = OrderedDict()
|
optiondescriptions = {}
|
||||||
optiondescriptions_name = []
|
|
||||||
optiondescriptions_info = {}
|
optiondescriptions_info = {}
|
||||||
needs = OrderedDict()
|
needs = {}
|
||||||
messages = list(list_messages(uris))
|
messages = list(list_messages(uris))
|
||||||
messages.sort()
|
messages.sort()
|
||||||
for message_name in messages:
|
optiondescriptions_name = [message_name.split('.', 1)[1] for message_name in messages]
|
||||||
message_def = get_message(message_name)
|
|
||||||
if message_def.pattern not in ['rpc', 'event']:
|
|
||||||
continue
|
|
||||||
optiondescriptions_name.append(message_def.uri)
|
|
||||||
optiondescriptions_name.sort()
|
|
||||||
select_option = ChoiceOption('message',
|
select_option = ChoiceOption('message',
|
||||||
'Nom du message.',
|
'Nom du message.',
|
||||||
tuple(optiondescriptions_name),
|
tuple(optiondescriptions_name),
|
||||||
properties=frozenset(['mandatory', 'positional']))
|
properties=frozenset(['mandatory', 'positional']))
|
||||||
for message_name in messages:
|
for message_name in messages:
|
||||||
message_def = get_message(message_name)
|
message_def = get_message(message_name)
|
||||||
if message_def.pattern not in ['rpc', 'event']:
|
|
||||||
continue
|
|
||||||
optiondescriptions_info[message_def.uri] = {'pattern': message_def.pattern}
|
optiondescriptions_info[message_def.uri] = {'pattern': message_def.pattern}
|
||||||
if message_def.pattern == 'rpc':
|
if message_def.pattern == 'rpc':
|
||||||
optiondescriptions_info[message_def.uri]['response'] = _parse_responses(message_def,
|
optiondescriptions_info[message_def.uri]['response'] = _parse_responses(message_def,
|
||||||
|
|
|
@ -8,7 +8,7 @@ from .utils import _
|
||||||
from .error import RegistrationError
|
from .error import RegistrationError
|
||||||
from .message import get_messages
|
from .message import get_messages
|
||||||
from .context import Context
|
from .context import Context
|
||||||
from .config import INTERNAL_USER, get_config
|
from .config import get_config
|
||||||
from .logger import log
|
from .logger import log
|
||||||
|
|
||||||
|
|
||||||
|
@ -39,11 +39,11 @@ class RegisterDispatcher:
|
||||||
self.messages = {}
|
self.messages = {}
|
||||||
# load tiramisu objects
|
# load tiramisu objects
|
||||||
messages, self.option = get_messages()
|
messages, self.option = get_messages()
|
||||||
#FIXME
|
version = get_config()['global']['version']
|
||||||
version = 'v1'
|
|
||||||
self.messages[version] = {}
|
self.messages[version] = {}
|
||||||
for tiramisu_message, obj in messages.items():
|
for tiramisu_message, obj in messages.items():
|
||||||
self.messages[version][tiramisu_message] = obj
|
self.messages[version][tiramisu_message] = obj
|
||||||
|
self.risotto_module = get_config()['global']['module_name']
|
||||||
|
|
||||||
def get_function_args(self,
|
def get_function_args(self,
|
||||||
function: Callable):
|
function: Callable):
|
||||||
|
@ -145,6 +145,9 @@ class RegisterDispatcher:
|
||||||
# xxx module can only be register with v1.xxxx..... message
|
# xxx module can only be register with v1.xxxx..... message
|
||||||
module_name = function.__module__.split('.')[-2]
|
module_name = function.__module__.split('.')[-2]
|
||||||
message_namespace = message.split('.', 1)[0]
|
message_namespace = message.split('.', 1)[0]
|
||||||
|
message_risotto_module, message_namespace, message_name = message.split('.', 2)
|
||||||
|
if message_risotto_module != self.risotto_module:
|
||||||
|
raise RegistrationError(_(f'cannot registered the "{message}" is not "{self.risotto_module}"'))
|
||||||
if self.messages[version][message]['pattern'] == 'rpc' and message_namespace != module_name:
|
if self.messages[version][message]['pattern'] == 'rpc' and message_namespace != module_name:
|
||||||
raise RegistrationError(_(f'cannot registered the "{message}" message in module "{module_name}"'))
|
raise RegistrationError(_(f'cannot registered the "{message}" message in module "{module_name}"'))
|
||||||
|
|
||||||
|
@ -221,6 +224,7 @@ class RegisterDispatcher:
|
||||||
raise RegistrationError(_(f'missing uri {missing_messages}'))
|
raise RegistrationError(_(f'missing uri {missing_messages}'))
|
||||||
|
|
||||||
async def on_join(self):
|
async def on_join(self):
|
||||||
|
internal_user = get_config()['global']['internal_user']
|
||||||
async with self.pool.acquire() as connection:
|
async with self.pool.acquire() as connection:
|
||||||
await connection.set_type_codec(
|
await connection.set_type_codec(
|
||||||
'json',
|
'json',
|
||||||
|
@ -231,7 +235,7 @@ class RegisterDispatcher:
|
||||||
async with connection.transaction():
|
async with connection.transaction():
|
||||||
for module_name, module in self.injected_self.items():
|
for module_name, module in self.injected_self.items():
|
||||||
risotto_context = Context()
|
risotto_context = Context()
|
||||||
risotto_context.username = INTERNAL_USER
|
risotto_context.username = internal_user
|
||||||
risotto_context.paths.append(f'{module_name}.on_join')
|
risotto_context.paths.append(f'{module_name}.on_join')
|
||||||
risotto_context.type = None
|
risotto_context.type = None
|
||||||
risotto_context.connection = connection
|
risotto_context.connection = connection
|
||||||
|
|
|
@ -21,11 +21,11 @@ class Risotto(Controller):
|
||||||
|
|
||||||
async def on_join(self,
|
async def on_join(self,
|
||||||
risotto_context: Context) -> None:
|
risotto_context: Context) -> None:
|
||||||
internal_source = await self.call('v1.source.create',
|
internal_source = await self.call('v1.setting.source.create',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=self.internal_source_name,
|
source_name=self.internal_source_name,
|
||||||
source_url='none')
|
source_url='none')
|
||||||
internal_release = await self.call('v1.source.release.create',
|
internal_release = await self.call('v1.setting.source.release.create',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=self.internal_source_name,
|
source_name=self.internal_source_name,
|
||||||
release_name=self.internal_release_name,
|
release_name=self.internal_release_name,
|
||||||
|
@ -65,14 +65,14 @@ class Risotto(Controller):
|
||||||
applicationservice_id,
|
applicationservice_id,
|
||||||
dependency)
|
dependency)
|
||||||
|
|
||||||
@register('v1.applicationservice.dependency.add')
|
@register('v1.setting.applicationservice.dependency.add')
|
||||||
async def applicationservice_dependency_add(self,
|
async def applicationservice_dependency_add(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
applicationservice_name: str,
|
applicationservice_name: str,
|
||||||
applicationservice_dependency: str,
|
applicationservice_dependency: str,
|
||||||
source_name: str,
|
source_name: str,
|
||||||
release_distribution: str) -> Dict:
|
release_distribution: str) -> Dict:
|
||||||
release = await self.call('v1.source.release.describe',
|
release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
release_distribution=release_distribution)
|
release_distribution=release_distribution)
|
||||||
|
@ -92,7 +92,7 @@ class Risotto(Controller):
|
||||||
await self.insert_dependency(risotto_context,
|
await self.insert_dependency(risotto_context,
|
||||||
as_descr['applicationservice_id'],
|
as_descr['applicationservice_id'],
|
||||||
[dependency_descr['applicationservice_id']])
|
[dependency_descr['applicationservice_id']])
|
||||||
await self.publish('v1.applicationservice.updated',
|
await self.publish('v1.setting.applicationservice.updated',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
**as_descr)
|
**as_descr)
|
||||||
await self.updated_related_applicationservice(risotto_context,
|
await self.updated_related_applicationservice(risotto_context,
|
||||||
|
@ -111,7 +111,7 @@ class Risotto(Controller):
|
||||||
dependency_id = dependency['applicationservice_id']
|
dependency_id = dependency['applicationservice_id']
|
||||||
applicationservice = await self._applicationservice_get_by_id(risotto_context,
|
applicationservice = await self._applicationservice_get_by_id(risotto_context,
|
||||||
dependency_id)
|
dependency_id)
|
||||||
await self.publish('v1.applicationservice.updated',
|
await self.publish('v1.setting.applicationservice.updated',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
**applicationservice)
|
**applicationservice)
|
||||||
await self.updated_related_applicationservice(risotto_context,
|
await self.updated_related_applicationservice(risotto_context,
|
||||||
|
@ -133,7 +133,7 @@ class Risotto(Controller):
|
||||||
dependency)
|
dependency)
|
||||||
return dependencies
|
return dependencies
|
||||||
|
|
||||||
@register('v1.applicationservice.create')
|
@register('v1.setting.applicationservice.create')
|
||||||
async def applicationservice_create(self,
|
async def applicationservice_create(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
applicationservice_name: str,
|
applicationservice_name: str,
|
||||||
|
@ -149,12 +149,12 @@ class Risotto(Controller):
|
||||||
applicationservice['applicationservice_dependencies'] = dependencies
|
applicationservice['applicationservice_dependencies'] = dependencies
|
||||||
return applicationservice
|
return applicationservice
|
||||||
|
|
||||||
@register('v1.applicationservice.dataset.updated')
|
@register('v1.setting.applicationservice.dataset.updated')
|
||||||
async def applicationservice_update(self,
|
async def applicationservice_update(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_name: str,
|
source_name: str,
|
||||||
release_distribution: str) -> Dict:
|
release_distribution: str) -> Dict:
|
||||||
release = await self.call('v1.source.release.describe',
|
release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
release_distribution=release_distribution)
|
release_distribution=release_distribution)
|
||||||
|
@ -188,7 +188,7 @@ class Risotto(Controller):
|
||||||
return {'retcode': 0,
|
return {'retcode': 0,
|
||||||
'returns': _('Application Services successfully loaded')}
|
'returns': _('Application Services successfully loaded')}
|
||||||
|
|
||||||
@register('v1.applicationservice.get_by_id')
|
@register('v1.setting.applicationservice.get_by_id')
|
||||||
async def applicationservice_get_by_id(self,
|
async def applicationservice_get_by_id(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
applicationservice_id: int) -> Dict:
|
applicationservice_id: int) -> Dict:
|
||||||
|
@ -228,13 +228,13 @@ class Risotto(Controller):
|
||||||
return dict(applicationservice)
|
return dict(applicationservice)
|
||||||
|
|
||||||
|
|
||||||
@register('v1.applicationservice.describe')
|
@register('v1.setting.applicationservice.describe')
|
||||||
async def applicationservice_describe(self,
|
async def applicationservice_describe(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
applicationservice_name,
|
applicationservice_name,
|
||||||
source_name,
|
source_name,
|
||||||
release_distribution):
|
release_distribution):
|
||||||
release = await self.call('v1.source.release.describe',
|
release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
release_distribution=release_distribution)
|
release_distribution=release_distribution)
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Risotto(Controller):
|
||||||
await log.info_msg(risotto_context,
|
await log.info_msg(risotto_context,
|
||||||
None,
|
None,
|
||||||
'Load servermodels')
|
'Load servermodels')
|
||||||
servermodels = await self.call('v1.servermodel.list',
|
servermodels = await self.call('v1.setting.servermodel.list',
|
||||||
risotto_context)
|
risotto_context)
|
||||||
|
|
||||||
# load each servermodels
|
# load each servermodels
|
||||||
|
@ -179,7 +179,7 @@ class Risotto(Controller):
|
||||||
None,
|
None,
|
||||||
f'Load servers')
|
f'Load servers')
|
||||||
# get all servers
|
# get all servers
|
||||||
servers = await self.call('v1.server.list',
|
servers = await self.call('v1.setting.server.list',
|
||||||
risotto_context)
|
risotto_context)
|
||||||
# loads servers
|
# loads servers
|
||||||
for server in servers:
|
for server in servers:
|
||||||
|
@ -258,7 +258,7 @@ class Risotto(Controller):
|
||||||
await config.property.read_only()
|
await config.property.read_only()
|
||||||
return config
|
return config
|
||||||
|
|
||||||
@register('v1.server.created')
|
@register('v1.setting.server.created')
|
||||||
async def server_created(self,
|
async def server_created(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
server_id: int,
|
server_id: int,
|
||||||
|
@ -273,7 +273,7 @@ class Risotto(Controller):
|
||||||
server_name,
|
server_name,
|
||||||
server_servermodel_id)
|
server_servermodel_id)
|
||||||
|
|
||||||
@register('v1.server.deleted')
|
@register('v1.setting.server.deleted')
|
||||||
async def server_deleted(self,
|
async def server_deleted(self,
|
||||||
server_id: int) -> None:
|
server_id: int) -> None:
|
||||||
for server_type in ['server', 'server_to_deploy']:
|
for server_type in ['server', 'server_to_deploy']:
|
||||||
|
@ -283,7 +283,7 @@ class Risotto(Controller):
|
||||||
await config.session.reset()
|
await config.session.reset()
|
||||||
del self.server[server_id]
|
del self.server[server_id]
|
||||||
|
|
||||||
@register('v1.servermodel.created')
|
@register('v1.setting.servermodel.created')
|
||||||
async def servermodel_created(self,
|
async def servermodel_created(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
servermodel_id: int,
|
servermodel_id: int,
|
||||||
|
@ -324,7 +324,7 @@ class Risotto(Controller):
|
||||||
await parent.config.pop(await mixconfig.session.id())
|
await parent.config.pop(await mixconfig.session.id())
|
||||||
return children
|
return children
|
||||||
|
|
||||||
@register('v1.servermodel.updated')
|
@register('v1.setting.servermodel.updated')
|
||||||
async def servermodel_updated(self,
|
async def servermodel_updated(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
servermodel_id: int,
|
servermodel_id: int,
|
||||||
|
@ -356,12 +356,12 @@ class Risotto(Controller):
|
||||||
else:
|
else:
|
||||||
await self.servermodel[servermodel_id].config.add(child)
|
await self.servermodel[servermodel_id].config.add(child)
|
||||||
|
|
||||||
@register('v1.config.configuration.server.get')
|
@register('v1.setting.config.configuration.server.get')
|
||||||
async def get_configuration(self,
|
async def get_configuration(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
server_name: str,
|
server_name: str,
|
||||||
deployed: bool) -> dict:
|
deployed: bool) -> dict:
|
||||||
server = await self.call('v1.server.describe',
|
server = await self.call('v1.setting.server.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
server_name=server_name)
|
server_name=server_name)
|
||||||
server_id = server['server_id']
|
server_id = server['server_id']
|
||||||
|
@ -394,13 +394,13 @@ class Risotto(Controller):
|
||||||
'deployed': deployed,
|
'deployed': deployed,
|
||||||
'configuration': configuration}
|
'configuration': configuration}
|
||||||
|
|
||||||
@register('v1.config.configuration.server.deploy')
|
@register('v1.setting.config.configuration.server.deploy')
|
||||||
async def deploy_configuration(self,
|
async def deploy_configuration(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
server_name: str) -> Dict:
|
server_name: str) -> Dict:
|
||||||
"""Copy values, permissions, permissives from config 'to deploy' to active config
|
"""Copy values, permissions, permissives from config 'to deploy' to active config
|
||||||
"""
|
"""
|
||||||
server = await self.call('v1.server.describe',
|
server = await self.call('v1.setting.server.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
server_name=server_name)
|
server_name=server_name)
|
||||||
server_id = server['server_id']
|
server_id = server['server_id']
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Risotto(Controller):
|
||||||
test: bool) -> None:
|
test: bool) -> None:
|
||||||
self.internal_source_name = get_config()['servermodel']['internal_source']
|
self.internal_source_name = get_config()['servermodel']['internal_source']
|
||||||
|
|
||||||
@register('v1.server.list')
|
@register('v1.setting.server.list')
|
||||||
async def server_list(self,
|
async def server_list(self,
|
||||||
risotto_context: Context) -> Dict:
|
risotto_context: Context) -> Dict:
|
||||||
sql = '''
|
sql = '''
|
||||||
|
@ -23,7 +23,7 @@ class Risotto(Controller):
|
||||||
servers = await risotto_context.connection.fetch(sql)
|
servers = await risotto_context.connection.fetch(sql)
|
||||||
return [dict(r) for r in servers]
|
return [dict(r) for r in servers]
|
||||||
|
|
||||||
@register('v1.server.create', 'v1.server.created')
|
@register('v1.setting.server.create', 'v1.setting.server.created')
|
||||||
async def server_create(self,
|
async def server_create(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
server_name: str,
|
server_name: str,
|
||||||
|
@ -31,7 +31,7 @@ class Risotto(Controller):
|
||||||
servermodel_name: str,
|
servermodel_name: str,
|
||||||
release_distribution: str) -> Dict:
|
release_distribution: str) -> Dict:
|
||||||
DomainnameOption('server_name', _('Server name'), server_name)
|
DomainnameOption('server_name', _('Server name'), server_name)
|
||||||
servermodel = await self.call('v1.servermodel.describe',
|
servermodel = await self.call('v1.setting.servermodel.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
servermodel_name=servermodel_name,
|
servermodel_name=servermodel_name,
|
||||||
source_name=self.internal_source_name,
|
source_name=self.internal_source_name,
|
||||||
|
@ -44,7 +44,7 @@ class Risotto(Controller):
|
||||||
server_name,
|
server_name,
|
||||||
server_description,
|
server_description,
|
||||||
servermodel['servermodel_id'])
|
servermodel['servermodel_id'])
|
||||||
await self.call('v1.user.role.create',
|
await self.call('v1.setting.user.role.create',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
user_login=risotto_context.username,
|
user_login=risotto_context.username,
|
||||||
role_name='server_rw',
|
role_name='server_rw',
|
||||||
|
@ -55,7 +55,7 @@ class Risotto(Controller):
|
||||||
'server_description': server_description,
|
'server_description': server_description,
|
||||||
'server_servermodel_id': servermodel['servermodel_id']}
|
'server_servermodel_id': servermodel['servermodel_id']}
|
||||||
|
|
||||||
@register('v1.server.describe')
|
@register('v1.setting.server.describe')
|
||||||
async def server_describe(self,
|
async def server_describe(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
server_name: str) -> Dict:
|
server_name: str) -> Dict:
|
||||||
|
|
|
@ -48,14 +48,14 @@ class Generator(Controller):
|
||||||
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')
|
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 dependency in dependencies:
|
for dependency in dependencies:
|
||||||
if dependency not in generate_cache['applicationservice']:
|
if dependency not in generate_cache['applicationservice']:
|
||||||
applicationservice = await self.call('v1.applicationservice.get_by_id',
|
applicationservice = await self.call('v1.setting.applicationservice.get_by_id',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
applicationservice_id=dependency)
|
applicationservice_id=dependency)
|
||||||
generate_cache['applicationservice'][dependency] = (applicationservice['applicationservice_name'],
|
generate_cache['applicationservice'][dependency] = (applicationservice['applicationservice_name'],
|
||||||
applicationservice['applicationservice_release_id'])
|
applicationservice['applicationservice_release_id'])
|
||||||
applicationservice_name, release_id = generate_cache['applicationservice'][dependency]
|
applicationservice_name, release_id = generate_cache['applicationservice'][dependency]
|
||||||
if release_id not in generate_cache['release_id']:
|
if release_id not in generate_cache['release_id']:
|
||||||
release = await self.call('v1.source.release.get_by_id',
|
release = await self.call('v1.setting.source.release.get_by_id',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
release_id=release_id)
|
release_id=release_id)
|
||||||
generate_cache['release_id'][release_id] = (release['source_name'],
|
generate_cache['release_id'][release_id] = (release['source_name'],
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Risotto(Generator):
|
||||||
|
|
||||||
async def on_join(self,
|
async def on_join(self,
|
||||||
risotto_context: Context) -> None:
|
risotto_context: Context) -> None:
|
||||||
internal_release = await self.call('v1.source.release.describe',
|
internal_release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=self.internal_source_name,
|
source_name=self.internal_source_name,
|
||||||
release_distribution=self.internal_distribution_name)
|
release_distribution=self.internal_distribution_name)
|
||||||
|
@ -53,7 +53,7 @@ class Risotto(Generator):
|
||||||
for servermodel_parent in servermodel_parents:
|
for servermodel_parent in servermodel_parents:
|
||||||
servermodel_parents_id.append(servermodel_parent['servermodel_id'])
|
servermodel_parents_id.append(servermodel_parent['servermodel_id'])
|
||||||
dependencies.append(servermodel_parent['servermodel_applicationservice_id'])
|
dependencies.append(servermodel_parent['servermodel_applicationservice_id'])
|
||||||
applicationservice = await self.call('v1.applicationservice.create',
|
applicationservice = await self.call('v1.setting.applicationservice.create',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
applicationservice_name=as_name,
|
applicationservice_name=as_name,
|
||||||
applicationservice_description=as_description,
|
applicationservice_description=as_description,
|
||||||
|
@ -79,7 +79,7 @@ class Risotto(Generator):
|
||||||
# for as_release_id in dependencies.values():
|
# for as_release_id in dependencies.values():
|
||||||
# applicationservice_name, as_release_id = applicationservice_infos
|
# applicationservice_name, as_release_id = applicationservice_infos
|
||||||
# if as_release_id not in release_cache:
|
# if as_release_id not in release_cache:
|
||||||
# release_cache[as_release_id] = await self.call('v1.source.release.get_by_id',
|
# release_cache[as_release_id] = await self.call('v1.setting.source.release.get_by_id',
|
||||||
# risotto_context,
|
# risotto_context,
|
||||||
# release_id=as_release_id)
|
# release_id=as_release_id)
|
||||||
await self.generate(risotto_context,
|
await self.generate(risotto_context,
|
||||||
|
@ -107,7 +107,7 @@ class Risotto(Generator):
|
||||||
self.parse_parents(servermodels, servermodels[parent], parents)
|
self.parse_parents(servermodels, servermodels[parent], parents)
|
||||||
return parents
|
return parents
|
||||||
|
|
||||||
@register('v1.applicationservice.updated')
|
@register('v1.setting.applicationservice.updated')
|
||||||
async def applicationservice_updated(self,
|
async def applicationservice_updated(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
applicationservice_id):
|
applicationservice_id):
|
||||||
|
@ -123,7 +123,7 @@ class Risotto(Generator):
|
||||||
servermodel_name = servermodel['servermodel_name']
|
servermodel_name = servermodel['servermodel_name']
|
||||||
servermodel_id = servermodel['servermodel_id']
|
servermodel_id = servermodel['servermodel_id']
|
||||||
release_id = servermodel['release_id']
|
release_id = servermodel['release_id']
|
||||||
applicationservice = await self.call('v1.applicationservice.get_by_id',
|
applicationservice = await self.call('v1.setting.applicationservice.get_by_id',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
applicationservice_id=applicationservice_id)
|
applicationservice_id=applicationservice_id)
|
||||||
dependencies = applicationservice['applicationservice_dependencies']
|
dependencies = applicationservice['applicationservice_dependencies']
|
||||||
|
@ -132,16 +132,16 @@ class Risotto(Generator):
|
||||||
servermodel_id,
|
servermodel_id,
|
||||||
dependencies,
|
dependencies,
|
||||||
None)
|
None)
|
||||||
await self.publish('v1.servermodel.updated',
|
await self.publish('v1.setting.servermodel.updated',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
**servermodel)
|
**servermodel)
|
||||||
|
|
||||||
@register('v1.servermodel.dataset.updated')
|
@register('v1.setting.servermodel.dataset.updated')
|
||||||
async def servermodel_dataset_updated(self,
|
async def servermodel_dataset_updated(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_name: str,
|
source_name: str,
|
||||||
release_distribution: int):
|
release_distribution: int):
|
||||||
release = await self.call('v1.source.release.describe',
|
release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
release_distribution=release_distribution)
|
release_distribution=release_distribution)
|
||||||
|
@ -189,7 +189,7 @@ class Risotto(Generator):
|
||||||
# link application service with this servermodel
|
# link application service with this servermodel
|
||||||
dependencies = []
|
dependencies = []
|
||||||
for depend in servermodels[new_servermodel]['applicationservices']:
|
for depend in servermodels[new_servermodel]['applicationservices']:
|
||||||
applicationservice = await self.call('v1.applicationservice.describe',
|
applicationservice = await self.call('v1.setting.applicationservice.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
applicationservice_name=depend,
|
applicationservice_name=depend,
|
||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
|
@ -205,7 +205,7 @@ class Risotto(Generator):
|
||||||
dependencies,
|
dependencies,
|
||||||
release_id,
|
release_id,
|
||||||
generate_cache)
|
generate_cache)
|
||||||
await self.publish('v1.servermodel.created',
|
await self.publish('v1.setting.servermodel.created',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
**servermodel_ob)
|
**servermodel_ob)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -216,7 +216,7 @@ class Risotto(Generator):
|
||||||
servermodel_description['done'] = True
|
servermodel_description['done'] = True
|
||||||
return {'retcode': 0, 'returns': _('Servermodels successfully loaded')}
|
return {'retcode': 0, 'returns': _('Servermodels successfully loaded')}
|
||||||
|
|
||||||
@register('v1.servermodel.list')
|
@register('v1.setting.servermodel.list')
|
||||||
async def servermodel_list(self,
|
async def servermodel_list(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_id: int):
|
source_id: int):
|
||||||
|
@ -227,13 +227,13 @@ class Risotto(Generator):
|
||||||
servermodels = await risotto_context.connection.fetch(sql)
|
servermodels = await risotto_context.connection.fetch(sql)
|
||||||
return [dict(r) for r in servermodels]
|
return [dict(r) for r in servermodels]
|
||||||
|
|
||||||
@register('v1.servermodel.describe')
|
@register('v1.setting.servermodel.describe')
|
||||||
async def servermodel_describe(self,
|
async def servermodel_describe(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
servermodel_name,
|
servermodel_name,
|
||||||
source_name,
|
source_name,
|
||||||
release_distribution) -> Dict:
|
release_distribution) -> Dict:
|
||||||
release = await self.call('v1.source.release.describe',
|
release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=source_name,
|
source_name=source_name,
|
||||||
release_distribution=release_distribution)
|
release_distribution=release_distribution)
|
||||||
|
@ -261,7 +261,7 @@ class Risotto(Generator):
|
||||||
raise Exception(_(f'"{servermodel_name}" is not a valid name for a servermodel in source "{source_name}" and release "{release_distribution}"'))
|
raise Exception(_(f'"{servermodel_name}" is not a valid name for a servermodel in source "{source_name}" and release "{release_distribution}"'))
|
||||||
return dict(servermodel)
|
return dict(servermodel)
|
||||||
|
|
||||||
@register('v1.servermodel.create', notification='v1.servermodel.created')
|
@register('v1.setting.servermodel.create', notification='v1.setting.servermodel.created')
|
||||||
async def create_servermodel(self,
|
async def create_servermodel(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
servermodel_name: str,
|
servermodel_name: str,
|
||||||
|
@ -269,7 +269,7 @@ class Risotto(Generator):
|
||||||
servermodel_parents_name: List[int],
|
servermodel_parents_name: List[int],
|
||||||
servermodel_parents_source_name: str,
|
servermodel_parents_source_name: str,
|
||||||
servermodel_parents_release_distribution: str) -> Dict:
|
servermodel_parents_release_distribution: str) -> Dict:
|
||||||
release = await self.call('v1.source.release.describe',
|
release = await self.call('v1.setting.source.release.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name=servermodel_parents_source_name,
|
source_name=servermodel_parents_source_name,
|
||||||
release_distribution=servermodel_parents_release_distribution)
|
release_distribution=servermodel_parents_release_distribution)
|
||||||
|
|
|
@ -66,14 +66,14 @@ class Risotto(Controller):
|
||||||
'mode': session['mode'],
|
'mode': session['mode'],
|
||||||
'debug': session['debug']}
|
'debug': session['debug']}
|
||||||
|
|
||||||
@register('v1.session.server.start')
|
@register('v1.setting.session.server.start')
|
||||||
async def start_session_server(self,
|
async def start_session_server(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
server_name: str) -> Dict:
|
server_name: str) -> Dict:
|
||||||
""" start a new config session for a server
|
""" start a new config session for a server
|
||||||
"""
|
"""
|
||||||
config_module = dispatcher.get_service('config')
|
config_module = dispatcher.get_service('config')
|
||||||
server = await self.call('v1.server.describe',
|
server = await self.call('v1.setting.server.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
server_name=server_name)
|
server_name=server_name)
|
||||||
if not server or server['server_id'] not in config_module.server:
|
if not server or server['server_id'] not in config_module.server:
|
||||||
|
@ -110,14 +110,14 @@ class Risotto(Controller):
|
||||||
session_id,
|
session_id,
|
||||||
'server')
|
'server')
|
||||||
|
|
||||||
@register('v1.session.servermodel.start')
|
@register('v1.setting.session.servermodel.start')
|
||||||
async def start_session_servermodel(self,
|
async def start_session_servermodel(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
servermodel_name: str) -> Dict:
|
servermodel_name: str) -> Dict:
|
||||||
""" start a new config session for a server or a servermodel
|
""" start a new config session for a server or a servermodel
|
||||||
"""
|
"""
|
||||||
config_module = dispatcher.get_service('config')
|
config_module = dispatcher.get_service('config')
|
||||||
servermodel = await self.call('v1.servermodel.describe',
|
servermodel = await self.call('v1.setting.servermodel.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
servermodel_name=servermodel_name,
|
servermodel_name=servermodel_name,
|
||||||
source_name=self.internal_source_name,
|
source_name=self.internal_source_name,
|
||||||
|
@ -156,7 +156,7 @@ class Risotto(Controller):
|
||||||
session_id,
|
session_id,
|
||||||
'servermodel')
|
'servermodel')
|
||||||
|
|
||||||
@register(['v1.session.server.list', 'v1.session.servermodel.list'])
|
@register(['v1.setting.session.server.list', 'v1.setting.session.servermodel.list'])
|
||||||
async def list_session_server(self,
|
async def list_session_server(self,
|
||||||
risotto_context: Context) -> Dict:
|
risotto_context: Context) -> Dict:
|
||||||
type = risotto_context.message.rsplit('.', 2)[-2]
|
type = risotto_context.message.rsplit('.', 2)[-2]
|
||||||
|
@ -164,7 +164,7 @@ class Risotto(Controller):
|
||||||
return [self.format_session(session_id, session) for session_id, session in storage.get_sessions().items()]
|
return [self.format_session(session_id, session) for session_id, session in storage.get_sessions().items()]
|
||||||
|
|
||||||
|
|
||||||
@register(['v1.session.server.filter', 'v1.session.servermodel.filter'])
|
@register(['v1.setting.session.server.filter', 'v1.setting.session.servermodel.filter'])
|
||||||
async def filter_session(self,
|
async def filter_session(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
session_id: str,
|
session_id: str,
|
||||||
|
@ -191,7 +191,7 @@ class Risotto(Controller):
|
||||||
session_id,
|
session_id,
|
||||||
type)
|
type)
|
||||||
|
|
||||||
@register(['v1.session.server.configure', 'v1.session.servermodel.configure'])
|
@register(['v1.setting.session.server.configure', 'v1.setting.session.servermodel.configure'])
|
||||||
async def configure_session(self,
|
async def configure_session(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
session_id: str,
|
session_id: str,
|
||||||
|
@ -228,7 +228,7 @@ class Risotto(Controller):
|
||||||
ret['index'] = index
|
ret['index'] = index
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@register(['v1.session.server.validate', 'v1.session.servermodel.validate'])
|
@register(['v1.setting.session.server.validate', 'v1.setting.session.servermodel.validate'])
|
||||||
async def validate_session(self,
|
async def validate_session(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
session_id: str) -> Dict:
|
session_id: str) -> Dict:
|
||||||
|
@ -257,7 +257,7 @@ class Risotto(Controller):
|
||||||
return self.format_session(session_id,
|
return self.format_session(session_id,
|
||||||
session)
|
session)
|
||||||
|
|
||||||
@register(['v1.session.server.get', 'v1.session.servermodel.get'])
|
@register(['v1.setting.session.server.get', 'v1.setting.session.servermodel.get'])
|
||||||
async def get_session_server(self,
|
async def get_session_server(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
session_id: str,
|
session_id: str,
|
||||||
|
@ -275,7 +275,7 @@ class Risotto(Controller):
|
||||||
info['content'] = content
|
info['content'] = content
|
||||||
return info
|
return info
|
||||||
|
|
||||||
@register(['v1.session.server.stop', 'v1.session.servermodel.stop'])
|
@register(['v1.setting.session.server.stop', 'v1.setting.session.servermodel.stop'])
|
||||||
async def stop_session(self,
|
async def stop_session(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
session_id: str,
|
session_id: str,
|
||||||
|
|
|
@ -10,7 +10,7 @@ from ...config import get_config
|
||||||
|
|
||||||
|
|
||||||
class Risotto(Controller):
|
class Risotto(Controller):
|
||||||
@register('v1.source.create')
|
@register('v1.setting.source.create')
|
||||||
async def source_create(self,
|
async def source_create(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_name: str,
|
source_name: str,
|
||||||
|
@ -43,7 +43,7 @@ class Risotto(Controller):
|
||||||
'source_url': source_url,
|
'source_url': source_url,
|
||||||
'source_id': source_id}
|
'source_id': source_id}
|
||||||
|
|
||||||
@register('v1.source.describe')
|
@register('v1.setting.source.describe')
|
||||||
async def source_describe(self,
|
async def source_describe(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_name: str) -> Dict:
|
source_name: str) -> Dict:
|
||||||
|
@ -57,7 +57,7 @@ class Risotto(Controller):
|
||||||
raise Exception(_(f'unknown source with name {source_name}'))
|
raise Exception(_(f'unknown source with name {source_name}'))
|
||||||
return dict(source)
|
return dict(source)
|
||||||
|
|
||||||
@register('v1.source.list')
|
@register('v1.setting.source.list')
|
||||||
async def source_list(self,
|
async def source_list(self,
|
||||||
risotto_context: Context) -> List[Dict]:
|
risotto_context: Context) -> List[Dict]:
|
||||||
source_list = """SELECT SourceId as source_id, SourceName as source_name, SourceURL as source_url
|
source_list = """SELECT SourceId as source_id, SourceName as source_name, SourceURL as source_url
|
||||||
|
@ -66,7 +66,7 @@ class Risotto(Controller):
|
||||||
result = await risotto_context.connection.fetch(source_list)
|
result = await risotto_context.connection.fetch(source_list)
|
||||||
return [dict(r) for r in result]
|
return [dict(r) for r in result]
|
||||||
|
|
||||||
@register('v1.source.dataset.update')
|
@register('v1.setting.source.dataset.update')
|
||||||
async def version_update(self,
|
async def version_update(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_id: int,
|
source_id: int,
|
||||||
|
@ -81,7 +81,7 @@ class Risotto(Controller):
|
||||||
return {'release_id': release_id,
|
return {'release_id': release_id,
|
||||||
'release_name': release_name}
|
'release_name': release_name}
|
||||||
|
|
||||||
@register('v1.source.release.create')
|
@register('v1.setting.source.release.create')
|
||||||
async def source_release_create(self,
|
async def source_release_create(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
source_name: str,
|
source_name: str,
|
||||||
|
@ -110,7 +110,7 @@ class Risotto(Controller):
|
||||||
source['release_distribution'] = release_distribution
|
source['release_distribution'] = release_distribution
|
||||||
return source
|
return source
|
||||||
|
|
||||||
@register('v1.source.release.list')
|
@register('v1.setting.source.release.list')
|
||||||
async def release_list(self,
|
async def release_list(self,
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name: str) -> Dict:
|
source_name: str) -> Dict:
|
||||||
|
@ -121,7 +121,7 @@ class Risotto(Controller):
|
||||||
source_name)
|
source_name)
|
||||||
return [dict(r) for r in result]
|
return [dict(r) for r in result]
|
||||||
|
|
||||||
@register('v1.source.release.describe')
|
@register('v1.setting.source.release.describe')
|
||||||
async def release_describe(self,
|
async def release_describe(self,
|
||||||
risotto_context,
|
risotto_context,
|
||||||
source_name: str,
|
source_name: str,
|
||||||
|
@ -136,7 +136,7 @@ class Risotto(Controller):
|
||||||
raise Exception(_(f'unknown release distribution {release_distribution} in source {source_name}'))
|
raise Exception(_(f'unknown release distribution {release_distribution} in source {source_name}'))
|
||||||
return dict(result)
|
return dict(result)
|
||||||
|
|
||||||
@register('v1.source.release.get_by_id')
|
@register('v1.setting.source.release.get_by_id')
|
||||||
async def release_get_by_id(self,
|
async def release_get_by_id(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
release_id: int) -> Dict:
|
release_id: int) -> Dict:
|
||||||
|
|
|
@ -17,12 +17,12 @@ class Risotto(Controller):
|
||||||
self.storage = Storage(engine='dictionary')
|
self.storage = Storage(engine='dictionary')
|
||||||
self.cache_root_path = join(get_config().get('cache').get('root_path'), 'servermodel')
|
self.cache_root_path = join(get_config().get('cache').get('root_path'), 'servermodel')
|
||||||
|
|
||||||
@register('v1.template.generate')
|
@register('v1.setting.template.generate')
|
||||||
async def template_get(self,
|
async def template_get(self,
|
||||||
risotto_context,
|
risotto_context,
|
||||||
server_name: str) -> Dict:
|
server_name: str) -> Dict:
|
||||||
# get informations for server
|
# get informations for server
|
||||||
server = await self.call('v1.server.describe',
|
server = await self.call('v1.setting.server.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
server_name=server_name)
|
server_name=server_name)
|
||||||
server_id = server['server_id']
|
server_id = server['server_id']
|
||||||
|
|
|
@ -9,63 +9,63 @@ from ...utils import _
|
||||||
class Risotto(Controller):
|
class Risotto(Controller):
|
||||||
async def on_join(self,
|
async def on_join(self,
|
||||||
risotto_context):
|
risotto_context):
|
||||||
for uri in ['v1.applicationservice.create',
|
for uri in ['v1.setting.applicationservice.create',
|
||||||
'v1.applicationservice.dataset.updated',
|
'v1.setting.applicationservice.dataset.updated',
|
||||||
'v1.applicationservice.dependency.add',
|
'v1.setting.applicationservice.dependency.add',
|
||||||
'v1.server.create',
|
'v1.setting.server.create',
|
||||||
'v1.servermodel.create',
|
'v1.setting.servermodel.create',
|
||||||
'v1.servermodel.dataset.updated',
|
'v1.setting.servermodel.dataset.updated',
|
||||||
'v1.session.server.start',
|
'v1.setting.session.server.start',
|
||||||
'v1.source.create',
|
'v1.setting.source.create',
|
||||||
'v1.source.dataset.update',
|
'v1.setting.source.dataset.update',
|
||||||
'v1.source.release.create',
|
'v1.setting.source.release.create',
|
||||||
'v1.template.generate',
|
'v1.setting.template.generate',
|
||||||
'v1.uri.role.join',
|
'v1.setting.uri.role.join',
|
||||||
'v1.uri.role.list',
|
'v1.setting.uri.role.list',
|
||||||
'v1.user.create',
|
'v1.setting.user.create',
|
||||||
'v1.user.delete',
|
'v1.setting.user.delete',
|
||||||
'v1.user.list',
|
'v1.setting.user.list',
|
||||||
'v1.user.role.create',
|
'v1.setting.user.role.create',
|
||||||
'v1.config.configuration.server.get',
|
'v1.setting.config.configuration.server.get',
|
||||||
'v1.user.role.list']:
|
'v1.setting.user.role.list']:
|
||||||
try:
|
try:
|
||||||
await self._uri_role_join(risotto_context,
|
await self._uri_role_join(risotto_context,
|
||||||
role_name='administrator',
|
role_name='administrator',
|
||||||
uri_name=uri)
|
uri_name=uri)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
for uri in ['v1.applicationservice.describe',
|
for uri in ['v1.setting.applicationservice.describe',
|
||||||
'v1.server.describe',
|
'v1.setting.server.describe',
|
||||||
'v1.server.list',
|
'v1.setting.server.list',
|
||||||
'v1.servermodel.list',
|
'v1.setting.servermodel.list',
|
||||||
'v1.session.server.configure',
|
'v1.setting.session.server.configure',
|
||||||
'v1.session.server.filter',
|
'v1.setting.session.server.filter',
|
||||||
'v1.session.server.get',
|
'v1.setting.session.server.get',
|
||||||
'v1.session.server.list',
|
'v1.setting.session.server.list',
|
||||||
'v1.session.servermodel.configure',
|
'v1.setting.session.servermodel.configure',
|
||||||
'v1.session.servermodel.filter',
|
'v1.setting.session.servermodel.filter',
|
||||||
'v1.session.servermodel.get',
|
'v1.setting.session.servermodel.get',
|
||||||
'v1.session.servermodel.list',
|
'v1.setting.session.servermodel.list',
|
||||||
'v1.session.servermodel.start',
|
'v1.setting.session.servermodel.start',
|
||||||
'v1.session.servermodel.stop',
|
'v1.setting.session.servermodel.stop',
|
||||||
'v1.session.servermodel.validate',
|
'v1.setting.session.servermodel.validate',
|
||||||
'v1.session.server.stop',
|
'v1.setting.session.server.stop',
|
||||||
'v1.session.server.validate',
|
'v1.setting.session.server.validate',
|
||||||
'v1.source.describe',
|
'v1.setting.source.describe',
|
||||||
'v1.source.list',
|
'v1.setting.source.list',
|
||||||
'v1.source.release.list']:
|
'v1.setting.source.release.list']:
|
||||||
try:
|
try:
|
||||||
await self._uri_role_join(risotto_context,
|
await self._uri_role_join(risotto_context,
|
||||||
role_name='all',
|
role_name='all',
|
||||||
uri_name=uri)
|
uri_name=uri)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
for uri in ['v1.server.describe',
|
for uri in ['v1.setting.server.describe',
|
||||||
'v1.applicationservice.dependency.add',
|
'v1.setting.applicationservice.dependency.add',
|
||||||
'v1.config.configuration.server.get',
|
'v1.setting.config.configuration.server.get',
|
||||||
'v1.config.configuration.server.deploy',
|
'v1.setting.config.configuration.server.deploy',
|
||||||
'v1.session.server.start',
|
'v1.setting.session.server.start',
|
||||||
'v1.template.generate']:
|
'v1.setting.template.generate']:
|
||||||
try:
|
try:
|
||||||
await self._uri_role_join(risotto_context,
|
await self._uri_role_join(risotto_context,
|
||||||
role_name='server_rw',
|
role_name='server_rw',
|
||||||
|
@ -73,7 +73,7 @@ class Risotto(Controller):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@register('v1.uri.role.join')
|
@register('v1.setting.uri.role.join')
|
||||||
async def uri_role_join(self,
|
async def uri_role_join(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
role_name: str,
|
role_name: str,
|
||||||
|
@ -106,7 +106,7 @@ class Risotto(Controller):
|
||||||
return {'role_name': role_name,
|
return {'role_name': role_name,
|
||||||
'uri_name': uri_name}
|
'uri_name': uri_name}
|
||||||
|
|
||||||
@register('v1.uri.role.list')
|
@register('v1.setting.uri.role.list')
|
||||||
async def uri_role_list(self,
|
async def uri_role_list(self,
|
||||||
risotto_context: Context) -> List[Dict]:
|
risotto_context: Context) -> List[Dict]:
|
||||||
sql = '''
|
sql = '''
|
||||||
|
|
|
@ -43,7 +43,7 @@ class Risotto(Controller):
|
||||||
user_login,
|
user_login,
|
||||||
user_name,
|
user_name,
|
||||||
user_surname)
|
user_surname)
|
||||||
await self.call('v1.user.role.create',
|
await self.call('v1.setting.user.role.create',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
user_login=user_login,
|
user_login=user_login,
|
||||||
role_name='all')
|
role_name='all')
|
||||||
|
@ -52,7 +52,7 @@ class Risotto(Controller):
|
||||||
'user_name': user_name,
|
'user_name': user_name,
|
||||||
'user_surname': user_surname}
|
'user_surname': user_surname}
|
||||||
|
|
||||||
@register('v1.user.create')
|
@register('v1.setting.user.create')
|
||||||
async def user_create(self,
|
async def user_create(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
user_login: str,
|
user_login: str,
|
||||||
|
@ -63,7 +63,7 @@ class Risotto(Controller):
|
||||||
user_name,
|
user_name,
|
||||||
user_surname)
|
user_surname)
|
||||||
|
|
||||||
@register('v1.user.list')
|
@register('v1.setting.user.list')
|
||||||
async def user_list(self,
|
async def user_list(self,
|
||||||
risotto_context: Context) -> Dict:
|
risotto_context: Context) -> Dict:
|
||||||
sql = '''
|
sql = '''
|
||||||
|
@ -73,7 +73,7 @@ class Risotto(Controller):
|
||||||
users = await risotto_context.connection.fetch(sql)
|
users = await risotto_context.connection.fetch(sql)
|
||||||
return [dict(r) for r in users]
|
return [dict(r) for r in users]
|
||||||
|
|
||||||
@register('v1.user.delete')
|
@register('v1.setting.user.delete')
|
||||||
async def user_delete(self,
|
async def user_delete(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
user_login: str) -> Dict:
|
user_login: str) -> Dict:
|
||||||
|
@ -138,7 +138,7 @@ class Risotto(Controller):
|
||||||
'role_attribute': role_attribute,
|
'role_attribute': role_attribute,
|
||||||
'role_attribute_value': role_attribute_value}
|
'role_attribute_value': role_attribute_value}
|
||||||
|
|
||||||
@register('v1.user.role.create')
|
@register('v1.setting.user.role.create')
|
||||||
async def user_role_create(self,
|
async def user_role_create(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
user_login: str,
|
user_login: str,
|
||||||
|
@ -151,7 +151,7 @@ class Risotto(Controller):
|
||||||
role_attribute,
|
role_attribute,
|
||||||
role_attribute_value)
|
role_attribute_value)
|
||||||
|
|
||||||
@register('v1.user.role.list')
|
@register('v1.setting.user.role.list')
|
||||||
async def user_role_list(self,
|
async def user_role_list(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
user_login: Optional[str]) -> Dict:
|
user_login: Optional[str]) -> Dict:
|
||||||
|
@ -183,7 +183,7 @@ class Risotto(Controller):
|
||||||
return [dict(r) for r in roles]
|
return [dict(r) for r in roles]
|
||||||
#
|
#
|
||||||
# FIXME comment savoir quel role il faut supprimer ? avec attribut ou juste l'ID ?
|
# FIXME comment savoir quel role il faut supprimer ? avec attribut ou juste l'ID ?
|
||||||
# @register('v1.user.role.delete')
|
# @register('v1.setting.user.role.delete')
|
||||||
# async def user_role_delete(self,
|
# async def user_role_delete(self,
|
||||||
# risotto_context: Context,
|
# risotto_context: Context,
|
||||||
# user_login: str,
|
# user_login: str,
|
||||||
|
|
Loading…
Reference in New Issue