From 94c4ec8a1e68fe7a764732a65a48322c7d1cc724 Mon Sep 17 00:00:00 2001 From: Eoghan Glynn Date: Tue, 25 Sep 2012 15:52:38 +0100 Subject: [PATCH] Revert explicit usage of tgt-adm --conf option. Fixes bug 1056246. This reverts commit 0903603971033536751ba40df98a3c39175d3189. This ensures that we fail-fast if the tgtd configuration does not include the directory for volume iscsi target configs, instead of only blowing up when tgtd is restarted. Change-Id: I30aa3f1d8944eb33cd4a42d65e227031023406b4 --- cinder/tests/test_iscsi.py | 3 +-- cinder/volume/iscsi.py | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cinder/tests/test_iscsi.py b/cinder/tests/test_iscsi.py index 04ebf233e..38c760835 100644 --- a/cinder/tests/test_iscsi.py +++ b/cinder/tests/test_iscsi.py @@ -95,8 +95,7 @@ class TgtAdmTestCase(test.TestCase, TargetAdminTestCase): self.flags(iscsi_helper='tgtadm') self.flags(volumes_dir=self.persist_tempdir) self.script_template = "\n".join([ - 'tgt-admin --conf %s/blaa --update iqn.2011-09.org.foo.bar:blaa' - % self.persist_tempdir, + 'tgt-admin --update iqn.2011-09.org.foo.bar:blaa', 'tgt-admin --delete iqn.2010-10.org.openstack:volume-blaa']) def tearDown(self): diff --git a/cinder/volume/iscsi.py b/cinder/volume/iscsi.py index ec6e40894..3fcc9bdc3 100644 --- a/cinder/volume/iscsi.py +++ b/cinder/volume/iscsi.py @@ -119,7 +119,8 @@ class TgtAdm(TargetAdmin): """ % (name, path) LOG.info(_('Creating volume: %s') % vol_id) - volume_path = os.path.join(FLAGS.volumes_dir, vol_id) + volumes_dir = FLAGS.volumes_dir + volume_path = os.path.join(volumes_dir, vol_id) f = open(volume_path, 'w+') f.write(volume_conf) @@ -127,8 +128,6 @@ class TgtAdm(TargetAdmin): try: (out, err) = self._execute('tgt-admin', - '--conf', - volume_path, '--update', name, run_as_root=True) @@ -143,6 +142,9 @@ class TgtAdm(TargetAdmin): iqn = '%s%s' % (FLAGS.iscsi_target_prefix, vol_id) tid = self._get_target(iqn) if tid is None: + LOG.error(_("Failed to create iscsi target for volume " + "id:%(vol_id)s. Please ensure your tgtd config file " + "contains 'include %(volumes_dir)s/*'") % locals()) raise exception.NotFound() return tid -- 2.45.2