diff options
author | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-03-18 11:00:49 -0700 |
---|---|---|
committer | Colin Patrick McCabe <cmccabe@alumni.cmu.edu> | 2011-03-18 15:10:46 -0700 |
commit | 1065bef0eb777117a2950fa7fefeff8233b4e29e (patch) | |
tree | 53919d061222d2e2756213fddc37ca1c884d2417 /src/test | |
parent | 9db1ecf34f2c2e4b9c801b08d934db5cab7b4ac6 (diff) | |
download | ceph-1065bef0eb777117a2950fa7fefeff8233b4e29e.tar.gz |
pybind: convert to new API
Fix the python bindings to use the new librados API.
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
Diffstat (limited to 'src/test')
-rwxr-xr-x | src/test/pybind-test.py | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/test/pybind-test.py b/src/test/pybind-test.py index d5f9cd72a1c..812d057ceea 100755 --- a/src/test/pybind-test.py +++ b/src/test/pybind-test.py @@ -3,63 +3,75 @@ import rados r = rados.Rados() +r.conf_read_file(); +r.connect() v = r.version() print "rados version %s" % str(v) + +try: + auid = 100 + r.create_pool("foo1", auid) + print "created pool foo1 with auid %d" % auid + r.delete_pool("foo1") + print "deleted pool foo1" +except rados.ObjectExists: + print "pool foo1 already exists" + try: r.create_pool("foo2") print "created pool foo2" except rados.ObjectExists: print "pool foo2 already exists" - if r.pool_exists("foo2") != True: raise RuntimeError("we just created pool 'foo2', but it doesn't exist?") - print "opening pool foo2" -foo2_pool = r.open_pool("foo2") +foo2_ioctx = r.open_ioctx("foo2") # give this pool to the anonymous AUID -foo2_pool.change_auid(rados.ANONYMOUS_AUID) +foo2_ioctx.change_auid(rados.ANONYMOUS_AUID) # well, actually, we want it back. -foo2_pool.change_auid(rados.ADMIN_AUID) +foo2_ioctx.change_auid(rados.ADMIN_AUID) +foo2_ioctx.close() # now delete print "deleting pool foo2" -foo2_pool.delete() +r.delete_pool("foo2") # create a pool and some objects try: r.create_pool("foo3") except rados.ObjectExists: pass -foo3_pool = r.open_pool("foo3") -foo3_pool.write("abc", "abc") -foo3_pool.write("def", "def") -abc_str = foo3_pool.read("abc") +foo3_ioctx = r.open_ioctx("foo3") +foo3_ioctx.write("abc", "abc") +foo3_ioctx.write("def", "def") +abc_str = foo3_ioctx.read("abc") if (abc_str != "abc"): raise RuntimeError("error reading object abc: expected value abc, \ got %s" % abc_str) # write_full replaces the whole 'def' object -foo3_pool.write_full("def", "d") -def_str = foo3_pool.read("def") +foo3_ioctx.write_full("def", "d") +def_str = foo3_ioctx.read("def") if (def_str != "d"): raise RuntimeError("error reading object def: expected value d, \ got %s" % def_str) -for obj in foo3_pool.list_objects(): +for obj in foo3_ioctx.list_objects(): print str(obj) # create some snapshots and do stuff with them print "creating snap bjork" -foo3_pool.create_snap("bjork") +foo3_ioctx.create_snap("bjork") print "creating snap aardvark" -foo3_pool.create_snap("aardvark") +foo3_ioctx.create_snap("aardvark") print "creating snap carnuba" -foo3_pool.create_snap("carnuba") +foo3_ioctx.create_snap("carnuba") print "listing snaps..." -for snap in foo3_pool.list_snaps(): +for snap in foo3_ioctx.list_snaps(): print str(snap) print "removing snap bjork" -foo3_pool.remove_snap("bjork") +foo3_ioctx.remove_snap("bjork") +foo3_ioctx.close() # remove foo3 print "deleting foo3" -foo3_pool.delete() +r.delete_pool("foo3") |