summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJohn Griffith <john.griffith@solidfire.com>2012-07-31 18:57:42 -0600
committerJohn Griffith <john.griffith@solidfire.com>2012-08-01 14:10:03 +0000
commiteb19ef9a195bb36ef4310277d072f2911eda0f73 (patch)
tree6016b9ef13e997cd85ce58f03bc00d7877c29776 /nova
parentfce61c1bc0ddb5e8bffdc5ed6345fc8c2d5bb0c3 (diff)
Fix failed iscsi tgt delete errors with new tgtadm
Now that the tgtadm patches are working, one problem was detected The delete target operation would fail, and as a result lvremove would fail due to an open connection. There were a number of issue using the config file method, but the most reliable way is to just use the iqn since we're going to perform an os.unlink on the config file anyway. devstack volumes.sh tests now pass and the detach/delete calls are succesful. Adjust test_iscsi for modifications to delete Change-Id: Ic34ca2194b8d75fb84a06dfba6793106eb8055fe
Diffstat (limited to 'nova')
-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)