try:
backup = self.backup_api.get(context, backup_id=id)
except exception.BackupNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
return self._view_builder.detail(req, backup)
try:
self.backup_api.delete(context, id)
except exception.BackupNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
except exception.InvalidBackup as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
return webob.Response(status_int=202)
new_backup = self.backup_api.create(context, name, description,
volume_id, container)
except exception.InvalidVolume as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.VolumeNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
except exception.ServiceNotFound as error:
- raise exc.HTTPInternalServerError(explanation=unicode(error))
+ raise exc.HTTPInternalServerError(explanation=error.msg)
retval = self._view_builder.summary(req, dict(new_backup.iteritems()))
return retval
backup_id=id,
volume_id=volume_id)
except exception.InvalidInput as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.InvalidVolume as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.InvalidBackup as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.BackupNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
except exception.VolumeNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
except exception.VolumeSizeExceedsAvailableQuota as error:
raise exc.HTTPRequestEntityTooLarge(
- explanation=error.message, headers={'Retry-After': 0})
+ explanation=error.msg, headers={'Retry-After': 0})
except exception.VolumeLimitExceeded as error:
raise exc.HTTPRequestEntityTooLarge(
- explanation=error.message, headers={'Retry-After': 0})
+ explanation=error.msg, headers={'Retry-After': 0})
retval = self._view_builder.restore_summary(
req, dict(new_restore.iteritems()))
try:
volume_types.get_volume_type(context, type_id)
except exception.NotFound as ex:
- raise webob.exc.HTTPNotFound(explanation=unicode(ex))
+ raise webob.exc.HTTPNotFound(explanation=ex.msg)
@wsgi.serializers(xml=VolumeTypeExtraSpecsTemplate)
def index(self, req, type_id):
try:
db.volume_type_extra_specs_delete(context, type_id, id)
except exception.VolumeTypeExtraSpecsNotFound as error:
- raise webob.exc.HTTPNotFound(explanation=unicode(error))
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
notifier_info = dict(type_id=type_id, id=id)
notifier_api.notify(context, 'volumeTypeExtraSpecs',
try:
volume = self.volume_api.get(context, id)
except exception.VolumeNotFound as error:
- raise webob.exc.HTTPNotFound(explanation=unicode(error))
+ raise webob.exc.HTTPNotFound(explanation=error.msg)
authorize(context, "upload_image")
image_metadata = {"container_format": params.get("container_format",
"bare"),
image_metadata,
force)
except exception.InvalidVolume as error:
- raise webob.exc.HTTPBadRequest(explanation=unicode(error))
+ raise webob.exc.HTTPBadRequest(explanation=error.msg)
except ValueError as error:
raise webob.exc.HTTPBadRequest(explanation=unicode(error))
except rpc_common.RemoteError as error:
try:
transfer = self.transfer_api.get(context, transfer_id=id)
except exception.TransferNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
return self._view_builder.detail(req, transfer)
try:
new_transfer = self.transfer_api.create(context, volume_id, name)
except exception.InvalidVolume as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.VolumeNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
transfer = self._view_builder.create(req,
dict(new_transfer.iteritems()))
auth_key)
except exception.VolumeSizeExceedsAvailableQuota as error:
raise exc.HTTPRequestEntityTooLarge(
- explanation=error.message, headers={'Retry-After': 0})
+ explanation=error.msg, headers={'Retry-After': 0})
except exception.InvalidVolume as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
transfer = \
self._view_builder.summary(req,
try:
self.transfer_api.delete(context, transfer_id=id)
except exception.TransferNotFound as error:
- raise exc.HTTPNotFound(explanation=unicode(error))
+ raise exc.HTTPNotFound(explanation=error.msg)
return webob.Response(status_int=202)
try:
volume_types.get_volume_type(context, type_id)
except exception.NotFound as ex:
- raise webob.exc.HTTPNotFound(explanation=unicode(ex))
+ raise webob.exc.HTTPNotFound(explanation=ex.msg)
def _check_encryption_input(self, encryption, create=True):
if 'key_size' in encryption.keys():
return True
if isinstance(ex_value, exception.NotAuthorized):
- msg = unicode(ex_value)
- raise Fault(webob.exc.HTTPForbidden(explanation=msg))
+ raise Fault(webob.exc.HTTPForbidden(explanation=ex_value.msg))
elif isinstance(ex_value, exception.Invalid):
raise Fault(exception.ConvertedException(
- code=ex_value.code, explanation=unicode(ex_value)))
+ code=ex_value.code, explanation=ex_value.msg))
elif isinstance(ex_value, TypeError):
exc_info = (ex_type, ex_value, ex_traceback)
LOG.error(_(
raise exc.HTTPBadRequest(explanation=msg)
except exception.InvalidVolumeMetadata as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.InvalidVolumeMetadataSize as error:
- raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error))
+ raise exc.HTTPRequestEntityTooLarge(explanation=error.msg)
@wsgi.serializers(xml=common.MetaItemTemplate)
def show(self, req, snapshot_id, id):
raise exc.HTTPBadRequest(explanation=msg)
except exception.InvalidVolumeMetadata as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.InvalidVolumeMetadataSize as error:
- raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error))
+ raise exc.HTTPRequestEntityTooLarge(explanation=error.msg)
@wsgi.serializers(xml=common.MetaItemTemplate)
def show(self, req, volume_id, id):
raise exc.HTTPBadRequest(explanation=msg)
except exception.InvalidVolumeMetadata as error:
- raise exc.HTTPBadRequest(explanation=unicode(error))
+ raise exc.HTTPBadRequest(explanation=error.msg)
except exception.InvalidVolumeMetadataSize as error:
- raise exc.HTTPRequestEntityTooLarge(explanation=unicode(error))
+ raise exc.HTTPRequestEntityTooLarge(explanation=error.msg)
@wsgi.serializers(xml=common.MetaItemTemplate)
def show(self, req, snapshot_id, id):
# at least get the core message out if something happened
message = self.message
+ # NOTE(luisg): We put the actual message in 'msg' so that we can access
+ # it, because if we try to access the message via 'message' it will be
+ # overshadowed by the class' message attribute
+ self.msg = message
super(CinderException, self).__init__(message)
+ def __unicode__(self):
+ return unicode(self.msg)
+
class GlanceConnectionFailed(CinderException):
message = _("Connection to glance failed") + ": %(reason)s"
self.assertEqual(res.status_int, 413)
self.assertEqual(res_dict['overLimit']['code'], 413)
self.assertEqual(res_dict['overLimit']['message'],
- 'Maximum number of volumes allowed '
- '(%(allowed)d) exceeded')
+ 'Maximum number of volumes allowed (1) exceeded')
def test_restore_backup_to_undersized_volume(self):
backup_size = 10