Backport 2.10: Setup virtualization_facts - add RHV and oVirt type (#73905)

* Setup virtualization_facts - add RHV and oVirt type

Signed-off-by: mnecas <necas.marty@gmail.com>

* initialize sys_vendor only once

* add changelog

* Update 72876-setup-facts-add-redhat-vendor.yml

* Update linux.py
pull/75417/head
Martin Nečas 3 years ago committed by GitHub
parent 46819a65fa
commit 93070d5dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- "Setup virtualization_facts - add RHV and oVirt type. This change will fully work for VMs in clusters at cluster level 4.4 or newer (https://github.com/ansible/ansible/pull/72876)."

@ -92,12 +92,22 @@ class LinuxVirtual(Virtual):
virtual_facts['virtualization_role'] = 'guest'
product_name = get_file_content('/sys/devices/virtual/dmi/id/product_name')
sys_vendor = get_file_content('/sys/devices/virtual/dmi/id/sys_vendor')
product_family = get_file_content('/sys/devices/virtual/dmi/id/product_family')
if product_name in ('KVM', 'KVM Server', 'Bochs', 'AHV'):
virtual_facts['virtualization_type'] = 'kvm'
return virtual_facts
if product_name == 'RHEV Hypervisor':
if sys_vendor == 'oVirt':
virtual_facts['virtualization_type'] = 'oVirt'
return virtual_facts
if sys_vendor == 'Red Hat':
if product_family == 'RHV':
virtual_facts['virtualization_type'] = 'RHV'
return virtual_facts
elif product_name == 'RHEV Hypervisor':
virtual_facts['virtualization_type'] = 'RHEV'
return virtual_facts
@ -123,9 +133,7 @@ class LinuxVirtual(Virtual):
virtual_facts['virtualization_type'] = 'kvm'
return virtual_facts
sys_vendor = get_file_content('/sys/devices/virtual/dmi/id/sys_vendor')
KVM_SYS_VENDORS = ('QEMU', 'oVirt', 'Amazon EC2', 'DigitalOcean', 'Google', 'Scaleway', 'Nutanix')
KVM_SYS_VENDORS = ('QEMU', 'Amazon EC2', 'DigitalOcean', 'Google', 'Scaleway', 'Nutanix')
if sys_vendor in KVM_SYS_VENDORS:
virtual_facts['virtualization_type'] = 'kvm'
return virtual_facts

Loading…
Cancel
Save