From 5ac9ec72f80eaace450e9db1174d2fd2e7b901fc Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 26 Feb 2020 08:29:25 +0100 Subject: [PATCH] server name is a domain name --- README.md | 5 ++--- src/risotto/services/config/config.py | 21 ++++++++++++++++----- src/risotto/services/server/server.py | 2 ++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1e41c95..bcf8ebc 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ drop table value; drop table property; drop table permissive; drop table informa # Heritage ## ACA -./script/cucchiaiata servermodel.create -n aca -d Aca -p eolebase -s eole -r last +./script/cucchiaiata servermodel.create -n aca -d Aca -p base -s eole -r last ./script/cucchiaiata session.servermodel.start -s aca S=xxxxxxxxxxxxxxxxxxxxxx ### verif @@ -100,7 +100,7 @@ S=xxxxxxxxxxxxxxxxxxxxxx XXXXX # Create a server -./script/cucchiaiata server.create -s test -d description -m unbound_etab1 -r last +./script/cucchiaiata server.create -s test.cadoles.com -d description -m unbound_etab1 -r last ./script/cucchiaiata session.server.start -s test S=xxxxxxxxxxxxxxxxxxxxxx @@ -114,4 +114,3 @@ S=xxxxxxxxxxxxxxxxxxxxxx # OpenSSH ./script/cucchiaiata applicationservice.dependency.add -n local_aca -a openssh -s eole -r last - diff --git a/src/risotto/services/config/config.py b/src/risotto/services/config/config.py index 0356207..2ce7e43 100644 --- a/src/risotto/services/config/config.py +++ b/src/risotto/services/config/config.py @@ -6,6 +6,7 @@ from traceback import print_exc from typing import Dict, List from tiramisu import Storage, MixConfig +from tiramisu.error import PropertiesOptionError from rougail import load as rougail_load from rougail.config import dtdfilename @@ -230,22 +231,31 @@ class Risotto(Controller): 'server_to_deploy': await self.build_config(f'std_{server_id}', server_id, server_name, - mixconfig), + mixconfig, + std=True), 'funcs_file': self.get_funcs_filename(server_servermodel_id)} async def build_config(self, session_id: str, server_id: int, server_name: str, - mixconfig: MixConfig) -> None: + mixconfig: MixConfig, + std: bool=False) -> None: """ build server's config """ config = await mixconfig.config.new(session_id, storage=self.save_storage) await config.information.set('server_id', server_id) await config.information.set('server_name', server_name) - await config.owner.set(server_name) - await config.property.read_only() + option_value = config.option('creole.interface_0.domain_name_eth0').value + if std: + try: + await option_value.get() + except PropertiesOptionError: + await config.owner.set(server_name) + await config.property.read_write() + await config.option('creole.interface_0.domain_name_eth0').value.set(server_name) + await config.property.read_only() return config @register('v1.server.created') @@ -307,7 +317,8 @@ class Risotto(Controller): mixconfig = self.servermodel.pop(servermodel_id) children = [] for child in await mixconfig.config.list(): - children.append(child) + if not (await child.session.id()).startswith('std_'): + children.append(child) await mixconfig.config.pop(await child.session.id()) for parent in await mixconfig.config.parents(): await parent.config.pop(await mixconfig.session.id()) diff --git a/src/risotto/services/server/server.py b/src/risotto/services/server/server.py index 3f2fd9b..ddc403c 100644 --- a/src/risotto/services/server/server.py +++ b/src/risotto/services/server/server.py @@ -1,4 +1,5 @@ from typing import Dict +from tiramisu import DomainnameOption from ...controller import Controller from ...register import register @@ -29,6 +30,7 @@ class Risotto(Controller): server_description: str, servermodel_name: str, release_distribution: str) -> Dict: + DomainnameOption('server_name', _('Server name'), server_name) servermodel = await self.call('v1.servermodel.describe', risotto_context, servermodel_name=servermodel_name,