summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-03-27 00:07:25 +0000
committerGerrit Code Review <review@openstack.org>2012-03-27 00:07:25 +0000
commit2483dbfe42a43ce372876afbd7c40c3c8daede6f (patch)
tree3ff52744b11d1290f424126c5873336a4eb6cc0b
parenta003e45af56e4f4c197c40fedc3b7d19a9684132 (diff)
parent42585a3b2559329f0e563bcd04ff6c8c19115439 (diff)
downloadnova-2483dbfe42a43ce372876afbd7c40c3c8daede6f.tar.gz
nova-2483dbfe42a43ce372876afbd7c40c3c8daede6f.tar.xz
nova-2483dbfe42a43ce372876afbd7c40c3c8daede6f.zip
Merge "Handle Forbidden and NotAuthenticated glance exc."
-rw-r--r--nova/image/glance.py6
-rw-r--r--nova/tests/image/test_glance.py13
2 files changed, 17 insertions, 2 deletions
diff --git a/nova/image/glance.py b/nova/image/glance.py
index 93e6cf273..a5f9e6865 100644
--- a/nova/image/glance.py
+++ b/nova/image/glance.py
@@ -485,7 +485,8 @@ def _reraise_translated_exception():
def _translate_image_exception(image_id, exc_type, exc_value):
- if exc_type in (glance_exception.NotAuthorized,
+ if exc_type in (glance_exception.Forbidden,
+ glance_exception.NotAuthenticated,
glance_exception.MissingCredentialError):
return exception.ImageNotAuthorized(image_id=image_id)
if exc_type is glance_exception.NotFound:
@@ -496,7 +497,8 @@ def _translate_image_exception(image_id, exc_type, exc_value):
def _translate_plain_exception(exc_type, exc_value):
- if exc_type in (glance_exception.NotAuthorized,
+ if exc_type in (glance_exception.Forbidden,
+ glance_exception.NotAuthenticated,
glance_exception.MissingCredentialError):
return exception.NotAuthorized(exc_value)
if exc_type is glance_exception.NotFound:
diff --git a/nova/tests/image/test_glance.py b/nova/tests/image/test_glance.py
index d41e87423..bc5969a45 100644
--- a/nova/tests/image/test_glance.py
+++ b/nova/tests/image/test_glance.py
@@ -556,6 +556,19 @@ class TestGlanceImageService(test.TestCase):
self.flags(glance_num_retries=1)
service.get(self.context, image_id, writer)
+ def test_client_raises_forbidden(self):
+ class MyGlanceStubClient(glance_stubs.StubGlanceClient):
+ """A client that fails the first time, then succeeds."""
+ def get_image(self, image_id):
+ raise glance_exception.Forbidden()
+
+ client = MyGlanceStubClient()
+ service = glance.GlanceImageService(client=client)
+ image_id = 1 # doesn't matter
+ writer = NullWriter()
+ self.assertRaises(exception.ImageNotAuthorized, service.get,
+ self.context, image_id, writer)
+
def test_glance_client_image_id(self):
fixture = self._make_fixture(name='test image')
image_id = self.service.create(self.context, fixture)['id']