0

I am new to Openstack. I am trying to get the list of tenants from OpenStack VM using the Keystone v2.0 python API.

from keystoneclient.v2_0 import client as ksclient
keystone_client = ksclient.Client(token='token', endpoint='http://1.1.1.1:35357/v2.0')
keystone_client.tenants.list()

The above fails with the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/keystoneclient/v2_0/tenants.py", line 116, in list
    tenant_list = self._list("/tenants%s" % query, "tenants")
  File "/usr/lib/python2.7/dist-packages/keystoneclient/base.py", line 68, in _list
    resp, body = self.api.get(url)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/client.py", line 587, in get
    return self._cs_request(url, 'GET', **kwargs)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/client.py", line 583, in _cs_request
    **kwargs)
  File "/usr/lib/python2.7/dist-packages/keystoneclient/client.py", line 555, in request
    raise exceptions.from_response(resp, body or resp.text)
keystoneclient.exceptions.ClientException: Unable to communicate with identity service:         <TITLE> Cannot Connect </TITLE>

<H2>Cannot Connect</H2>

Could you please share your insights on this one?

Unihedron
  • 10,902
  • 13
  • 62
  • 72
maisheri
  • 21
  • 4
  • Which version of OpenStack are you using? – flopez Jul 21 '14 at 07:08
  • nova --version is 2.14.1.1 keystone --version is 0.3.1.1 – maisheri Jul 22 '14 at 01:07
  • can't find my code for this... but this seems correct from my memory. might try hitting up keystone with keystoneclient and the -debug flag. – Matt Joyce Jul 22 '14 at 02:49
  • By any chance there would be any missing environment variables which would help ? – maisheri Jul 22 '14 at 09:01
  • Looks like the keystone endpoint isn't accessible. Can you trying pinging it or use a REST client to see if you get any response? – Harsh Shah Jul 30 '14 at 15:15
  • @HarshShah I tried pinging the endpoint and it was reachable. The script worked on the Open Stack instance but didn't work on another off box instance. I moved the logic on to the Open Stack instance for time being. I think this needs more understanding of the authentication mechanism for off box applications, probably missing some key parameters needed in authentication. – maisheri Aug 01 '14 at 11:16

1 Answers1

0

Seems like the keystone service is stopped.

If you are using devstack then check if the keystone process is running

ps -ef | grep keystone

If you have installed keystone manually as a service then

service --status-all | grep keystone

If you are using devstack , then you can rejoin the stack , Ctrl + A + 1 to go to the keystone logs.

cd /path/to/devstack
./rejoin-stack.sh
Durgadas Kamath
  • 400
  • 2
  • 12