Raise correct exception if deleting of LIO iSCSI target is failed
When using LVM driver and LIO target, terminate_connection in LIO target raises ISCSITargetAttachFailed if deleting of iSCSI target is failed. This should raise ISCSITargetDetachFailed. Closes-Bug: #1414207 Change-Id: I98060d5a0bcd720df15434305ab8d3e31bdb1a43
This commit is contained in:
parent
9906718cc2
commit
40e7f19a67
|
@ -917,6 +917,10 @@ class ISCSITargetAttachFailed(CinderException):
|
|||
message = _("Failed to attach iSCSI target for volume %(volume_id)s.")
|
||||
|
||||
|
||||
class ISCSITargetDetachFailed(CinderException):
|
||||
message = _("Failed to detach iSCSI target for volume %(volume_id)s.")
|
||||
|
||||
|
||||
# X-IO driver exception.
|
||||
class XIODriverException(VolumeDriverException):
|
||||
message = _("X-IO Volume Driver exception!")
|
||||
|
|
|
@ -91,3 +91,27 @@ class TestLioAdmDriver(test_tgt.TestTgtAdmDriver):
|
|||
'iqn.2010-10.org.openstack:testvol',
|
||||
1, 0, self.fake_volumes_dir, 'IncomingUser foo bar',
|
||||
check_exit_code=False)
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_terminate_connection(self, _mock_execute):
|
||||
|
||||
connector = {'initiator': 'fake_init'}
|
||||
self.target.terminate_connection(self.testvol_1,
|
||||
connector)
|
||||
_mock_execute.assert_called_once_with(
|
||||
'cinder-rtstool', 'delete-initiator',
|
||||
'iqn.2010-10.org.openstack:'
|
||||
'volume-ed2c2222-5fc0-11e4-aa15-123b93f75cba',
|
||||
connector['initiator'],
|
||||
run_as_root=True)
|
||||
|
||||
@mock.patch.object(utils, 'execute')
|
||||
def test_terminate_connection_fail(self, _mock_execute):
|
||||
|
||||
_mock_execute.side_effect = \
|
||||
exception.ISCSITargetDetachFailed(self.testvol_1['id'])
|
||||
connector = {'initiator': 'fake_init'}
|
||||
self.assertRaises(exception.ISCSITargetDetachFailed,
|
||||
self.target.terminate_connection,
|
||||
self.testvol_1,
|
||||
connector)
|
||||
|
|
|
@ -195,4 +195,4 @@ class LioAdm(TgtAdm):
|
|||
except putils.ProcessExecutionError:
|
||||
LOG.error(_LE("Failed to delete initiator iqn %s to target.") %
|
||||
connector['initiator'])
|
||||
raise exception.ISCSITargetAttachFailed(volume_id=volume['id'])
|
||||
raise exception.ISCSITargetDetachFailed(volume_id=volume['id'])
|
||||
|
|
Loading…
Reference in New Issue