[Kimchi-devel] [PATCHv7 1/7] Export list vms functionality

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Mon Mar 10 09:05:40 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

List vms is a common function which is likely to be refered
by multiple module,
make it static will avoid unnecessary instantiation of vms model
and stats collecting task to start.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
---
 src/kimchi/model/vms.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 3f3a152..3b8a666 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -226,7 +226,11 @@ class VMsModel(object):
         return name
 
     def get_list(self):
-        conn = self.conn.get()
+        return self.get_vms(self.conn)
+
+    @staticmethod
+    def get_vms(conn):
+        conn = conn.get()
         names = [dom.name().decode('utf-8') for dom in conn.listAllDomains(0)]
         return sorted(names, key=unicode.lower)
 
-- 
1.8.1.2




More information about the Kimchi-devel mailing list