Skip to content

Commit

Permalink
Ensure image status filter matches glance format
Browse files Browse the repository at this point in the history
* Fixes bug 943259

Change-Id: Id5172aa40be2f5a337b3e192b4bee8139c16c4d3
  • Loading branch information
bcwaldon committed Mar 1, 2012
1 parent d65a4e4 commit ff716de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions nova/api/openstack/compute/images.py
Expand Up @@ -124,6 +124,11 @@ def _get_filters(self, req):
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)
Expand Down
8 changes: 4 additions & 4 deletions nova/tests/api/openstack/compute/test_images.py
Expand Up @@ -857,7 +857,7 @@ def test_image_filter_with_min_disk(self):

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([])
Expand Down Expand Up @@ -915,7 +915,7 @@ def test_image_filter_with_type(self):

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']
Expand Down Expand Up @@ -950,7 +950,7 @@ def test_image_detail_filter_with_name(self):

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']
Expand Down Expand Up @@ -1024,7 +1024,7 @@ def test_image_detail_filter_with_type(self):

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']
Expand Down

0 comments on commit ff716de

Please sign in to comment.