Compare commits
4 Commits
9741669487
...
pkg/dev/ri
Author | SHA1 | Date | |
---|---|---|---|
40eff91684 | |||
46ea792c5e | |||
5708cb1ea9 | |||
664a2404fa |
13
README.md
13
README.md
@ -36,12 +36,19 @@ Chacun de ces services documente la structure de la table mais ne se charge pas
|
|||||||
La création de la table, selon le schéma fournit dans la documentation, est à la charge de l’administrateur du système.
|
La création de la table, selon le schéma fournit dans la documentation, est à la charge de l’administrateur du système.
|
||||||
|
|
||||||
# Empty database:
|
# Empty database:
|
||||||
su - postgres
|
|
||||||
psql -U postgres risotto
|
|
||||||
drop table log; drop table userrole; drop table release; drop table source; drop table server; drop table servermodel; drop table applicationservice; drop table roleuri; drop table risottouser; drop table uri;
|
|
||||||
|
|
||||||
|
````
|
||||||
|
psql -U postgres
|
||||||
|
drop database risotto;
|
||||||
|
drop user risotto;
|
||||||
|
\q
|
||||||
|
reconfigure
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
psql -U postgres tiramisu
|
psql -U postgres tiramisu
|
||||||
drop table value; drop table property; drop table permissive; drop table information; drop table session;
|
drop table value; drop table property; drop table permissive; drop table information; drop table session;
|
||||||
|
```
|
||||||
|
|
||||||
# Import EOLE
|
# Import EOLE
|
||||||
./script/cucchiaiata source.create -n eole -u http://localhost
|
./script/cucchiaiata source.create -n eole -u http://localhost
|
||||||
|
2
debian/control
vendored
2
debian/control
vendored
@ -9,6 +9,6 @@ Homepage: https://forge.cadoles.com/Infra/risotto
|
|||||||
Package: risotto
|
Package: risotto
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Pre-Depends: dpkg, python3, ${misc:Pre-Depends}
|
Pre-Depends: dpkg, python3, ${misc:Pre-Depends}
|
||||||
Depends: ${python:Depends}, ${misc:Depends}
|
Depends: ${python:Depends}, ${misc:Depends}, python3-asyncpg
|
||||||
Description: configuration manager
|
Description: configuration manager
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ from os import environ
|
|||||||
|
|
||||||
CONFIGURATION_DIR = environ.get('CONFIGURATION_DIR', '/srv/risotto/configurations')
|
CONFIGURATION_DIR = environ.get('CONFIGURATION_DIR', '/srv/risotto/configurations')
|
||||||
PROVIDER_FACTORY_CONFIG_DIR = environ.get('PROVIDER_FACTORY_CONFIG_DIR', '/srv/factory')
|
PROVIDER_FACTORY_CONFIG_DIR = environ.get('PROVIDER_FACTORY_CONFIG_DIR', '/srv/factory')
|
||||||
TMP_DIR = 'tmp'
|
TMP_DIR = '/tmp'
|
||||||
DEFAULT_USER = environ.get('DEFAULT_USER', 'Anonymous')
|
DEFAULT_USER = environ.get('DEFAULT_USER', 'Anonymous')
|
||||||
RISOTTO_DB_NAME = environ.get('RISOTTO_DB_NAME', 'risotto')
|
RISOTTO_DB_NAME = environ.get('RISOTTO_DB_NAME', 'risotto')
|
||||||
RISOTTO_DB_PASSWORD = environ.get('RISOTTO_DB_PASSWORD', 'risotto')
|
RISOTTO_DB_PASSWORD = environ.get('RISOTTO_DB_PASSWORD', 'risotto')
|
||||||
@ -15,11 +15,10 @@ DB_ADDRESS = environ.get('DB_ADDRESS', 'localhost')
|
|||||||
MESSAGE_PATH = environ.get('MESSAGE_PATH', '/root/risotto-message/messages')
|
MESSAGE_PATH = environ.get('MESSAGE_PATH', '/root/risotto-message/messages')
|
||||||
SQL_DIR = environ.get('SQL_DIR', './sql')
|
SQL_DIR = environ.get('SQL_DIR', './sql')
|
||||||
CACHE_ROOT_PATH = environ.get('CACHE_ROOT_PATH', '/var/cache/risotto')
|
CACHE_ROOT_PATH = environ.get('CACHE_ROOT_PATH', '/var/cache/risotto')
|
||||||
SRV_SEED_PATH = environ.get('SRV_SEED_PATH', '/srv/seed')
|
|
||||||
|
|
||||||
|
|
||||||
def dsn_factory(database, user, password, address=DB_ADDRESS):
|
def dsn_factory(database, user, password, address=DB_ADDRESS):
|
||||||
mangled_address = '/var/run/postgresql' if address == 'localhost' else address
|
mangled_address = '/var/run/postgresql' if address == 'localhost' else address
|
||||||
return f'postgres:///{database}?host={mangled_address}/&user={user}&password={password}'
|
return f'postgres:///{database}?host={mangled_address}/&user={user}&password={password}'
|
||||||
|
|
||||||
|
|
||||||
@ -36,7 +35,6 @@ def get_config():
|
|||||||
'check_role': True,
|
'check_role': True,
|
||||||
'admin_user': DEFAULT_USER,
|
'admin_user': DEFAULT_USER,
|
||||||
'sql_dir': SQL_DIR},
|
'sql_dir': SQL_DIR},
|
||||||
'source': {'root_path': SRV_SEED_PATH},
|
|
||||||
'cache': {'root_path': CACHE_ROOT_PATH},
|
'cache': {'root_path': CACHE_ROOT_PATH},
|
||||||
'servermodel': {'internal_source': 'internal',
|
'servermodel': {'internal_source': 'internal',
|
||||||
'internal_distribution': 'last',
|
'internal_distribution': 'last',
|
||||||
|
@ -24,7 +24,7 @@ class Controller:
|
|||||||
if args:
|
if args:
|
||||||
raise ValueError(_(f'the URI "{uri}" can only be called with keyword arguments'))
|
raise ValueError(_(f'the URI "{uri}" can only be called with keyword arguments'))
|
||||||
if module not in self.risotto_modules:
|
if module not in self.risotto_modules:
|
||||||
return await remote.remove_call(module,
|
return await remote.remote_call(module,
|
||||||
version,
|
version,
|
||||||
message,
|
message,
|
||||||
kwargs)
|
kwargs)
|
||||||
@ -44,7 +44,7 @@ class Controller:
|
|||||||
if args:
|
if args:
|
||||||
raise ValueError(_(f'the URI "{uri}" can only be published with keyword arguments'))
|
raise ValueError(_(f'the URI "{uri}" can only be published with keyword arguments'))
|
||||||
if module not in self.risotto_modules:
|
if module not in self.risotto_modules:
|
||||||
await remote.remove_call(module,
|
await remote.remote_call(module,
|
||||||
version,
|
version,
|
||||||
submessage,
|
submessage,
|
||||||
kwargs)
|
kwargs)
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from tiramisu import Config
|
try:
|
||||||
|
from tiramisu3 import Config
|
||||||
|
except:
|
||||||
|
from tiramisu import Config
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from typing import Dict, Callable, List, Optional
|
from typing import Dict, Callable, List, Optional
|
||||||
@ -10,7 +13,7 @@ from .logger import log
|
|||||||
from .config import get_config
|
from .config import get_config
|
||||||
from .context import Context
|
from .context import Context
|
||||||
from . import register
|
from . import register
|
||||||
from .remote import Remote
|
#from .remote import Remote
|
||||||
import asyncpg
|
import asyncpg
|
||||||
|
|
||||||
|
|
||||||
@ -147,44 +150,43 @@ class PublishDispatcher:
|
|||||||
check_role,
|
check_role,
|
||||||
kwargs,
|
kwargs,
|
||||||
function_objs)
|
function_objs)
|
||||||
else:
|
try:
|
||||||
try:
|
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',
|
encoder=dumps,
|
||||||
encoder=dumps,
|
decoder=loads,
|
||||||
decoder=loads,
|
schema='pg_catalog'
|
||||||
schema='pg_catalog'
|
)
|
||||||
)
|
risotto_context.connection = connection
|
||||||
risotto_context.connection = connection
|
async with connection.transaction():
|
||||||
async with connection.transaction():
|
return await self.launch(version,
|
||||||
return await self.launch(version,
|
message,
|
||||||
message,
|
risotto_context,
|
||||||
risotto_context,
|
check_role,
|
||||||
check_role,
|
kwargs,
|
||||||
kwargs,
|
function_objs)
|
||||||
function_objs)
|
except CallError as err:
|
||||||
except CallError as err:
|
raise err
|
||||||
raise err
|
except Exception as err:
|
||||||
except Exception as err:
|
# if there is a problem with arguments, just send an error and do nothing
|
||||||
# if there is a problem with arguments, just send an error and do nothing
|
if get_config()['global']['debug']:
|
||||||
if get_config()['global']['debug']:
|
print_exc()
|
||||||
print_exc()
|
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',
|
encoder=dumps,
|
||||||
encoder=dumps,
|
decoder=loads,
|
||||||
decoder=loads,
|
schema='pg_catalog'
|
||||||
schema='pg_catalog'
|
)
|
||||||
)
|
risotto_context.connection = connection
|
||||||
risotto_context.connection = connection
|
async with connection.transaction():
|
||||||
async with connection.transaction():
|
await log.error_msg(risotto_context, kwargs, err)
|
||||||
await log.error_msg(risotto_context, kwargs, err)
|
raise err
|
||||||
raise err
|
|
||||||
|
|
||||||
|
|
||||||
class Dispatcher(register.RegisterDispatcher,
|
class Dispatcher(register.RegisterDispatcher,
|
||||||
Remote,
|
# Remote,
|
||||||
CallDispatcher,
|
CallDispatcher,
|
||||||
PublishDispatcher):
|
PublishDispatcher):
|
||||||
""" Manage message (call or publish)
|
""" Manage message (call or publish)
|
||||||
@ -329,8 +331,6 @@ class Dispatcher(register.RegisterDispatcher,
|
|||||||
if key in function_obj['arguments']:
|
if key in function_obj['arguments']:
|
||||||
kw[key] = value
|
kw[key] = value
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
kw['risotto_context'] = risotto_context
|
kw['risotto_context'] = risotto_context
|
||||||
returns = await function(self.injected_self[function_obj['module']], **kw)
|
returns = await function(self.injected_self[function_obj['module']], **kw)
|
||||||
if risotto_context.type == 'rpc':
|
if risotto_context.type == 'rpc':
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
from aiohttp.web import Application, Response, get, post, HTTPBadRequest, HTTPInternalServerError, HTTPNotFound
|
from aiohttp.web import Application, Response, get, post, HTTPBadRequest, HTTPInternalServerError, HTTPNotFound
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from tiramisu import Config, default_storage
|
try:
|
||||||
|
from tiramisu3 import Config, default_storage
|
||||||
|
except:
|
||||||
|
from tiramisu import Config, default_storage
|
||||||
|
|
||||||
|
|
||||||
from .dispatcher import dispatcher
|
from .dispatcher import dispatcher
|
||||||
|
@ -2,9 +2,14 @@ from os import listdir
|
|||||||
from os.path import join, basename, dirname, isfile
|
from os.path import join, basename, dirname, isfile
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from gettext import translation
|
from gettext import translation
|
||||||
from tiramisu import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, SymLinkOption, FloatOption, \
|
try:
|
||||||
Calculation, Params, ParamOption, ParamValue, calc_value, calc_value_property_help, \
|
from tiramisu3 import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, \
|
||||||
groups, Option
|
SymLinkOption, FloatOption, Calculation, Params, ParamOption, \
|
||||||
|
ParamValue, calc_value, calc_value_property_help, groups, Option
|
||||||
|
except:
|
||||||
|
from tiramisu import StrOption, IntOption, BoolOption, ChoiceOption, OptionDescription, \
|
||||||
|
SymLinkOption, FloatOption, Calculation, Params, ParamOption, \
|
||||||
|
ParamValue, calc_value, calc_value_property_help, groups, Option
|
||||||
from yaml import load, SafeLoader
|
from yaml import load, SafeLoader
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
from tiramisu import Config
|
try:
|
||||||
|
from tiramisu3 import Config
|
||||||
|
except:
|
||||||
|
from tiramisu import Config
|
||||||
from inspect import signature
|
from inspect import signature
|
||||||
from typing import Callable, Optional
|
from typing import Callable, Optional
|
||||||
import asyncpg
|
import asyncpg
|
||||||
|
@ -31,7 +31,7 @@ class Remote:
|
|||||||
self.submodules[module] = json
|
self.submodules[module] = json
|
||||||
return Config(self.submodules[module])
|
return Config(self.submodules[module])
|
||||||
|
|
||||||
async def remove_call(self,
|
async def remote_call(self,
|
||||||
module: str,
|
module: str,
|
||||||
version: str,
|
version: str,
|
||||||
submessage: str,
|
submessage: str,
|
||||||
|
Reference in New Issue
Block a user