Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add transitional support for migrate data objects to compute manager
This introduces a base live migration data object and makes compute manager convert any migrate data objects received from the driver back to dicts. This is transitional as we build support for using these objects, as well as infrastructure around handling the conversion to them over the next RPC major version. The goal here will be to unify all of the random dicts that we pass around between live migration steps with one type of object (which will be subclassed per driver). Right now, we have dest_check_data, migrate_data, and pre_live_migration_result which are all weird semi-overlapping versions of each other. But, in order to this in a graceful way, we need to support generating the old dict format, which is even weirder when it comes from something uniform. Hang on, it's going to be a bumpy ride, but better in the long run. In this patch, we're setting the stage for per-driver conversions to come afterwards. This converts the hyperv driver in-place, because it's trivial. Related to blueprint objectify-live-migrate-data Change-Id: Id4bbb818fb7032a3f8fe48d6bd39b4d52d6117a2
- Loading branch information
Showing
5 changed files
with
150 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2015 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from nova.objects import base as obj_base | ||
from nova.objects import fields | ||
|
||
|
||
@obj_base.NovaObjectRegistry.register_if(False) | ||
class LiveMigrateData(obj_base.NovaObject): | ||
fields = { | ||
'is_volume_backed': fields.BooleanField(), | ||
'migration': fields.ObjectField('Migration'), | ||
} | ||
|
||
def to_legacy_dict(self, pre_migration_result=False): | ||
legacy = {} | ||
if self.obj_attr_is_set('is_volume_backed'): | ||
legacy['is_volume_backed'] = self.is_volume_backed | ||
if self.obj_attr_is_set('migration'): | ||
legacy['migration'] = self.migration | ||
if pre_migration_result: | ||
legacy['pre_live_migration_result'] = {} | ||
|
||
return legacy | ||
|
||
def from_legacy_dict(self, legacy): | ||
if 'is_volume_backed' in legacy: | ||
self.is_volume_backed = legacy['is_volume_backed'] | ||
if 'migration' in legacy: | ||
self.migration = legacy['migration'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2015 Red Hat, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
# not use this file except in compliance with the License. You may obtain | ||
# a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from nova import objects | ||
from nova.objects import migrate_data | ||
from nova.tests.unit.objects import test_objects | ||
|
||
|
||
class _TestLiveMigrateData(object): | ||
def test_to_legacy_dict(self): | ||
obj = migrate_data.LiveMigrateData(is_volume_backed=False) | ||
self.assertEqual({'is_volume_backed': False}, | ||
obj.to_legacy_dict()) | ||
|
||
def test_from_legacy_dict(self): | ||
obj = migrate_data.LiveMigrateData() | ||
obj.from_legacy_dict({'is_volume_backed': False, 'ignore': 'foo'}) | ||
self.assertEqual(False, obj.is_volume_backed) | ||
|
||
def test_from_legacy_dict_migration(self): | ||
migration = objects.Migration() | ||
obj = migrate_data.LiveMigrateData() | ||
obj.from_legacy_dict({'is_volume_backed': False, 'ignore': 'foo', | ||
'migration': migration}) | ||
self.assertEqual(False, obj.is_volume_backed) | ||
self.assertIsInstance(obj.migration, objects.Migration) | ||
|
||
def test_legacy_with_pre_live_migration_result(self): | ||
obj = migrate_data.LiveMigrateData(is_volume_backed=False) | ||
self.assertEqual({'pre_live_migration_result': {}, | ||
'is_volume_backed': False}, | ||
obj.to_legacy_dict(pre_migration_result=True)) | ||
|
||
|
||
class TestLiveMigrateData(test_objects._LocalTest, | ||
_TestLiveMigrateData): | ||
pass | ||
|
||
|
||
class TestRemoteLiveMigrateData(test_objects._RemoteTest, | ||
_TestLiveMigrateData): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters