From 39b635ae799eb51cf8e2f4618b3a292453668cc5 Mon Sep 17 00:00:00 2001 From: Maciej Delmanowski Date: Sat, 25 Jul 2015 18:23:01 +0200 Subject: [PATCH] Rewrite method to not use try/except Additional checks are not needed, because 'self.conn.get_entry(-1)' returns all existing entries, each one should have state defined. --- cloud/misc/virt_pool.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/cloud/misc/virt_pool.py b/cloud/misc/virt_pool.py index 3c31c82a0f1..4ca06e2a63a 100644 --- a/cloud/misc/virt_pool.py +++ b/cloud/misc/virt_pool.py @@ -405,18 +405,13 @@ class VirtStoragePool(object): return self.conn.find_entry(entryid) def list_pools(self, state=None): - entries = self.conn.find_entry(-1) results = [] - for x in entries: - try: - if state: - entrystate = self.conn.get_status2(x) - if entrystate == state: - results.append(x.name()) - else: - results.append(x.name()) - except: - pass + for entry in self.conn.find_entry(-1): + if state: + if state == self.conn.get_status2(entry): + results.append(entry.name()) + else: + results.append(entry.name()) return results def state(self):