]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Check for non-default volume name template.
authorJohn Griffith <john.griffith@solidfire.com>
Sun, 20 Jan 2013 22:52:52 +0000 (22:52 +0000)
committerjohn-griffith <john.griffith@solidfire.com>
Thu, 24 Jan 2013 05:58:32 +0000 (22:58 -0700)
The iscsi delete methods in iscsi.py had hard-coded volume names
'volume-%s'.

If a user configured volume_name_template to
something other than default the result is failure to remove
the iscsi_target.

volume create worked appropriately and created the correct name
in the DB, so the persistence files were the only thing affected
or named incorrectly.

Fixes bug: 1101071

Change-Id: Id5575874b2cebd9b3509d739cb92abf06c503c4e

cinder/volume/iscsi.py

index a5ed8c7243f1fe906b5e3dbb8714bc92c6f4fe7c..9f7a78de9929a3ec6543f8423dc37e8461829f49 100644 (file)
@@ -43,6 +43,7 @@ iscsi_helper_opt = [cfg.StrOpt('iscsi_helper',
 
 FLAGS = flags.FLAGS
 FLAGS.register_opts(iscsi_helper_opt)
+FLAGS.import_opt('volume_name_template', 'cinder.db')
 
 
 class TargetAdmin(object):
@@ -172,7 +173,7 @@ class TgtAdm(TargetAdmin):
 
     def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
         LOG.info(_('Removing volume: %s') % vol_id)
-        vol_uuid_file = 'volume-%s' % vol_id
+        vol_uuid_file = FLAGS.volume_name_template % vol_id
         volume_path = os.path.join(FLAGS.volumes_dir, vol_uuid_file)
         if os.path.isfile(volume_path):
             iqn = '%s%s' % (FLAGS.iscsi_target_prefix,
@@ -239,7 +240,7 @@ class IetAdm(TargetAdmin):
         LOG.info(_('Removing volume: %s') % vol_id)
         self._delete_logicalunit(tid, lun, **kwargs)
         self._delete_target(tid, **kwargs)
-        vol_uuid = 'volume-%s' % vol_id
+        vol_uuid_file = FLAGS.volume_name_template % vol_id
         conf_file = FLAGS.iet_conf
         if os.path.exists(conf_file):
             with utils.temporary_chown(conf_file):
@@ -252,7 +253,7 @@ class IetAdm(TargetAdmin):
                         if count > 0:
                             count -= 1
                             continue
-                        elif re.search(vol_uuid, line):
+                        elif re.search(vol_uuid_file, line):
                             count = 2
                             continue
                         else: