Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- File: rbd_script.py
- import rados,sys,rbd
- cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
- cluster.connect()
- ioctx = cluster.open_ioctx('big_dick')
- try:
- rbd_inst = rbd.RBD()
- #size = 4 * 1024**3
- #rbd_inst.create(ioctx,'cock_image',size)
- image = rbd.Image(ioctx, 'cock_image')
- try:
- data = 'SanyaHyiSosi' * 100
- image.write(data,0)
- finally:
- image.close()
- finally:
- ioctx.close()
- cluster.shutdown()
- ------------------------------------------------------------------------------
- GNU nano 2.5.3 File: connect_to_ceph.py
- import rados, sys
- cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
- print "\nlibrados version: " + str(cluster.version())
- print "Will attempt to connect to: " + str(cluster.conf_get('mon initial members'))
- cluster.connect()
- print "\nCluster ID: " + cluster.get_fsid()
- print "\n\nCluster Statistics"
- print "=================="
- cluster_stats = cluster.get_cluster_stats()
- for key, value in cluster_stats.iteritems():
- print key, value
- print "\n\nPool Operations"
- print "==============="
- print "\nAvailable Pools"
- print "----------------"
- pools = cluster.list_pools()
- for pool in pools:
- print pool
- print "\nCreate 'test' Pool"
- print "------------------"
- cluster.create_pool('test')
- print "\nPool named 'test' exists: " + str(cluster.pool_exists('test'))
- print "\nVerify 'test' Pool Exists"
- print "-------------------------"
- pools = cluster.list_pools()
- for pool in pools:
- print pool
- print "\nDelete 'test' Pool"
- print "------------------"
- cluster.delete_pool('test')
- print "\nPool named 'test' exists: " + str(cluster.pool_exists('test'))
- ioctx = cluster.open_ioctx('big_dick')
- print "\nWriting object 'hw' with contents 'Hello World!' to pool 'big_dick'."
- ioctx.write_full("hw","Hello World")
- print "\n\nContents of object 'hw'\n------------------------\n"
- print ioctx.read("hw")
- print "\nRemoving object 'hw'"
- ioctx.remove_object("hw")
- print "\nClosing the connection."
- ioctx.close()
- ------------------------------------------------------------------------------
- GNU nano 2.5.3 File: watch_objects.py
- import rados, sys
- cluster = rados.Rados(conffile='/etc/ceph/ceph.conf')
- cluster.connect()
- ioctx = cluster.open_ioctx('big_dick')
- object_iterator = ioctx.list_objects()
- while True:
- try :
- rados_object = object_iterator.next()
- print "Object contents = " + rados_object.read()
- except StopIteration :
- break
- ioctx.close()
- cluster.shutdown()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement