summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-12 17:58:24 +0000
committerGerrit Code Review <review@openstack.org>2012-03-12 17:58:24 +0000
commit39a8abf3572cdf5e7233f41f638d0111540eaa90 (patch)
tree2c944b3eef4dda75bd9d046ac336b9bac33da3ca
parent9b8275659b5de8c8291d64d48a11edd83a276837 (diff)
parent33def9e714fbd13a6dc4b755ade4841c971f7ae5 (diff)
downloadnova-39a8abf3572cdf5e7233f41f638d0111540eaa90.tar.gz
nova-39a8abf3572cdf5e7233f41f638d0111540eaa90.tar.xz
nova-39a8abf3572cdf5e7233f41f638d0111540eaa90.zip
Merge "Fix live-migration in multi_host network"
-rw-r--r--nova/compute/manager.py30
-rw-r--r--nova/tests/test_compute.py16
2 files changed, 24 insertions, 22 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index 6572c5a3a..889e9e5f0 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -2000,10 +2000,6 @@ class ComputeManager(manager.SchedulerDependentManager):
# Releasing vlan.
# (not necessary in current implementation?)
- # NOTE(tr3buchet): tear down networks on source host
- self.network_api.setup_networks_on_host(ctxt, instance_ref,
- self.host, teardown=True)
-
network_info = self._get_instance_nw_info(ctxt, instance_ref)
# Releasing security group ingress rule.
self.driver.unfilter_instance(instance_ref,
@@ -2041,15 +2037,6 @@ class ComputeManager(manager.SchedulerDependentManager):
"args": {'instance_id': instance_ref['id'],
'block_migration': block_migration}})
- # Restore instance state
- current_power_state = self._get_power_state(ctxt, instance_ref)
- self._instance_update(ctxt,
- instance_ref["id"],
- host=dest,
- power_state=current_power_state,
- vm_state=vm_states.ACTIVE,
- task_state=None)
-
# Restore volume state
for volume_ref in instance_ref['volumes']:
self.volume_api.update(ctxt, volume_ref, {'status': 'in-use'})
@@ -2067,6 +2054,10 @@ class ComputeManager(manager.SchedulerDependentManager):
self.driver.unplug_vifs(instance_ref,
self._legacy_nw_info(network_info))
+ # NOTE(tr3buchet): tear down networks on source host
+ self.network_api.setup_networks_on_host(ctxt, instance_ref,
+ self.host, teardown=True)
+
LOG.info(_('Migrating instance to %(dest)s finished successfully.'),
locals(), instance=instance_ref)
LOG.info(_("You may see the error \"libvirt: QEMU error: "
@@ -2098,6 +2089,19 @@ class ComputeManager(manager.SchedulerDependentManager):
self.driver.post_live_migration_at_destination(context, instance_ref,
self._legacy_nw_info(network_info),
block_migration)
+ # Restore instance state
+ current_power_state = self._get_power_state(context, instance_ref)
+ self._instance_update(context,
+ instance_ref['id'],
+ host=self.host,
+ power_state=current_power_state,
+ vm_state=vm_states.ACTIVE,
+ task_state=None)
+
+ # NOTE(vish): this is necessary to update dhcp
+ self.network_api.setup_networks_on_host(context,
+ instance_ref,
+ self.host)
def rollback_live_migration(self, context, instance_ref,
dest, block_migration):
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py
index bcfe90e0e..f30fefeba 100644
--- a/nova/tests/test_compute.py
+++ b/nova/tests/test_compute.py
@@ -1387,26 +1387,24 @@ class ComputeTestCase(BaseTestCase):
self.mox.StubOutWithMock(self.compute.driver, 'unfilter_instance')
self.compute.driver.unfilter_instance(i_ref, [])
self.mox.StubOutWithMock(rpc, 'call')
- rpc.call(c, 'network', {'method': 'setup_networks_on_host',
- 'args': {'instance_id': instance_id,
- 'host': self.compute.host,
- 'teardown': True}})
rpc.call(c, db.queue_get_for(c, FLAGS.compute_topic, dest),
{"method": "post_live_migration_at_destination",
"args": {'instance_id': i_ref['id'], 'block_migration': False}})
self.mox.StubOutWithMock(self.compute.driver, 'unplug_vifs')
self.compute.driver.unplug_vifs(i_ref, [])
+ rpc.call(c, 'network', {'method': 'setup_networks_on_host',
+ 'args': {'instance_id': instance_id,
+ 'host': self.compute.host,
+ 'teardown': True}})
# start test
self.mox.ReplayAll()
self.compute.post_live_migration(c, i_ref, dest)
- # make sure every data is rewritten to destinatioin hostname.
- i_ref = db.instance_get(c, i_ref['id'])
- c1 = (i_ref['host'] == dest)
+ # make sure floating ips are rewritten to destinatioin hostname.
flo_refs = db.floating_ip_get_all_by_host(c, dest)
- c2 = (len(flo_refs) != 0 and flo_refs[0]['address'] == flo_addr)
- self.assertTrue(c1 and c2)
+ self.assertTrue(flo_refs)
+ self.assertEqual(flo_refs[0]['address'], flo_addr)
# cleanup
db.instance_destroy(c, instance_id)