From 6221327b13eeb21e8b7bb83551b8bf979c624365 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Thu, 12 Jan 2017 00:38:38 +0100 Subject: 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. --- lib/ansible/modules/cloud/misc/virt_net.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/ansible/modules/cloud/misc/virt_net.py b/lib/ansible/modules/cloud/misc/virt_net.py index a37c7ca9e3..849e44a304 100644 --- a/lib/ansible/modules/cloud/misc/virt_net.py +++ b/lib/ansible/modules/cloud/misc/virt_net.py @@ -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) -- cgit v1.2.1