summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Handle <ah@mynet.at>2012-10-22 13:23:34 +0200
committerAlex Handle <ah@mynet.at>2012-10-24 19:39:45 +0200
commit2543705986789658725aac808e85e2cb638ea3dd (patch)
tree3b3e5ec4aa625dbc317c334e74dc792ba132dc3f
parenta6297a1b93525a93e9f401511c9630b065005b86 (diff)
Fix live migration volume assignment.
In pre_live_migration volumes should get assigned (self.volume_api.initialize_connection) to the live migration target host. In post_live_migration the volumes should get unassigned (self.volume_api.terminate_connection) from the live migration source host. Fixes bug 1066887 Change-Id: Ic2db456cd5efbdf15db92f843c92230489efc551
-rw-r--r--nova/compute/manager.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index eae7149e9..77ce04e0e 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -2218,6 +2218,13 @@ class ComputeManager(manager.SchedulerDependentManager):
if not block_device_info['block_device_mapping']:
LOG.info(_('Instance has no volume.'), instance=instance)
+ # assign the volume to host system
+ # needed by the lefthand volume driver and maybe others
+ connector = self.driver.get_volume_connector(instance)
+ for bdm in self._get_instance_volume_bdms(context, instance['uuid']):
+ volume = self.volume_api.get(context, bdm['volume_id'])
+ self.volume_api.initialize_connection(context, volume, connector)
+
network_info = self._get_instance_nw_info(context, instance)
# TODO(tr3buchet): figure out how on the earth this is necessary
@@ -2299,12 +2306,16 @@ class ComputeManager(manager.SchedulerDependentManager):
instance=instance_ref)
# Detaching volumes.
+ connector = self.driver.get_volume_connector(instance_ref)
for bdm in self._get_instance_volume_bdms(ctxt, instance_ref['uuid']):
# NOTE(vish): We don't want to actually mark the volume
# detached, or delete the bdm, just remove the
# connection from this host.
- self.remove_volume_connection(ctxt, bdm['volume_id'],
- instance_ref)
+
+ # remove the volume connection without detaching from hypervisor
+ # because the instance is not running anymore on the current host
+ volume = self.volume_api.get(ctxt, bdm['volume_id'])
+ self.volume_api.terminate_connection(ctxt, volume, connector)
# Releasing vlan.
# (not necessary in current implementation?)