diff options
author | Michael Scherer <mscherer@users.noreply.github.com> | 2017-01-12 00:38:38 +0100 |
---|---|---|
committer | ansibot <ansibot@users.noreply.github.com> | 2017-01-11 18:38:38 -0500 |
commit | 6221327b13eeb21e8b7bb83551b8bf979c624365 (patch) | |
tree | 6d4c95296de642c95db504cde96d678d861754d7 | |
parent | eeebd51f21f0e05cfc546ec8fd1246174f85fd01 (diff) | |
download | ansible-6221327b13eeb21e8b7bb83551b8bf979c624365.tar.gz |
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.
-rw-r--r-- | lib/ansible/modules/cloud/misc/virt_net.py | 9 |
1 files changed, 9 insertions, 0 deletions
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) |