[Kimchi-devel] [PATCH 14/15] Move all resources related to plugins to control/plugins.py

Aline Manera alinefm at linux.vnet.ibm.com
Thu Dec 26 21:49:02 UTC 2013


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

Plugins(Collection) was moved to a new - control/plugins.py
That way we can easily know where plugins resource is implemented.

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 src/kimchi/control/plugins.py |   45 +++++++++++++++++++++++++++++++++++++++++
 src/kimchi/controller.py      |   19 -----------------
 src/kimchi/root.py            |    3 ++-
 3 files changed, 47 insertions(+), 20 deletions(-)
 create mode 100644 src/kimchi/control/plugins.py

diff --git a/src/kimchi/control/plugins.py b/src/kimchi/control/plugins.py
new file mode 100644
index 0000000..af32709
--- /dev/null
+++ b/src/kimchi/control/plugins.py
@@ -0,0 +1,45 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+#  Aline Manera <alinefm at linux.vnet.ibm.com>
+#  ShaoHe Feng <shaohef at linux.vnet.ibm.com>
+#  zhoumeina <zhoumein 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
+
+import kimchi.template
+from kimchi.control.base import Collection, Resource
+from kimchi.control.utils import get_class_name, model_fn
+
+
+class Plugins(Collection):
+    def __init__(self, model):
+        super(Plugins, self).__init__(model)
+
+    @property
+    def data(self):
+        return self.info
+
+    def get(self):
+        res_list = []
+        try:
+            get_list = getattr(self.model, model_fn(self, 'get_list'))
+            res_list = get_list(*self.model_args)
+        except AttributeError:
+            pass
+        return kimchi.template.render(get_class_name(self), res_list)
diff --git a/src/kimchi/controller.py b/src/kimchi/controller.py
index aca54f2..4684e11 100644
--- a/src/kimchi/controller.py
+++ b/src/kimchi/controller.py
@@ -50,22 +50,3 @@ class Tasks(Collection):
     def __init__(self, model):
         super(Tasks, self).__init__(model)
         self.resource = Task
-
-
-class Plugins(Collection):
-    def __init__(self, model):
-        super(Plugins, self).__init__(model)
-        self.model = model
-
-    @property
-    def data(self):
-        return self.info
-
-    def get(self):
-        res_list = []
-        try:
-            get_list = getattr(self.model, model_fn(self, 'get_list'))
-            res_list = get_list(*self.model_args)
-        except AttributeError:
-            pass
-        return kimchi.template.render(get_class_name(self), res_list)
diff --git a/src/kimchi/root.py b/src/kimchi/root.py
index 6e5f282..8ea15d8 100644
--- a/src/kimchi/root.py
+++ b/src/kimchi/root.py
@@ -36,6 +36,7 @@ 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.templates import Templates
 from kimchi.control.vms import VMs
@@ -65,7 +66,7 @@ class Root(Resource):
         self.config = Config(model)
         self.host = Host(model)
         self.debugreports = DebugReports(model)
-        self.plugins = controller.Plugins(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.7.10.4




More information about the Kimchi-devel mailing list