diff --git a/messages/v1/messages/servermodel.describe.yml b/messages/v1/messages/servermodel.describe.yml index 3b0e6ef..b8d5672 100644 --- a/messages/v1/messages/servermodel.describe.yml +++ b/messages/v1/messages/servermodel.describe.yml @@ -9,7 +9,7 @@ pattern: rpc public: true parameters: - servermodelid: + servermodel_id: type: Number shortarg: s description: Identifiant du modèle de serveur à récupérer. diff --git a/messages/v1/messages/source.release.create.yml b/messages/v1/messages/source.release.create.yml new file mode 100644 index 0000000..c7db7d4 --- /dev/null +++ b/messages/v1/messages/source.release.create.yml @@ -0,0 +1,24 @@ +--- +uri: source.release.create + +description: | + Créer une version. + +pattern: rpc + +public: false + +parameters: + source_id: + type: Number + shortarg: i + description: ID de la source. + release_name: + type: String + shortarg: n + description: | + Nom de la version. + +response: + type: 'Release' + description: Information sur la version. diff --git a/messages/v1/types/applicationservice.yml b/messages/v1/types/applicationservice.yml index 9a50344..3bf3dbe 100644 --- a/messages/v1/types/applicationservice.yml +++ b/messages/v1/types/applicationservice.yml @@ -27,5 +27,4 @@ required: - servermodelname - servermodeldescription - servermodelsubreleaseid - - sourceid - subreleasename diff --git a/messages/v1/types/servermodel.source.yml b/messages/v1/types/servermodel.source.yml index 5fdc8d6..a2f8ca8 100644 --- a/messages/v1/types/servermodel.source.yml +++ b/messages/v1/types/servermodel.source.yml @@ -3,16 +3,16 @@ title: ServermodelSource type: object description: Description de la source. properties: - sourceid: + source_id: type: number description: ID de la source. - sourcename: + source_name: type: string description: Nom de la source. - sourceurl: + source_url: type: string description: URL de la source. required: - - sourceid - - sourcename - - sourceurl + - source_id + - source_name + - source_url diff --git a/src/risotto/dispatcher.py b/src/risotto/dispatcher.py index 5590bfb..e966fab 100644 --- a/src/risotto/dispatcher.py +++ b/src/risotto/dispatcher.py @@ -250,7 +250,7 @@ class Dispatcher(register.RegisterDispatcher, CallDispatcher, PublishDispatcher) except AttributeError: if DEBUG: print_exc() - raise AttributeError(_(f'unknown parameter "{key}"')) + raise ValueError(_(f'unknown parameter "{key}"')) # check mandatories options config.property.read_only() mandatories = list(config.value.mandatory()) diff --git a/src/risotto/services/config/config.py b/src/risotto/services/config/config.py index 85d8d2e..088796b 100644 --- a/src/risotto/services/config/config.py +++ b/src/risotto/services/config/config.py @@ -280,7 +280,7 @@ class Risotto(Controller): self.load_server(risotto_context, server_id, servername, - servermodel_id) + servermodelid) @register('v1.server.deleted') async def server_deleted(self, diff --git a/src/risotto/services/servermodel/servermodel.py b/src/risotto/services/servermodel/servermodel.py index da937b8..cea60bb 100644 --- a/src/risotto/services/servermodel/servermodel.py +++ b/src/risotto/services/servermodel/servermodel.py @@ -137,7 +137,7 @@ class Risotto(Controller): return [dict(r) for r in servermodels] @register('v1.servermodel.describe', None) - async def servermodel_describe(self, inheritance, creolefuncs, servermodelid, schema, conffiles, resolvdepends, probes): + async def servermodel_describe(self, inheritance, creolefuncs, servermodel_id, schema, conffiles, resolvdepends, probes): schema = """ @@ -188,4 +188,4 @@ class Risotto(Controller): """ - return {'servermodelid': 1, 'servermodelname': 'name', 'servermodeldescription': 'description', 'subreleasename': 'name', 'source_id': 1, 'schema': schema, 'creolefuncs': ''} + return {'servermodel_id': 1, 'servermodel_name': 'name', 'servermodel_description': 'description', 'release_id': 1, 'schema': schema, 'creolefuncs': ''} diff --git a/tests/fake_services/servermodel/servermodel.py b/tests/fake_services/servermodel/servermodel.py index ad94b65..57d1b70 100644 --- a/tests/fake_services/servermodel/servermodel.py +++ b/tests/fake_services/servermodel/servermodel.py @@ -3,21 +3,19 @@ from risotto.register import register class Risotto(Controller): @register('v1.servermodel.list', None) - async def servermodel_list(self, sourceid): - return [{'servermodelid': 1, - 'servermodelname': 'name1', - 'subreleasename': 'name1', - 'sourceid': 1, - 'servermodeldescription': 'description1'}, - {'servermodelid': 2, - 'servermodelname': 'name2', - 'subreleasename': 'name2', - 'sourceid': 2, - 'servermodeldescription': 'description2', - 'servermodelparentsid': [1]}] + async def servermodel_list(self, source_id): + return [{'servermodel_id': 1, + 'servermodel_name': 'name1', + 'release_id': 1, + 'servermodel_description': 'description1'}, + {'servermodel_id': 2, + 'servermodel_name': 'name2', + 'release_id': 2, + 'servermodel_description': 'description2', + 'servermodel_parents_id': [1]}] @register('v1.servermodel.describe', None) - async def servermodel_describe(self, inheritance, creolefuncs, servermodelid, schema, conffiles, resolvdepends, probes): + async def servermodel_describe(self, inheritance, creolefuncs, servermodel_id, schema, conffiles, resolvdepends, probes): schema = """ @@ -68,4 +66,4 @@ class Risotto(Controller): """ - return {'servermodelid': 1, 'servermodelname': 'name', 'servermodeldescription': 'description', 'subreleasename': 'name', 'sourceid': 1, 'schema': schema, 'creolefuncs': ''} + return {'servermodel_id': 1, 'servermodel_name': 'name', 'servermodel_description': 'description', 'release_id': 1, 'schema': schema, 'creolefuncs': ''} diff --git a/tests/test_config.py b/tests/test_config.py index f788010..b57b257 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -105,11 +105,10 @@ async def test_servermodel_created(): await dispatcher.publish('v1', 'servermodel.created', fake_context, - servermodelid=3, - servermodeldescription='name3', - subreleasename='2.7.0', - sourceid=1, - servermodelname='name3') + servermodel_id=3, + servermodel_description='name3', + release_id=1, + servermodel_name='name3') assert list(config_module.servermodel) == [1, 2, 3] assert not list(config_module.servermodel[3].config.parents()) @@ -124,12 +123,11 @@ async def test_servermodel_herited_created(): await dispatcher.publish('v1', 'servermodel.created', fake_context, - servermodelid=3, - servermodelname='name3', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name3', - servermodelparentsid=[1]) + servermodel_id=3, + servermodel_name='name3', + release_id=1, + servermodel_description='name3', + servermodel_parents_id=[1]) assert list(config_module.servermodel) == [1, 2, 3] assert len(list(config_module.servermodel[3].config.parents())) == 1 @@ -144,12 +142,11 @@ async def test_servermodel_multi_herited_created(): await dispatcher.publish('v1', 'servermodel.created', fake_context, - servermodelid=3, - servermodelname='name3', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name3', - servermodelparentsid=[1, 2]) + servermodel_id=3, + servermodel_name='name3', + release_id=1, + servermodel_description='name3', + servermodel_parents_id=[1, 2]) assert list(config_module.servermodel) == [1, 2, 3] assert len(list(config_module.servermodel[3].config.parents())) == 2 @@ -164,12 +161,11 @@ async def test_servermodel_updated_not_exists(): await dispatcher.publish('v1', 'servermodel.updated', fake_context, - servermodelid=3, - servermodelname='name3', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name3', - servermodelparentsid=[1, 2]) + servermodel_id=3, + servermodel_name='name3', + release_id=1, + servermodel_description='name3', + servermodel_parents_id=[1, 2]) assert list(config_module.servermodel) == [1, 2, 3] assert len(list(config_module.servermodel[3].config.parents())) == 2 @@ -193,11 +189,10 @@ async def test_servermodel_updated1(): await dispatcher.publish('v1', 'servermodel.updated', fake_context, - servermodelid=1, - servermodelname='name1-1', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name1-1') + servermodel_id=1, + servermodel_name='name1-1', + release_id=1, + servermodel_description='name1-1') assert set(config_module.servermodel) == {1, 2} assert config_module.servermodel[1].information.get('servermodel_name') == 'name1-1' assert metaconfig1 != config_module.servermodel[1] @@ -226,12 +221,11 @@ async def test_servermodel_updated2(): await dispatcher.publish('v1', 'servermodel.created', fake_context, - servermodelid=3, - servermodelname='name3', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name3', - servermodelparentsid=[1]) + servermodel_id=3, + servermodel_name='name3', + release_id=1, + servermodel_description='name3', + servermodel_parents_id=[1]) assert list(config_module.servermodel) == [1, 2, 3] assert len(list(config_module.servermodel[3].config.parents())) == 1 assert config_module.servermodel[3].information.get('servermodel_name') == 'name3' @@ -241,12 +235,11 @@ async def test_servermodel_updated2(): await dispatcher.publish('v1', 'servermodel.updated', fake_context, - servermodelid=3, - servermodelname='name3-1', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name3-1', - servermodelparentsid=[1, 2]) + servermodel_id=3, + servermodel_name='name3-1', + release_id=1, + servermodel_description='name3-1', + servermodel_parents_id=[1, 2]) assert list(config_module.servermodel) == [1, 2, 3] assert config_module.servermodel[3].information.get('servermodel_name') == 'name3-1' assert len(list(mixconfig1.config.list())) == 2 @@ -267,11 +260,10 @@ async def test_servermodel_updated_config(): await dispatcher.publish('v1', 'servermodel.updated', fake_context, - servermodelid=1, - servermodelname='name1-1', - subreleasename='2.7.0', - sourceid=1, - servermodeldescription='name1-1') + servermodel_id=1, + servermodel_name='name1-1', + release_id=1, + servermodel_description='name1-1') assert config_module.servermodel[1].option('creole.general.mode_conteneur_actif').value.get() == 'oui'