<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 12/26/2013 02:55 PM, Shu Ming wrote:<br>
</div>
<blockquote cite="mid:52BBD2F0.2000406@linux.vnet.ibm.com"
type="cite">2013/12/24 2:41, Aline Manera:
<br>
<blockquote type="cite">From: Aline Manera
<a class="moz-txt-link-rfc2396E" href="mailto:alinefm@br.ibm.com"><alinefm@br.ibm.com></a>
<br>
<br>
The current implemenation put all resources implementation into
controller.py
<br>
file. That way this file tends to increase to infinity as more
resources are
<br>
added to Kimchi.
<br>
<br>
This patch splits controller module (controller.py) into small
modules.
<br>
So each resource will have its own controller implementation
under /control
<br>
It will make maintenance easier and anyone can easily identify
where any resource
<br>
is implemented.
<br>
</blockquote>
I would argue that most the resources defined are pretty trival
and splitting these definitions into different files will add many
small files which cause unnecessary maintenance. From another
point of view, the real logical is in model.py, do you have plan
to split the model.py file?
<br>
</blockquote>
Maybe we can refactor the controller-model structure, make it more
better. <br>
such some <font size="3">mechanism to register different <font
color="#000000">collection</font></font>s.<br>
<br>
For src/kimchi/control/tasks.py <br>
<br>
@expose("tasks", "auth")<br>
+class Tasks(Collection):
<br>
+ def __init__(self, model):
<br>
+ super(Tasks, self).__init__(model)
<br>
+ self.resource = Task
<br>
<br>
<br>
"expose" means Tasks will be added as an exposed attribute "tasks"
of root.<br>
src/kimchi/control/__init__.py can do the <font size="3">register.</font><br>
Then we will no need to assign Tasks to Root.tasks manually.<br>
<pre wrap="">
And these code in root.py can be removed.
--- a/src/kimchi/root.py
+++ b/src/kimchi/root.py
src/kimchi/root.py
+from kimchi.control.tasks import Tasks
+class Root(Resource):
def __init__(self, model, dev_env):
+ self.tasks = Tasks(model)</pre>
<br>
<br>
<blockquote cite="mid:52BBD2F0.2000406@linux.vnet.ibm.com"
type="cite">
<br>
<br>
<blockquote type="cite">
<br>
This patch set does not change any logic - just move classes
from controller
<br>
to a new module.
<br>
<br>
Aline Manera (16):
<br>
Move generate_action_handler() function to Resource() class
<br>
Move common functions for Resource and Collection to
control/utils.py
<br>
Move login() and logout() functions from controller.py to
root.py
<br>
Move basic controller resources to control/base.py
<br>
Move all resources related to vms to control/vms.py
<br>
Move all resources related to templates to
control/templates.py
<br>
Move all resources related to debug reports to
<br>
control/debugreports.py
<br>
Move all resources related to storage pools to
<br>
control/storagepools.py
<br>
Move all resources related to storage volume to
<br>
control/storagevolumes.py
<br>
Move all resources related to interfaces to
control/interfaces.py
<br>
Move all resources related to networks to control/networks.py
<br>
Move all resources related to config to control/config.py
<br>
Move all resources related to host to control/host.py
<br>
Move all resources related to plugins to control/plugins.py
<br>
Move all resources related to tasks to control/tasks.py
<br>
Use new control modules in root.py
<br>
<br>
Makefile.am | 13 +
<br>
src/kimchi/control/__init__.py | 21 +
<br>
src/kimchi/control/base.py | 290 +++++++++++++
<br>
src/kimchi/control/config.py | 65 +++
<br>
src/kimchi/control/debugreports.py | 52 +++
<br>
src/kimchi/control/host.py | 61 +++
<br>
src/kimchi/control/interfaces.py | 44 ++
<br>
src/kimchi/control/networks.py | 48 +++
<br>
src/kimchi/control/plugins.py | 44 ++
<br>
src/kimchi/control/storagepools.py | 125 ++++++
<br>
src/kimchi/control/storagevolumes.py | 79 ++++
<br>
src/kimchi/control/tasks.py | 41 ++
<br>
src/kimchi/control/templates.py | 51 +++
<br>
src/kimchi/control/utils.py | 103 +++++
<br>
src/kimchi/control/vms.py | 64 +++
<br>
src/kimchi/controller.py | 755
----------------------------------
<br>
src/kimchi/root.py | 61 ++-
<br>
17 files changed, 1147 insertions(+), 770 deletions(-)
<br>
create mode 100644 src/kimchi/control/__init__.py
<br>
create mode 100644 src/kimchi/control/base.py
<br>
create mode 100644 src/kimchi/control/config.py
<br>
create mode 100644 src/kimchi/control/debugreports.py
<br>
create mode 100644 src/kimchi/control/host.py
<br>
create mode 100644 src/kimchi/control/interfaces.py
<br>
create mode 100644 src/kimchi/control/networks.py
<br>
create mode 100644 src/kimchi/control/plugins.py
<br>
create mode 100644 src/kimchi/control/storagepools.py
<br>
create mode 100644 src/kimchi/control/storagevolumes.py
<br>
create mode 100644 src/kimchi/control/tasks.py
<br>
create mode 100644 src/kimchi/control/templates.py
<br>
create mode 100644 src/kimchi/control/utils.py
<br>
create mode 100644 src/kimchi/control/vms.py
<br>
delete mode 100644 src/kimchi/controller.py
<br>
<br>
</blockquote>
<br>
_______________________________________________
<br>
Kimchi-devel mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
<br>
<br>
<br>
<br>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Sheldon Feng(冯少合)<a class="moz-txt-link-rfc2396E" href="mailto:shaohef@linux.vnet.ibm.com"><shaohef@linux.vnet.ibm.com></a>
IBM Linux Technology Center</pre>
</body>
</html>