From: Dan Prince Date: Fri, 7 Sep 2012 02:52:35 +0000 (-0400) Subject: Handle missing 'provider_location' in rm_export. X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=42cfb8fbb29577e1a0ab98ec7d8614c270f241ae;p=openstack-build%2Fcinder-build.git 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 --- 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'])