[Kimchi-devel] [PATCH 05/23] refactor model: Create a separated model for task resource

Aline Manera alinefm at linux.vnet.ibm.com
Wed Jan 29 23:34:46 UTC 2014


From: Aline Manera <alinefm at br.ibm.com>

The model implementation for config and its sub-resources were added to
model_/tasks.py

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 Makefile.am                   |    1 +
 src/kimchi/model_/__init__.py |   21 +++++++++++++++++++++
 src/kimchi/model_/tasks.py    |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 61 insertions(+)
 create mode 100644 src/kimchi/model_/__init__.py
 create mode 100644 src/kimchi/model_/tasks.py

diff --git a/Makefile.am b/Makefile.am
index fa7b6b6..1ffe6db 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ PEP8_WHITELIST = \
 	src/kimchi/iscsi.py \
 	src/kimchi/isoinfo.py \
 	src/kimchi/kvmusertests.py \
+	src/kimchi/model_/*.py \
 	src/kimchi/rollbackcontext.py \
 	src/kimchi/root.py \
 	src/kimchi/server.py \
diff --git a/src/kimchi/model_/__init__.py b/src/kimchi/model_/__init__.py
new file mode 100644
index 0000000..8a37cc4
--- /dev/null
+++ b/src/kimchi/model_/__init__.py
@@ -0,0 +1,21 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+#  Aline Manera <alinefm at 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
diff --git a/src/kimchi/model_/tasks.py b/src/kimchi/model_/tasks.py
new file mode 100644
index 0000000..40ca1d6
--- /dev/null
+++ b/src/kimchi/model_/tasks.py
@@ -0,0 +1,39 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+#  Aline Manera <alinefm at 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
+
+
+class TasksModel(object):
+    def __init__(self, **kargs):
+        self.objstore = kargs['objstore']
+
+    def get_list(self):
+        with self.objstore as session:
+            return session.get_list('task')
+
+
+class TaskModel(object):
+    def __init__(self, **kargs):
+        self.objstore = kargs['objstore']
+
+    def lookup(self, id):
+        with self.objstore as session:
+            return session.get('task', str(id))
-- 
1.7.10.4




More information about the Kimchi-devel mailing list