-
-
Save lemonlatte/5409664 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Import of the Python Rados library classes | |
### https://github.com/ceph/ceph/blob/master/src/pybind/rados.py | |
from rados import Rados,ObjectIterator | |
### Initialize Rados class | |
cluster = Rados() | |
### /etc/ceph/ceph.conf file is readen | |
cluster.conf_read_file() | |
print "Configuration file successfully loaded [OK]" | |
### Connection to the RADOS cluster | |
cluster.connect() | |
print "Connection to cluster initialised [OK]" | |
### Returns an array of the pools present in RADOS | |
print "The pools present in rados cluster are: \n", cluster.list_pools() | |
### Here I create a pool | |
cluster.create_pool("mypool") | |
### Opens a IO context | |
mypool = cluster.open_ioctx("mypool") | |
### I create data | |
data = 'mydata' * 10 | |
### Object myobject is created with "My data" in it | |
mypool.write('myobject', data) | |
### data is outputed out of the RADOS cluster | |
print mypool.read('myobject') | |
### Close the IO context | |
mypool.close() | |
### The pool is deleted | |
cluster.delete_pool("mypool") | |
### Close the connection to RADOS | |
cluster.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment