[PATCH 0/4] improve controller

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> add a method to load root sub collections/resouces automatically ShaoHe Feng (4): improve controller: add a method to load root sub collections/resouces automatically improve controller: tag the collections/resouces of root with @urlSubNode improve controller: Root loads collections/resouces automatically improve controller: set authentication automatically src/kimchi/control/__init__.py | 8 ++++++++ src/kimchi/control/config.py | 2 ++ src/kimchi/control/debugreports.py | 2 ++ src/kimchi/control/host.py | 2 ++ src/kimchi/control/interfaces.py | 2 ++ src/kimchi/control/networks.py | 2 ++ src/kimchi/control/plugins.py | 2 ++ src/kimchi/control/storagepools.py | 2 ++ src/kimchi/control/tasks.py | 2 ++ src/kimchi/control/templates.py | 2 ++ src/kimchi/control/vms.py | 2 ++ src/kimchi/root.py | 26 +++++-------------------- src/kimchi/server.py | 12 +++++------- src/kimchi/utils.py | 39 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 77 insertions(+), 28 deletions(-) -- 1.8.4.2

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> load_url_sub_node can load collections/resouces automatically when they are tagged with @urlSubNode Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/utils.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py index 331da91..6d3f2ad 100644 --- a/src/kimchi/utils.py +++ b/src/kimchi/utils.py @@ -22,6 +22,7 @@ # import cherrypy +import imp import os import subprocess import urllib2 @@ -154,3 +155,41 @@ def run_command(cmd, timeout=None): finally: if timer and not timeout_flag[0]: timer.cancel() + + +class urlSubNode(object): + def __init__(self, name, auth=False): + self.name = name + self.auth = auth + + def __call__(self, fun): + fun._url_sub_node_name = {"name": self.name} + fun._url_sub_node_auth = self.auth + return fun + + +def listPathModules(path): + modules = set() + for f in os.listdir(path): + base, ext = os.path.splitext(f) + if ext in ('.py', '.pyc', '.pyo'): + modules.add(base) + return sorted(modules) + + +def load_url_sub_node(path, except_attr="_url_sub_node_name"): + sub_nodes = {} + + for mod_name in listPathModules(path): + if mod_name.startswith("_"): + continue + mod_fobj, mod_absp, mod_desc = imp.find_module(mod_name, [path]) + module = imp.load_module(mod_name, mod_fobj, + mod_absp, mod_desc) + for node in [getattr(module, x) for x in dir(module)]: + if not hasattr(node, except_attr): + continue + name = getattr(node, except_attr)["name"] + sub_nodes.update({name: node}) + + return sub_nodes -- 1.8.4.2

on 2014/01/20 14:00, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
load_url_sub_node can load collections/resouces automatically when they are tagged with @urlSubNode
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/utils.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py index 331da91..6d3f2ad 100644 --- a/src/kimchi/utils.py +++ b/src/kimchi/utils.py @@ -22,6 +22,7 @@ #
import cherrypy +import imp import os import subprocess import urllib2 @@ -154,3 +155,41 @@ def run_command(cmd, timeout=None): finally: if timer and not timeout_flag[0]: timer.cancel() + + +class urlSubNode(object): + def __init__(self, name, auth=False): + self.name = name + self.auth = auth + + def __call__(self, fun): + fun._url_sub_node_name = {"name": self.name} + fun._url_sub_node_auth = self.auth + return fun + + +def listPathModules(path): + modules = set() + for f in os.listdir(path): + base, ext = os.path.splitext(f) + if ext in ('.py', '.pyc', '.pyo'): + modules.add(base) + return sorted(modules) + + +def load_url_sub_node(path, except_attr="_url_sub_node_name"): + sub_nodes = {} + + for mod_name in listPathModules(path): + if mod_name.startswith("_"): + continue + mod_fobj, mod_absp, mod_desc = imp.find_module(mod_name, [path]) + module = imp.load_module(mod_name, mod_fobj, + mod_absp, mod_desc) + for node in [getattr(module, x) for x in dir(module)]: + if not hasattr(node, except_attr): + continue + name = getattr(node, except_attr)["name"] + sub_nodes.update({name: node}) + + return sub_nodes
It seems except_attr should be renamed to expect_attr. -- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

