Ask Your Question
0

Unable to list glance images using python api

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

anonymous user

Anonymous

As per the documentation https://docs.openstack.org/newton/user-guide/sdk-manage-images.html (https://docs.openstack.org/newton/use...) , 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 "auth.py", line 10, in <module> list(images) File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 524, in next return self._next() File "/usr/lib/python2.7/site-packages/glanceclient/common/utils.py", line 517, in _next obj, resp = next(self._self_wrapped) File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", line 183, in list for image, resp in paginate(url, page_size, limit): File "/usr/lib/python2.7/site-packages/glanceclient/v2/images.py", 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/http.py", line 286, in get return self._request('GET', url, **kwargs) File "/usr/lib/python2.7/site-packages/glanceclient/common/http.py", 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
0

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

Stats

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

Seen: 63 times

Last updated: Mar 26