Re: [ceph-users] Permissions for mon status command

2017-12-22 Thread Andreas Calminder
Thanks!
I completely missed that, adding name='client.something' did the trick.

/andreas

On 22 December 2017 at 02:22, David Turner  wrote:
> You aren't specifying your cluster user, only the keyring.  So the
> connection command is still trying to use the default client.admin instead
> of client.python.  Here's the connect line I use in my scripts.
>
> rados.Rados(conffile='/etc/ceph/ceph.conf', conf=dict(keyring =
> '/etc/ceph/ceph.client.python.keyring'), name='client.python')
>
> On Thu, Dec 21, 2017 at 6:55 PM Alvaro Soto  wrote:
>>
>> Hi Andreas,
>> I believe is not a problem of caps, I have tested using the same cap on
>> mon and I have the same problem, still looking into.
>>
>> [client.python]
>>
>> key = AQDORjxaYHG9JxAA0qiZC0Rmf3qulsO3P/bZgw==
>>
>> caps mon = "allow r"
>>
>>
>>
>> # ceph -n client.python --keyring ceph.client.python.keyring health
>>
>> HEALTH_OK
>>
>>
>> but if I run the python script that contains a connect command to the
>> cluster.
>>
>>
>> # python health.py
>>
>> Traceback (most recent call last):
>>
>>   File "health.py", line 13, in 
>>
>> r.connect()
>>
>>   File "/usr/lib/python2.7/dist-packages/rados.py", line 429, in connect
>>
>> raise make_ex(ret, "error connecting to the cluster")
>>
>> rados.Error: error connecting to the cluster: errno EINVAL
>>
>>
>> ** PYTHON SCRIPT 
>>
>> #!/usr/bin/env python
>>
>>
>> import rados
>>
>> import json
>>
>>
>> def get_cluster_health(r):
>>
>> cmd = {"prefix":"status", "format":"json"}
>>
>> ret, buf, errs = r.mon_command(json.dumps(cmd), b'', timeout=5)
>>
>> result = json.loads(buf)
>>
>> return result['health']['overall_status']
>>
>>
>> r = rados.Rados(conffile = '/etc/ceph/ceph.conf', conf = dict (keyring =
>> '/etc/ceph/ceph.client.python.keyring'))
>>
>> r.connect()
>>
>>
>> print("{0}".format(get_cluster_health(r)))
>>
>>
>> if r is not None:
>>
>> r.shutdown()
>>
>> *
>>
>>
>>
>>
>> On Thu, Dec 21, 2017 at 4:15 PM, Andreas Calminder
>>  wrote:
>>>
>>> Hi,
>>> I'm writing a small python script using librados to display cluster
>>> health, same info as ceph health detail show, it works fine but I rather not
>>> use the admin keyring for something like this. However I have no clue what
>>> kind of caps I should or can set, I was kind of hoping that mon allow r
>>> would do it, but that didn't work, and I'm unable to find any documentation
>>> that covers this. Any pointers would be appreciated.
>>>
>>> Thanks,
>>> Andreas
>>>
>>> ___
>>> ceph-users mailing list
>>> ceph-users@lists.ceph.com
>>> http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com
>>>
>>
>>
>>
>> --
>>
>> ATTE. Alvaro Soto Escobar
>>
>> --
>> Great people talk about ideas,
>> average people talk about things,
>> small people talk ... about other people.
>> ___
>> ceph-users mailing list
>> ceph-users@lists.ceph.com
>> http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com
___
ceph-users mailing list
ceph-users@lists.ceph.com
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com


Re: [ceph-users] Permissions for mon status command

2017-12-21 Thread David Turner
You aren't specifying your cluster user, only the keyring.  So the
connection command is still trying to use the default client.admin instead
of client.python.  Here's the connect line I use in my scripts.

