From 797b3db39b526d0f46e49349a57a42bac547aaa1 Mon Sep 17 00:00:00 2001 From: Chris Glass Date: Thu, 10 Jan 2013 14:43:49 +0100 Subject: [PATCH] Added python wrapper to rados_cluster_stat 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 --- src/pybind/rados.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pybind/rados.py b/src/pybind/rados.py index 09af5ac2aec18..cff2c24a64788 100755 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -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 @@ def connect(self): 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")