Glance v2 index does not support 'admin_as_user' parameter

Bug #1413146 reported by whhw on 2015-01-21
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Glance
Wishlist
whhw

Bug Description

When admin user list images, we add admin_as_user=False to query images that are owned by the user, shared to the user and other public images, instead of list all the images.
But if I add this to v2 command like:

curl -i -X GET -H 'X-Auth-Token:07abcf7d5a4d4ad6a03570b73d7ab98a' http://172.30.101.153:9292/v2/images?admin_as_user=True

the result will always be empty, like:

{"images": [], "schema": "/v2/schemas/images", "first": "/v2/images?admin_as_user=True"}

It is because the index of v2 implementation does not accept 'admin_as_user', instead all the other parameters that are not present will be passed into 'filters'.

[glance/api/v2/images.py]:
def index(self, req, marker=None, limit=None, sort_key='created_at',
          sort_dir='desc', filters=None, member_status='accepted'):

A simple method to fix is, add this code to image_get_all(), so we can get it from the filters before querying database.
[glance/db/sqlachemy/api.py]:
def image_get_all(context, filters=None, marker=None, limit=None,
                  sort_key='created_at', sort_dir='desc',
                  member_status='accepted', is_public=None,
                  admin_as_user=False, return_tag=False):
......

# added
if 'admin_as_user' in filters:
  admin_as_user = filters.pop('admin_as_user')
  admin_as_user = (admin_as_user.lower() == 'true')

whhw (wanghuan2) on 2015-01-21
Changed in glance:
assignee: nobody → whhw (wanghuan2)
whhw (wanghuan2) on 2015-01-21
description: updated
Ian Cordasco (icordasc) wrote :

whhw, please don't work on this until we can confirm that this is something that is desired for v2 of the API.

Changed in glance:
status: New → Incomplete
Ian Cordasco (icordasc) wrote :

Looking at the specification for v2's Image Listing [1] this isn't explicitly defined as something we want.

[1] http://specs.openstack.org/openstack/glance-specs/specs/api/v2/lists-image-api-v2.html

whhw (wanghuan2) wrote :

Well, the specification for v1's Image Listing doesn't mention it too, but v1actually supports the 'admin_as_user' parameter. Maybe it was omitted in v2, and I think it is useful sometimes.

Otherwise, we can only use the v1 instead to query admin's own images.

Erno Kuvaja (jokke) wrote :

Marking as wishlist item as this is not exactly a bug.

Changed in glance:
importance: Undecided → Wishlist
Ian Cordasco (icordasc) on 2015-02-11
summary: - Glance v2 index dose not support 'admin_as_user' parameter
+ Glance v2 index does not support 'admin_as_user' parameter
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers