Merge "Hyper-V: Fixes wrong hypervisor_version"
This commit is contained in:
@@ -34,7 +34,6 @@ class HostOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
FAKE_NAME = 'fake_name'
|
||||
FAKE_MANUFACTURER = 'FAKE_MANUFACTURER'
|
||||
FAKE_NUM_CPUS = 1
|
||||
FAKE_WIN_VERSION = '6.3.0'
|
||||
FAKE_INSTANCE_DIR = "C:/fake/dir"
|
||||
FAKE_LOCAL_IP = '10.11.12.13'
|
||||
FAKE_TICK_COUNT = 1000000
|
||||
@@ -95,11 +94,14 @@ class HostOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
self.assertEqual((2, 1, 1), response)
|
||||
|
||||
def test_get_hypervisor_version(self):
|
||||
self._hostops._hostutils.get_windows_version.return_value = (
|
||||
self.FAKE_WIN_VERSION)
|
||||
response = self._hostops._get_hypervisor_version()
|
||||
self._hostops._hostutils.get_windows_version.assert_called_once_with()
|
||||
self.assertEqual(self.FAKE_WIN_VERSION.replace('.', ''), response)
|
||||
self._hostops._hostutils.get_windows_version.return_value = '6.3.9600'
|
||||
response_lower = self._hostops._get_hypervisor_version()
|
||||
|
||||
self._hostops._hostutils.get_windows_version.return_value = '10.1.0'
|
||||
response_higher = self._hostops._get_hypervisor_version()
|
||||
|
||||
self.assertEqual(6003, response_lower)
|
||||
self.assertEqual(10001, response_higher)
|
||||
|
||||
@mock.patch.object(hostops.HostOps, '_get_cpu_info')
|
||||
@mock.patch.object(hostops.HostOps, '_get_memory_info')
|
||||
|
||||
@@ -90,9 +90,17 @@ class HostOps(object):
|
||||
|
||||
def _get_hypervisor_version(self):
|
||||
"""Get hypervisor version.
|
||||
:returns: hypervisor version (ex. 12003)
|
||||
:returns: hypervisor version (ex. 6003)
|
||||
"""
|
||||
version = self._hostutils.get_windows_version().replace('.', '')
|
||||
|
||||
# NOTE(claudiub): The hypervisor_version will be stored in the database
|
||||
# as an Integer and it will be used by the scheduler, if required by
|
||||
# the image property 'hypervisor_version_requires'.
|
||||
# The hypervisor_version will then be converted back to a version
|
||||
# by splitting the int in groups of 3 digits.
|
||||
# E.g.: hypervisor_version 6003 is converted to '6.3'.
|
||||
version = self._hostutils.get_windows_version().split('.')
|
||||
version = int(version[0]) * 1000 + int(version[1])
|
||||
LOG.debug('Windows version: %s ', version)
|
||||
return version
|
||||
|
||||
|
||||
Reference in New Issue
Block a user