1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add DHCP leases to the facts return by the module (#19700)

On RHEL 6, where the feature is not present, this will
be ignored and return nothing.
This commit is contained in:
Michael Scherer 2017-01-12 00:38:38 +01:00 committed by ansibot
parent eeebd51f21
commit 6221327b13

View file

@ -369,6 +369,10 @@ class LibvirtConnection(object):
state = self.find_entry(entryid).isPersistent()
return ENTRY_STATE_PERSISTENT_MAP.get(state,"unknown")
def get_dhcp_leases(self, entryid):
network = self.find_entry(entryid)
return network.DHCPLeases()
def define_from_xml(self, entryid, xml):
if not self.module.check_mode:
return self.conn.networkDefineXML(xml)
@ -454,6 +458,11 @@ class VirtNetwork(object):
results[entry]["state"] = self.conn.get_status(entry)
results[entry]["bridge"] = self.conn.get_bridge(entry)
results[entry]["uuid"] = self.conn.get_uuid(entry)
try:
results[entry]["dhcp_leases"] = self.conn.get_dhcp_leases(entry)
# not supported on RHEL 6
except AttributeError:
pass
try:
results[entry]["forward_mode"] = self.conn.get_forward(entry)