VMware: enable driver to work with postgres database
The hypervisor version is expected to be an integer and not
a string. The nova/utils.py change is part of the following
patch but is not being backported as it adds new feature
functionality and is therefore not acceptable for backport
https://review.openstack.org/#/c/36073/
Closes-Bug: #1195139
(cherry picked from commit e2efa57ab2
)
Conflicts:
nova/tests/virt/vmwareapi/test_vmwareapi.py
nova/virt/vmwareapi/host.py
Change-Id: Ifac9ca3480191413e3a02f0dae94e452707ae82f
This commit is contained in:
parent
efd628c9d6
commit
00d18827aa
|
@ -1208,6 +1208,7 @@ class VMwareAPIHostTestCase(test.NoDBTestCase):
|
|||
self.assertEquals(stats['disk_used'], 1024 - 500)
|
||||
self.assertEquals(stats['host_memory_total'], 1024)
|
||||
self.assertEquals(stats['host_memory_free'], 1024 - 500)
|
||||
self.assertEquals(stats['hypervisor_version'], 5000000)
|
||||
supported_instances = [('i686', 'vmware', 'hvm'),
|
||||
('x86_64', 'vmware', 'hvm')]
|
||||
self.assertEquals(stats['supported_instances'], supported_instances)
|
||||
|
@ -1277,7 +1278,7 @@ class VMwareAPIVCDriverTestCase(VMwareAPIVMTestCase):
|
|||
self.assertEquals(stats['memory_mb'], 1000)
|
||||
self.assertEquals(stats['memory_mb_used'], 500)
|
||||
self.assertEquals(stats['hypervisor_type'], 'VMware vCenter Server')
|
||||
self.assertEquals(stats['hypervisor_version'], '5.1.0')
|
||||
self.assertEquals(stats['hypervisor_version'], 5001000)
|
||||
self.assertEquals(stats['hypervisor_hostname'], self.node_name)
|
||||
self.assertEquals(stats['cpu_info'], jsonutils.dumps(cpu_info))
|
||||
self.assertEquals(stats['supported_instances'],
|
||||
|
|
|
@ -1165,7 +1165,17 @@ def is_none_string(val):
|
|||
|
||||
|
||||
def convert_version_to_int(version):
|
||||
return version[0] * 1000000 + version[1] * 1000 + version[2]
|
||||
try:
|
||||
if type(version) == str:
|
||||
version = convert_version_to_tuple(version)
|
||||
if type(version) == tuple:
|
||||
return reduce(lambda x, y: (x * 1000) + y, version)
|
||||
except Exception:
|
||||
raise exception.NovaException(message="Hypervisor version invalid.")
|
||||
|
||||
|
||||
def convert_version_to_tuple(version_str):
|
||||
return tuple(int(part) for part in version_str.split('.'))
|
||||
|
||||
|
||||
def is_neutron():
|
||||
|
|
|
@ -21,6 +21,7 @@ Management class for host-related functions (start, reboot, etc).
|
|||
from nova import exception
|
||||
from nova.openstack.common.gettextutils import _
|
||||
from nova.openstack.common import log as logging
|
||||
from nova import utils
|
||||
from nova.virt.vmwareapi import vim_util
|
||||
from nova.virt.vmwareapi import vm_util
|
||||
|
||||
|
@ -133,7 +134,8 @@ class HostState(object):
|
|||
data["host_memory_free"] = data["host_memory_total"] - \
|
||||
summary.quickStats.overallMemoryUsage
|
||||
data["hypervisor_type"] = summary.config.product.name
|
||||
data["hypervisor_version"] = summary.config.product.version
|
||||
data["hypervisor_version"] = utils.convert_version_to_int(
|
||||
str(summary.config.product.version))
|
||||
data["hypervisor_hostname"] = self._host_name
|
||||
data["supported_instances"] = [('i686', 'vmware', 'hvm'),
|
||||
('x86_64', 'vmware', 'hvm')]
|
||||
|
@ -186,7 +188,8 @@ class VCState(object):
|
|||
data["host_memory_total"] = stats['mem']['total']
|
||||
data["host_memory_free"] = stats['mem']['free']
|
||||
data["hypervisor_type"] = about_info.name
|
||||
data["hypervisor_version"] = about_info.version
|
||||
data["hypervisor_version"] = utils.convert_version_to_int(
|
||||
str(about_info.version))
|
||||
data["hypervisor_hostname"] = self._host_name
|
||||
data["supported_instances"] = [('i686', 'vmware', 'hvm'),
|
||||
('x86_64', 'vmware', 'hvm')]
|
||||
|
|
Loading…
Reference in New Issue