From 42cfb8fbb29577e1a0ab98ec7d8614c270f241ae Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Thu, 6 Sep 2012 22:52:35 -0400 Subject: [PATCH] Handle missing 'provider_location' in rm_export. Updates the remove_export function in the ISCSIDriver so that it handles the case where provider_location isn't set on a volume. This can occur if a volume is created but not exported. This was a regression from a previous commit (9785963c841aff5ea1c159da81f93c2bf62c70c6) which changed the way iscsi targets are created/deleted. Fixes LP Bug #1046484. Change-Id: Ie762b092dd2a84fe4f3b72c46c03a97ae67c53b7 --- cinder/volume/driver.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 8c667aeb5..6901ecead 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -369,13 +369,6 @@ class ISCSIDriver(VolumeDriver): def remove_export(self, context, volume): """Removes an export for a logical volume.""" - #BOOKMARK jdg - location = volume['provider_location'].split(' ') - iqn = location[1] - if 'iqn' not in iqn: - LOG.warning(_("Jacked... didn't get an iqn")) - return - # NOTE(jdg): tgtadm doesn't use the iscsi_targets table # TODO(jdg): In the future move all of the dependent stuff into the # cooresponding target admin class @@ -391,9 +384,16 @@ class ISCSIDriver(VolumeDriver): iscsi_target = 0 try: + + # NOTE: provider_location may be unset if the volume hasn't + # been exported + location = volume['provider_location'].split(' ') + iqn = location[1] + # ietadm show will exit with an error # this export has already been removed self.tgtadm.show_target(iscsi_target, iqn=iqn) + except Exception as e: LOG.info(_("Skipping remove_export. No iscsi_target " "is presently exported for volume: %s"), volume['id']) -- 2.45.2