<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/24/2013 04:26 AM, Mark Wu wrote:<br>
</div>
<blockquote cite="mid:52B9290A.7060505@linux.vnet.ibm.com"
type="cite">On 12/24/2013 02:41 AM, Aline Manera wrote:
<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>
VMs(Collection), VM(Resource) and VMScreenshot(Resource) were
moved to a new -
<br>
control/vms.py
<br>
That way we can easily know where vm resource is implemented.
<br>
<br>
Signed-off-by: Aline Manera <a class="moz-txt-link-rfc2396E" href="mailto:alinefm@br.ibm.com"><alinefm@br.ibm.com></a>
<br>
---
<br>
Makefile.am | 1 +
<br>
src/kimchi/control/vms.py | 64
+++++++++++++++++++++++++++++++++++++++++++++
<br>
2 files changed, 65 insertions(+)
<br>
create mode 100644 src/kimchi/control/vms.py
<br>
<br>
diff --git a/Makefile.am b/Makefile.am
<br>
index 997d4cc..3fda86f 100644
<br>
--- a/Makefile.am
<br>
+++ b/Makefile.am
<br>
@@ -47,6 +47,7 @@ PEP8_WHITELIST = \
<br>
src/kimchi/server.py \
<br>
src/kimchi/control/base.py \
<br>
src/kimchi/control/utils.py \
<br>
+ src/kimchi/control/vms.py \
<br>
plugins/__init__.py \
<br>
plugins/sample/__init__.py \
<br>
plugins/sample/model.py \
<br>
diff --git a/src/kimchi/control/vms.py
b/src/kimchi/control/vms.py
<br>
new file mode 100644
<br>
index 0000000..da960cd
<br>
--- /dev/null
<br>
+++ b/src/kimchi/control/vms.py
<br>
@@ -0,0 +1,64 @@
<br>
+#
<br>
+# Project Kimchi
<br>
+#
<br>
+# Copyright IBM, Corp. 2013
<br>
+#
<br>
+# Authors:
<br>
+# Adam Litke <a class="moz-txt-link-rfc2396E" href="mailto:agl@linux.vnet.ibm.com"><agl@linux.vnet.ibm.com></a>
<br>
+# Aline Manera <a class="moz-txt-link-rfc2396E" href="mailto:alinefm@linux.vnet.ibm.com"><alinefm@linux.vnet.ibm.com></a>
<br>
+#
<br>
+# This library is free software; you can redistribute it and/or
<br>
+# modify it under the terms of the GNU Lesser General Public
<br>
+# License as published by the Free Software Foundation; either
<br>
+# version 2.1 of the License, or (at your option) any later
version.
<br>
+#
<br>
+# This library is distributed in the hope that it will be
useful,
<br>
+# but WITHOUT ANY WARRANTY; without even the implied warranty
of
<br>
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU
<br>
+# Lesser General Public License for more details.
<br>
+#
<br>
+# You should have received a copy of the GNU Lesser General
Public
<br>
+# License along with this library; if not, write to the Free
Software
<br>
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA
<br>
+
<br>
+from kimchi.control.base import Collection, Resource
<br>
+from kimchi.control.utils import internal_redirect
<br>
+
<br>
+
<br>
+class VMs(Collection):
<br>
+ def __init__(self, model):
<br>
+ super(VMs, self).__init__(model)
<br>
+ self.resource = VM
<br>
+
<br>
+
<br>
+class VM(Resource):
<br>
+ def __init__(self, model, ident):
<br>
+ super(VM, self).__init__(model, ident)
<br>
+ self.update_params = ["name"]
<br>
+ self.screenshot = VMScreenShot(model, ident)
<br>
+ self.uri_fmt = '/vms/%s'
<br>
+ self.start = self.generate_action_handler(self,
'start')
<br>
+ self.stop = self.generate_action_handler(self, 'stop')
<br>
+ self.connect = self.generate_action_handler(self,
'connect')
<br>
+
<br>
+ @property
<br>
+ def data(self):
<br>
+ return {'name': self.ident,
<br>
+ 'uuid': self.info['uuid'],
<br>
+ 'stats': self.info['stats'],
<br>
+ 'memory': self.info['memory'],
<br>
+ 'cpus': self.info['cpus'],
<br>
+ 'state': self.info['state'],
<br>
+ 'screenshot': self.info['screenshot'],
<br>
+ 'icon': self.info['icon'],
<br>
+ 'graphics': {'type':
self.info['graphics']['type'],
<br>
+ 'port':
self.info['graphics']['port']}}
<br>
+
<br>
+
<br>
+class VMScreenShot(Resource):
<br>
+ def __init__(self, model, ident):
<br>
+ super(VMScreenShot, self).__init__(model, ident)
<br>
+
<br>
+ def get(self):
<br>
+ self.lookup()
<br>
+ raise internal_redirect(self.info)
<br>
</blockquote>
I don't understand why the original code was remained there.
<br>
</blockquote>
<br>
<font face="DejaVu Sans Mono">I removed the controller.py file in
the last commit.<br>
After all changes are done.<br>
</font>
</body>
</html>