On 01/20/2014 04:30 PM, Zhou Zheng Sheng wrote:
on 2014/01/20 14:00, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
load_url_sub_node can load collections/resouces automatically when they are tagged with @urlSubNode
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/utils.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/src/kimchi/utils.py b/src/kimchi/utils.py index 331da91..6d3f2ad 100644 --- a/src/kimchi/utils.py +++ b/src/kimchi/utils.py @@ -22,6 +22,7 @@ #
import cherrypy +import imp import os import subprocess import urllib2 @@ -154,3 +155,41 @@ def run_command(cmd, timeout=None): finally: if timer and not timeout_flag[0]: timer.cancel() + + +class urlSubNode(object): + def __init__(self, name, auth=False): + self.name = name + self.auth = auth + + def __call__(self, fun): + fun._url_sub_node_name = {"name": self.name} + fun._url_sub_node_auth = self.auth + return fun + + +def listPathModules(path): + modules = set() + for f in os.listdir(path): + base, ext = os.path.splitext(f) + if ext in ('.py', '.pyc', '.pyo'): + modules.add(base) + return sorted(modules) + + +def load_url_sub_node(path, except_attr="_url_sub_node_name"): + sub_nodes = {} + + for mod_name in listPathModules(path): + if mod_name.startswith("_"): + continue + mod_fobj, mod_absp, mod_desc = imp.find_module(mod_name, [path]) + module = imp.load_module(mod_name, mod_fobj, + mod_absp, mod_desc) + for node in [getattr(module, x) for x in dir(module)]: + if not hasattr(node, except_attr): + continue + name = getattr(node, except_attr)["name"] + sub_nodes.update({name: node}) + + return sub_nodes
It seems except_attr should be renamed to expect_attr. yes. expect_attr
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> we can difine a /host as follow: @urlSubNode("host", True) class Host(Resource): def __init__(self, model, id=None): super(Host, self).__init__(model, id) @urlSubNode("host", True) means: the URL "/host" is root.Host, and it need authentication Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/control/__init__.py | 8 ++++++++ src/kimchi/control/config.py | 2 ++ src/kimchi/control/debugreports.py | 2 ++ src/kimchi/control/host.py | 2 ++ src/kimchi/control/interfaces.py | 2 ++ src/kimchi/control/networks.py | 2 ++ src/kimchi/control/plugins.py | 2 ++ src/kimchi/control/storagepools.py | 2 ++ src/kimchi/control/tasks.py | 2 ++ src/kimchi/control/templates.py | 2 ++ src/kimchi/control/vms.py | 2 ++ 11 files changed, 28 insertions(+) diff --git a/src/kimchi/control/__init__.py b/src/kimchi/control/__init__.py index 8a37cc4..3d64099 100644 --- a/src/kimchi/control/__init__.py +++ b/src/kimchi/control/__init__.py @@ -19,3 +19,11 @@ # 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 os + + +from kimchi.utils import load_url_sub_node + + +sub_nodes = load_url_sub_node(os.path.dirname(__file__)) diff --git a/src/kimchi/control/config.py b/src/kimchi/control/config.py index 603f51d..9813b8d 100644 --- a/src/kimchi/control/config.py +++ b/src/kimchi/control/config.py @@ -27,8 +27,10 @@ import cherrypy from kimchi.config import config from kimchi.control.base import Collection, Resource +from kimchi.utils import urlSubNode +@urlSubNode("config") class Config(Resource): def __init__(self, model, id=None): super(Config, self).__init__(model, id) diff --git a/src/kimchi/control/debugreports.py b/src/kimchi/control/debugreports.py index a55ba38..7c594ae 100644 --- a/src/kimchi/control/debugreports.py +++ b/src/kimchi/control/debugreports.py @@ -23,8 +23,10 @@ from kimchi.control.base import AsyncCollection, Resource from kimchi.control.utils import internal_redirect +from kimchi.utils import urlSubNode +@urlSubNode("debugreports", True) class DebugReports(AsyncCollection): def __init__(self, model): super(DebugReports, self).__init__(model) diff --git a/src/kimchi/control/host.py b/src/kimchi/control/host.py index 9b19577..2fc64be 100644 --- a/src/kimchi/control/host.py +++ b/src/kimchi/control/host.py @@ -24,8 +24,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from kimchi.control.base import Collection, Resource +from kimchi.utils import urlSubNode +@urlSubNode("host", True) class Host(Resource): def __init__(self, model, id=None): super(Host, self).__init__(model, id) diff --git a/src/kimchi/control/interfaces.py b/src/kimchi/control/interfaces.py index 28be26e..e6a1e77 100644 --- a/src/kimchi/control/interfaces.py +++ b/src/kimchi/control/interfaces.py @@ -23,8 +23,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from kimchi.control.base import Collection, Resource +from kimchi.utils import urlSubNode +@urlSubNode("interfaces") class Interfaces(Collection): def __init__(self, model): super(Interfaces, self).__init__(model) diff --git a/src/kimchi/control/networks.py b/src/kimchi/control/networks.py index f3f0b41..ac1aaed 100644 --- a/src/kimchi/control/networks.py +++ b/src/kimchi/control/networks.py @@ -22,8 +22,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from kimchi.control.base import Collection, Resource +from kimchi.utils import urlSubNode +@urlSubNode("networks", True) class Networks(Collection): def __init__(self, model): super(Networks, self).__init__(model) diff --git a/src/kimchi/control/plugins.py b/src/kimchi/control/plugins.py index af32709..ff448bd 100644 --- a/src/kimchi/control/plugins.py +++ b/src/kimchi/control/plugins.py @@ -25,8 +25,10 @@ import kimchi.template from kimchi.control.base import Collection, Resource from kimchi.control.utils import get_class_name, model_fn +from kimchi.utils import urlSubNode +@urlSubNode("plugins") class Plugins(Collection): def __init__(self, model): super(Plugins, self).__init__(model) diff --git a/src/kimchi/control/storagepools.py b/src/kimchi/control/storagepools.py index 782f5a6..88d2aa3 100644 --- a/src/kimchi/control/storagepools.py +++ b/src/kimchi/control/storagepools.py @@ -31,8 +31,10 @@ from kimchi.control.storagevolumes import IsoVolumes, StorageVolumes from kimchi.control.utils import get_class_name, model_fn, parse_request from kimchi.control.utils import validate_params from kimchi.model import ISO_POOL_NAME +from kimchi.utils import urlSubNode +@urlSubNode("storagepools", True) class StoragePools(Collection): def __init__(self, model): super(StoragePools, self).__init__(model) diff --git a/src/kimchi/control/tasks.py b/src/kimchi/control/tasks.py index b799422..869cecf 100644 --- a/src/kimchi/control/tasks.py +++ b/src/kimchi/control/tasks.py @@ -22,8 +22,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from kimchi.control.base import Collection, Resource +from kimchi.utils import urlSubNode +@urlSubNode("tasks", True) class Tasks(Collection): def __init__(self, model): super(Tasks, self).__init__(model) diff --git a/src/kimchi/control/templates.py b/src/kimchi/control/templates.py index a77936e..8f59152 100644 --- a/src/kimchi/control/templates.py +++ b/src/kimchi/control/templates.py @@ -22,8 +22,10 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA from kimchi.control.base import Collection, Resource +from kimchi.utils import urlSubNode +@urlSubNode("templates", True) class Templates(Collection): def __init__(self, model): super(Templates, self).__init__(model) diff --git a/src/kimchi/control/vms.py b/src/kimchi/control/vms.py index 7843be7..25474fc 100644 --- a/src/kimchi/control/vms.py +++ b/src/kimchi/control/vms.py @@ -24,8 +24,10 @@ from kimchi.control.base import Collection, Resource from kimchi.control.utils import internal_redirect +from kimchi.utils import urlSubNode +@urlSubNode("vms", True) class VMs(Collection): def __init__(self, model): super(VMs, self).__init__(model) -- 1.8.4.2

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> Root loads collections/resouces automatically Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/root.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/src/kimchi/root.py b/src/kimchi/root.py index 3cc6321..9a04162 100644 --- a/src/kimchi/root.py +++ b/src/kimchi/root.py @@ -28,23 +28,15 @@ import json from kimchi import auth from kimchi import template from kimchi.config import get_api_schema_file +from kimchi.control import sub_nodes from kimchi.control.base import Resource -from kimchi.control.config import Config -from kimchi.control.debugreports import DebugReports -from kimchi.control.host import Host -from kimchi.control.interfaces import Interfaces -from kimchi.control.networks import Networks -from kimchi.control.plugins import Plugins -from kimchi.control.storagepools import StoragePools -from kimchi.control.tasks import Tasks -from kimchi.control.templates import Templates from kimchi.control.utils import parse_request -from kimchi.control.vms import VMs from kimchi.exception import OperationFailed class Root(Resource): def __init__(self, model, dev_env): + super(Root, self).__init__(model) self._handled_error = ['error_page.400', 'error_page.404', 'error_page.405', 'error_page.406', 'error_page.415', 'error_page.500'] @@ -55,18 +47,10 @@ class Root(Resource): else: self._cp_config = dict([(key, self.error_development_handler) for key in self._handled_error]) + print sub_nodes + for ident, node in sub_nodes.items(): + setattr(self, ident, node(model)) - Resource.__init__(self, model) - self.vms = VMs(model) - self.templates = Templates(model) - self.storagepools = StoragePools(model) - self.interfaces = Interfaces(model) - self.networks = Networks(model) - self.tasks = Tasks(model) - self.config = Config(model) - self.host = Host(model) - self.debugreports = DebugReports(model) - self.plugins = Plugins(model) self.api_schema = json.load(open(get_api_schema_file())) def error_production_handler(self, status, message, traceback, version): -- 1.8.4.2

