[Kimchi-devel] [PATCH] [Wok] Add system arch to /config API

Aline Manera posted 1 patch 84 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/kimchi-wok tags/patchew/20170425190619.3472-1-alinefm@linux.vnet.ibm.com
docs/API/config.md         | 2 ++
src/wok/model/config.py    | 4 ++++
tests/test_api.py          | 2 +-
tests/test_config_model.py | 2 +-
tests/test_server_root.py  | 6 +++---
5 files changed, 11 insertions(+), 5 deletions(-)

[Kimchi-devel] [PATCH] [Wok] Add system arch to /config API

Posted by Aline Manera 84 weeks ago
It may be useful when UI differs depending on system arch.

It is part of solution to remove Ginger Base dependency from Kimchi.

Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
---
 docs/API/config.md         | 2 ++
 src/wok/model/config.py    | 4 ++++
 tests/test_api.py          | 2 +-
 tests/test_config_model.py | 2 +-
 tests/test_server_root.py  | 6 +++---
 5 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/docs/API/config.md b/docs/API/config.md
index d1d1007..b810f2a 100644
--- a/docs/API/config.md
+++ b/docs/API/config.md
@@ -12,6 +12,8 @@ Contains information about the application environment and configuration.
     * proxy_port: SSL port to list on
     * websockets_port: Port for websocket proxy to listen on
     * auth: Authentication method used to log in to Wok
+    * server_root: Wok root API path
+    * arch: System architecture
     * version: Wok version
 * **POST**: *See Task Actions*
 
diff --git a/src/wok/model/config.py b/src/wok/model/config.py
index b69f2dd..54aaf54 100644
--- a/src/wok/model/config.py
+++ b/src/wok/model/config.py
@@ -18,12 +18,15 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
 import cherrypy
+import platform
 import time
 
 from wok.config import config, get_version
 from wok.model.notifications import add_notification
 from wok.utils import wok_log
 
+ARCH = platform.machine()
+
 
 class ConfigModel(object):
     def __init__(self, **kargs):
@@ -34,6 +37,7 @@ class ConfigModel(object):
                 'websockets_port': config.get('server', 'websockets_port'),
                 'auth': config.get('authentication', 'method'),
                 'server_root': config.get('server', 'server_root'),
+                'arch': ARCH,
                 'version': get_version()}
 
     def reload(self, name):
diff --git a/tests/test_api.py b/tests/test_api.py
index 6fbee75..4e2e413 100644
--- a/tests/test_api.py
+++ b/tests/test_api.py
@@ -52,7 +52,7 @@ class APITests(unittest.TestCase):
     def test_config(self):
         resp = self.request('/config').read()
         conf = json.loads(resp)
-        keys = ["auth", "proxy_port", "websockets_port", "version",
+        keys = ["arch", "auth", "proxy_port", "websockets_port", "version",
                 "server_root"]
         self.assertEquals(sorted(keys), sorted(conf.keys()))
 
diff --git a/tests/test_config_model.py b/tests/test_config_model.py
index f8b0848..df2b058 100644
--- a/tests/test_config_model.py
+++ b/tests/test_config_model.py
@@ -30,7 +30,7 @@ class ConfigModelTests(unittest.TestCase):
         config = inst.config_lookup('')
         self.assertItemsEqual(
             ['proxy_port', 'websockets_port', 'auth',
-             'server_root', 'version'],
+             'server_root', 'arch', 'version'],
             config.keys()
         )
 
diff --git a/tests/test_server_root.py b/tests/test_server_root.py
index e95a13b..89f34d3 100644
--- a/tests/test_server_root.py
+++ b/tests/test_server_root.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
@@ -49,7 +49,7 @@ class ServerRootTests(unittest.TestCase):
         # check if server_root in config is the same used to start server
         resp = request(server_root + '/config').read()
         conf = json.loads(resp)
