Ask Your Question

Unable to list glance images using python api

asked 2018-02-23 15:51:22 -0500

anonymous user


As per the documentation ( , I wrote the following code:


from os import environ as env
import os_client_config
nova = os_client_config.make_client('compute',auth_url=env['OS_AUTH_URL'],username=env['OS_USERNAME'],password=env['OS_PASSWORD'], project_name=env['OS_PROJECT_NAME'], user_domain_name=env['OS_USER_DOMAIN_NAME'])
import glanceclient.v2.client as glclient
glance = glclient.Client('2',auth_url=env['OS_AUTH_URL'],username=env['OS_USERNAME'],password=env['OS_PASSWORD'], project_name=env['OS_PROJECT_NAME'], user_domain_name=env['OS_USER_DOMAIN_NAME'])
images = glance.images.list()
images list(images)


The following error is shown:
Traceback (most recent call last): File "", line 10, in <module> list(images) File "/usr/lib/python2.7/site-packages/glanceclient/common/", line 524, in next return self._next() File "/usr/lib/python2.7/site-packages/glanceclient/common/", line 517, in _next obj, resp = next(self._self_wrapped) File "/usr/lib/python2.7/site-packages/glanceclient/v2/", line 183, in list for image, resp in paginate(url, page_size, limit): File "/usr/lib/python2.7/site-packages/glanceclient/v2/", line 110, in paginate resp, body = self.http_client.get(next_url, headers=req_id_hdr) File "/usr/lib/python2.7/site-packages/glanceclient/common/", line 286, in get return self._request('GET', url, **kwargs) File "/usr/lib/python2.7/site-packages/glanceclient/common/", line 262, in _request raise exc.CommunicationError(message=message) glanceclient.exc.CommunicationError: Error communicating with 2 Invalid URL '2/v2/images?limit=20': No schema supplied. Perhaps you meant http://2/v2/images?limit=20? </module>

I have been trying running this past few days. Any help would be appreciated.
(Note : I am a beginner and need guidance.)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2019-03-26 02:14:44 -0500

VINAY gravatar image

images is generator object so run for loop on images make sure before getting python shell source novarc file

>>> import os
>>> import os_client_config
>>> glance=os_client_config.make_client('image')
>>> images=glance.images.list
>>> print images
<bound method Controller.list of <glanceclient.v2.images.Controller object at 0x7f89eea2d550>>
>>> images=glance.images.list()
>>> print images
<generator object list at 0x7f89eea26780>
>>> for i in images:
...   print i
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2018-02-23 15:51:22 -0500

Seen: 51 times

Last updated: Mar 26