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

shaohef at linux.vnet.ibm.com shaohef at linux.vnet.ibm.com
Fri Jan 24 01:38:13 UTC 2014


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

Remove hard code from server.py.
We do not need to touch server.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..2a9f53f 100644
--- a/src/kimchi/server.py
+++ b/src/kimchi/server.py
@@ -33,6 +33,7 @@ from kimchi import config
 from kimchi import model
 from kimchi import mockmodel
 from kimchi import vnc
+from kimchi.control import sub_nodes
 from kimchi.root import Root
 from kimchi.utils import get_enabled_plugins, import_class
 
@@ -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