-        self.assertEquals(len(conf), 5)
+        self.assertEquals(len(conf), 6)
 
     def test_development_env(self):
         """
@@ -61,4 +61,4 @@ class ServerRootTests(unittest.TestCase):
         # check if server_root in config is the same used to start server
         resp = request(server_root + '/config').read()
         conf = json.loads(resp)
-        self.assertEquals(len(conf), 5)
+        self.assertEquals(len(conf), 6)
-- 
2.9.3

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel

Re: [Kimchi-devel] [PATCH] [Wok] Add system arch to /config API

Posted by Daniel Henrique Barboza 84 weeks ago
Reviewed-by: Daniel Barboza <danielhb@linux.vnet.ibm.com>

On 04/25/2017 04:06 PM, Aline Manera wrote:
> It may be useful when UI differs depending on system arch.
>
> It is part of solution to remove Ginger Base dependency from Kimchi.
>
> Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
> ---
>   docs/API/config.md         | 2 ++
>   src/wok/model/config.py    | 4 ++++
>   tests/test_api.py          | 2 +-
>   tests/test_config_model.py | 2 +-
>   tests/test_server_root.py  | 6 +++---
>   5 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/docs/API/config.md b/docs/API/config.md
> index d1d1007..b810f2a 100644
> --- a/docs/API/config.md
> +++ b/docs/API/config.md
> @@ -12,6 +12,8 @@ Contains information about the application environment and configuration.
>       * proxy_port: SSL port to list on
>       * websockets_port: Port for websocket proxy to listen on
>       * auth: Authentication method used to log in to Wok
> +    * server_root: Wok root API path
> +    * arch: System architecture
>       * version: Wok version
>   * **POST**: *See Task Actions*
>   
> diff --git a/src/wok/model/config.py b/src/wok/model/config.py
> index b69f2dd..54aaf54 100644
> --- a/src/wok/model/config.py
> +++ b/src/wok/model/config.py
> @@ -18,12 +18,15 @@
>   # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
>   
>   import cherrypy
> +import platform
>   import time
>   
>   from wok.config import config, get_version
>   from wok.model.notifications import add_notification
>   from wok.utils import wok_log
>   
> +ARCH = platform.machine()
> +
>   
>   class ConfigModel(object):
>       def __init__(self, **kargs):
> @@ -34,6 +37,7 @@ class ConfigModel(object):
>                   'websockets_port': config.get('server', 'websockets_port'),
>                   'auth': config.get('authentication', 'method'),
>                   'server_root': config.get('server', 'server_root'),
> +                'arch': ARCH,
>                   'version': get_version()}
>   
>       def reload(self, name):
> diff --git a/tests/test_api.py b/tests/test_api.py
> index 6fbee75..4e2e413 100644
> --- a/tests/test_api.py
> +++ b/tests/test_api.py
> @@ -52,7 +52,7 @@ class APITests(unittest.TestCase):
>       def test_config(self):
>           resp = self.request('/config').read()
>           conf = json.loads(resp)
> -        keys = ["auth", "proxy_port", "websockets_port", "version",
> +        keys = ["arch", "auth", "proxy_port", "websockets_port", "version",
>                   "server_root"]
>           self.assertEquals(sorted(keys), sorted(conf.keys()))
>   
> diff --git a/tests/test_config_model.py b/tests/test_config_model.py
> index f8b0848..df2b058 100644
> --- a/tests/test_config_model.py
> +++ b/tests/test_config_model.py
> @@ -30,7 +30,7 @@ class ConfigModelTests(unittest.TestCase):
>           config = inst.config_lookup('')
>           self.assertItemsEqual(
>               ['proxy_port', 'websockets_port', 'auth',
> -             'server_root', 'version'],
> +             'server_root', 'arch', 'version'],
>               config.keys()
>           )
>   
> diff --git a/tests/test_server_root.py b/tests/test_server_root.py
> index e95a13b..89f34d3 100644
> --- a/tests/test_server_root.py
> +++ b/tests/test_server_root.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
> @@ -49,7 +49,7 @@ class ServerRootTests(unittest.TestCase):
>           # check if server_root in config is the same used to start server
>           resp = request(server_root + '/config').read()
>           conf = json.loads(resp)
> -        self.assertEquals(len(conf), 5)
> +        self.assertEquals(len(conf), 6)
>   
>       def test_development_env(self):
>           """
> @@ -61,4 +61,4 @@ class ServerRootTests(unittest.TestCase):
>           # check if server_root in config is the same used to start server
>           resp = request(server_root + '/config').read()
>           conf = json.loads(resp)
> -        self.assertEquals(len(conf), 5)
> +        self.assertEquals(len(conf), 6)

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel

Re: [Kimchi-devel] [PATCH] [Wok] Add system arch to /config API

Posted by Aline Manera 84 weeks ago
Please, ignore this patch.

