virt_net: add way to get facts for only one specified network
This commit is contained in:
parent
46b821d51f
commit
6f9f67be18
2 changed files with 17 additions and 3 deletions
|
@ -450,9 +450,13 @@ class VirtNetwork(object):
|
||||||
def info(self):
|
def info(self):
|
||||||
return self.facts(facts_mode='info')
|
return self.facts(facts_mode='info')
|
||||||
|
|
||||||
def facts(self, facts_mode='facts'):
|
def facts(self, name=None, facts_mode='facts'):
|
||||||
results = dict()
|
results = dict()
|
||||||
for entry in self.list_nets():
|
if name:
|
||||||
|
entries = [name]
|
||||||
|
else:
|
||||||
|
entries = self.list_nets()
|
||||||
|
for entry in entries:
|
||||||
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)
|
||||||
|
@ -565,7 +569,10 @@ def core(module):
|
||||||
return VIRT_SUCCESS, res
|
return VIRT_SUCCESS, res
|
||||||
|
|
||||||
elif hasattr(v, command):
|
elif hasattr(v, command):
|
||||||
res = getattr(v, command)()
|
if command == 'facts' and name:
|
||||||
|
res = v.facts(name)
|
||||||
|
else:
|
||||||
|
res = getattr(v, command)()
|
||||||
if not isinstance(res, dict):
|
if not isinstance(res, dict):
|
||||||
res = {command: res}
|
res = {command: res}
|
||||||
return VIRT_SUCCESS, res
|
return VIRT_SUCCESS, res
|
||||||
|
|
|
@ -42,6 +42,13 @@
|
||||||
name: foobar
|
name: foobar
|
||||||
register: second_virt_net_start
|
register: second_virt_net_start
|
||||||
|
|
||||||
|
- name: Get facts for default network
|
||||||
|
virt_net:
|
||||||
|
uri: qemu:///system
|
||||||
|
command: facts
|
||||||
|
name: foobar
|
||||||
|
register: virt_net_facts
|
||||||
|
|
||||||
- name: Destroy the foobar network
|
- name: Destroy the foobar network
|
||||||
virt_net:
|
virt_net:
|
||||||
command: destroy
|
command: destroy
|
||||||
|
|
Loading…
Reference in a new issue