[Kimchi-devel] [PATCH 12/16] Move all resources related to config to control/config.py

Aline Manera alinefm at linux.vnet.ibm.com
Mon Dec 23 18:41:27 UTC 2013


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

Config(Resource), Capabilities(Resource), Distros(Collection) and Distro(Resource)
were moved to a new - control/config.py
That way we can easily know where config resource is implemented.

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 Makefile.am                  |    1 +
 src/kimchi/control/config.py |   65 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 66 insertions(+)
 create mode 100644 src/kimchi/control/config.py

diff --git a/Makefile.am b/Makefile.am
index 988702e..5ae93cd 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/config.py \
 	src/kimchi/control/debugreports.py \
 	src/kimchi/control/interfaces.py \
 	src/kimchi/control/networks.py \
diff --git a/src/kimchi/control/config.py b/src/kimchi/control/config.py
new file mode 100644
index 0000000..df4d89b
--- /dev/null
+++ b/src/kimchi/control/config.py
@@ -0,0 +1,65 @@
+#
+# Project Kimchi
+#
+# Copyright IBM, Corp. 2013
+#
+# Authors:
+#  Adam Litke <agl at linux.vnet.ibm.com>
+#  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
+
+from kimchi.control.base import Collection, Resource
+
+
+class Config(Resource):
+    def __init__(self, model, id=None):
+        super(Config, self).__init__(model, id)
+        self.capabilities = Capabilities(self.model)
+        self.capabilities.exposed = True
+        self.distros = Distros(model)
+        self.distros.exposed = True
+
+    @property
+    def data(self):
+        return {'http_port': cherrypy.server.socket_port}
+
+
+class Capabilities(Resource):
+    def __init__(self, model, id=None):
+        super(Capabilities, self).__init__(model, id)
+
+    @property
+    def data(self):
+        caps = ['libvirt_stream_protocols', 'qemu_stream',
+                'screenshot', 'system_report_tool']
+        ret = dict([(x, None) for x in caps])
+        ret.update(self.model.get_capabilities())
+        return ret
+
+
+class Distros(Collection):
+    def __init__(self, model):
+        super(Distros, self).__init__(model)
+        self.resource = Distro
+
+
+class Distro(Resource):
+    def __init__(self, model, ident):
+        super(Distro, self).__init__(model, ident)
+
+    @property
+    def data(self):
+        return self.info
-- 
1.7.10.4




More information about the Kimchi-devel mailing list