raise make_ex(ret, "error opening pool '%s'" % pool_name)
return Pool(pool_name, self.librados, pool)
+ # Returns true if the pool exists; false otherwise.
+ def pool_exists(self, pool_name):
+ pool = c_void_p()
+ ret = self.librados.rados_lookup_pool(c_char_p(pool_name))
+ if (ret >= 0):
+ return True
+ elif (ret == -errno.ENOENT):
+ return False
+ else:
+ raise make_ex(ret, "error looking up pool '%s'" % pool_name)
+
class ObjectIterator(object):
"""rados.Pool Object iterator"""
def __init__(self, pool):
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")
print "deleting pool foo2"