In HostModel._get_vms_list_by_state(), it gets a list of domain objects
and extracts the names, then it traverses the names and calls
lookupByName(name) to get domain objects. This is redundant because it
has a list of domain object already.
This patch fixes the problem.
Signed-off-by: Zhou Zheng Sheng <zhshzhou(a)linux.vnet.ibm.com>
---
src/kimchi/model/host.py | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py
index e9ac487..5844f4b 100644
--- a/src/kimchi/model/host.py
+++ b/src/kimchi/model/host.py
@@ -104,15 +104,9 @@ class HostModel(object):
def _get_vms_list_by_state(self, state):
conn = self.conn.get()
- names = [dom.name().decode('utf-8') for dom in conn.listAllDomains(0)]
-
- ret_list = []
- for name in names:
- dom = conn.lookupByName(name.encode("utf-8"))
- info = dom.info()
- if (DOM_STATE_MAP[info[0]]) == state:
- ret_list.append(name)
- return ret_list
+ return [dom.name().decode('utf-8')
+ for dom in conn.listAllDomains(0)
+ if (DOM_STATE_MAP[dom.info()[0]]) == state]
class HostStatsModel(object):
--
1.9.3