[Kimchi-devel] [PATCH V2 4/4] improve controller: set authentication automatically

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Tue Jan 21 14:03:20 UTC 2014


From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>

Remove hard code from server.py.
We do not need to touch root.py any more when we add a new sub
collection/resouce.

Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
 src/kimchi/server.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/kimchi/server.py b/src/kimchi/server.py
index b820263..6acf2f4 100644
--- a/src/kimchi/server.py
+++ b/src/kimchi/server.py
@@ -35,6 +35,7 @@ from kimchi import mockmodel
 from kimchi import vnc
 from kimchi.root import Root
 from kimchi.utils import get_enabled_plugins, import_class
+from kimchi.control import sub_nodes
 
 
 LOGGING_LEVEL = {"debug": logging.DEBUG,
@@ -74,13 +75,6 @@ class Server(object):
               'tools.sessions.storage_type': 'file',
               'tools.sessions.storage_path': config.get_session_path(),
               'tools.kimchiauth.on': False},
-        '/host': {'tools.kimchiauth.on': True},
-        '/vms': {'tools.kimchiauth.on': True},
-        '/templates': {'tools.kimchiauth.on': True},
-        '/networks': {'tools.kimchiauth.on': True},
-        '/storagepools': {'tools.kimchiauth.on': True},
-        '/tasks': {'tools.kimchiauth.on': True},
-        '/debugreports': {'tools.kimchiauth.on': True},
         '/css': {
             'tools.staticdir.on': True,
             'tools.staticdir.dir': 'ui/css',
@@ -193,6 +187,10 @@ class Server(object):
             vnc_ws_proxy = vnc.new_ws_proxy()
             cherrypy.engine.subscribe('exit', vnc_ws_proxy.kill)
 
+        for ident, node in sub_nodes.items():
+            if node.url_auth:
+                self.configObj["/%s" % ident] = {'tools.kimchiauth.on': True}
+
         self.app = cherrypy.tree.mount(Root(model_instance, dev_env),
                                        config=self.configObj)
         self._load_plugins()
-- 
1.8.4.2




More information about the Kimchi-devel mailing list