on 2014/01/20 14:00, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Root loads collections/resouces automatically
Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com> --- src/kimchi/root.py | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-)
diff --git a/src/kimchi/root.py b/src/kimchi/root.py index 3cc6321..9a04162 100644 --- a/src/kimchi/root.py +++ b/src/kimchi/root.py @@ -28,23 +28,15 @@ import json from kimchi import auth from kimchi import template from kimchi.config import get_api_schema_file +from kimchi.control import sub_nodes from kimchi.control.base import Resource -from kimchi.control.config import Config -from kimchi.control.debugreports import DebugReports -from kimchi.control.host import Host -from kimchi.control.interfaces import Interfaces -from kimchi.control.networks import Networks -from kimchi.control.plugins import Plugins -from kimchi.control.storagepools import StoragePools -from kimchi.control.tasks import Tasks -from kimchi.control.templates import Templates from kimchi.control.utils import parse_request -from kimchi.control.vms import VMs from kimchi.exception import OperationFailed
class Root(Resource): def __init__(self, model, dev_env): + super(Root, self).__init__(model) self._handled_error = ['error_page.400', 'error_page.404', 'error_page.405', 'error_page.406', 'error_page.415', 'error_page.500'] @@ -55,18 +47,10 @@ class Root(Resource): else: self._cp_config = dict([(key, self.error_development_handler) for key in self._handled_error]) + print sub_nodes
It seems log is better than print.
+ for ident, node in sub_nodes.items(): + setattr(self, ident, node(model))
- Resource.__init__(self, model) - self.vms = VMs(model) - self.templates = Templates(model) - self.storagepools = StoragePools(model) - self.interfaces = Interfaces(model) - self.networks = Networks(model) - self.tasks = Tasks(model) - self.config = Config(model) - self.host = Host(model) - self.debugreports = DebugReports(model) - self.plugins = Plugins(model) self.api_schema = json.load(open(get_api_schema_file()))
def error_production_handler(self, status, message, traceback, version):
-- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

