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.
This commit is contained in:
Dag Wieers 2016-12-02 18:24:47 +01:00 committed by Brian Coca
parent d5eff47fcc
commit b52159163b

View file

@ -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