~ubuntu-branches/ubuntu/quantal/nova/quantal-proposed

« back to all changes in this revision

Viewing changes to nova/image/glance.py

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman, Adam Gandelman, Chuck Short
  • Date: 2012-08-27 15:37:18 UTC
  • mfrom: (1.1.60)
  • Revision ID: package-import@ubuntu.com-20120827153718-lj8er44eqqz1gsrj
Tags: 2012.2~rc1~20120827.15815-0ubuntu1
[ Adam Gandelman ]
* New upstream release.

[ Chuck Short ]
* debian/patches/0001-Update-tools-hacking-for-pep8-1.2-and-
  beyond.patch: Dropped we dont run pep8 tests anymore.
* debian/control: Drop pep8 build depends
* debian/*.upstart.in: Make sure we transition correctly from runlevel
  1 to 2. (LP: #820694)

Show diffs side-by-side

added added

removed removed

Lines of Context:
346
346
def _reraise_translated_image_exception(image_id):
347
347
    """Transform the exception for the image but keep its traceback intact."""
348
348
    exc_type, exc_value, exc_trace = sys.exc_info()
349
 
    new_exc = _translate_image_exception(image_id, exc_type, exc_value)
 
349
    new_exc = _translate_image_exception(image_id, exc_value)
350
350
    raise new_exc, None, exc_trace
351
351
 
352
352
 
353
353
def _reraise_translated_exception():
354
354
    """Transform the exception but keep its traceback intact."""
355
355
    exc_type, exc_value, exc_trace = sys.exc_info()
356
 
    new_exc = _translate_plain_exception(exc_type, exc_value)
 
356
    new_exc = _translate_plain_exception(exc_value)
357
357
    raise new_exc, None, exc_trace
358
358
 
359
359
 
360
 
def _translate_image_exception(image_id, exc_type, exc_value):
361
 
    if exc_type in (glanceclient.exc.Forbidden,
362
 
                    glanceclient.exc.Unauthorized):
 
360
def _translate_image_exception(image_id, exc_value):
 
361
    if isinstance(exc_value, (glanceclient.exc.Forbidden,
 
362
                    glanceclient.exc.Unauthorized)):
363
363
        return exception.ImageNotAuthorized(image_id=image_id)
364
 
    if exc_type is glanceclient.exc.NotFound:
 
364
    if isinstance(exc_value, glanceclient.exc.NotFound):
365
365
        return exception.ImageNotFound(image_id=image_id)
366
 
    if exc_type is glanceclient.exc.BadRequest:
 
366
    if isinstance(exc_value, glanceclient.exc.BadRequest):
367
367
        return exception.Invalid(exc_value)
368
368
    return exc_value
369
369
 
370
370
 
371
 
def _translate_plain_exception(exc_type, exc_value):
372
 
    if exc_type in (glanceclient.exc.Forbidden,
373
 
                    glanceclient.exc.Unauthorized):
 
371
def _translate_plain_exception(exc_value):
 
372
    if isinstance(exc_value, (glanceclient.exc.Forbidden,
 
373
                    glanceclient.exc.Unauthorized)):
374
374
        return exception.NotAuthorized(exc_value)
375
 
    if exc_type is glanceclient.exc.NotFound:
 
375
    if isinstance(exc_value, glanceclient.exc.NotFound):
376
376
        return exception.NotFound(exc_value)
377
 
    if exc_type is glanceclient.exc.BadRequest:
 
377
    if isinstance(exc_value, glanceclient.exc.BadRequest):
378
378
        return exception.Invalid(exc_value)
379
379
    return exc_value
380
380