From 94d8553201e50e3e9e25992bfe4735addae4ffda Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Sat, 28 Jan 2012 01:17:00 -0800 Subject: Add initiator to initialize_connection Some volumes need to know the name of the initiator that will be connecting to the iscsi volume. This adds a call down to the hypervisor driver to get the ip and the initiator name for the vm before calling initialize connection. This connection is passed down to the volume driver so that it can be used to authenticate when the hypervisor tries to connect to the volume. * Adds initiator initialize_connection * Makes a call to driver to get initiator name and ip address * Gets initiator from openiscsi for libvirt * Gets initiator from config for xenapi * Add tests for the driver calls * Fixes bug 924461 Change-Id: I5b6a2dd84560c7f7b447571e0abf0993e5512ca0 --- nova/compute/manager.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'nova/compute') diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 64401eeca..bd911ae0d 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -652,9 +652,10 @@ class ComputeManager(manager.SchedulerDependentManager): # NOTE(vish): actual driver detach done in driver.destroy, so # just tell nova-volume that we are done with it. volume = self.volume_api.get(context, bdm['volume_id']) + connector = self.driver.get_volume_connector(instance) self.volume_api.terminate_connection(context, volume, - FLAGS.my_ip) + connector) self.volume_api.detach(context, volume) except exception.DiskNotFound as exc: LOG.warn(_("Ignoring DiskNotFound: %s") % exc) @@ -1597,10 +1598,10 @@ class ComputeManager(manager.SchedulerDependentManager): msg = _("instance %(instance_uuid)s: booting with " "volume %(volume_id)s at %(mountpoint)s") LOG.audit(msg % locals(), context=context) - address = FLAGS.my_ip + connector = self.driver.get_volume_connector(instance) connection_info = self.volume_api.initialize_connection(context, volume, - address) + connector) self.volume_api.attach(context, volume, instance_id, mountpoint) return connection_info @@ -1616,10 +1617,10 @@ class ComputeManager(manager.SchedulerDependentManager): msg = _("instance %(instance_uuid)s: attaching volume %(volume_id)s" " to %(mountpoint)s") LOG.audit(msg % locals(), context=context) - address = FLAGS.my_ip + connector = self.driver.get_volume_connector(instance_ref) connection_info = self.volume_api.initialize_connection(context, volume, - address) + connector) try: self.driver.attach_volume(connection_info, instance_ref['name'], @@ -1631,7 +1632,7 @@ class ComputeManager(manager.SchedulerDependentManager): LOG.exception(msg % locals(), context=context) self.volume_api.terminate_connection(context, volume, - address) + connector) self.volume_api.attach(context, volume, instance_id, mountpoint) values = { @@ -1674,7 +1675,8 @@ class ComputeManager(manager.SchedulerDependentManager): bdm = self._get_instance_volume_bdm(context, instance_id, volume_id) self._detach_volume(context, instance_ref, bdm) volume = self.volume_api.get(context, volume_id) - self.volume_api.terminate_connection(context, volume, FLAGS.my_ip) + connector = self.driver.get_volume_connector(instance_ref) + self.volume_api.terminate_connection(context, volume, connector) self.volume_api.detach(context.elevated(), volume) self.db.block_device_mapping_destroy_by_instance_and_volume( context, instance_id, volume_id) @@ -1693,7 +1695,8 @@ class ComputeManager(manager.SchedulerDependentManager): volume_id) self._detach_volume(context, instance_ref, bdm) volume = self.volume_api.get(context, volume_id) - self.volume_api.terminate_connection(context, volume, FLAGS.my_ip) + connector = self.driver.get_volume_connector(instance_ref) + self.volume_api.terminate_connection(context, volume, connector) except exception.NotFound: pass -- cgit