[PATCH] [WoK 0/3] 'restart' API implementation

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> This patch set implements a new WOK API called 'restart' under /config/restart. Daniel Henrique Barboza (3): restart API: doc changes restart API: control and model changes restart API: new file tests/test_config_model.py docs/API/config.md | 2 +- src/wok/control/config.py | 4 +++- src/wok/model/config.py | 7 ++++++- tests/test_config_model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/test_config_model.py -- 2.7.4

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> This patch adds the documentation of the new 'restart' API in docs/API/config.md. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- docs/API/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/API/config.md b/docs/API/config.md index 0c273e2..0541fc0 100644 --- a/docs/API/config.md +++ b/docs/API/config.md @@ -17,7 +17,7 @@ Contains information about the application environment and configuration. **Actions (POST):** -*No actions defined* +* restart: restarts the server. This process will drop all existing WoK connections, restart WoK and reload all WoK plug-ins. #### Examples GET /config -- 2.7.4

On 01/12/2017 02:41 PM, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
This patch adds the documentation of the new 'restart' API in docs/API/config.md.
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- docs/API/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/API/config.md b/docs/API/config.md index 0c273e2..0541fc0 100644 --- a/docs/API/config.md +++ b/docs/API/config.md @@ -17,7 +17,7 @@ Contains information about the application environment and configuration.
**Actions (POST):**
-*No actions defined* +* restart: restarts the server. This process will drop all existing WoK connections, restart WoK and reload all WoK plug-ins.
"Reload Wok configuration. This process will drop all ... and reload Wok and its plugins."
#### Examples GET /config

Ok, I'll rename the API to 'reload' in v2. Daniel On 01/16/2017 03:46 PM, Aline Manera wrote:
On 01/12/2017 02:41 PM, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
This patch adds the documentation of the new 'restart' API in docs/API/config.md.
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- docs/API/config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/docs/API/config.md b/docs/API/config.md index 0c273e2..0541fc0 100644 --- a/docs/API/config.md +++ b/docs/API/config.md @@ -17,7 +17,7 @@ Contains information about the application environment and configuration.
**Actions (POST):**
-*No actions defined* +* restart: restarts the server. This process will drop all existing WoK connections, restart WoK and reload all WoK plug-ins.
"Reload Wok configuration. This process will drop all ... and reload Wok and its plugins."
#### Examples GET /config
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> - added a new action handler called 'restart' in control/config.py - added a method 'restart' in model/config.py that calls 'cherrypy.engine.restart()'. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- src/wok/control/config.py | 4 +++- src/wok/model/config.py | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wok/control/config.py b/src/wok/control/config.py index 338306c..b274978 100644 --- a/src/wok/control/config.py +++ b/src/wok/control/config.py @@ -1,7 +1,7 @@ # # Project Wok # -# Copyright IBM Corp, 2016 +# Copyright IBM Corp, 2016-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,8 @@ from wok.control.utils import UrlSubNode class Config(Resource): def __init__(self, model, id=None): super(Config, self).__init__(model, id) + self.uri_fmt = '/config/%s' + self.restart = self.generate_action_handler('restart') @property def data(self): diff --git a/src/wok/model/config.py b/src/wok/model/config.py index 7e8ae4f..31624ea 100644 --- a/src/wok/model/config.py +++ b/src/wok/model/config.py @@ -1,7 +1,7 @@ # # Project Wok # -# Copyright IBM Corp, 2016 +# Copyright IBM Corp, 2016-2017 # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -17,6 +17,8 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +import cherrypy + from wok.config import config, get_version @@ -30,3 +32,6 @@ class ConfigModel(object): 'auth': config.get('authentication', 'method'), 'server_root': config.get('server', 'server_root'), 'version': get_version()} + + def restart(self, name): + cherrypy.engine.restart() -- 2.7.4

