← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1413146] [NEW] Glance v2 index dose not support 'admin_as_user' parameter

 

Public bug reported:

When admin user list images, we add admin_ad_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 inplementation 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')
if admin_as_user.lower() == 'true':
    admin_as_user = True
else:
    admin_as_user = False

** Affects: glance
     Importance: Undecided
     Assignee: whhw (wanghuan2)
         Status: New

** Changed in: glance
     Assignee: (unassigned) => whhw (wanghuan2)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to Glance.
https://bugs.launchpad.net/bugs/1413146

Title:
  Glance v2 index dose not support 'admin_as_user' parameter

Status in OpenStack Image Registry and Delivery Service (Glance):
  New

Bug description:
  When admin user list images, we add admin_ad_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 inplementation 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')
  if admin_as_user.lower() == 'true':
      admin_as_user = True
  else:
      admin_as_user = False

To manage notifications about this bug go to:
https://bugs.launchpad.net/glance/+bug/1413146/+subscriptions


Follow ups

References