From: Aline Manera <alinefm(a)br.ibm.com>
Templates(Collection) and Template(Resource) were moved to a new -
control/templates.py
That way we can easily know where template resource is implemented.
Signed-off-by: Aline Manera <alinefm(a)br.ibm.com>
---
Makefile.am | 1 +
src/kimchi/control/templates.py | 51 +++++++++++++++++++++++++++++++++++++++
2 files changed, 52 insertions(+)
create mode 100644 src/kimchi/control/templates.py
diff --git a/Makefile.am b/Makefile.am
index 3fda86f..f510e11 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,6 +46,7 @@ PEP8_WHITELIST = \
src/kimchi/root.py \
src/kimchi/server.py \
src/kimchi/control/base.py \
+ src/kimchi/control/templates.py \
src/kimchi/control/utils.py \
src/kimchi/control/vms.py \
plugins/__init__.py \
diff --git a/src/kimchi/control/templates.py b/src/kimchi/control/templates.py
new file mode 100644
index 0000000..a0de25c
--- /dev/null
+++ b/src/kimchi/control/templates.py
@@ -0,0 +1,51 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+# Adam Litke <agl(a)linux.vnet.ibm.com>
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# 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
+
+from kimchi.control.base import Collection, Resource
+
+
+class Templates(Collection):
+ def __init__(self, model):
+ super(Templates, self).__init__(model)
+ self.resource = Template
+
+
+class Template(Resource):
+ def __init__(self, model, ident):
+ super(Template, self).__init__(model, ident)
+ self.update_params = ["name", "folder", "icon",
"os_distro",
+ "storagepool", "os_version",
"cpus",
+ "memory", "cdrom", "disks"]
+ self.uri_fmt = "/templates/%s"
+
+ @property
+ def data(self):
+ return {'name': self.ident,
+ 'icon': self.info['icon'],
+ 'os_distro': self.info['os_distro'],
+ 'os_version': self.info['os_version'],
+ 'cpus': self.info['cpus'],
+ 'memory': self.info['memory'],
+ 'cdrom': self.info['cdrom'],
+ 'disks': self.info['disks'],
+ 'storagepool': self.info['storagepool'],
+ 'folder': self.info.get('folder', [])}
--
1.7.10.4