From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> Created a new unit test file for model/config.py since the existing test_config.py is testing WokConfig. Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- tests/test_config_model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/test_config_model.py diff --git a/tests/test_config_model.py b/tests/test_config_model.py new file mode 100644 index 0000000..d07032d --- /dev/null +++ b/tests/test_config_model.py @@ -0,0 +1,41 @@ +# +# Project Wok +# +# Copyright IBM Corp, 2017 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import mock +import unittest + +from wok.model import model + + +class ConfigModelTests(unittest.TestCase): + + def test_config_lookup(self): + inst = model.Model() + config = inst.config_lookup('') + self.assertItemsEqual( + ['proxy_port', 'websockets_port', 'auth', + 'server_root', 'version'], + config.keys() + ) + + @mock.patch('cherrypy.engine.restart') + def test_config_restart(self, mock_restart): + inst = model.Model() + inst.config_restart('') + mock_restart.assert_called_once_with() -- 2.7.4

On 01/12/2017 02:41 PM, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Created a new unit test file for model/config.py since the existing test_config.py is testing WokConfig.
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- tests/test_config_model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/test_config_model.py
diff --git a/tests/test_config_model.py b/tests/test_config_model.py new file mode 100644 index 0000000..d07032d --- /dev/null +++ b/tests/test_config_model.py @@ -0,0 +1,41 @@ +# +# Project Wok +# +# Copyright IBM Corp, 2017 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import mock +import unittest + +from wok.model import model + + +class ConfigModelTests(unittest.TestCase): + + def test_config_lookup(self): + inst = model.Model() + config = inst.config_lookup('') + self.assertItemsEqual( + ['proxy_port', 'websockets_port', 'auth', + 'server_root', 'version'], + config.keys() + ) + + @mock.patch('cherrypy.engine.restart') + def test_config_restart(self, mock_restart): + inst = model.Model() + inst.config_restart('') + mock_restart.assert_called_once_with()
Please, update Mockmodel for the tests needs and add tests using the API.

On 01/16/2017 03:49 PM, Aline Manera wrote:
On 01/12/2017 02:41 PM, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
Created a new unit test file for model/config.py since the existing test_config.py is testing WokConfig.
Signed-off-by: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com> --- tests/test_config_model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tests/test_config_model.py
diff --git a/tests/test_config_model.py b/tests/test_config_model.py new file mode 100644 index 0000000..d07032d --- /dev/null +++ b/tests/test_config_model.py @@ -0,0 +1,41 @@ +# +# Project Wok +# +# Copyright IBM Corp, 2017 +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +import mock +import unittest + +from wok.model import model + + +class ConfigModelTests(unittest.TestCase): + + def test_config_lookup(self): + inst = model.Model() + config = inst.config_lookup('') + self.assertItemsEqual( + ['proxy_port', 'websockets_port', 'auth', + 'server_root', 'version'], + config.keys() + ) + + @mock.patch('cherrypy.engine.restart') + def test_config_restart(self, mock_restart): + inst = model.Model() + inst.config_restart('') + mock_restart.assert_called_once_with()
Please, update Mockmodel for the tests needs and add tests using the API.
I'll add tests in test_rest.py. There is no mockmodel in WoK :) Daniel
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel

Reviewed-By: Lucio Correia <luciojhc@linux.vnet.ibm.com> On 12/01/2017 14:41, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
This patch set implements a new WOK API called 'restart' under /config/restart.
Daniel Henrique Barboza (3): restart API: doc changes restart API: control and model changes restart API: new file tests/test_config_model.py
docs/API/config.md | 2 +- src/wok/control/config.py | 4 +++- src/wok/model/config.py | 7 ++++++- tests/test_config_model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/test_config_model.py
-- Lucio Correia

Hi Daniel, I'd say to name this API as 'reload' as it is makes more sense when nesting to /config. On 01/12/2017 02:41 PM, dhbarboza82@gmail.com wrote:
From: Daniel Henrique Barboza <danielhb@linux.vnet.ibm.com>
This patch set implements a new WOK API called 'restart' under /config/restart.
Daniel Henrique Barboza (3): restart API: doc changes restart API: control and model changes restart API: new file tests/test_config_model.py
docs/API/config.md | 2 +- src/wok/control/config.py | 4 +++- src/wok/model/config.py | 7 ++++++- tests/test_config_model.py | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/test_config_model.py
participants (4)
-
Aline Manera
-
Daniel Henrique Barboza
-
dhbarboza82@gmail.com
-
Lucio Correia