[Kimchi-devel] [PATCH] Use resource's lookup interface to fetch capabilities

Mark Wu wudxw at linux.vnet.ibm.com
Tue Jan 28 23:51:43 UTC 2014


Capabilities is kind of resource, so we can use its lookup
interface to fetch information from model. It can reduce the
special code, which is helpful for further refactoring.

This patch removes the dict initialization in controller level
intentionally, because the model should return full information of
capabilities always.

Signed-off-by: Mark Wu <wudxw at linux.vnet.ibm.com>
---
 src/kimchi/control/config.py | 6 +-----
 src/kimchi/mockmodel.py      | 2 +-
 src/kimchi/model.py          | 2 +-
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/kimchi/control/config.py b/src/kimchi/control/config.py
index c28e6e3..16cc384 100644
--- a/src/kimchi/control/config.py
+++ b/src/kimchi/control/config.py
@@ -50,11 +50,7 @@ class Capabilities(Resource):
 
     @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
+        return self.info
 
 
 class Distros(Collection):
diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py
index 916020a..0fe69dd 100644
--- a/src/kimchi/mockmodel.py
+++ b/src/kimchi/mockmodel.py
@@ -60,7 +60,7 @@ class MockModel(object):
         self.objstore = ObjectStore(objstore_loc)
         self.distros = self._get_distros()
 
-    def get_capabilities(self):
+    def capabilities_lookup(self, name):
         return {'libvirt_stream_protocols': ['http', 'https', 'ftp', 'ftps', 'tftp'],
                 'qemu_stream': True,
                 'screenshot': True,
diff --git a/src/kimchi/model.py b/src/kimchi/model.py
index 81c1507..1f98bfa 100644
--- a/src/kimchi/model.py
+++ b/src/kimchi/model.py
@@ -242,7 +242,7 @@ class Model(object):
         kimchi_log.info("*** Feature tests completed ***")
     _set_capabilities.priority = 90
 
-    def get_capabilities(self):
+    def capabilities_lookup(self, name):
         report_tool = self._get_system_report_tool()
 
         return {'libvirt_stream_protocols': self.libvirt_stream_protocols,
-- 
1.8.4.2




More information about the Kimchi-devel mailing list