From ff716dee035dd51257b240fad842ecfd70d9d90d Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 1 Mar 2012 14:51:03 -0800 Subject: Ensure image status filter matches glance format * Fixes bug 943259 Change-Id: Id5172aa40be2f5a337b3e192b4bee8139c16c4d3 --- nova/api/openstack/compute/images.py | 5 +++++ nova/tests/api/openstack/compute/test_images.py | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/nova/api/openstack/compute/images.py b/nova/api/openstack/compute/images.py index 1a957bc56..8cf6ea4ad 100644 --- a/nova/api/openstack/compute/images.py +++ b/nova/api/openstack/compute/images.py @@ -124,6 +124,11 @@ class Controller(wsgi.Controller): except (AttributeError, IndexError, KeyError): pass + filter_name = 'status' + if filter_name in filters: + # The Image API expects us to use lowercase strings for status + filters[filter_name] = filters[filter_name].lower() + return filters @wsgi.serializers(xml=ImageTemplate) diff --git a/nova/tests/api/openstack/compute/test_images.py b/nova/tests/api/openstack/compute/test_images.py index 660345031..88eeaefc5 100644 --- a/nova/tests/api/openstack/compute/test_images.py +++ b/nova/tests/api/openstack/compute/test_images.py @@ -857,7 +857,7 @@ class ImagesControllerTest(test.TestCase): def test_image_filter_with_status(self): image_service = self.mox.CreateMockAnything() - filters = {'status': 'ACTIVE'} + filters = {'status': 'active'} request = fakes.HTTPRequest.blank('/v2/images?status=ACTIVE') context = request.environ['nova.context'] image_service.index(context, filters=filters).AndReturn([]) @@ -915,7 +915,7 @@ class ImagesControllerTest(test.TestCase): def test_image_filter_not_supported(self): image_service = self.mox.CreateMockAnything() - filters = {'status': 'ACTIVE'} + filters = {'status': 'active'} request = fakes.HTTPRequest.blank('/v2/images?status=ACTIVE&' 'UNSUPPORTEDFILTER=testname') context = request.environ['nova.context'] @@ -950,7 +950,7 @@ class ImagesControllerTest(test.TestCase): def test_image_detail_filter_with_status(self): image_service = self.mox.CreateMockAnything() - filters = {'status': 'ACTIVE'} + filters = {'status': 'active'} request = fakes.HTTPRequest.blank('/v2/fake/images/detail' '?status=ACTIVE') context = request.environ['nova.context'] @@ -1024,7 +1024,7 @@ class ImagesControllerTest(test.TestCase): def test_image_detail_filter_not_supported(self): image_service = self.mox.CreateMockAnything() - filters = {'status': 'ACTIVE'} + filters = {'status': 'active'} request = fakes.HTTPRequest.blank('/v2/fake/images/detail?status=' 'ACTIVE&UNSUPPORTEDFILTER=testname') context = request.environ['nova.context'] -- cgit