From: ShaoHe Feng <shaohef@linux.vnet.ibm.com> set authentication automatically Signed-off-by: ShaoHe Feng <shaohef@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..d44a5a0 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_sub_node_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

On 01/20/2014 04:00 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
set authentication automatically
Signed-off-by: ShaoHe Feng <shaohef@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..d44a5a0 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_sub_node_auth:
If you would like to access _url_sub_node_auth outside its class you should made it public node.url_sub_node_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()

on 2014/01/21 00:44, Aline Manera wrote:
On 01/20/2014 04:00 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
set authentication automatically
Signed-off-by: ShaoHe Feng <shaohef@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..d44a5a0 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_sub_node_auth:
If you would like to access _url_sub_node_auth outside its class you should made it public
node.url_sub_node_auth
I partly agree. I think "_url_sub_node_auth" is not part of the "normal" public interface, and it's not related to any of the controller responsibilities. It's implementation detail. It's also true we have to visit it outside the class, so we'd better create a "auth" property method to wrap "_url_sub_node_auth" inside the class, and have the function who generated the "_url_sub_node_auth" also generate a "auth" property method.
+ self.configObj["/%s" % ident] = {'tools.kimchiauth.on': True} + self.app = cherrypy.tree.mount(Root(model_instance, dev_env), config=self.configObj) self._load_plugins()
_______________________________________________ Kimchi-devel mailing list Kimchi-devel@ovirt.org http://lists.ovirt.org/mailman/listinfo/kimchi-devel
-- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

