move Nexenta exception
This patch moves the nexenta specific exception to the nexenta utils.py file. Change-Id: I220c83b3d751410150cb75db48437d4afab97f63
This commit is contained in:
parent
22e09a4bf3
commit
9c00ebbed0
|
@ -1255,11 +1255,6 @@ class NotSupportedOperation(Invalid):
|
|||
code = 405
|
||||
|
||||
|
||||
# NexentaStor driver exception
|
||||
class NexentaException(VolumeDriverException):
|
||||
message = "%(reason)s"
|
||||
|
||||
|
||||
# Kaminario K2
|
||||
class KaminarioCinderDriverException(VolumeDriverException):
|
||||
message = _("KaminarioCinderDriver failure: %(reason)s")
|
||||
|
|
|
@ -22,7 +22,6 @@ from oslo_utils import units
|
|||
|
||||
from cinder import context
|
||||
from cinder import db
|
||||
from cinder import exception
|
||||
from cinder import test
|
||||
from cinder.volume import configuration as conf
|
||||
from cinder.volume.drivers.nexenta import iscsi
|
||||
|
@ -216,7 +215,7 @@ class TestNexentaISCSIDriver(test.TestCase):
|
|||
# Check that exception not raised if snapshot does not exist
|
||||
self.drv.delete_snapshot(self.TEST_SNAPSHOT_REF)
|
||||
self.nms_mock.snapshot.destroy.side_effect = (
|
||||
exception.NexentaException('does not exist'))
|
||||
utils.NexentaException('does not exist'))
|
||||
self.nms_mock.snapshot.destroy.assert_called_with(
|
||||
'cinder/volume1@snapshot1', '')
|
||||
|
||||
|
@ -236,7 +235,7 @@ class TestNexentaISCSIDriver(test.TestCase):
|
|||
def _stub_all_export_methods(self):
|
||||
self.nms_mock.scsidisk.lu_exists.return_value = False
|
||||
self.nms_mock.scsidisk.lu_shared.side_effect = (
|
||||
exception.NexentaException(['does not exist for zvol']))
|
||||
utils.NexentaException(['does not exist for zvol']))
|
||||
self.nms_mock.scsidisk.create_lu.return_value = {'lun': 0}
|
||||
self.nms_mock.stmf.list_targets.return_value = []
|
||||
self.nms_mock.stmf.list_targetgroups.return_value = []
|
||||
|
@ -480,12 +479,12 @@ class TestNexentaNfsDriver(test.TestCase):
|
|||
mock_chmod.assert_called_with(
|
||||
'chmod ugo+rw /volumes/stack/share/volume-1/volume')
|
||||
mock_truncate = self.nms_mock.appliance.execute
|
||||
mock_truncate.side_effect = exception.NexentaException(
|
||||
mock_truncate.side_effect = utils.NexentaException(
|
||||
'fake_exception')
|
||||
self.nms_mock.server.get_prop.return_value = '/volumes'
|
||||
self.nms_mock.folder.get_child_props.return_value = {
|
||||
'available': 1, 'used': 1}
|
||||
self.assertRaises(exception.NexentaException,
|
||||
self.assertRaises(utils.NexentaException,
|
||||
self.drv._do_create_volume, volume)
|
||||
|
||||
def test_create_sparsed_file(self):
|
||||
|
@ -637,7 +636,7 @@ class TestNexentaNfsDriver(test.TestCase):
|
|||
# Check that exception not raised if folder does not exist on
|
||||
# NexentaStor appliance.
|
||||
mock = self.nms_mock.folder.destroy
|
||||
mock.side_effect = exception.NexentaException('Folder does not exist')
|
||||
mock.side_effect = utils.NexentaException('Folder does not exist')
|
||||
self.drv.delete_volume({
|
||||
'id': '1',
|
||||
'name': 'volume-1',
|
||||
|
|
|
@ -23,6 +23,7 @@ from cinder import exception
|
|||
from cinder import test
|
||||
from cinder.volume import configuration as conf
|
||||
from cinder.volume.drivers.nexenta.nexentaedge import iscsi
|
||||
from cinder.volume.drivers.nexenta import utils
|
||||
|
||||
NEDGE_BUCKET = 'c/t/bk'
|
||||
NEDGE_SERVICE = 'isc'
|
||||
|
@ -138,7 +139,7 @@ class TestNexentaEdgeISCSIDriver(test.TestCase):
|
|||
}
|
||||
|
||||
self.mock_api.side_effect = my_side_effect
|
||||
self.assertRaises(exception.NexentaException,
|
||||
self.assertRaises(utils.NexentaException,
|
||||
self.driver.do_setup, self.context)
|
||||
|
||||
def check_for_setup_error(self):
|
||||
|
|
|
@ -139,7 +139,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
try:
|
||||
self.nms.iscsitarget.create_target({
|
||||
'target_name': target_name})
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'already' in exc.args[0]:
|
||||
LOG.info('Ignored target creation error "%s" while '
|
||||
'ensuring export.',
|
||||
|
@ -149,7 +149,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
if not self._target_group_exists(target_group_name):
|
||||
try:
|
||||
self.nms.stmf.create_targetgroup(target_group_name)
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if ('already' in exc.args[0]):
|
||||
LOG.info('Ignored target group creation error "%s" '
|
||||
'while ensuring export.',
|
||||
|
@ -161,7 +161,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
try:
|
||||
self.nms.stmf.add_targetgroup_member(target_group_name,
|
||||
target_name)
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if ('already' in exc.args[0]):
|
||||
LOG.info('Ignored target group member addition error '
|
||||
'"%s" while ensuring export.',
|
||||
|
@ -248,7 +248,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
try:
|
||||
props = self.nms.zvol.get_child_props(volume_name, 'origin') or {}
|
||||
self.nms.zvol.destroy(volume_name, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'does not exist' in exc.args[0]:
|
||||
LOG.info('Volume %s does not exist, it '
|
||||
'seems it was already deleted.', volume_name)
|
||||
|
@ -281,14 +281,14 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
self.create_volume_from_snapshot(volume, snapshot)
|
||||
self._mark_as_garbage('@'.join(
|
||||
(self._get_zvol_name(src_vref['name']), snapshot['name'])))
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.exception(
|
||||
'Volume creation failed, deleting created snapshot '
|
||||
'%(volume_name)s@%(name)s', snapshot)
|
||||
try:
|
||||
self.delete_snapshot(snapshot)
|
||||
except (exception.NexentaException, exception.SnapshotIsBusy):
|
||||
except (utils.NexentaException, exception.SnapshotIsBusy):
|
||||
LOG.warning('Failed to delete zfs snapshot '
|
||||
'%(volume_name)s@%(name)s', snapshot)
|
||||
raise
|
||||
|
@ -368,7 +368,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
|
||||
try:
|
||||
self.nms.appliance.execute(self._get_zfs_send_recv_cmd(src, dst))
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot send source snapshot %(src)s to "
|
||||
"destination %(dst)s. Reason: %(exc)s",
|
||||
{'src': src, 'dst': dst, 'exc': exc})
|
||||
|
@ -376,13 +376,13 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
finally:
|
||||
try:
|
||||
self.delete_snapshot(snapshot)
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot delete temporary source snapshot "
|
||||
"%(src)s on NexentaStor Appliance: %(exc)s",
|
||||
{'src': src, 'exc': exc})
|
||||
try:
|
||||
self.delete_volume(volume)
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot delete source volume %(volume)s on "
|
||||
"NexentaStor Appliance: %(exc)s",
|
||||
{'volume': volume['name'], 'exc': exc})
|
||||
|
@ -392,7 +392,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
snapshot['name'])
|
||||
try:
|
||||
dst_nms.snapshot.destroy(dst_snapshot, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot delete temporary destination snapshot "
|
||||
"%(dst)s on NexentaStor Appliance: %(exc)s",
|
||||
{'dst': dst_snapshot, 'exc': exc})
|
||||
|
@ -459,7 +459,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
nms.zvol.set_child_prop(
|
||||
zvol, options[opt], new)
|
||||
retyped = True
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
LOG.error('Error trying to change %(opt)s'
|
||||
' from %(old)s to %(new)s',
|
||||
{'opt': opt, 'old': old, 'new': new})
|
||||
|
@ -498,7 +498,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
snapshot_name = '%s@%s' % (volume_name, snapshot['name'])
|
||||
try:
|
||||
self.nms.snapshot.destroy(snapshot_name, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if "does not exist" in exc.args[0]:
|
||||
LOG.info('Snapshot %s does not exist, it seems it was '
|
||||
'already deleted.', snapshot_name)
|
||||
|
@ -564,7 +564,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
"""
|
||||
try:
|
||||
return bool(self.nms.scsidisk.lu_exists(zvol_name))
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'does not exist' not in exc.args[0]:
|
||||
raise
|
||||
return False
|
||||
|
@ -578,7 +578,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
"""
|
||||
try:
|
||||
shared = self.nms.scsidisk.lu_shared(zvol_name) > 0
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'does not exist for zvol' not in exc.args[0]:
|
||||
raise # Zvol does not exists
|
||||
shared = False # LU does not exist
|
||||
|
@ -609,7 +609,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
if not self._lu_exists(zvol_name):
|
||||
try:
|
||||
entry = self.nms.scsidisk.create_lu(zvol_name, {})
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'in use' not in exc.args[0]:
|
||||
raise
|
||||
LOG.info('Ignored LU creation error "%s" while ensuring '
|
||||
|
@ -618,7 +618,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
try:
|
||||
entry = self.nms.scsidisk.add_lun_mapping_entry(zvol_name, {
|
||||
'target_group': target_group_name})
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'view entry exists' not in exc.args[0]:
|
||||
raise
|
||||
LOG.info('Ignored LUN mapping entry addition error "%s" '
|
||||
|
@ -703,7 +703,7 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
parent = '/'.join((path, volume))
|
||||
try:
|
||||
self.nms.snapshot.destroy(zfs_object, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.debug('Error occurred while trying to delete a '
|
||||
'snapshot: %s', exc)
|
||||
return
|
||||
|
@ -711,13 +711,13 @@ class NexentaISCSIDriver(driver.ISCSIDriver):
|
|||
try:
|
||||
props = self.nms.zvol.get_child_props(
|
||||
zfs_object, 'origin') or {}
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
props = {}
|
||||
parent = (props['origin'] if 'origin' in props and
|
||||
props['origin'] else '')
|
||||
try:
|
||||
self.nms.zvol.destroy(zfs_object, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.debug('Error occurred while trying to delete a '
|
||||
'volume: %s', exc)
|
||||
return
|
||||
|
|
|
@ -17,8 +17,8 @@ from oslo_log import log as logging
|
|||
from oslo_serialization import jsonutils
|
||||
import requests
|
||||
|
||||
from cinder import exception
|
||||
from cinder.utils import retry
|
||||
from cinder.volume.drivers.nexenta import utils
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
TIMEOUT = 60
|
||||
|
@ -82,5 +82,5 @@ class NexentaJSONProxy(object):
|
|||
LOG.debug('Got response: %s', response)
|
||||
if response.get('error') is not None:
|
||||
message = response['error'].get('message', '')
|
||||
raise exception.NexentaException(message)
|
||||
raise utils.NexentaException(message)
|
||||
return response.get('result')
|
||||
|
|
|
@ -136,7 +136,7 @@ class NexentaEdgeISCSIDriver(driver.ISCSIDriver):
|
|||
data['X-ISCSI-TargetName'], data['X-ISCSI-TargetID'])
|
||||
if 'X-VIPS' in data:
|
||||
if self.target_vip not in data['X-VIPS']:
|
||||
raise exception.NexentaException(
|
||||
raise nexenta_utils.NexentaException(
|
||||
'Configured client IP address does not match any VIP'
|
||||
' provided by iSCSI service %s' % self.iscsi_service)
|
||||
else:
|
||||
|
@ -302,13 +302,13 @@ class NexentaEdgeISCSIDriver(driver.ISCSIDriver):
|
|||
self.create_snapshot(snapshot)
|
||||
try:
|
||||
self.create_volume_from_snapshot(volume, snapshot)
|
||||
except exception.NexentaException:
|
||||
except nexenta_utils.NexentaException:
|
||||
LOG.error('Volume creation failed, deleting created snapshot '
|
||||
'%s', '@'.join([snapshot['volume_name'],
|
||||
snapshot['name']]))
|
||||
try:
|
||||
self.delete_snapshot(snapshot)
|
||||
except (exception.NexentaException, exception.SnapshotIsBusy):
|
||||
except (nexenta_utils.NexentaException, exception.SnapshotIsBusy):
|
||||
LOG.warning('Failed to delete zfs snapshot '
|
||||
'%s', '@'.join([snapshot['volume_name'],
|
||||
snapshot['name']]))
|
||||
|
|
|
@ -201,7 +201,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
dst = ':'.join([dst_host, dst_volume.split('/volumes/')[1]])
|
||||
try:
|
||||
nms.appliance.execute(self._get_zfs_send_recv_cmd(src, dst))
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot send source snapshot %(src)s to "
|
||||
"destination %(dst)s. Reason: %(exc)s",
|
||||
{'src': src, 'dst': dst, 'exc': exc})
|
||||
|
@ -209,13 +209,13 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
finally:
|
||||
try:
|
||||
self.delete_snapshot(snapshot)
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot delete temporary source snapshot "
|
||||
"%(src)s on NexentaStor Appliance: %(exc)s",
|
||||
{'src': src, 'exc': exc})
|
||||
try:
|
||||
self.delete_volume(volume)
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot delete source volume %(volume)s on "
|
||||
"NexentaStor Appliance: %(exc)s",
|
||||
{'volume': volume['name'], 'exc': exc})
|
||||
|
@ -225,7 +225,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
volume['name'], snapshot['name'])
|
||||
try:
|
||||
dst_nms.snapshot.destroy(dst_snapshot, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
LOG.warning("Cannot delete temporary destination snapshot "
|
||||
"%(dst)s on NexentaStor Appliance: %(exc)s",
|
||||
{'dst': dst_snapshot, 'exc': exc})
|
||||
|
@ -320,7 +320,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
nms.folder.set_child_prop(
|
||||
folder, options[opt], new)
|
||||
retyped = True
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
LOG.error('Error trying to change %(opt)s'
|
||||
' from %(old)s to %(new)s',
|
||||
{'opt': opt, 'old': old, 'new': new})
|
||||
|
@ -371,10 +371,10 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
volume)
|
||||
self._ensure_share_mounted(sub_share, mnt_path)
|
||||
self._get_capacity_info(nfs_share)
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
try:
|
||||
nms.folder.destroy('%s/%s' % (vol, folder))
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
LOG.warning("Cannot destroy created folder: "
|
||||
"%(vol)s/%(folder)s",
|
||||
{'vol': vol, 'folder': folder})
|
||||
|
@ -401,10 +401,10 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
|
||||
try:
|
||||
self._share_folder(nms, vol, folder)
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
try:
|
||||
nms.folder.destroy('%s/%s' % (vol, folder), '')
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
LOG.warning("Cannot destroy cloned folder: "
|
||||
"%(vol)s/%(folder)s",
|
||||
{'vol': vol, 'folder': folder})
|
||||
|
@ -438,12 +438,12 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
self.create_snapshot(snapshot)
|
||||
try:
|
||||
return self.create_volume_from_snapshot(volume, snapshot)
|
||||
except exception.NexentaException:
|
||||
except utils.NexentaException:
|
||||
LOG.error('Volume creation failed, deleting created snapshot '
|
||||
'%(volume_name)s@%(name)s', snapshot)
|
||||
try:
|
||||
self.delete_snapshot(snapshot)
|
||||
except (exception.NexentaException, exception.SnapshotIsBusy):
|
||||
except (utils.NexentaException, exception.SnapshotIsBusy):
|
||||
LOG.warning('Failed to delete zfs snapshot '
|
||||
'%(volume_name)s@%(name)s', snapshot)
|
||||
raise
|
||||
|
@ -465,7 +465,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
try:
|
||||
props = nms.folder.get_child_props(folder, 'origin') or {}
|
||||
nms.folder.destroy(folder, '-r')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'does not exist' in exc.args[0]:
|
||||
LOG.info('Folder %s does not exist, it was '
|
||||
'already deleted.', folder)
|
||||
|
@ -476,7 +476,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
if origin and self._is_clone_snapshot_name(origin):
|
||||
try:
|
||||
nms.snapshot.destroy(origin, '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'does not exist' in exc.args[0]:
|
||||
LOG.info('Snapshot %s does not exist, it was '
|
||||
'already deleted.', origin)
|
||||
|
@ -536,7 +536,7 @@ class NexentaNfsDriver(nfs.NfsDriver): # pylint: disable=R0921
|
|||
folder = '%s/%s/%s' % (vol, dataset, volume['name'])
|
||||
try:
|
||||
nms.snapshot.destroy('%s@%s' % (folder, snapshot['name']), '')
|
||||
except exception.NexentaException as exc:
|
||||
except utils.NexentaException as exc:
|
||||
if 'does not exist' in exc.args[0]:
|
||||
LOG.info('Snapshot %(folder)s@%(snapshot)s does not '
|
||||
'exist, it was already deleted.',
|
||||
|
|
|
@ -19,9 +19,14 @@ import six
|
|||
from oslo_utils import units
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from cinder import exception
|
||||
from cinder.i18n import _
|
||||
|
||||
|
||||
class NexentaException(exception.VolumeDriverException):
|
||||
message = "%(reason)s"
|
||||
|
||||
|
||||
def str2size(s, scale=1024):
|
||||
"""Convert size-string.
|
||||
|
||||
|
|
Loading…
Reference in New Issue