try:
vol = self.volume_api.get_snapshot(context, id)
except exception.NotFound:
- raise exc.HTTPNotFound()
+ msg = _("Snapshot could not be found")
+ raise exc.HTTPNotFound(explanation=msg)
return {'snapshot': _translate_snapshot_detail_view(context, vol)}
snapshot = self.volume_api.get_snapshot(context, id)
self.volume_api.delete_snapshot(context, snapshot)
except exception.NotFound:
- raise exc.HTTPNotFound()
+ msg = _("Snapshot could not be found")
+ raise exc.HTTPNotFound(explanation=msg)
+
return webob.Response(status_int=202)
@wsgi.serializers(xml=SnapshotsTemplate)
context = req.environ['cinder.context']
if not self.is_valid_body(body, 'snapshot'):
- raise exc.HTTPBadRequest()
+ msg = (_("Missing required element '%s' in request body") %
+ 'snapshot')
+ raise exc.HTTPBadRequest(explanation=msg)
snapshot = body['snapshot']
kwargs['metadata'] = snapshot.get('metadata', None)
context = req.environ['cinder.context']
if not body:
- raise exc.HTTPBadRequest()
+ msg = _("Missing request body")
+ raise exc.HTTPBadRequest(explanation=msg)
if 'snapshot' not in body:
- raise exc.HTTPBadRequest()
+ msg = (_("Missing required element '%s' in request body") %
+ 'snapshot')
+ raise exc.HTTPBadRequest(explanation=msg)
snapshot = body['snapshot']
update_dict = {}
snapshot = self.volume_api.get_snapshot(context, id)
self.volume_api.update_snapshot(context, snapshot, update_dict)
except exception.NotFound:
- raise exc.HTTPNotFound()
+ msg = _("Snapshot could not be found")
+ raise exc.HTTPNotFound(explanation=msg)
snapshot.update(update_dict)
try:
vol = self.volume_api.get(context, id)
except exception.NotFound:
- raise exc.HTTPNotFound()
+ msg = _("Volume could not be found")
+ raise exc.HTTPNotFound(explanation=msg)
return self._view_builder.detail(req, vol)
volume = self.volume_api.get(context, id)
self.volume_api.delete(context, volume)
except exception.NotFound:
- raise exc.HTTPNotFound()
+ msg = _("Volume could not be found")
+ raise exc.HTTPNotFound(explanation=msg)
except exception.VolumeAttached:
- explanation = 'Volume cannot be deleted while in attached state'
- raise exc.HTTPBadRequest(explanation=explanation)
+ msg = _("Volume cannot be deleted while in attached state")
+ raise exc.HTTPBadRequest(explanation=msg)
return webob.Response(status_int=202)
@wsgi.serializers(xml=VolumesTemplate)
def create(self, req, body):
"""Creates a new volume."""
if not self.is_valid_body(body, 'volume'):
- raise exc.HTTPBadRequest()
+ msg = _("Missing required element '%s' in request body") % 'volume'
+ raise exc.HTTPBadRequest(explanation=msg)
LOG.debug('Create volume request body: %s', body)
context = req.environ['cinder.context']
kwargs['volume_type'] = volume_types.get_volume_type(
context, req_volume_type)
except exception.VolumeTypeNotFound:
- explanation = 'Volume type not found.'
- raise exc.HTTPNotFound(explanation=explanation)
+ msg = _("Volume type not found")
+ raise exc.HTTPNotFound(explanation=msg)
kwargs['metadata'] = volume.get('metadata', None)
context = req.environ['cinder.context']
if not body:
- raise exc.HTTPBadRequest()
+ msg = _("Missing request body")
+ raise exc.HTTPBadRequest(explanation=msg)
if 'volume' not in body:
- raise exc.HTTPBadRequest()
+ msg = _("Missing required element '%s' in request body") % 'volume'
+ raise exc.HTTPBadRequest(explanation=msg)
volume = body['volume']
update_dict = {}
volume = self.volume_api.get(context, id)
self.volume_api.update(context, volume, update_dict)
except exception.NotFound:
- raise exc.HTTPNotFound()
+ msg = _("Volume could not be found")
+ raise exc.HTTPNotFound(explanation=msg)
volume.update(update_dict)