Ask Your Question
0

Unauthorized exception in cinder-client [closed]

asked 2015-02-28 02:55:01 -0500

Pradip gravatar image

Hello,

I am getting basic authorization error from cinder client on volume listing. The keystone service-list and endpoint-list are checked. Those are fine.

>>> from cinderclient import client
>>> cinder = client.Client('2', 'admin', pw, 'demo', 'http://10.72.xx.yyyy:8776/v2')
>>> cinder.volumes.list()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/stack/python-cinderclient/cinderclient/v2/volumes.py", line 291, in list
    "volumes", limit=limit)
  File "/opt/stack/python-cinderclient/cinderclient/base.py", line 65, in _list
    resp, body = self.api.client.get(url)
  File "/opt/stack/python-cinderclient/cinderclient/client.py", line 288, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/opt/stack/python-cinderclient/cinderclient/client.py", line 245, in _cs_request
    self.authenticate()
  File "/opt/stack/python-cinderclient/cinderclient/client.py", line 400, in authenticate
    auth_url = self._v1_auth(auth_url)
  File "/opt/stack/python-cinderclient/cinderclient/client.py", line 423, in _v1_auth
    resp, body = self.request(url, 'GET', headers=headers)
  File "/opt/stack/python-cinderclient/cinderclient/client.py", line 234, in request
    raise exceptions.from_response(resp, body)
cinderclient.exceptions.Unauthorized: Unauthorized (HTTP 401)

However 'cinder list' or the horizon works fine.

Any such clue will be helpful.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Pradip
close date 2015-02-28 04:44:44.876043

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-02-28 03:50:50 -0500

SamYaple gravatar image

401 Unauthorized is an error authenticating yourself with Keystone. In this case it is just the parameters you are passing that are wrong.

>>> from cinderclient import client
>>> c = client.Client(USER, PASS, TENANT, AUTH_URL, service_type="volume")
>>> c.volumes.list()

AUTH_URL will be your Identity endpoint (Keystone). You pass service_type so that Keystone will tell you where Cinder is.

Additionally, you may need to hit the admin endpoint for some operations.

edit flag offensive delete link more

Comments

1

Thanks, it worked! I just need to pass the cinder-version as first parameter.

c = client.Client('2', 'admin', 'netapp1!', 'demo', 'http://127.0.0.1:5000/v2.0', service_type="volume")
Pradip gravatar imagePradip ( 2015-02-28 04:43:50 -0500 )edit

Cool! I believe you can also pass that as service_type="volumev2", but its been a while since ive messed with the python api. Glad it's working for you!

SamYaple gravatar imageSamYaple ( 2015-02-28 15:14:48 -0500 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2015-02-28 02:55:01 -0500

Seen: 455 times

Last updated: Feb 28 '15