From f02c575b4b28b69cade6c1c06dd772c62754fc9c Mon Sep 17 00:00:00 2001 From: John Griffith Date: Sun, 20 Jan 2013 22:52:52 +0000 Subject: [PATCH] Check for non-default volume name template. 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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cinder/volume/iscsi.py b/cinder/volume/iscsi.py index a5ed8c724..9f7a78de9 100644 --- a/cinder/volume/iscsi.py +++ b/cinder/volume/iscsi.py @@ -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: -- 2.45.2