From df1fb2978c854beb58646406796c2bef2bfb047f Mon Sep 17 00:00:00 2001 From: Jian Wen Date: Fri, 21 Sep 2012 17:30:18 +0800 Subject: Migrate network of an instance In multi_host mode, floating ip(s) addr and NAT rules are still on source node after resize/migrate instance. This patch fixes it up by adding new methods in network.api to moving them to the destination node. Also adds the new methods to network/quantumv2/api.py. They do nothing but pass for now. This patch updates network RPC API to version 1.1 Fixes bug 1053344 Change-Id: If9f30050d37831f108ac4a1c8a018d820818f3b6 --- nova/compute/manager.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 515737992..eae7149e9 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -1471,6 +1471,11 @@ class ComputeManager(manager.SchedulerDependentManager): self.network_api.setup_networks_on_host(context, instance, teardown=True) + if migration_ref['dest_compute'] != \ + migration_ref['source_compute']: + self.network_api.migrate_instance_start(context, instance, + migration_ref['dest_compute']) + network_info = self._get_instance_nw_info(context, instance) block_device_info = self._get_instance_volume_block_device_info( context, instance['uuid']) @@ -1532,6 +1537,11 @@ class ComputeManager(manager.SchedulerDependentManager): self._legacy_nw_info(network_info), block_device_info) + if migration_ref['dest_compute'] != \ + migration_ref['source_compute']: + self.network_api.migrate_instance_finish(context, instance, + migration_ref['source_compute']) + # Just roll back the record. There's no need to resize down since # the 'old' VM already has the preferred attributes self._instance_update(context, @@ -1659,6 +1669,11 @@ class ComputeManager(manager.SchedulerDependentManager): self.volume_api.terminate_connection(context, volume, connector) + if migration_ref['dest_compute'] != \ + migration_ref['source_compute']: + self.network_api.migrate_instance_start(context, instance, + self.host) + self.db.migration_update(context, migration_id, {'status': 'post-migrating'}) @@ -1697,6 +1712,11 @@ class ComputeManager(manager.SchedulerDependentManager): self.network_api.setup_networks_on_host(context, instance, migration_ref['dest_compute']) + if migration_ref['dest_compute'] != \ + migration_ref['source_compute']: + self.network_api.migrate_instance_finish(context, instance, + migration_ref['dest_compute']) + network_info = self._get_instance_nw_info(context, instance) self._instance_update(context, instance['uuid'], -- cgit