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:
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
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:07abcf7d5 a4d4ad6a03570b7 3d7ab98a' 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'. api/v2/ images. py] 'created_ at',
sort_ dir='desc' , filters=None, member_ status= 'accepted' ):
[glance/
def index(self, req, marker=None, limit=None, sort_key=
A simple method to fix is, add this code to image_get_all(), so we can get it from the filters before querying database. db/sqlachemy/ api.py] : 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):
[glance/
def image_get_
......
# added pop('admin_ as_user' ) user.lower( ) == 'true':
if 'admin_as_user' in filters:
admin_as_user = filters.
if admin_as_
admin_as_user = True
else:
admin_as_user = False