From b52159163b5979ed291c7d694facc73d3f724e55 Mon Sep 17 00:00:00 2001 From: Dag Wieers Date: Fri, 2 Dec 2016 18:24:47 +0100 Subject: [PATCH] Add RHEV host detection support (#17177) * Add RHEV host detection support This adds RHEV host detection support based on a running 'vdsm' process and the existence of _/rhev/_ (which are both part of the vdsm RPM package in a RHEV installation). Without this change, a RHEV host would be reported as a kvm host (which is also true, but often not specific enough). This closes #17058 * Only scan the process list when we determined /rhev/ exists Small performance improvement, so we do not have to scan the process list if /rhev/ does not exist. --- lib/ansible/module_utils/facts.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/facts.py b/lib/ansible/module_utils/facts.py index 2401408140..9118c17067 100644 --- a/lib/ansible/module_utils/facts.py +++ b/lib/ansible/module_utils/facts.py @@ -3353,7 +3353,22 @@ class LinuxVirtual(Virtual): modules.append(data[0]) if 'kvm' in modules: - self.facts['virtualization_type'] = 'kvm' + + if os.path.isdir('/rhev/'): + + # Check whether this is a RHEV hypervisor (is vdsm running ?) + for f in glob.glob('/proc/[0-9]*/comm'): + try: + if open(f).read().rstrip() == 'vdsm': + self.facts['virtualization_type'] = 'RHEV' + break + except: + pass + else: + self.facts['virtualization_type'] = 'kvm' + + else: + self.facts['virtualization_type'] = 'kvm' self.facts['virtualization_role'] = 'host' return