Rados error
cmd = json.dumps({“prefix”: “osd pool ls detail”,”format”: “json”}) r = cluster.mon_command(cmd,b””)
err: (-22, ”, u’command not known’)
The story started
One afternoon, K was debugging the Cinder project. The Ceph Rados interface is called. It is ok to run ceph OSD pool ls detail on the command line. But there is an error in calling detail from the Rades Command interface.
cmd = json.dumps({"prefix": "osd pool ls detail"."format": "json"})
r = cluster.mon_command(cmd,b"detail")
print(r)
python learn_rados.py
-->
(-22, ' ', u'command not known')
Copy the code
However, the OSD Pool LS can be successfully executed.
cmd = json.dumps({"prefix": "osd pool ls detail"."format": "json"})
r = cluster.mon_command(cmd,b"detail")
print(r)
python learn_rados.py
-->
(0, '["volumes","backups","nvme","rados_create_pool"]', u' ')
Copy the code
solution
Can’t handle, beg the boss, funny. My bosses are all code farmers.
/usr/bin/ceph can run ceph osd pool ls detail
You can debug the Python code.
Debug Python from the command line
python -m pdb /root/codes/ceph.py osd pool ls detail
Copy the code
Vscode interface debugging
Remember to set command parameters in debug Settings
cd/root/codes ; /usr/bin/env /usr/bin/python / root/vscode - server/extensions/ms - python. Python - 2020.12.424452561 / pythonFiles/lib/python/debugpy / 14937 - the launcher /root/codes/ceph.py osd pool ls detailCopy the code
To solve the problem
cmd = json.dumps({"prefix": "osd pool ls"."detail":"detail"."format": "json"})
r = cluster.mon_command(cmd,b"")
print(r)
-->
python learn_rados.py
(0, '[{"pool_id":1,"pool_name":"volumes","create_time":"2020-12-16 21:02:52. 159080 ", "flags" : 8193, "flags_names" : "hashpspool, selfmanaged_snaps", "type" : 1, size: 2,Copy the code