setup - virtualization facts add Red Hat vendor (#72876)

Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
Martin Nečas 2021-03-15 10:50:44 +01:00 committed by GitHub
parent 9ec4e08534
commit 7099a5f448
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View file

@ -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)."

View file

@ -139,6 +139,8 @@ class LinuxVirtual(Virtual):
virtual_facts['virtualization_role'] = 'guest' virtual_facts['virtualization_role'] = 'guest'
product_name = get_file_content('/sys/devices/virtual/dmi/id/product_name') 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'): if product_name in ('KVM', 'KVM Server', 'Bochs', 'AHV'):
guest_tech.add('kvm') guest_tech.add('kvm')
@ -146,12 +148,24 @@ class LinuxVirtual(Virtual):
virtual_facts['virtualization_type'] = 'kvm' virtual_facts['virtualization_type'] = 'kvm'
found_virt = True found_virt = True
if product_name == 'RHEV Hypervisor': if sys_vendor == 'oVirt':
guest_tech.add('RHEV') guest_tech.add('oVirt')
if not found_virt: if not found_virt:
virtual_facts['virtualization_type'] = 'RHEV' virtual_facts['virtualization_type'] = 'oVirt'
found_virt = True found_virt = True
if sys_vendor == 'Red Hat':
if product_family == 'RHV':
guest_tech.add('RHV')
if not found_virt:
virtual_facts['virtualization_type'] = 'RHV'
found_virt = True
elif product_family == 'RHEV Hypervisor':
guest_tech.add('RHEV')
if not found_virt:
virtual_facts['virtualization_type'] = 'RHEV'
found_virt = True
if product_name in ('VMware Virtual Platform', 'VMware7,1'): if product_name in ('VMware Virtual Platform', 'VMware7,1'):
guest_tech.add('VMware') guest_tech.add('VMware')
if not found_virt: if not found_virt:
@ -184,9 +198,7 @@ class LinuxVirtual(Virtual):
virtual_facts['virtualization_type'] = 'kvm' virtual_facts['virtualization_type'] = 'kvm'
found_virt = True found_virt = True
sys_vendor = get_file_content('/sys/devices/virtual/dmi/id/sys_vendor') KVM_SYS_VENDORS = ('QEMU', 'Amazon EC2', 'DigitalOcean', 'Google', 'Scaleway', 'Nutanix')
KVM_SYS_VENDORS = ('QEMU', 'oVirt', 'Amazon EC2', 'DigitalOcean', 'Google', 'Scaleway', 'Nutanix')
if sys_vendor in KVM_SYS_VENDORS: if sys_vendor in KVM_SYS_VENDORS:
guest_tech.add('kvm') guest_tech.add('kvm')
if not found_virt: if not found_virt: