readd std server configuration
This commit is contained in:
parent
3ace1dfae5
commit
37993add10
@ -109,6 +109,7 @@ 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
|
||||||
|
@ -12,6 +12,10 @@ parameters:
|
|||||||
ref: Server.ServerName
|
ref: Server.ServerName
|
||||||
shortarg: s
|
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
|
||||||
|
@ -163,7 +163,6 @@ class Risotto(Controller):
|
|||||||
msg)
|
msg)
|
||||||
|
|
||||||
# do link
|
# do link
|
||||||
# mix = await servermodel_parent.config.get('m_v_' + str(servermodel_parent_id))
|
|
||||||
try:
|
try:
|
||||||
await servermodel_parent.config.add(self.servermodel[servermodel_id])
|
await servermodel_parent.config.add(self.servermodel[servermodel_id])
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
@ -228,6 +227,10 @@ class Risotto(Controller):
|
|||||||
server_id,
|
server_id,
|
||||||
server_name,
|
server_name,
|
||||||
mixconfig),
|
mixconfig),
|
||||||
|
'server_to_deploy': await self.build_config(f'std_{server_id}',
|
||||||
|
server_id,
|
||||||
|
server_name,
|
||||||
|
mixconfig),
|
||||||
'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,
|
||||||
@ -263,12 +266,11 @@ class Risotto(Controller):
|
|||||||
@register('v1.server.deleted')
|
@register('v1.server.deleted')
|
||||||
async def server_deleted(self,
|
async def server_deleted(self,
|
||||||
server_id: int) -> None:
|
server_id: int) -> None:
|
||||||
# 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.session.id())
|
await parent.config.pop(await config.config.name())
|
||||||
await config.session.reset()
|
await config.session.reset()
|
||||||
# delete mixconfig
|
|
||||||
del self.server[server_id]
|
del self.server[server_id]
|
||||||
|
|
||||||
@register('v1.servermodel.created')
|
@register('v1.servermodel.created')
|
||||||
@ -309,7 +311,6 @@ class Risotto(Controller):
|
|||||||
await mixconfig.config.pop(await child.session.id())
|
await mixconfig.config.pop(await child.session.id())
|
||||||
for parent in await mixconfig.config.parents():
|
for parent in await mixconfig.config.parents():
|
||||||
await parent.config.pop(await mixconfig.session.id())
|
await parent.config.pop(await mixconfig.session.id())
|
||||||
await mixconfig.session.reset()
|
|
||||||
return children
|
return children
|
||||||
|
|
||||||
@register('v1.servermodel.updated')
|
@register('v1.servermodel.updated')
|
||||||
@ -347,7 +348,8 @@ class Risotto(Controller):
|
|||||||
@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) -> dict:
|
server_name: str,
|
||||||
|
deployed: bool) -> dict:
|
||||||
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)
|
||||||
@ -359,17 +361,57 @@ 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')
|
||||||
|
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}
|
||||||
|
@ -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']
|
config = config_module.server[id]['server_to_deploy']
|
||||||
|
|
||||||
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']
|
config = config_module.server[id_]['server_to_deploy']
|
||||||
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's_{server_id}'
|
return f'std_{server_id}'
|
||||||
|
|
||||||
async def set_owner(self,
|
async def set_owner(self,
|
||||||
config: Config,
|
config: Config,
|
||||||
|
Loading…
Reference in New Issue
Block a user