rados.Rados(conffile='/etc/ceph/ceph.conf', conf=dict(keyring = '
/etc/ceph/ceph.client.python.keyring'), name='client.python')

On Thu, Dec 21, 2017 at 6:55 PM Alvaro Soto  wrote:

> Hi Andreas,
> I believe is not a problem of caps, I have tested using the same cap on
> mon and I have the same problem, still looking into.
>
> [client.python]
>
> key = AQDORjxaYHG9JxAA0qiZC0Rmf3qulsO3P/bZgw==
>
> caps mon = "allow r"
>
>
>
> # ceph -n client.python --keyring ceph.client.python.keyring health
>
> HEALTH_OK
>
>
> but if I run the python script that contains a connect command to the
> cluster.
>
>
> # python health.py
>
> Traceback (most recent call last):
>
>   File "health.py", line 13, in 
>
> r.connect()
>
>   File "/usr/lib/python2.7/dist-packages/rados.py", line 429, in connect
>
> raise make_ex(ret, "error connecting to the cluster")
>
> rados.Error: error connecting to the cluster: errno EINVAL
>
>
> ** PYTHON SCRIPT 
>
> #!/usr/bin/env python
>
>
> import rados
>
> import json
>
>
> def get_cluster_health(r):
>
> cmd = {"prefix":"status", "format":"json"}
>
> ret, buf, errs = r.mon_command(json.dumps(cmd), b'', timeout=5)
>
> result = json.loads(buf)
>
> return result['health']['overall_status']
>
>
> r = rados.Rados(conffile = '/etc/ceph/ceph.conf', conf = dict (keyring =
> '/etc/ceph/ceph.client.python.keyring'))
>
> r.connect()
>
>
> print("{0}".format(get_cluster_health(r)))
>
>
> if r is not None:
>
> r.shutdown()
>
> *
>
>
>
> On Thu, Dec 21, 2017 at 4:15 PM, Andreas Calminder <
> andreas.calmin...@klarna.com> wrote:
>
>> Hi,
>> I'm writing a small python script using librados to display cluster
>> health, same info as ceph health detail show, it works fine but I rather
>> not use the admin keyring for something like this. However I have no clue
>> what kind of caps I should or can set, I was kind of hoping that mon allow
>> r would do it, but that didn't work, and I'm unable to find any
>> documentation that covers this. Any pointers would be appreciated.
>>
>> Thanks,
>> Andreas
>>
>> ___
>> ceph-users mailing list
>> ceph-users@lists.ceph.com
>> http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com
>>
>>
>
>
> --
>
> ATTE. Alvaro Soto Escobar
>
> --
> Great people talk about ideas,
> average people talk about things,
> small people talk ... about other people.
> ___
> ceph-users mailing list
> ceph-users@lists.ceph.com
> http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com
>
___
ceph-users mailing list
ceph-users@lists.ceph.com
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com


Re: [ceph-users] Permissions for mon status command

2017-12-21 Thread Alvaro Soto
Hi Andreas,
I believe is not a problem of caps, I have tested using the same cap on mon
and I have the same problem, still looking into.

[client.python]

key = AQDORjxaYHG9JxAA0qiZC0Rmf3qulsO3P/bZgw==

caps mon = "allow r"



# ceph -n client.python --keyring ceph.client.python.keyring health

HEALTH_OK


but if I run the python script that contains a connect command to the
cluster.


# python health.py

Traceback (most recent call last):

  File "health.py", line 13, in 

r.connect()

  File "/usr/lib/python2.7/dist-packages/rados.py", line 429, in connect

raise make_ex(ret, "error connecting to the cluster")

rados.Error: error connecting to the cluster: errno EINVAL


** PYTHON SCRIPT 

#!/usr/bin/env python


import rados

import json


def get_cluster_health(r):

cmd = {"prefix":"status", "format":"json"}

ret, buf, errs = r.mon_command(json.dumps(cmd), b'', timeout=5)

result = json.loads(buf)

return result['health']['overall_status']


r = rados.Rados(conffile = '/etc/ceph/ceph.conf', conf = dict (keyring =
'/etc/ceph/ceph.client.python.keyring'))

r.connect()


print("{0}".format(get_cluster_health(r)))


if r is not None:

r.shutdown()

*



On Thu, Dec 21, 2017 at 4:15 PM, Andreas Calminder <
andreas.calmin...@klarna.com> wrote:

> Hi,
> I'm writing a small python script using librados to display cluster
> health, same info as ceph health detail show, it works fine but I rather
> not use the admin keyring for something like this. However I have no clue
> what kind of caps I should or can set, I was kind of hoping that mon allow
> r would do it, but that didn't work, and I'm unable to find any
> documentation that covers this. Any pointers would be appreciated.
>
> Thanks,
> Andreas
>
> ___
> ceph-users mailing list
> ceph-users@lists.ceph.com
> http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com
>
>


-- 

ATTE. Alvaro Soto Escobar

--
Great people talk about ideas,
average people talk about things,
small people talk ... about other people.
___
ceph-users mailing list
ceph-users@lists.ceph.com
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com


[ceph-users] Permissions for mon status command

2017-12-21 Thread Andreas Calminder
Hi,
I'm writing a small python script using librados to display cluster health,
same info as ceph health detail show, it works fine but I rather not use
the admin keyring for something like this. However I have no clue what kind
of caps I should or can set, I was kind of hoping that mon allow r would do
it, but that didn't work, and I'm unable to find any documentation that
covers this. Any pointers would be appreciated.

Thanks,
Andreas
___
ceph-users mailing list
ceph-users@lists.ceph.com
http://lists.ceph.com/listinfo.cgi/ceph-users-ceph.com