Hi, The patches look good. I'd like to know whether ths mechanism can be extended to support subcollection. Is the patch series part of your big plan or they are just to automate root resource controller attaching? on 2014/01/20 14:00, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
add a method to load root sub collections/resouces automatically
ShaoHe Feng (4): improve controller: add a method to load root sub collections/resouces automatically improve controller: tag the collections/resouces of root with @urlSubNode improve controller: Root loads collections/resouces automatically improve controller: set authentication automatically
src/kimchi/control/__init__.py | 8 ++++++++ src/kimchi/control/config.py | 2 ++ src/kimchi/control/debugreports.py | 2 ++ src/kimchi/control/host.py | 2 ++ src/kimchi/control/interfaces.py | 2 ++ src/kimchi/control/networks.py | 2 ++ src/kimchi/control/plugins.py | 2 ++ src/kimchi/control/storagepools.py | 2 ++ src/kimchi/control/tasks.py | 2 ++ src/kimchi/control/templates.py | 2 ++ src/kimchi/control/vms.py | 2 ++ src/kimchi/root.py | 26 +++++-------------------- src/kimchi/server.py | 12 +++++------- src/kimchi/utils.py | 39 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 77 insertions(+), 28 deletions(-)
-- Thanks and best regards! Zhou Zheng Sheng / 周征晟 E-mail: zhshzhou@linux.vnet.ibm.com Telephone: 86-10-82454397

On 01/20/2014 04:51 PM, Zhou Zheng Sheng wrote:
Hi,
The patches look good. I'd like to know whether ths mechanism can be extended to support subcollection. Is the patch series part of your big plan or they are just to automate root resource controller attaching? actually, I just want to support VM subcollection.
Mark think it should be done as a general facility.
on 2014/01/20 14:00, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
add a method to load root sub collections/resouces automatically
ShaoHe Feng (4): improve controller: add a method to load root sub collections/resouces automatically improve controller: tag the collections/resouces of root with @urlSubNode improve controller: Root loads collections/resouces automatically improve controller: set authentication automatically
src/kimchi/control/__init__.py | 8 ++++++++ src/kimchi/control/config.py | 2 ++ src/kimchi/control/debugreports.py | 2 ++ src/kimchi/control/host.py | 2 ++ src/kimchi/control/interfaces.py | 2 ++ src/kimchi/control/networks.py | 2 ++ src/kimchi/control/plugins.py | 2 ++ src/kimchi/control/storagepools.py | 2 ++ src/kimchi/control/tasks.py | 2 ++ src/kimchi/control/templates.py | 2 ++ src/kimchi/control/vms.py | 2 ++ src/kimchi/root.py | 26 +++++-------------------- src/kimchi/server.py | 12 +++++------- src/kimchi/utils.py | 39 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 77 insertions(+), 28 deletions(-)
-- Thanks and best regards! Sheldon Feng(冯少合)<shaohef@linux.vnet.ibm.com> IBM Linux Technology Center

In addition to comments made on patches, I would like to ask you to improve the commit description. In many of them you are just repeating the commit title. Use the commit description to describe with details why the patch is needed and important and what it does. On 01/20/2014 04:00 AM, shaohef@linux.vnet.ibm.com wrote:
From: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
add a method to load root sub collections/resouces automatically
ShaoHe Feng (4): improve controller: add a method to load root sub collections/resouces automatically improve controller: tag the collections/resouces of root with @urlSubNode improve controller: Root loads collections/resouces automatically improve controller: set authentication automatically
src/kimchi/control/__init__.py | 8 ++++++++ src/kimchi/control/config.py | 2 ++ src/kimchi/control/debugreports.py | 2 ++ src/kimchi/control/host.py | 2 ++ src/kimchi/control/interfaces.py | 2 ++ src/kimchi/control/networks.py | 2 ++ src/kimchi/control/plugins.py | 2 ++ src/kimchi/control/storagepools.py | 2 ++ src/kimchi/control/tasks.py | 2 ++ src/kimchi/control/templates.py | 2 ++ src/kimchi/control/vms.py | 2 ++ src/kimchi/root.py | 26 +++++-------------------- src/kimchi/server.py | 12 +++++------- src/kimchi/utils.py | 39 ++++++++++++++++++++++++++++++++++++++ 14 files changed, 77 insertions(+), 28 deletions(-)
participants (4)
-
Aline Manera
-
shaohef@linux.vnet.ibm.com
-
Sheldon
-
Zhou Zheng Sheng