add servermodel.updated
This commit is contained in:
parent
4c775c21e4
commit
3ace1dfae5
13
README.md
13
README.md
|
@ -80,7 +80,7 @@ S=xxxxxxxxxxxxxxxxxxxxxx
|
||||||
./script/cucchiaiata session.servermodel.stop -s $S -a
|
./script/cucchiaiata session.servermodel.stop -s $S -a
|
||||||
|
|
||||||
## unbound
|
## unbound
|
||||||
./script/cucchiaiata servermodel.create -n unbound -d "generic unbound configuration" -p eolebase -s eole -r last
|
./script/cucchiaiata servermodel.create -n unbound -d "generic unbound configuration" -s eole -r last
|
||||||
./script/cucchiaiata session.servermodel.start -s unbound
|
./script/cucchiaiata session.servermodel.start -s unbound
|
||||||
S=xxxxxxxxxxxxxxxxxxxxxx
|
S=xxxxxxxxxxxxxxxxxxxxxx
|
||||||
./script/cucchiaiata session.servermodel.configure -s $S --creole.serveur_dns.unbound_local_zones cadoles.com
|
./script/cucchiaiata session.servermodel.configure -s $S --creole.serveur_dns.unbound_local_zones cadoles.com
|
||||||
|
@ -109,17 +109,8 @@ S=xxxxxxxxxxxxxxxxxxxxxx
|
||||||
./script/cucchiaiata session.server.stop -s $S -a
|
./script/cucchiaiata session.server.stop -s $S -a
|
||||||
|
|
||||||
# Generate configuration
|
# Generate configuration
|
||||||
./script/cucchiaiata config.configuration.server.deploy -s test
|
|
||||||
./script/cucchiaiata template.generate -s test
|
./script/cucchiaiata template.generate -s test
|
||||||
|
|
||||||
|
|
||||||
# OpenSSH
|
# OpenSSH
|
||||||
#add servermodel openssh link to eolebase
|
./script/cucchiaiata applicationservice.dependency.add -n local_aca -a openssh -s eole -r last
|
||||||
#add servermodel openssh2 lint to openssh
|
|
||||||
#link openssh applicationservice to this servermodel
|
|
||||||
|
|
||||||
./script/cucchiaiata servermodel.create -n openssh_1 -d description -p eolebase -s eole -r last
|
|
||||||
./script/cucchiaiata servermodel.create -n openssh_2 -d openssh_2 -p openssh_1 -s internal -r last
|
|
||||||
./script/cucchiaiata applicationservice.dependency.add -n local_openssh_1 -a openssh -s eole -r last
|
|
||||||
|
|
||||||
#./script/cucchiaiata server.create -s test -d description -m eolebase -r last
|
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
---
|
|
||||||
uri: config.configuration.server.deploy
|
|
||||||
|
|
||||||
description: Déployer la configuration d'un serveur.
|
|
||||||
|
|
||||||
pattern: rpc
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
server_name:
|
|
||||||
type: String
|
|
||||||
ref: Server.ServerName
|
|
||||||
shortarg: s
|
|
||||||
description: Nom du serveur.
|
|
||||||
|
|
||||||
response:
|
|
||||||
type: Deploy
|
|
||||||
description: La configuration du serveur est déployée.
|
|
|
@ -10,11 +10,8 @@ parameters:
|
||||||
server_name:
|
server_name:
|
||||||
type: String
|
type: String
|
||||||
ref: Server.ServerName
|
ref: Server.ServerName
|
||||||
|
shortarg: s
|
||||||
description: Nom du serveur.
|
description: Nom du serveur.
|
||||||
deployed:
|
|
||||||
type: Boolean
|
|
||||||
description: Configuration de type déployée.
|
|
||||||
default: true
|
|
||||||
|
|
||||||
response:
|
response:
|
||||||
type: ConfigConfiguration
|
type: ConfigConfiguration
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
---
|
|
||||||
uri: config.configuration.server.updated
|
|
||||||
|
|
||||||
description: |
|
|
||||||
Une configuration de serveur a été mise à jour.
|
|
||||||
|
|
||||||
pattern: event
|
|
||||||
|
|
||||||
parameters:
|
|
||||||
server_id:
|
|
||||||
type: Number
|
|
||||||
description: |
|
|
||||||
Identifiant du serveur.
|
|
||||||
server_name:
|
|
||||||
type: String
|
|
||||||
ref: Server.ServerName
|
|
||||||
shortarg: s
|
|
||||||
description: Nom du serveur.
|
|
||||||
deployed:
|
|
||||||
type: Boolean
|
|
||||||
description: Configuration de type déployée.
|
|
|
@ -21,6 +21,7 @@ parameters:
|
||||||
ref: Servermodel.ServermodelName
|
ref: Servermodel.ServermodelName
|
||||||
shortarg: p
|
shortarg: p
|
||||||
description: Nom des modèles de serveur parents auquels rattacher le nouveau modèle.
|
description: Nom des modèles de serveur parents auquels rattacher le nouveau modèle.
|
||||||
|
default: null
|
||||||
servermodel_parents_source_name:
|
servermodel_parents_source_name:
|
||||||
type: String
|
type: String
|
||||||
shortarg: s
|
shortarg: s
|
||||||
|
|
|
@ -89,7 +89,6 @@ class Risotto(Controller):
|
||||||
as_descr['applicationservice_id'],
|
as_descr['applicationservice_id'],
|
||||||
dependency_descr['applicationservice_id']):
|
dependency_descr['applicationservice_id']):
|
||||||
raise Exception(_(f'{applicationservice_name} has already a dependency to {applicationservice_dependency}'))
|
raise Exception(_(f'{applicationservice_name} has already a dependency to {applicationservice_dependency}'))
|
||||||
else:
|
|
||||||
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']])
|
||||||
|
|
|
@ -5,7 +5,7 @@ from os.path import isdir, isfile, join
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from typing import Dict, List
|
from typing import Dict, List
|
||||||
|
|
||||||
from tiramisu import Storage, delete_session, MetaConfig, MixConfig
|
from tiramisu import Storage, MixConfig
|
||||||
from rougail import load as rougail_load
|
from rougail import load as rougail_load
|
||||||
from rougail.config import dtdfilename
|
from rougail.config import dtdfilename
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class Risotto(Controller):
|
||||||
with open(cache_file) as fileio:
|
with open(cache_file) as fileio:
|
||||||
xmlroot = parse(fileio).getroot()
|
xmlroot = parse(fileio).getroot()
|
||||||
try:
|
try:
|
||||||
self.servermodel[servermodel_id] = await self.build_metaconfig(servermodel_id,
|
self.servermodel[servermodel_id] = await self.build_mixconfig(servermodel_id,
|
||||||
servermodel_name,
|
servermodel_name,
|
||||||
xmlroot,
|
xmlroot,
|
||||||
funcs_file)
|
funcs_file)
|
||||||
|
@ -101,12 +101,12 @@ class Risotto(Controller):
|
||||||
None,
|
None,
|
||||||
msg)
|
msg)
|
||||||
|
|
||||||
async def build_metaconfig(self,
|
async def build_mixconfig(self,
|
||||||
servermodel_id: int,
|
servermodel_id: int,
|
||||||
servermodel_name: str,
|
servermodel_name: str,
|
||||||
xmlroot: str,
|
xmlroot: str,
|
||||||
funcs_file: str) -> MetaConfig:
|
funcs_file: str) -> MixConfig:
|
||||||
""" Build metaconfig for a servermodel
|
""" Build mixconfig for a servermodel
|
||||||
"""
|
"""
|
||||||
# build tiramisu's session ID
|
# build tiramisu's session ID
|
||||||
session_id = f'v_{servermodel_id}'
|
session_id = f'v_{servermodel_id}'
|
||||||
|
@ -114,37 +114,31 @@ class Risotto(Controller):
|
||||||
dtdfilename,
|
dtdfilename,
|
||||||
funcs_file)
|
funcs_file)
|
||||||
|
|
||||||
# build servermodel metaconfig (v_xxx.m_v_xxx)
|
# build servermodel mixconfig (v_xxx)
|
||||||
metaconfig = await MetaConfig([],
|
mixconfig = await MixConfig(children=[],
|
||||||
optiondescription=optiondescription,
|
optiondescription=optiondescription,
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
storage=self.save_storage)
|
storage=self.save_storage)
|
||||||
mixconfig = await MixConfig(children=[],
|
|
||||||
optiondescription=optiondescription,
|
|
||||||
session_id='m_' + session_id,
|
|
||||||
storage=self.save_storage)
|
|
||||||
await metaconfig.config.add(mixconfig)
|
|
||||||
|
|
||||||
# change default rights
|
# change default rights
|
||||||
ro_origin = await metaconfig.property.getdefault('read_only', 'append')
|
ro_origin = await mixconfig.property.getdefault('read_only', 'append')
|
||||||
ro_append = frozenset(ro_origin - {'force_store_value'})
|
ro_append = frozenset(ro_origin - {'force_store_value'})
|
||||||
rw_origin = await metaconfig.property.getdefault('read_write', 'append')
|
rw_origin = await mixconfig.property.getdefault('read_write', 'append')
|
||||||
rw_append = frozenset(rw_origin - {'force_store_value'})
|
rw_append = frozenset(rw_origin - {'force_store_value'})
|
||||||
await metaconfig.property.setdefault(ro_append, 'read_only', 'append')
|
await mixconfig.property.setdefault(ro_append, 'read_only', 'append')
|
||||||
await metaconfig.property.setdefault(rw_append, 'read_write', 'append')
|
await mixconfig.property.setdefault(rw_append, 'read_write', 'append')
|
||||||
|
|
||||||
await metaconfig.property.read_only()
|
await mixconfig.property.read_only()
|
||||||
await metaconfig.permissive.add('basic')
|
await mixconfig.permissive.add('basic')
|
||||||
await metaconfig.permissive.add('normal')
|
await mixconfig.permissive.add('normal')
|
||||||
await metaconfig.permissive.add('expert')
|
await mixconfig.permissive.add('expert')
|
||||||
|
|
||||||
# set informtion and owner
|
# set informtion and owner
|
||||||
await metaconfig.owner.set('v_{}'.format(servermodel_name))
|
await mixconfig.owner.set('v_{}'.format(servermodel_name))
|
||||||
await metaconfig.information.set('servermodel_id', servermodel_id)
|
await mixconfig.information.set('servermodel_id', servermodel_id)
|
||||||
await metaconfig.information.set('servermodel_name', servermodel_name)
|
await mixconfig.information.set('servermodel_name', servermodel_name)
|
||||||
|
|
||||||
# return configuration
|
# return configuration
|
||||||
return metaconfig
|
return mixconfig
|
||||||
|
|
||||||
async def servermodel_legacy(self,
|
async def servermodel_legacy(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
|
@ -169,9 +163,9 @@ class Risotto(Controller):
|
||||||
msg)
|
msg)
|
||||||
|
|
||||||
# do link
|
# do link
|
||||||
mix = await servermodel_parent.config.get('m_v_' + str(servermodel_parent_id))
|
# mix = await servermodel_parent.config.get('m_v_' + str(servermodel_parent_id))
|
||||||
try:
|
try:
|
||||||
await mix.config.add(self.servermodel[servermodel_id])
|
await servermodel_parent.config.add(self.servermodel[servermodel_id])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
await log.error_msg(risotto_context,
|
await log.error_msg(risotto_context,
|
||||||
None,
|
None,
|
||||||
|
@ -190,6 +184,8 @@ class Risotto(Controller):
|
||||||
# loads servers
|
# loads servers
|
||||||
for server in servers:
|
for server in servers:
|
||||||
try:
|
try:
|
||||||
|
if server['server_id'] in self.server:
|
||||||
|
return
|
||||||
await self.load_server(risotto_context,
|
await self.load_server(risotto_context,
|
||||||
server['server_id'],
|
server['server_id'],
|
||||||
server['server_name'],
|
server['server_name'],
|
||||||
|
@ -211,8 +207,6 @@ class Risotto(Controller):
|
||||||
server_servermodel_id: int) -> None:
|
server_servermodel_id: int) -> None:
|
||||||
""" Loads a server
|
""" Loads a server
|
||||||
"""
|
"""
|
||||||
if server_id in self.server:
|
|
||||||
return
|
|
||||||
await log.info_msg(risotto_context,
|
await log.info_msg(risotto_context,
|
||||||
None,
|
None,
|
||||||
f'Load server {server_name} ({server_id})')
|
f'Load server {server_name} ({server_id})')
|
||||||
|
@ -226,28 +220,24 @@ class Risotto(Controller):
|
||||||
# check if server was already created
|
# check if server was already created
|
||||||
session_id = f's_{server_id}'
|
session_id = f's_{server_id}'
|
||||||
|
|
||||||
# get the servermodel's metaconfig
|
# get the servermodel's mixconfig
|
||||||
metaconfig = self.servermodel[server_servermodel_id]
|
mixconfig = self.servermodel[server_servermodel_id]
|
||||||
|
|
||||||
# create server configuration and server 'to deploy' configuration and store it
|
# create server configuration and store it
|
||||||
self.server[server_id] = {'server': await self.build_config(session_id,
|
self.server[server_id] = {'server': await self.build_config(session_id,
|
||||||
server_id,
|
server_id,
|
||||||
server_name,
|
server_name,
|
||||||
metaconfig),
|
mixconfig),
|
||||||
'server_to_deploy': await self.build_config(f'std_{server_id}',
|
|
||||||
server_id,
|
|
||||||
server_name,
|
|
||||||
metaconfig),
|
|
||||||
'funcs_file': self.get_funcs_filename(server_servermodel_id)}
|
'funcs_file': self.get_funcs_filename(server_servermodel_id)}
|
||||||
|
|
||||||
async def build_config(self,
|
async def build_config(self,
|
||||||
session_id: str,
|
session_id: str,
|
||||||
server_id: int,
|
server_id: int,
|
||||||
server_name: str,
|
server_name: str,
|
||||||
metaconfig: MetaConfig) -> None:
|
mixconfig: MixConfig) -> None:
|
||||||
""" build server's config
|
""" build server's config
|
||||||
"""
|
"""
|
||||||
config = await metaconfig.config.new(session_id,
|
config = await mixconfig.config.new(session_id,
|
||||||
storage=self.save_storage)
|
storage=self.save_storage)
|
||||||
await config.information.set('server_id', server_id)
|
await config.information.set('server_id', server_id)
|
||||||
await config.information.set('server_name', server_name)
|
await config.information.set('server_name', server_name)
|
||||||
|
@ -263,6 +253,8 @@ class Risotto(Controller):
|
||||||
server_servermodel_id: int) -> None:
|
server_servermodel_id: int) -> None:
|
||||||
""" Loads server's configuration when a new server is created
|
""" Loads server's configuration when a new server is created
|
||||||
"""
|
"""
|
||||||
|
if server_id in self.server:
|
||||||
|
return
|
||||||
await self.load_server(risotto_context,
|
await self.load_server(risotto_context,
|
||||||
server_id,
|
server_id,
|
||||||
server_name,
|
server_name,
|
||||||
|
@ -272,13 +264,11 @@ class Risotto(Controller):
|
||||||
async def server_deleted(self,
|
async def server_deleted(self,
|
||||||
server_id: int) -> None:
|
server_id: int) -> None:
|
||||||
# delete config to it's parents
|
# delete config to it's parents
|
||||||
for server_type in ['server', 'server_to_deploy']:
|
|
||||||
config = self.server[server_id]['server']
|
config = self.server[server_id]['server']
|
||||||
for parent in await config.config.parents():
|
for parent in await config.config.parents():
|
||||||
await parent.config.pop(await config.config.name())
|
await parent.config.pop(await config.session.id())
|
||||||
delete_session(storage=self.save_storage,
|
await config.session.reset()
|
||||||
session_id=await config.config.name())
|
# delete mixconfig
|
||||||
# delete metaconfig
|
|
||||||
del self.server[server_id]
|
del self.server[server_id]
|
||||||
|
|
||||||
@register('v1.servermodel.created')
|
@register('v1.servermodel.created')
|
||||||
|
@ -311,68 +301,53 @@ class Risotto(Controller):
|
||||||
servermodelparentid)
|
servermodelparentid)
|
||||||
|
|
||||||
async def servermodel_delete(self,
|
async def servermodel_delete(self,
|
||||||
servermodel_id: int) -> List[MetaConfig]:
|
servermodel_id: int) -> List[MixConfig]:
|
||||||
metaconfig = self.servermodel.pop(servermodel_id)
|
mixconfig = self.servermodel.pop(servermodel_id)
|
||||||
mixconfig = await metaconfig.config.list()[0]
|
|
||||||
children = []
|
children = []
|
||||||
for child in await mixconfig.config.list():
|
for child in await mixconfig.config.list():
|
||||||
children.append(child)
|
children.append(child)
|
||||||
await mixconfig.config.pop(await child.config.name())
|
await mixconfig.config.pop(await child.session.id())
|
||||||
await metaconfig.config.pop(await mixconfig.config.name())
|
for parent in await mixconfig.config.parents():
|
||||||
delete_session(storage=self.save_storage,
|
await parent.config.pop(await mixconfig.session.id())
|
||||||
session_id=await mixconfig.config.name())
|
await mixconfig.session.reset()
|
||||||
del mixconfig
|
|
||||||
for parent in await metaconfig.config.parents():
|
|
||||||
await parent.config.pop(await metaconfig.config.name())
|
|
||||||
delete_session(storage=self.save_storage,
|
|
||||||
session_id=await metaconfig.config.name())
|
|
||||||
return children
|
return children
|
||||||
#
|
|
||||||
# @register('v1.servermodel.updated')
|
@register('v1.servermodel.updated')
|
||||||
# async def servermodel_updated(self,
|
async def servermodel_updated(self,
|
||||||
# risotto_context: Context,
|
risotto_context: Context,
|
||||||
# servermodel_id: int,
|
servermodel_id: int,
|
||||||
# servermodel_name: str,
|
servermodel_name: str,
|
||||||
# servermodel_parents_id: List[int]) -> None:
|
servermodel_parents_id: List[int]) -> None:
|
||||||
# log.info_msg(risotto_context,
|
await log.info_msg(risotto_context,
|
||||||
# None,
|
None,
|
||||||
# f'Reload servermodel {servermodel_name} ({servermodel_id})')
|
f'Reload servermodel {servermodel_name} ({servermodel_id})')
|
||||||
# # unlink cache to force download new aggregated file
|
# store all informations
|
||||||
# cache_file = join(self.cache_root_path, str(servermodel_id)+".xml")
|
if servermodel_id in self.servermodel:
|
||||||
# if isfile(cache_file):
|
children = await self.servermodel_delete(servermodel_id)
|
||||||
# unlink(cache_file)
|
else:
|
||||||
#
|
children = []
|
||||||
# # store all informations
|
|
||||||
# if servermodel_id in self.servermodel:
|
# create new one
|
||||||
# old_values = await self.servermodel[servermodel_id].value.exportation()
|
await self.load_and_link_servermodel(risotto_context,
|
||||||
# old_permissives = await self.servermodel[servermodel_id].permissive.exportation()
|
servermodel_id,
|
||||||
# old_properties = await self.servermodel[servermodel_id].property.exportation()
|
servermodel_name,
|
||||||
# children = await self.servermodel_delete(servermodel_id)
|
servermodel_parents_id)
|
||||||
# else:
|
# recreate link to children
|
||||||
# old_values = None
|
for child in children:
|
||||||
#
|
if await child.config.type() == 'config':
|
||||||
# # create new one
|
server_id = await child.information.get('server_id')
|
||||||
# await self.load_and_link_servermodel(risotto_context,
|
server_name = await child.information.get('server_name')
|
||||||
# servermodel_id,
|
await self.load_server(risotto_context,
|
||||||
# servermodel_name,
|
server_id,
|
||||||
# servermodel_parents_id)
|
server_name,
|
||||||
#
|
servermodel_id)
|
||||||
# # migrates informations
|
else:
|
||||||
# if old_values is not None:
|
await self.servermodel[servermodel_id].config.add(child)
|
||||||
# await self.servermodel[servermodel_id].value.importation(old_values)
|
|
||||||
# await self.servermodel[servermodel_id].permissive.importation(old_permissives)
|
|
||||||
# await self.servermodel[servermodel_id].property.importation(old_properties)
|
|
||||||
# for child in children:
|
|
||||||
# await self.servermodel_legacy(risotto_context,
|
|
||||||
# await child.information.get('servermodel_name'),
|
|
||||||
# await child.information.get('servermodel_id'),
|
|
||||||
# servermodel_id)
|
|
||||||
|
|
||||||
@register('v1.config.configuration.server.get')
|
@register('v1.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) -> dict:
|
||||||
deployed: bool) -> bytes:
|
|
||||||
server = await self.call('v1.server.describe',
|
server = await self.call('v1.server.describe',
|
||||||
risotto_context,
|
risotto_context,
|
||||||
server_name=server_name)
|
server_name=server_name)
|
||||||
|
@ -384,57 +359,17 @@ class Risotto(Controller):
|
||||||
msg)
|
msg)
|
||||||
raise CallError(msg)
|
raise CallError(msg)
|
||||||
|
|
||||||
if deployed:
|
|
||||||
server = self.server[server_id]['server']
|
server = self.server[server_id]['server']
|
||||||
else:
|
|
||||||
server = self.server[server_id]['server_to_deploy']
|
|
||||||
|
|
||||||
await server.property.read_only()
|
await server.property.read_only()
|
||||||
try:
|
try:
|
||||||
configuration = await server.value.dict(fullpath=True,
|
configuration = await server.value.dict(fullpath=True,
|
||||||
leader_to_list=True)
|
leader_to_list=True)
|
||||||
except:
|
except:
|
||||||
if deployed:
|
|
||||||
msg = _(f'No configuration available for server {server_id}')
|
msg = _(f'No configuration available for server {server_id}')
|
||||||
else:
|
|
||||||
msg = _(f'No undeployed configuration available for server {server_id}')
|
|
||||||
await log.error_msg(risotto_context,
|
await log.error_msg(risotto_context,
|
||||||
None,
|
None,
|
||||||
msg)
|
msg)
|
||||||
raise CallError(msg)
|
raise CallError(msg)
|
||||||
return {'server_name': server_name,
|
return {'server_name': server_name,
|
||||||
'deployed': deployed,
|
|
||||||
'configuration': configuration}
|
'configuration': configuration}
|
||||||
|
|
||||||
@register('v1.config.configuration.server.deploy', 'v1.config.configuration.server.updated')
|
|
||||||
async def deploy_configuration(self,
|
|
||||||
risotto_context: Context,
|
|
||||||
server_name: str) -> Dict:
|
|
||||||
"""Copy values, permissions, permissives from config 'to deploy' to active config
|
|
||||||
"""
|
|
||||||
server = await self.call('v1.server.describe',
|
|
||||||
risotto_context,
|
|
||||||
server_name=server_name)
|
|
||||||
server_id = server['server_id']
|
|
||||||
# FIXME is server_to_deploy working?
|
|
||||||
config = self.server[server_id]['server']
|
|
||||||
config_std = self.server[server_id]['server_to_deploy']
|
|
||||||
|
|
||||||
# when deploy, calculate force_store_value
|
|
||||||
ro = await config_std.property.getdefault('read_only', 'append')
|
|
||||||
if 'force_store_value' not in ro:
|
|
||||||
ro = frozenset(list(ro) + ['force_store_value'])
|
|
||||||
await config_std.property.setdefault(ro, 'read_only', 'append')
|
|
||||||
rw = await config_std.property.getdefault('read_write', 'append')
|
|
||||||
rw = frozenset(list(rw) + ['force_store_value'])
|
|
||||||
await config_std.property.setdefault(rw, 'read_write', 'append')
|
|
||||||
await config_std.property.add('force_store_value')
|
|
||||||
|
|
||||||
# copy informations from server 'to deploy' configuration to server configuration
|
|
||||||
await config.value.importation(await config_std.value.exportation())
|
|
||||||
await config.permissive.importation(await config_std.permissive.exportation())
|
|
||||||
await config.property.importation(await config_std.property.exportation())
|
|
||||||
|
|
||||||
return {'server_id': server_id,
|
|
||||||
'server_name': server_name,
|
|
||||||
'deployed': True}
|
|
||||||
|
|
|
@ -183,7 +183,9 @@ class Risotto(Generator):
|
||||||
if not servermodel_parent and parent is not None:
|
if not servermodel_parent and parent is not None:
|
||||||
servermodel_parent = [await self._servermodel_describe(risotto_context,
|
servermodel_parent = [await self._servermodel_describe(risotto_context,
|
||||||
parent,
|
parent,
|
||||||
release_id)]
|
release_id,
|
||||||
|
source_name,
|
||||||
|
release_distribution)]
|
||||||
# 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']:
|
||||||
|
@ -237,12 +239,16 @@ class Risotto(Generator):
|
||||||
release_distribution=release_distribution)
|
release_distribution=release_distribution)
|
||||||
return await self._servermodel_describe(risotto_context,
|
return await self._servermodel_describe(risotto_context,
|
||||||
servermodel_name,
|
servermodel_name,
|
||||||
release['release_id'])
|
release['release_id'],
|
||||||
|
source_name,
|
||||||
|
release_distribution)
|
||||||
|
|
||||||
async def _servermodel_describe(self,
|
async def _servermodel_describe(self,
|
||||||
risotto_context,
|
risotto_context,
|
||||||
servermodel_name,
|
servermodel_name,
|
||||||
release_id):
|
release_id,
|
||||||
|
source_name,
|
||||||
|
release_distribution):
|
||||||
sql = '''
|
sql = '''
|
||||||
SELECT ServermodelId as servermodel_id, ServermodelName as servermodel_name, ServermodelDescription as servermodel_description, ServermodelParentsId as servermodel_parents_id, ServermodelReleaseId as release_id, ServermodelApplicationServiceId as servermodel_applicationservice_id
|
SELECT ServermodelId as servermodel_id, ServermodelName as servermodel_name, ServermodelDescription as servermodel_description, ServermodelParentsId as servermodel_parents_id, ServermodelReleaseId as release_id, ServermodelApplicationServiceId as servermodel_applicationservice_id
|
||||||
FROM Servermodel
|
FROM Servermodel
|
||||||
|
@ -272,7 +278,9 @@ class Risotto(Generator):
|
||||||
for servermodel_parent_name in servermodel_parents_name:
|
for servermodel_parent_name in servermodel_parents_name:
|
||||||
servermodel_parents.append(await self._servermodel_describe(risotto_context,
|
servermodel_parents.append(await self._servermodel_describe(risotto_context,
|
||||||
servermodel_parent_name,
|
servermodel_parent_name,
|
||||||
release_id))
|
release_id,
|
||||||
|
servermodel_parents_source_name,
|
||||||
|
servermodel_parents_release_distribution))
|
||||||
return await self._servermodel_create(risotto_context,
|
return await self._servermodel_create(risotto_context,
|
||||||
servermodel_name,
|
servermodel_name,
|
||||||
servermodel_description,
|
servermodel_description,
|
||||||
|
|
|
@ -79,7 +79,7 @@ class Risotto(Controller):
|
||||||
if not server or server['server_id'] not in config_module.server:
|
if not server or server['server_id'] not in config_module.server:
|
||||||
raise Exception(_(f'cannot find server with name {server_name}'))
|
raise Exception(_(f'cannot find server with name {server_name}'))
|
||||||
id = server['server_id']
|
id = server['server_id']
|
||||||
config = config_module.server[id]['server_to_deploy']
|
config = config_module.server[id]['server']
|
||||||
|
|
||||||
storage = self.get_storage('server')
|
storage = self.get_storage('server')
|
||||||
|
|
||||||
|
@ -287,7 +287,7 @@ class Risotto(Controller):
|
||||||
id_ = session['id']
|
id_ = session['id']
|
||||||
config_module = dispatcher.get_service('config')
|
config_module = dispatcher.get_service('config')
|
||||||
if type == 'server':
|
if type == 'server':
|
||||||
config = config_module.server[id_]['server_to_deploy']
|
config = config_module.server[id_]['server']
|
||||||
else:
|
else:
|
||||||
config = config_module.servermodel[id_]
|
config = config_module.servermodel[id_]
|
||||||
if save:
|
if save:
|
||||||
|
|
|
@ -124,7 +124,7 @@ class Storage(object):
|
||||||
class StorageServer(Storage):
|
class StorageServer(Storage):
|
||||||
def get_config_name(self,
|
def get_config_name(self,
|
||||||
server_id: int):
|
server_id: int):
|
||||||
return f'std_{server_id}'
|
return f's_{server_id}'
|
||||||
|
|
||||||
async def set_owner(self,
|
async def set_owner(self,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
|
Loading…
Reference in New Issue