Ask Your Question
0

python glance client attribute error

asked 2016-06-07 15:42:18 -0600

tking gravatar image

Part of our service will be grabbing builds and uploading them into glance. I've written a test for the glance image list using http://docs.openstack.org/developer/python-glanceclient/apiv2.html (http://docs.openstack.org/developer/p...).

From the code (pardon the line numbers):

232     def testme(self):
233         print self.auth_url
234         print self.tenant_name
235         print "testage!"
236         loader = loading.get_plugin_loader('password')
237         auth = loader.load_from_options(
238             auth_url=self.auth_url,
239             username=self.username,
240             password=self.password,
241             project_name=self.tenant_name)
242         sess = session.Session(auth=auth)
243         keystone = ksclient.Client(session=sess)
244         glance = Client('2', endpoint=self.glance_url, session=keystone)
245
246         for image in glance.images.list():
247             print image

The image list fails:

 python runner.py
http://xx.xx.xx.xx:5000/v3
admin
testage!
Traceback (most recent call last):
  File "runner.py", line 11, in <module>
    watcher.testme()
  File "/usr/local/bin/tools/f5watcher.py", line 246, in testme
    for image in glance.images.list():
  File "/usr/lib/python2.7/dist-packages/glanceclient/v2/images.py", line 176, in list
    for image in paginate(url, page_size, limit):
  File "/usr/lib/python2.7/dist-packages/glanceclient/v2/images.py", line 108, in paginate
    resp, body = self.http_client.get(next_url)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/adapter.py", line 176, in get
    return self.request(url, 'GET', **kwargs)
  File "/usr/lib/python2.7/dist-packages/glanceclient/common/http.py", line 332, in request
    return self._handle_response(resp)
  File "/usr/lib/python2.7/dist-packages/glanceclient/common/http.py", line 81, in _handle_response
    if not resp.ok:
AttributeError: 'tuple' object has no attribute 'ok'

I've found no other mention of this issue via Google or Bing - is this a glance client bug or my bad coding?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-06-07 19:01:46 -0600

tking gravatar image

Fixed.

The issue was my code. Taking out the 'keystone =', removing 'endpoint=', and pointing session to 'sess' cleared up the attribute problem. I also had to pass user_domain_name and project_domain_name into loader.load_from_options for auth.

Passing in the domain name will make the code even better.

Working code:

    226     def auth_glance(self):
    227         loader = loading.get_plugin_loader('password')
    228         auth = loader.load_from_options(
    229             auth_url=self.auth_url,
    230             username=self.username,
    231             password=self.password,
    232             project_name=self.tenant_name,
    233             user_domain_name='default',
    234             project_domain_name='default')
    235
...
    240         sess = session.Session(auth=auth)
...
    243         glance = Client('2', session=sess)
    244         return glance
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: 2016-06-07 15:42:18 -0600

Seen: 191 times

Last updated: Jun 07 '16