Skip to content

Commit

Permalink
Merge pull request #31 from chrisglass/expose_cluster_stats_to_python
Browse files Browse the repository at this point in the history
Added python wrapper to rados_cluster_stat
  • Loading branch information
gregsfortytwo committed Jan 10, 2013
2 parents 00898c1 + 797b3db commit eb997e2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/pybind/rados.py
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit eb997e2

Please sign in to comment.