]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/rados: Add Rados.pool_exists
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 17 Feb 2011 17:58:20 +0000 (09:58 -0800)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Thu, 17 Feb 2011 17:58:20 +0000 (09:58 -0800)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/pybind/rados.py
src/test/pybind-test.py

index acff2819c204ac1ccdf63071862540b74beb4b12..46c72ab095ab4b73e9fc041fc70d7003ba330aef 100755 (executable)
@@ -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):
index 8e0ec5ec44b2b04946623aa2c6279c37b06e4404..8fd4f8f8ccd574a04f06afffa49a76a1df6f46d6 100755 (executable)
@@ -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"