mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
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
1f65953090
commit
e1084e5caa
1 changed files with 6 additions and 11 deletions
|
@ -317,18 +317,13 @@ class VirtNetwork(object):
|
||||||
return self.conn.find_entry(entryid)
|
return self.conn.find_entry(entryid)
|
||||||
|
|
||||||
def list_nets(self, state=None):
|
def list_nets(self, state=None):
|
||||||
entries = self.conn.find_entry(-1)
|
|
||||||
results = []
|
results = []
|
||||||
for x in entries:
|
for entry in self.conn.find_entry(-1):
|
||||||
try:
|
if state:
|
||||||
if state:
|
if state == self.conn.get_status2(entry):
|
||||||
entrystate = self.conn.get_status2(x)
|
results.append(entry.name())
|
||||||
if entrystate == state:
|
else:
|
||||||
results.append(x.name())
|
results.append(entry.name())
|
||||||
else:
|
|
||||||
results.append(x.name())
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
Loading…
Reference in a new issue