From 555b8413a1fafaa15b38b715ba32ad7d22500350 Mon Sep 17 00:00:00 2001 From: Ryan Butler Date: Mon, 19 Aug 2019 00:27:01 -0500 Subject: [PATCH] VMware: Add uptime and maintenance mode in vmware_host_facts (#60688) * adding host facts * adding to test --- lib/ansible/modules/cloud/vmware/vmware_host_facts.py | 4 ++++ test/integration/targets/vmware_host_facts/tasks/main.yml | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/ansible/modules/cloud/vmware/vmware_host_facts.py b/lib/ansible/modules/cloud/vmware/vmware_host_facts.py index 493c13f866e..9e13c410293 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_host_facts.py +++ b/lib/ansible/modules/cloud/vmware/vmware_host_facts.py @@ -110,6 +110,7 @@ ansible_facts: "ansible_distribution_build": "4887370", "ansible_distribution_version": "6.5.0", "ansible_hostname": "10.76.33.100", + "ansible_in_maintenance_mode": true, "ansible_interfaces": [ "vmk0" ], @@ -123,6 +124,7 @@ ansible_facts: "ansible_product_name": "KVM", "ansible_product_serial": "NA", "ansible_system_vendor": "Red Hat", + "ansible_uptime": 1791680, "ansible_vmk0": { "device": "vmk0", "ipv4": { @@ -277,6 +279,8 @@ class VMwareHostFactManager(PyVmomi): 'ansible_product_serial': sn, 'ansible_bios_date': self.host.hardware.biosInfo.releaseDate, 'ansible_bios_version': self.host.hardware.biosInfo.biosVersion, + 'ansible_uptime': self.host.summary.quickStats.uptime, + 'ansible_in_maintenance_mode': self.host.runtime.inMaintenanceMode, } return facts diff --git a/test/integration/targets/vmware_host_facts/tasks/main.yml b/test/integration/targets/vmware_host_facts/tasks/main.yml index 215d7518f8e..89e5c41449f 100644 --- a/test/integration/targets/vmware_host_facts/tasks/main.yml +++ b/test/integration/targets/vmware_host_facts/tasks/main.yml @@ -18,6 +18,8 @@ that: - "'ansible_hostname' in facts['ansible_facts']" - "'ansible_processor' in facts['ansible_facts']" + - "'ansible_in_maintenance_mode' in facts['ansible_facts']" + - "'ansible_uptime' in facts['ansible_facts']" - name: get host facts through from a host vmware_host_facts: @@ -32,3 +34,5 @@ that: - "'ansible_hostname' in facts['ansible_facts']" - "'ansible_processor' in facts['ansible_facts']" + - "'ansible_in_maintenance_mode' in facts['ansible_facts']" + - "'ansible_uptime' in facts['ansible_facts']" \ No newline at end of file