]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Handle missing 'provider_location' in rm_export.
authorDan Prince <dprince@redhat.com>
Fri, 7 Sep 2012 02:52:35 +0000 (22:52 -0400)
committerDan Prince <dprince@redhat.com>
Fri, 7 Sep 2012 02:52:35 +0000 (22:52 -0400)
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

index 8c667aeb5561dd1cbd955acf1b5bfaca640feb90..6901ecead6a33af386c35b5c24d7112f297ae91c 100644 (file)
@@ -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'])