Search code examples
pythonceph

How to connect to Ceph cluster using librbd (Python)


I am trying to connect to my Ceph cluster using librbd and Python. If I try this example from the Ceph documentation I get an error saying "error connecting to the cluster: error code 95". See code example below.

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.    
>>> import rados
>>> cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
>>> cluster.connect()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rados.pyx", line 785, in rados.Rados.connect (/build/ceph-10.2.6/src/build/rados.c:10073)
rados.Error: error connecting to the cluster: error code 95

The Ceph cluster is up and healthy (HEALTH_OK). What does this error code mean and what can I do to solve it?


Solution

  • Ok, I found a solution. The problem was that the ceph client key ceph.client.admin.keyring in /etc/ceph/ could only be read by sudo users. Depending on your situation you can:

    • update the file permissions

    • run the process as sudo

    • or add the current user to sudoers

    I solved it by updating the file permissions. This allows all users on the client node to run ceph commands:

    $ sudo chmod 644 /etc/ceph/ceph.client.admin.keyring