RBD Python API
#!/usr/bin/env python
import rbd
import rados
import json
conf = {'keyring': './keyring'}
with rados.Rados(conffile='./ceph.conf', conf=conf) as cluster:
out = cluster.mgr_command(
[json.dumps({
"prefix": "pg ls-by-pool",
"poolstr": "rbd",
"target": ["mgr", ""],
"format": "json",
})],
'',
0
)
print(out)
pool_name = 'rbd'
image_name = 'i1'
with rados.Rados(conffile='./ceph.conf', conf=conf) as cluster:
with cluster.open_ioctx(pool_name) as ioctx:
with rbd.Image(ioctx, image_name) as image:
image.write('abc', 0)
最后修改于 2019-02-20