From: Colin Patrick McCabe Date: Thu, 17 Feb 2011 17:58:20 +0000 (-0800) Subject: pybind/rados: Add Rados.pool_exists X-Git-Tag: v0.25~98 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8be3ad125626708b28e326e5934a98503e16c1e4;p=ceph.git pybind/rados: Add Rados.pool_exists Signed-off-by: Colin McCabe --- diff --git a/src/pybind/rados.py b/src/pybind/rados.py index acff2819c204a..46c72ab095ab4 100755 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -91,6 +91,17 @@ class Rados(object): 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): diff --git a/src/test/pybind-test.py b/src/test/pybind-test.py index 8e0ec5ec44b2b..8fd4f8f8ccd57 100755 --- a/src/test/pybind-test.py +++ b/src/test/pybind-test.py @@ -10,6 +10,9 @@ try: 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"