I realized that Kimchi as a /host API which may be used to return the arch.

I will send that solution that only changes Kimchi.

On 04/25/2017 04:06 PM, Aline Manera wrote:
> It may be useful when UI differs depending on system arch.
>
> It is part of solution to remove Ginger Base dependency from Kimchi.
>
> Signed-off-by: Aline Manera <alinefm@linux.vnet.ibm.com>
> ---
>   docs/API/config.md         | 2 ++
>   src/wok/model/config.py    | 4 ++++
>   tests/test_api.py          | 2 +-
>   tests/test_config_model.py | 2 +-
>   tests/test_server_root.py  | 6 +++---
>   5 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/docs/API/config.md b/docs/API/config.md
> index d1d1007..b810f2a 100644
> --- a/docs/API/config.md
> +++ b/docs/API/config.md
> @@ -12,6 +12,8 @@ Contains information about the application environment and configuration.
>       * proxy_port: SSL port to list on
>       * websockets_port: Port for websocket proxy to listen on
>       * auth: Authentication method used to log in to Wok
> +    * server_root: Wok root API path
> +    * arch: System architecture
>       * version: Wok version
>   * **POST**: *See Task Actions*
>
> diff --git a/src/wok/model/config.py b/src/wok/model/config.py
> index b69f2dd..54aaf54 100644
> --- a/src/wok/model/config.py
> +++ b/src/wok/model/config.py
> @@ -18,12 +18,15 @@
>   # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
>
>   import cherrypy
> +import platform
>   import time
>
>   from wok.config import config, get_version
>   from wok.model.notifications import add_notification
>   from wok.utils import wok_log
>
> +ARCH = platform.machine()
> +
>
>   class ConfigModel(object):
>       def __init__(self, **kargs):
> @@ -34,6 +37,7 @@ class ConfigModel(object):
>                   'websockets_port': config.get('server', 'websockets_port'),
>                   'auth': config.get('authentication', 'method'),
>                   'server_root': config.get('server', 'server_root'),
> +                'arch': ARCH,
>                   'version': get_version()}
>
>       def reload(self, name):
> diff --git a/tests/test_api.py b/tests/test_api.py
> index 6fbee75..4e2e413 100644
> --- a/tests/test_api.py
> +++ b/tests/test_api.py
> @@ -52,7 +52,7 @@ class APITests(unittest.TestCase):
>       def test_config(self):
>           resp = self.request('/config').read()
>           conf = json.loads(resp)
> -        keys = ["auth", "proxy_port", "websockets_port", "version",
> +        keys = ["arch", "auth", "proxy_port", "websockets_port", "version",
>                   "server_root"]
>           self.assertEquals(sorted(keys), sorted(conf.keys()))
>
> diff --git a/tests/test_config_model.py b/tests/test_config_model.py
> index f8b0848..df2b058 100644
> --- a/tests/test_config_model.py
> +++ b/tests/test_config_model.py
> @@ -30,7 +30,7 @@ class ConfigModelTests(unittest.TestCase):
>           config = inst.config_lookup('')
>           self.assertItemsEqual(
>               ['proxy_port', 'websockets_port', 'auth',
> -             'server_root', 'version'],
> +             'server_root', 'arch', 'version'],
>               config.keys()
>           )
>
> diff --git a/tests/test_server_root.py b/tests/test_server_root.py
> index e95a13b..89f34d3 100644
> --- a/tests/test_server_root.py
> +++ b/tests/test_server_root.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
> @@ -49,7 +49,7 @@ class ServerRootTests(unittest.TestCase):
>           # check if server_root in config is the same used to start server
>           resp = request(server_root + '/config').read()
>           conf = json.loads(resp)
> -        self.assertEquals(len(conf), 5)
> +        self.assertEquals(len(conf), 6)
>
>       def test_development_env(self):
>           """
> @@ -61,4 +61,4 @@ class ServerRootTests(unittest.TestCase):
>           # check if server_root in config is the same used to start server
>           resp = request(server_root + '/config').read()
>           conf = json.loads(resp)
> -        self.assertEquals(len(conf), 5)
> +        self.assertEquals(len(conf), 6)

_______________________________________________
Kimchi-devel mailing list
Kimchi-devel@ovirt.org
http://lists.ovirt.org/mailman/listinfo/kimchi-devel