201
202
self.image.set_data(data, size)
202
203
except exception.StorageFull as e:
203
msg = _("Image storage media is full: %s") % e
204
msg = (_("Image storage media is full: %s") % e)
204
205
self.notifier.error('image.upload', msg)
206
raise webob.exc.HTTPRequestEntityTooLarge(explanation=msg)
205
207
except exception.StorageWriteDenied as e:
206
msg = _("Insufficient permissions on image storage media: %s") % e
207
self.notifier.error('image.upload', msg)
208
msg = (_("Insufficient permissions on image storage media: %s")
210
self.notifier.error('image.upload', msg)
211
raise webob.exc.HTTPServiceUnavailable(explanation=msg)
212
except ValueError as e:
213
msg = (_("Cannot save data for image %s: %s")
214
% (self.image.image_id, e))
215
self.notifier.error('image.upload', msg)
216
raise webob.exc.HTTPBadRequest(explanation=unicode(e))
217
except exception.Duplicate as e:
218
msg = (_("Unable to upload duplicate image data for image %s: %s")
219
% (self.image.image_id, e))
220
self.notifier.error('image.upload', msg)
221
raise webob.exc.HTTPConflict(explanation=msg)
222
except exception.Forbidden as e:
223
msg = (_("Not allowed to upload image data for image %s: %s")
224
% (self.image.image_id, e))
225
self.notifier.error('image.upload', msg)
226
raise webob.exc.HTTPForbidden(explanation=msg)
227
except exception.NotFound as e:
228
msg = (_("Image %s could not be found after upload. The image may "
229
"have been deleted during the upload: %s")
230
% (self.image.image_id, e))
231
self.notifier.error('image.upload', msg)
232
raise webob.exc.HTTPNotFound(explanation=unicode(e))
233
except webob.exc.HTTPError as e:
234
msg = (_("Failed to upload image data for image %s"
235
" due to HTTP error: %s")
236
% (self.image.image_id, e))
237
self.notifier.error('image.upload', msg)
239
except Exception as e:
240
msg = (_("Failed to upload image data for image %s "
241
"due to internal error: %s")
242
% (self.image.image_id, e))
243
self.notifier.error('image.upload', msg)
209
246
payload = format_image_notification(self.image)
210
247
self.notifier.info('image.upload', payload)