self.driver.delete_volume(VOLUME)
expected = [mock.call.destroy_volume(vol_name)]
self.array.assert_has_calls(expected)
+ self.array.destroy_volume.side_effect = exception.PureAPIException(
+ code=400, reason="reason")
+ self.driver.delete_snapshot(SNAPSHOT)
+ self.array.destroy_volume.side_effect = None
self.assert_error_propagates([self.array.destroy_volume],
self.driver.delete_volume, VOLUME)
self.driver.delete_snapshot(SNAPSHOT)
expected = [mock.call.destroy_volume(snap_name)]
self.array.assert_has_calls(expected)
+ self.array.destroy_volume.side_effect = exception.PureAPIException(
+ code=400, reason="reason")
+ self.driver.delete_snapshot(SNAPSHOT)
+ self.array.destroy_volume.side_effect = None
self.assert_error_propagates([self.array.destroy_volume],
self.driver.delete_snapshot, SNAPSHOT)
mock_host.return_value = HOST_NAME
self.driver.terminate_connection(VOLUME, CONNECTOR)
self.array.disconnect_host.assert_called_with(HOST_NAME, vol_name)
+ self.array.disconnect_host.side_effect = exception.PureAPIException(
+ code=400, reason="reason")
+ self.driver.terminate_connection(VOLUME, CONNECTOR)
+ self.array.disconnect_host.assert_called_with(HOST_NAME, vol_name)
+ self.array.disconnect_host.side_effect = None
+ self.array.disconnect_host.reset_mock()
+ mock_host.side_effect = exception.PureDriverException(reason="reason")
+ self.assertFalse(self.array.disconnect_host.called)
+ mock_host.side_effect = None
self.assert_error_propagates(
[self.array.disconnect_host],
self.driver.terminate_connection, VOLUME, CONNECTOR)
try:
self._array.destroy_volume(vol_name)
except exception.PureAPIException as err:
- with excutils.save_and_reraise_exception as ctxt:
+ with excutils.save_and_reraise_exception() as ctxt:
if err.kwargs["code"] == 400:
- # This happens if the volume does not exist.
+ # Happens if the volume does not exist.
ctxt.reraise = False
- LOG.error(_("Disconnection failed with message: {}"
+ LOG.error(_("Volume deletion failed with message: {0}"
).format(err.msg))
LOG.debug("Leave PureISCSIDriver.delete_volume.")
try:
self._array.destroy_volume(snap_name)
except exception.PureAPIException as err:
- with excutils.save_and_reraise_exception as ctxt:
+ with excutils.save_and_reraise_exception() as ctxt:
if err.kwargs["code"] == 400:
- # This happens if the snapshot does not exist.
+ # Happens if the snapshot does not exist.
ctxt.reraise = False
- LOG.error(_("Disconnection failed with message: {}"
+ LOG.error(_("Snapshot deletion failed with message: {0}"
).format(err.msg))
LOG.debug("Leave PureISCSIDriver.delete_snapshot.")
"""Terminate connection."""
LOG.debug("Enter PureISCSIDriver.terminate_connection.")
vol_name = _get_vol_name(volume)
+ message = _("Disconnection failed with message: {0}")
try:
host_name = self._get_host_name(connector)
- self._array.disconnect_host(host_name, vol_name)
- except exception.PureAPIException as err:
- with excutils.save_and_reraise_exception as ctxt:
- if err.kwargs["code"] == 400:
- # This happens if the host and volume are not connected
- ctxt.reraise = False
- LOG.error(_("Disconnection failed with message: {}"
- ).format(err.msg))
+ except exception.PureDriverException as err:
+ # Happens if the host object is missing.
+ LOG.error(message.format(err.msg))
+ else:
+ try:
+ self._array.disconnect_host(host_name, vol_name)
+ except exception.PureAPIException as err:
+ with excutils.save_and_reraise_exception() as ctxt:
+ if err.kwargs["code"] == 400:
+ # Happens if the host and volume are not connected.
+ ctxt.reraise = False
+ LOG.error(message.format(err.msg))
LOG.debug("Leave PureISCSIDriver.terminate_connection.")
def get_volume_stats(self, refresh=False):