summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-08-01 18:40:02 +0000
committerGerrit Code Review <review@openstack.org>2012-08-01 18:40:02 +0000
commitf08cbf615206997df01f1abfc2189424430ef53e (patch)
tree2e23d1671067f50408b8d3ed9e8602e0889e4a42
parent74ee613d40d722398586fd7c9df5a90c72744803 (diff)
parenteb19ef9a195bb36ef4310277d072f2911eda0f73 (diff)
Merge "Fix failed iscsi tgt delete errors with new tgtadm"
-rw-r--r--nova/tests/test_iscsi.py5
-rw-r--r--nova/volume/iscsi.py16
2 files changed, 15 insertions, 6 deletions
diff --git a/nova/tests/test_iscsi.py b/nova/tests/test_iscsi.py
index d0db6d62f..b88bd3fce 100644
--- a/nova/tests/test_iscsi.py
+++ b/nova/tests/test_iscsi.py
@@ -14,6 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import os.path
import string
from nova import test
@@ -32,6 +33,8 @@ class TargetAdminTestCase(object):
self.vol_id = 'blaa'
self.script_template = None
+ self.stubs.Set(os.path, 'isfile', lambda _: True)
+ self.stubs.Set(os, 'unlink', lambda _: '')
def get_script_params(self):
return {'tid': self.tid,
@@ -87,7 +90,7 @@ class TgtAdmTestCase(test.TestCase, TargetAdminTestCase):
self.script_template = "\n".join([
"tgt-admin --execute --conf ./blaa --update blaa",
"tgtadm --op show --lld=iscsi --mode=target --tid=1",
- "tgt-admin --conf ./blaa --delete blaa"])
+ "tgt-admin --delete iqn.2010-10.org.openstack:volume-blaa"])
class IetAdmTestCase(test.TestCase, TargetAdminTestCase):
diff --git a/nova/volume/iscsi.py b/nova/volume/iscsi.py
index 97e905ebf..7d714aeab 100644
--- a/nova/volume/iscsi.py
+++ b/nova/volume/iscsi.py
@@ -115,8 +115,9 @@ class TgtAdm(TargetAdmin):
f.write(volume_conf)
f.close()
- self._execute('tgt-admin', '--execute', '--conf %s' % volume_path,
- '--update %s' % vol_id, run_as_root=True)
+ self._execute('tgt-admin', '--execute',
+ '--conf %s' % volume_path,
+ '--update %s' % vol_id, run_as_root=True)
except Exception as ex:
LOG.exception(ex)
@@ -126,10 +127,15 @@ class TgtAdm(TargetAdmin):
def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
try:
LOG.info(_('Removing volume: %s') % vol_id)
- volume_path = os.path.join(FLAGS.volumes_dir, vol_id)
+ vol_uuid_file = 'volume-%s' % vol_id
+ volume_path = os.path.join(FLAGS.volumes_dir, vol_uuid_file)
if os.path.isfile(volume_path):
- self._execute('tgt-admin', '--conf %s' % volume_path,
- '--delete %s' % vol_id, run_as_root_root=True)
+ delete_file = '%s%s' % (FLAGS.iscsi_target_prefix,
+ vol_uuid_file)
+ self._execute('tgt-admin',
+ '--delete',
+ delete_file,
+ run_as_root=True)
os.unlink(volume_path)
except Exception as ex:
LOG.exception(ex)