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.
This commit is contained in:
parent
d8b6dd5927
commit
39b635ae79
1 changed files with 6 additions and 11 deletions
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue