server name is a domain name

This commit is contained in:
Emmanuel Garette 2020-02-26 08:29:25 +01:00
parent 9d79eef47f
commit 5ac9ec72f8
3 changed files with 20 additions and 8 deletions

View File

@ -59,7 +59,7 @@ drop table value; drop table property; drop table permissive; drop table informa
# Heritage # Heritage
## ACA ## 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 ./script/cucchiaiata session.servermodel.start -s aca
S=xxxxxxxxxxxxxxxxxxxxxx S=xxxxxxxxxxxxxxxxxxxxxx
### verif ### verif
@ -100,7 +100,7 @@ S=xxxxxxxxxxxxxxxxxxxxxx
XXXXX XXXXX
# Create a server # 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 ./script/cucchiaiata session.server.start -s test
S=xxxxxxxxxxxxxxxxxxxxxx S=xxxxxxxxxxxxxxxxxxxxxx
@ -114,4 +114,3 @@ S=xxxxxxxxxxxxxxxxxxxxxx
# OpenSSH # OpenSSH
./script/cucchiaiata applicationservice.dependency.add -n local_aca -a openssh -s eole -r last ./script/cucchiaiata applicationservice.dependency.add -n local_aca -a openssh -s eole -r last

View File

@ -6,6 +6,7 @@ from traceback import print_exc
from typing import Dict, List from typing import Dict, List
from tiramisu import Storage, MixConfig from tiramisu import Storage, MixConfig
from tiramisu.error import PropertiesOptionError
from rougail import load as rougail_load from rougail import load as rougail_load
from rougail.config import dtdfilename from rougail.config import dtdfilename
@ -230,22 +231,31 @@ class Risotto(Controller):
'server_to_deploy': await self.build_config(f'std_{server_id}', 'server_to_deploy': await self.build_config(f'std_{server_id}',
server_id, server_id,
server_name, server_name,
mixconfig), mixconfig,
std=True),
'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,
mixconfig: MixConfig) -> None: mixconfig: MixConfig,
std: bool=False) -> None:
""" build server's config """ build server's config
""" """
config = await mixconfig.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)
await config.owner.set(server_name) option_value = config.option('creole.interface_0.domain_name_eth0').value
await config.property.read_only() 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 return config
@register('v1.server.created') @register('v1.server.created')
@ -307,7 +317,8 @@ class Risotto(Controller):
mixconfig = self.servermodel.pop(servermodel_id) mixconfig = self.servermodel.pop(servermodel_id)
children = [] children = []
for child in await mixconfig.config.list(): 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()) 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())

View File

@ -1,4 +1,5 @@
from typing import Dict from typing import Dict
from tiramisu import DomainnameOption
from ...controller import Controller from ...controller import Controller
from ...register import register from ...register import register
@ -29,6 +30,7 @@ class Risotto(Controller):
server_description: str, server_description: str,
servermodel_name: str, servermodel_name: str,
release_distribution: str) -> Dict: release_distribution: str) -> Dict:
DomainnameOption('server_name', _('Server name'), server_name)
servermodel = await self.call('v1.servermodel.describe', servermodel = await self.call('v1.servermodel.describe',
risotto_context, risotto_context,
servermodel_name=servermodel_name, servermodel_name=servermodel_name,