Merge "Require Migration object arg to migrate_instance_finish method"
This commit is contained in:
commit
543c874cfe
|
@ -8038,9 +8038,9 @@ class ComputeManager(manager.Manager):
|
|||
# NOTE(mriedem): This is a no-op for neutron.
|
||||
self.network_api.setup_networks_on_host(context, instance,
|
||||
self.host)
|
||||
migration = {'source_compute': instance.host,
|
||||
'dest_compute': self.host,
|
||||
'migration_type': 'live-migration'}
|
||||
migration = objects.Migration(source_compute=instance.host,
|
||||
dest_compute=self.host,
|
||||
migration_type='live-migration')
|
||||
# TODO(gibi): calculate and pass resource_provider_mapping
|
||||
self.network_api.migrate_instance_finish(
|
||||
context, instance, migration, provider_mappings=None)
|
||||
|
|
|
@ -510,15 +510,15 @@ class API(base_api.NetworkAPI):
|
|||
instance_uuid=instance.uuid,
|
||||
rxtx_factor=flavor['rxtx_factor'],
|
||||
project_id=instance.project_id,
|
||||
source_compute=migration['source_compute'],
|
||||
dest_compute=migration['dest_compute'],
|
||||
source_compute=migration.source_compute,
|
||||
dest_compute=migration.dest_compute,
|
||||
floating_addresses=None,
|
||||
)
|
||||
|
||||
multi_host, addresses = self._get_multi_addresses(context, instance)
|
||||
if multi_host:
|
||||
args['floating_addresses'] = addresses
|
||||
args['host'] = migration['dest_compute']
|
||||
args['host'] = migration.dest_compute
|
||||
|
||||
self.network_rpcapi.migrate_instance_finish(context, **args)
|
||||
|
||||
|
|
|
@ -2834,9 +2834,18 @@ class API(base_api.NetworkAPI):
|
|||
|
||||
def migrate_instance_finish(
|
||||
self, context, instance, migration, provider_mappings):
|
||||
"""Finish migrating the network of an instance."""
|
||||
"""Finish migrating the network of an instance.
|
||||
|
||||
:param context: nova auth request context
|
||||
:param instance: Instance object being migrated
|
||||
:param migration: Migration object for the operation; used to determine
|
||||
the phase of the migration which dictates what to do with claimed
|
||||
PCI devices for SR-IOV ports
|
||||
:param provider_mappings: a dict of list of resource provider uuids
|
||||
keyed by port uuid
|
||||
"""
|
||||
self._update_port_binding_for_instance(
|
||||
context, instance, migration['dest_compute'], migration=migration,
|
||||
context, instance, migration.dest_compute, migration=migration,
|
||||
provider_mappings=provider_mappings)
|
||||
|
||||
def add_network_to_project(self, context, project_id, network_uuid=None):
|
||||
|
|
|
@ -6043,7 +6043,7 @@ class ComputeTestCase(BaseTestCase,
|
|||
# NOTE(hanrong): Prove that we pass the right value to the
|
||||
# "self.network_api.migrate_instance_finish".
|
||||
def fake_migrate_instance_finish(cls, context, instance, migration):
|
||||
self.assertEqual(source_compute, migration['dest_compute'])
|
||||
self.assertEqual(source_compute, migration.dest_compute)
|
||||
self.stub_out('nova.network.api.API.migrate_instance_finish',
|
||||
fake_migrate_instance_finish)
|
||||
|
||||
|
|
|
@ -52,6 +52,7 @@ from nova.network import api as network_api
|
|||
from nova.network import model as network_model
|
||||
from nova.network.neutronv2 import api as neutronv2_api
|
||||
from nova import objects
|
||||
from nova.objects import base as base_obj
|
||||
from nova.objects import block_device as block_device_obj
|
||||
from nova.objects import fields
|
||||
from nova.objects import instance as instance_obj
|
||||
|
@ -9039,10 +9040,14 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
|
|||
|
||||
migrate_instance_finish.assert_called_once_with(
|
||||
self.context, self.instance,
|
||||
{'source_compute': cn_old,
|
||||
'dest_compute': self.compute.host,
|
||||
'migration_type': 'live-migration'},
|
||||
test.MatchType(objects.Migration),
|
||||
provider_mappings=None)
|
||||
mig = migrate_instance_finish.call_args[0][2]
|
||||
self.assertTrue(base_obj.obj_equal_prims(
|
||||
objects.Migration(source_compute=cn_old,
|
||||
dest_compute=self.compute.host,
|
||||
migration_type='live-migration'),
|
||||
mig))
|
||||
_get_instance_block_device_info.assert_called_once_with(
|
||||
self.context, self.instance
|
||||
)
|
||||
|
|
|
@ -235,8 +235,9 @@ class ApiTestCase(test.TestCase):
|
|||
instance_type_id=fake_flavor['id'],
|
||||
flavor=fake_flavor,
|
||||
system_metadata={})
|
||||
fake_migration = {'source_compute': 'fake_compute_source',
|
||||
'dest_compute': 'fake_compute_dest'}
|
||||
fake_migration = objects.Migration(
|
||||
source_compute='fake_compute_source',
|
||||
dest_compute='fake_compute_dest')
|
||||
|
||||
def fake_mig_inst_method(*args, **kwargs):
|
||||
info['kwargs'] = kwargs
|
||||
|
|
|
@ -6552,8 +6552,8 @@ class TestNeutronv2Portbinding(TestNeutronv2Base):
|
|||
'test1', port_req_body)
|
||||
|
||||
def test_migrate_instance_finish_binding_true(self):
|
||||
migration = {'source_compute': self.instance.get('host'),
|
||||
'dest_compute': 'dest_host'}
|
||||
migration = objects.Migration(source_compute=self.instance.get('host'),
|
||||
dest_compute='dest_host')
|
||||
instance = self._fake_instance_object(self.instance)
|
||||
self._test_update_port_binding_true('dest_host',
|
||||
'migrate_instance_finish',
|
||||
|
@ -6563,8 +6563,8 @@ class TestNeutronv2Portbinding(TestNeutronv2Base):
|
|||
{})
|
||||
|
||||
def test_migrate_instance_finish_binding_true_exception(self):
|
||||
migration = {'source_compute': self.instance.get('host'),
|
||||
'dest_compute': 'dest_host'}
|
||||
migration = objects.Migration(source_compute=self.instance.get('host'),
|
||||
dest_compute='dest_host')
|
||||
instance = self._fake_instance_object(self.instance)
|
||||
self._test_update_port_true_exception('dest_host',
|
||||
'migrate_instance_finish',
|
||||
|
|
Loading…
Reference in New Issue