Hyper-V: update live migrate data object

The Hyper-V driver does not properly handle shared storage at the moment.

In order to address this, and ensure that proper cleanup is performed
in case of failed live migrations, we'll need to update the
HyperVLiveMigrateData object and make sure that the compute manager
properly uses it.

This change is part of a bigger series, attempting to fix HyperV shared
storage related issues.

Change-Id: I1beb56530134c83b8359ac137cdffc37a86ec8cc
Partial-Bug: #1565895
This commit is contained in:
Lucian Petrut 2016-06-16 11:41:20 +03:00
parent d219e25452
commit a4d2327733
3 changed files with 61 additions and 2 deletions

View File

@ -267,4 +267,28 @@ class XenapiLiveMigrateData(LiveMigrateData):
@obj_base.NovaObjectRegistry.register
class HyperVLiveMigrateData(LiveMigrateData):
VERSION = '1.0'
# Version 1.0: Initial version
# Version 1.1: Added is_shared_instance_path
VERSION = '1.1'
fields = {'is_shared_instance_path': fields.BooleanField()}
def obj_make_compatible(self, primitive, target_version):
super(HyperVLiveMigrateData, self).obj_make_compatible(
primitive, target_version)
target_version = versionutils.convert_version_to_tuple(target_version)
if target_version < (1, 1):
if 'is_shared_instance_path' in primitive:
del primitive['is_shared_instance_path']
def to_legacy_dict(self, pre_migration_result=False):
legacy = super(HyperVLiveMigrateData, self).to_legacy_dict()
if self.obj_attr_is_set('is_shared_instance_path'):
legacy['is_shared_instance_path'] = self.is_shared_instance_path
return legacy
def from_legacy_dict(self, legacy):
super(HyperVLiveMigrateData, self).from_legacy_dict(legacy)
if 'is_shared_instance_path' in legacy:
self.is_shared_instance_path = legacy['is_shared_instance_path']

View File

@ -317,3 +317,38 @@ class TestXenapiLiveMigrateData(test_objects._LocalTest,
class TestRemoteXenapiLiveMigrateData(test_objects._RemoteTest,
_TestXenapiLiveMigrateData):
pass
class _TestHyperVLiveMigrateData(object):
def test_obj_make_compatible(self):
obj = migrate_data.HyperVLiveMigrateData(
is_shared_instance_path=True)
primitive = obj.obj_to_primitive(target_version='1.0')
self.assertNotIn('is_shared_instance_path', primitive)
def test_to_legacy_dict(self):
obj = migrate_data.HyperVLiveMigrateData(
is_shared_instance_path=False)
expected = {
'is_shared_instance_path': False,
}
self.assertEqual(expected, obj.to_legacy_dict())
def test_from_legacy_dict(self):
obj = migrate_data.HyperVLiveMigrateData(
is_shared_instance_path=False)
legacy = obj.to_legacy_dict()
obj2 = migrate_data.HyperVLiveMigrateData()
obj2.from_legacy_dict(legacy)
self.assertEqual(obj.is_shared_instance_path,
obj2.is_shared_instance_path)
class TestHyperVLiveMigrateData(test_objects._LocalTest,
_TestHyperVLiveMigrateData):
pass
class TestRemoteHyperVLiveMigrateData(test_objects._RemoteTest,
_TestHyperVLiveMigrateData):
pass

View File

@ -1128,7 +1128,7 @@ object_data = {
'FloatingIP': '1.10-52a67d52d85eb8b3f324a5b7935a335b',
'FloatingIPList': '1.11-7f2ba670714e1b7bab462ab3290f7159',
'HostMapping': '1.0-1a3390a696792a552ab7bd31a77ba9ac',
'HyperVLiveMigrateData': '1.0-0b868dd6228a09c3f3e47016dddf6a1c',
'HyperVLiveMigrateData': '1.1-9987a3cec31a81abac6fba7cc722e43f',
'HVSpec': '1.2-db672e73304da86139086d003f3977e7',
'IDEDeviceBus': '1.0-29d4c9f27ac44197f01b6ac1b7e16502',
'ImageMeta': '1.8-642d1b2eb3e880a367f37d72dd76162d',