Unable to filter images by server ID, contrary to API spec

Bug #912837 reported by Jay Pipes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Brian Waldon

Bug Description

Tempest has two test cases that check filtering of images through the Compute API 1.1.

jpipes@librebox:~/repos/tempest$ nosetests -sv tempest.tests.test_list_images
...
The images should contain images filtered by server id ... FAIL
The list of servers should be filtered by server ref ... ok
...
======================================================================
FAIL: The images should contain images filtered by server id
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jpipes/repos/tempest/tempest/tests/test_list_images.py", line 119, in test_list_images_filter_by_server_id
    (self.image1_id, images))
AssertionError: False is not True : Failed to find image 0075eec2-3e12-4e8f-86d1-e5d780a2fcf3 in images. Got images []

According to the documentation here:

http://docs.openstack.org/api/openstack-compute/1.1/content/List_Images-d1e4435.html

It should be possible to supply *either* and server ID *or* a server HREF. However, only a server HREF seems to be supported.

Here are the two test cases in question. The first is filtered by server ID, the second by server HREF. The first fails, the second passes.

    @attr(type='positive')
    def test_list_images_filter_by_server_id(self):
        """The images should contain images filtered by server id"""
        params = {'server': self.server1['id']}
        resp, images = self.client.list_images(params)

        self.assertTrue(any([i for i in images if i['id'] == self.image1_id]),
                        "Failed to find image %s in images. Got images %s" %
                        (self.image1_id, images))
        self.assertTrue(any([i for i in images if i['id'] == self.image2_id]))
        self.assertFalse(any([i for i in images if i['id'] == self.image3_id]))

    @attr(type='positive')
    def test_list_images_filter_by_server_ref(self):
        """The list of servers should be filtered by server ref"""
        params = {'server': self.image3['metadata']['instance_ref']}
        resp, images = self.client.list_images(params)

        self.assertFalse(any([i for i in images if i['id'] == self.image1_id]))
        self.assertFalse(any([i for i in images if i['id'] == self.image2_id]))
        self.assertTrue(any([i for i in images if i['id'] == self.image3_id]))

Tags: api images
Brian Waldon (bcwaldon)
Changed in nova:
assignee: nobody → Brian Waldon (bcwaldon)
status: New → In Progress
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/3032

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/3032
Committed: http://github.com/openstack/nova/commit/6e7e3870a4ca047185ba5e3320d63afaa08357b8
Submitter: Jenkins
Branch: master

commit 6e7e3870a4ca047185ba5e3320d63afaa08357b8
Author: Brian Waldon <email address hidden>
Date: Thu Jan 12 22:50:32 2012 -0800

    Increase robustness of image filtering by server

    * fix bug 912837
    * fix bug 912927
    * filter images based on instance_uuid rather than instance_ref
    * stop adding instance_ref to snapshot properties

    Change-Id: I5eed1611b1e885553d0c91380e414e9476dc251c

Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → essex-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: essex-3 → 2012.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.