summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnthony Young <sleepsonthefloor@gmail.com>2012-03-26 14:50:17 -0700
committerAnthony Young <sleepsonthefloor@gmail.com>2012-03-26 14:52:33 -0700
commit42585a3b2559329f0e563bcd04ff6c8c19115439 (patch)
treef6946ac13e8873b236afe8a8f1566a9aac1bb686
parent81587ba245c0929944e1edaf79909b5070c9a92e (diff)
downloadnova-42585a3b2559329f0e563bcd04ff6c8c19115439.tar.gz
nova-42585a3b2559329f0e563bcd04ff6c8c19115439.tar.xz
nova-42585a3b2559329f0e563bcd04ff6c8c19115439.zip
Handle Forbidden and NotAuthenticated glance exc.
* Remove references to deprecated NotAuthorized exception * Handle Forbidden and NotAuthenticated * Fixes bug 965540 Change-Id: Ib5eef3015239e0fafdb01c975a0f5d553f70519e
-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']