]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Added python wrapper to rados_cluster_stat 31/head
authorChris Glass <tribaal@gmail.com>
Thu, 10 Jan 2013 13:43:49 +0000 (14:43 +0100)
committerChris Glass <tribaal@gmail.com>
Thu, 10 Jan 2013 13:43:49 +0000 (14:43 +0100)
The new get_cluster_stats() method on the rados.Rados object calls
the rados_cluster_stat() function in the librados library.

Signed-off-by: Christopher Glass <christopher.glass@canonical.com>
src/pybind/rados.py

index 09af5ac2aec1827d8fbb401dcd586c6b1560a325..cff2c24a64788b554940839cdf882dc6aa0ed639 100755 (executable)
@@ -80,6 +80,12 @@ class rados_pool_stat_t(Structure):
                 ("num_wr", c_uint64),
                 ("num_wr_kb", c_uint64)]
 
+class rados_cluster_stat_t(Structure):
+    _fields_ = [("kb", c_uint64),
+                ("kb_used", c_uint64),
+                ("kb_avail", c_uint64),
+                ("num_objects", c_uint64)]
+
 class Version(object):
     def __init__(self, major, minor, extra):
         self.major = major
@@ -185,6 +191,17 @@ Rados object in state %s." % (self.state))
             raise make_ex(ret, "error calling connect")
         self.state = "connected"
 
+    def get_cluster_stats(self):
+        stats = rados_cluster_stat_t()
+        ret = self.librados.rados_cluster_stat(self.cluster, byref(stats))
+        if ret < 0:
+            raise make_ex(
+                ret, "Rados.get_cluster_stats(%s): get_stats failed" % self.name)
+        return {'kb': stats.kb,
+                'kb_used': stats.kb_used,
+                'kb_avail': stats.kb_avail,
+                'num_objects': stats.num_objects}
+
     # Returns true if the pool exists; false otherwise.
     def pool_exists(self, pool_name):
         self.require_state("connected")