0
votes

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?

1
Which version of OpenStack are you using?flopez
nova --version is 2.14.1.1 keystone --version is 0.3.1.1maisheri
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
By any chance there would be any missing environment variables which would help ?maisheri
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

1 Answers

0
votes

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