Remove exception.Error class
CinderException can be used as a low-level exception so we don't need to introduce one more wrapper for Exception. TSM backup driver modified without testing. Removed code was broken because it tried to use not existing Exception class attributes. Change-Id: Ie67d919f8f59572268f1f07946fb2d2f14a851f1
This commit is contained in:
parent
e32c9b8c43
commit
ac2f6391e2
@ -140,7 +140,8 @@ class ExtensionManager(object):
|
||||
LOG.debug('Loaded extension: %s', alias)
|
||||
|
||||
if alias in self.extensions:
|
||||
raise exception.Error("Found duplicate extension: %s" % alias)
|
||||
raise exception.CinderException(
|
||||
"Found duplicate extension: %s" % alias)
|
||||
self.extensions[alias] = ext
|
||||
|
||||
def get_resources(self):
|
||||
|
@ -406,18 +406,6 @@ class TSMBackupDriver(driver.BackupDriver):
|
||||
'err': exc.stderr})
|
||||
LOG.error(err)
|
||||
raise exception.InvalidBackup(reason=err)
|
||||
except exception.Error as exc:
|
||||
err = (_('backup: %(vol_id)s failed to run dsmc '
|
||||
'due to invalid arguments '
|
||||
'on %(bpath)s.\n'
|
||||
'stdout: %(out)s\n stderr: %(err)s')
|
||||
% {'vol_id': backup.volume_id,
|
||||
'bpath': backup_path,
|
||||
'out': exc.stdout,
|
||||
'err': exc.stderr})
|
||||
LOG.error(err)
|
||||
raise exception.InvalidBackup(reason=err)
|
||||
|
||||
finally:
|
||||
_cleanup_device_hardlink(backup_path, volume_path,
|
||||
backup.volume_id)
|
||||
@ -466,18 +454,6 @@ class TSMBackupDriver(driver.BackupDriver):
|
||||
'err': exc.stderr})
|
||||
LOG.error(err)
|
||||
raise exception.InvalidBackup(reason=err)
|
||||
except exception.Error as exc:
|
||||
err = (_('restore: %(vol_id)s failed to run dsmc '
|
||||
'due to invalid arguments '
|
||||
'on %(bpath)s.\n'
|
||||
'stdout: %(out)s\n stderr: %(err)s')
|
||||
% {'vol_id': volume_id,
|
||||
'bpath': restore_path,
|
||||
'out': exc.stdout,
|
||||
'err': exc.stderr})
|
||||
LOG.error(err)
|
||||
raise exception.InvalidBackup(reason=err)
|
||||
|
||||
finally:
|
||||
_cleanup_device_hardlink(restore_path, volume_path, volume_id)
|
||||
|
||||
@ -519,16 +495,6 @@ class TSMBackupDriver(driver.BackupDriver):
|
||||
'err': exc.stderr})
|
||||
LOG.error(err)
|
||||
raise exception.InvalidBackup(reason=err)
|
||||
except exception.Error as exc:
|
||||
err = (_('delete: %(vol_id)s failed to run dsmc '
|
||||
'due to invalid arguments with '
|
||||
'stdout: %(out)s\n stderr: %(err)s')
|
||||
% {'vol_id': backup.volume_id,
|
||||
'out': exc.stdout,
|
||||
'err': exc.stderr})
|
||||
LOG.error(err)
|
||||
raise exception.InvalidBackup(reason=err)
|
||||
|
||||
success = _check_dsmc_output(out, delete_attrs)
|
||||
if not success:
|
||||
# log error if tsm cannot delete the backup object
|
||||
|
@ -57,10 +57,6 @@ class ConvertedException(webob.exc.WSGIHTTPException):
|
||||
super(ConvertedException, self).__init__()
|
||||
|
||||
|
||||
class Error(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class CinderException(Exception):
|
||||
"""Base Cinder Exception
|
||||
|
||||
|
@ -517,7 +517,7 @@ class GetBlkdevMajorMinorTestCase(test.TestCase):
|
||||
@mock.patch('stat.S_ISBLK', return_value=False)
|
||||
def test_get_blkdev_failure(self, mock_isblk, mock_ischr, mock_stat):
|
||||
path = '/some/path'
|
||||
self.assertRaises(exception.Error,
|
||||
self.assertRaises(exception.CinderException,
|
||||
utils.get_blkdev_major_minor,
|
||||
path, lookup_for_file=False)
|
||||
mock_stat.assert_called_once_with(path)
|
||||
|
@ -590,7 +590,7 @@ def get_blkdev_major_minor(path, lookup_for_file=True):
|
||||
return get_blkdev_major_minor(devpath, False)
|
||||
else:
|
||||
msg = _("Unable to get a block device for file \'%s\'") % path
|
||||
raise exception.Error(msg)
|
||||
raise exception.CinderException(msg)
|
||||
|
||||
|
||||
def check_string_length(value, name, min_length=0, max_length=None,
|
||||
|
@ -75,7 +75,7 @@ class BlkioCgroup(Throttle):
|
||||
def _get_device_number(self, path):
|
||||
try:
|
||||
return utils.get_blkdev_major_minor(path)
|
||||
except exception.Error as e:
|
||||
except exception.CinderException as e:
|
||||
LOG.error('Failed to get device number for throttling: '
|
||||
'%(error)s', {'error': e})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user