From: Royce Lv <lvroyce(a)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(a)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