~ubuntu-branches/ubuntu/trusty/glance/trusty

« back to all changes in this revision

Viewing changes to glance/notifier/__init__.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, James Page
  • Date: 2013-09-09 13:06:09 UTC
  • mfrom: (1.1.54)
  • Revision ID: package-import@ubuntu.com-20130909130609-33p9xrv7zu4b5sh7
Tags: 1:2013.2~b3-0ubuntu1
[ Chuck Short ]
* New upstream release. 
* debian/control: Add python-oslo.sphinx as a build 
  dependency.

[ James Page ]
* d/p/*: Refreshed patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import uuid
21
21
 
22
22
from oslo.config import cfg
 
23
import webob
23
24
 
24
25
from glance.common import exception
25
26
import glance.domain
200
201
        try:
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")
 
209
                   % e)
 
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)
 
238
            raise
 
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)
 
244
            raise
208
245
        else:
209
246
            payload = format_image_notification(self.image)
210
247
            self.notifier.info('image.upload', payload)