From fb6f37f7f91c47aced8b19e527e2771743911d0a Mon Sep 17 00:00:00 2001 From: Dan Smith Date: 2016年3月11日 07:15:38 -0800 Subject: [PATCH] Fix pre_live_migration result processing from legacy computes The objectification of the live migration data ended up with a bug in the compatibility path for the pre_live_migration result where we convert a legacy dict response back to an object. The legacy dict processing looks for 'pre_live_migration_result' in the input to trigger handling of those keys, but we weren't properly wrapping the result like that so it was never digesting those keys. Change-Id: I5142e1cb9d526c92529fc24ee0441b5730931160 Closes-Bug: #1556126 --- nova/compute/rpcapi.py | 3 ++- nova/tests/unit/compute/test_rpcapi.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py index 0f8950cf6513..ac3cc643d545 100644 --- a/nova/compute/rpcapi.py +++ b/nova/compute/rpcapi.py @@ -693,7 +693,8 @@ class ComputeAPI(object): if isinstance(result, migrate_data_obj.LiveMigrateData): return result elif migrate_data_orig and result: - migrate_data_orig.from_legacy_dict(result) + migrate_data_orig.from_legacy_dict( + {'pre_live_migration_result': result}) return migrate_data_orig else: return result diff --git a/nova/tests/unit/compute/test_rpcapi.py b/nova/tests/unit/compute/test_rpcapi.py index a3b3f369d0df..58ec05c6e652 100644 --- a/nova/tests/unit/compute/test_rpcapi.py +++ b/nova/tests/unit/compute/test_rpcapi.py @@ -626,7 +626,8 @@ class ComputeRpcAPITestCase(test.NoDBTestCase): callret=None, calltype='cast') - def test_pre_live_migration_converts_objects(self): + @mock.patch('nova.objects.migrate_data.LiveMigrateData.from_legacy_dict') + def test_pre_live_migration_converts_objects(self, mock_fld): obj = migrate_data_obj.LiveMigrateData() result = self._test_simple_call('pre_live_migration', inargs={'instance': 'foo', @@ -639,6 +640,7 @@ class ComputeRpcAPITestCase(test.NoDBTestCase): 'disk': None, 'migrate_data': {}}, callret=obj) + self.assertFalse(mock_fld.called) self.assertEqual(obj, result) result = self._test_simple_call('pre_live_migration', inargs={'instance': 'foo', @@ -651,6 +653,8 @@ class ComputeRpcAPITestCase(test.NoDBTestCase): 'disk': None, 'migrate_data': {}}, callret={'foo': 'bar'}) + mock_fld.assert_called_once_with( + {'pre_live_migration_result': {'foo': 'bar'}}) self.assertIsInstance(result, migrate_data_obj.LiveMigrateData) def test_rollback_live_migration_at_destination_converts_objects(self):

AltStyle によって変換されたページ (->オリジナル) /