Make hyperv driver use flavor fields instead of legacy ones
This makes the hyperv driver use instance.flavor.root_gb instead of the legacy instance.root_gb field (and friends). Also note I believe I found a bug in the test_cache_rescue_image_bigger_than_flavor test, which was not properly returning an image size in bytes. This was passing only because the fake_instance object had a root_gb of 0, which made the unit disparity moot. Change-Id: I03207a267f1ffb21ea464165c1910f66962caab6
This commit is contained in:
@@ -75,7 +75,7 @@ class ImageCacheTestCase(test_base.HyperVBaseTestCase):
|
||||
|
||||
def test_get_root_vhd_size_gb(self):
|
||||
ret_val = self._test_get_root_vhd_size_gb(old_flavor=False)
|
||||
self.assertEqual(self.instance.root_gb, ret_val)
|
||||
self.assertEqual(self.instance.flavor.root_gb, ret_val)
|
||||
|
||||
@mock.patch.object(imagecache.ImageCache, '_get_root_vhd_size_gb')
|
||||
def test_resize_and_cache_vhd_smaller(self, mock_get_vhd_size_gb):
|
||||
@@ -166,7 +166,7 @@ class ImageCacheTestCase(test_base.HyperVBaseTestCase):
|
||||
fake_rescue_image_id = 'fake_rescue_image_id'
|
||||
|
||||
self.imagecache._vhdutils.get_vhd_info.return_value = {
|
||||
'VirtualSize': self.instance.root_gb + 1}
|
||||
'VirtualSize': (self.instance.flavor.root_gb + 1) * units.Gi}
|
||||
(expected_path,
|
||||
expected_vhd_path) = self._prepare_get_cached_image(
|
||||
rescue_image_id=fake_rescue_image_id)
|
||||
|
||||
@@ -140,7 +140,7 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
|
||||
def test_check_target_flavor(self):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
mock_instance.root_gb = 1
|
||||
mock_instance.flavor.root_gb = 1
|
||||
mock_flavor = mock.MagicMock(root_gb=0)
|
||||
self.assertRaises(exception.InstanceFaultRollback,
|
||||
self._migrationops._check_target_flavor,
|
||||
@@ -376,7 +376,7 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
mock_check_attach_config_drive,
|
||||
disk_type=constants.DISK):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
mock_instance.ephemeral_gb = 1
|
||||
mock_instance.flavor.ephemeral_gb = 1
|
||||
root_device = {'type': disk_type}
|
||||
block_device_info = {'root_disk': root_device, 'ephemerals': []}
|
||||
|
||||
@@ -404,7 +404,7 @@ class MigrationOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
mock_vhd_info.get.return_value)
|
||||
expected_check_resize.append(
|
||||
mock.call(root_device_path, mock_vhd_info,
|
||||
mock_instance.root_gb * units.Gi))
|
||||
mock_instance.flavor.root_gb * units.Gi))
|
||||
|
||||
ephemerals = block_device_info['ephemerals']
|
||||
mock_check_eph_disks.assert_called_once_with(
|
||||
|
||||
@@ -172,12 +172,12 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
def _prepare_create_root_device_mocks(self, use_cow_images, vhd_format,
|
||||
vhd_size):
|
||||
mock_instance = fake_instance.fake_instance_obj(self.context)
|
||||
mock_instance.root_gb = self.FAKE_SIZE
|
||||
mock_instance.flavor.root_gb = self.FAKE_SIZE
|
||||
self.flags(use_cow_images=use_cow_images)
|
||||
self._vmops._vhdutils.get_vhd_info.return_value = {'VirtualSize':
|
||||
vhd_size * units.Gi}
|
||||
self._vmops._vhdutils.get_vhd_format.return_value = vhd_format
|
||||
root_vhd_internal_size = mock_instance.root_gb * units.Gi
|
||||
root_vhd_internal_size = mock_instance.flavor.root_gb * units.Gi
|
||||
get_size = self._vmops._vhdutils.get_internal_vhd_size_by_file_size
|
||||
get_size.return_value = root_vhd_internal_size
|
||||
self._vmops._pathutils.exists.return_value = True
|
||||
@@ -213,7 +213,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
mock_get_cached_image.return_value = fake_vhd_path
|
||||
|
||||
fake_root_path = self._vmops._pathutils.get_root_vhd_path.return_value
|
||||
root_vhd_internal_size = mock_instance.root_gb * units.Gi
|
||||
root_vhd_internal_size = mock_instance.flavor.root_gb * units.Gi
|
||||
get_size = self._vmops._vhdutils.get_internal_vhd_size_by_file_size
|
||||
|
||||
response = self._vmops._create_root_vhd(context=self.context,
|
||||
@@ -248,7 +248,7 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
mock.sentinel.rescue_image_id if is_rescue_vhd else None)
|
||||
|
||||
fake_root_path = self._vmops._pathutils.get_root_vhd_path.return_value
|
||||
root_vhd_internal_size = mock_instance.root_gb * units.Gi
|
||||
root_vhd_internal_size = mock_instance.flavor.root_gb * units.Gi
|
||||
get_size = self._vmops._vhdutils.get_internal_vhd_size_by_file_size
|
||||
|
||||
response = self._vmops._create_root_vhd(
|
||||
@@ -466,8 +466,8 @@ class VMOpsTestCase(test_base.HyperVBaseTestCase):
|
||||
block_device_info=block_device_info,
|
||||
vm_gen=vm_gen)
|
||||
self._vmops._vmutils.create_vm.assert_called_once_with(
|
||||
mock_instance.name, mock_instance.memory_mb,
|
||||
mock_instance.vcpus, CONF.hyperv.limit_cpu_features,
|
||||
mock_instance.name, mock_instance.flavor.memory_mb,
|
||||
mock_instance.flavor.vcpus, CONF.hyperv.limit_cpu_features,
|
||||
CONF.hyperv.dynamic_memory_ratio, vm_gen, instance_path,
|
||||
[mock_instance.uuid])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user