Rewrite for loops in a more Pythonic style
This commit is contained in:
parent
2fde14aaf1
commit
1f65953090
1 changed files with 4 additions and 8 deletions
|
@ -177,14 +177,12 @@ class LibvirtConnection(object):
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
# Get active entries
|
# Get active entries
|
||||||
entries = self.conn.listNetworks()
|
for name in self.conn.listNetworks():
|
||||||
for name in entries:
|
|
||||||
entry = self.conn.networkLookupByName(name)
|
entry = self.conn.networkLookupByName(name)
|
||||||
results.append(entry)
|
results.append(entry)
|
||||||
|
|
||||||
# Get inactive entries
|
# Get inactive entries
|
||||||
entries = self.conn.listDefinedNetworks()
|
for name in self.conn.listDefinedNetworks():
|
||||||
for name in entries:
|
|
||||||
entry = self.conn.networkLookupByName(name)
|
entry = self.conn.networkLookupByName(name)
|
||||||
results.append(entry)
|
results.append(entry)
|
||||||
|
|
||||||
|
@ -334,9 +332,8 @@ class VirtNetwork(object):
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def state(self):
|
def state(self):
|
||||||
entries = self.list_nets()
|
|
||||||
results = []
|
results = []
|
||||||
for entry in entries:
|
for entry in self.list_nets():
|
||||||
state_blurb = self.conn.get_status(entry)
|
state_blurb = self.conn.get_status(entry)
|
||||||
results.append("%s %s" % (entry,state_blurb))
|
results.append("%s %s" % (entry,state_blurb))
|
||||||
return results
|
return results
|
||||||
|
@ -378,9 +375,8 @@ class VirtNetwork(object):
|
||||||
return self.facts(facts_mode)
|
return self.facts(facts_mode)
|
||||||
|
|
||||||
def facts(self, facts_mode='facts'):
|
def facts(self, facts_mode='facts'):
|
||||||
entries = self.list_nets()
|
|
||||||
results = dict()
|
results = dict()
|
||||||
for entry in entries:
|
for entry in self.list_nets():
|
||||||
results[entry] = dict()
|
results[entry] = dict()
|
||||||
results[entry]["autostart"] = self.conn.get_autostart(entry)
|
results[entry]["autostart"] = self.conn.get_autostart(entry)
|
||||||
results[entry]["persistent"] = self.conn.get_persistent(entry)
|
results[entry]["persistent"] = self.conn.get_persistent(entry)
|
||||||
|
|
Loading…
Reference in a new issue