Last active
October 11, 2015 15:57
-
-
Save bussyjd/3882989 to your computer and use it in GitHub Desktop.
A simple demonstration of LIBRADOS binding to RADOS cluster
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 read | |
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') | |
### The pool is deleted | |
cluster.delete_pool("mypool") | |
### I close the IO context and the connection to RADOS | |
mypool.close() | |
cluster.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment