Extend OpenStack related hypervisor detection (#15166)

* fixed detection of ansible_virtualization_(role|path) facts for VM's running in
OpenStack Instances

* NOTE: this will break detection of ansible_virtualization_(role|path) facts
        if you are using Openstack Instaces with nested virtualization

* fixed detection of ansible_virtualization_(role|path) facts for VM's running in
OpenStack Instances

Fixes #15165

* NOTE: this will break detection of ansible_virtualization_(role|path) facts
        if you are using Openstack Instaces with nested virtualization
This commit is contained in:
gl0bus 2016-12-02 18:23:43 +01:00 committed by Brian Coca
parent 435dfc2b9c
commit d5eff47fcc

View file

@ -3259,6 +3259,11 @@ class LinuxVirtual(Virtual):
self.facts['virtualization_role'] = 'guest' self.facts['virtualization_role'] = 'guest'
return return
if product_name == 'OpenStack Nova':
self.facts['virtualization_type'] = 'openstack'
self.facts['virtualization_role'] = 'guest'
return
bios_vendor = get_file_content('/sys/devices/virtual/dmi/id/bios_vendor') bios_vendor = get_file_content('/sys/devices/virtual/dmi/id/bios_vendor')
if bios_vendor == 'Xen': if bios_vendor == 'Xen':
@ -3294,6 +3299,11 @@ class LinuxVirtual(Virtual):
self.facts['virtualization_role'] = 'guest' self.facts['virtualization_role'] = 'guest'
return return
if sys_vendor == 'OpenStack Foundation':
self.facts['virtualization_type'] = 'openstack'
self.facts['virtualization_role'] = 'guest'
return
if os.path.exists('/proc/self/status'): if os.path.exists('/proc/self/status'):
for line in get_file_lines('/proc/self/status'): for line in get_file_lines('/proc/self/status'):
if re.match('^VxID: \d+', line): if re.match('^VxID: \d+', line):