diff options
author | Joao Eduardo Luis <joao.luis@inktank.com> | 2013-10-15 17:49:57 +0100 |
---|---|---|
committer | Joao Eduardo Luis <joao.luis@inktank.com> | 2013-10-23 02:54:40 +0100 |
commit | 400cb18bbc4202168286f3c5347ad51471eebf0d (patch) | |
tree | 80fb025ae11c9bf05f439c1b7b8772941dc5381f | |
parent | 1a2e0ebaf1f9253ef91304456a64e53b610dc557 (diff) | |
download | ceph-400cb18bbc4202168286f3c5347ad51471eebf0d.tar.gz |
pybind: rados: ping a monitor via librados
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rw-r--r-- | src/pybind/rados.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/pybind/rados.py b/src/pybind/rados.py index 0977bd08bce..fecf4bb16d0 100644 --- a/src/pybind/rados.py +++ b/src/pybind/rados.py @@ -366,6 +366,37 @@ Rados object in state %s." % (self.state)) if (ret != 0): raise make_ex(ret, "error calling conf_set") + + def ping_monitor(self, mon_id): + """ + Ping a monitor to assess liveness + + May be used as a simply way to assess liveness, or to obtain + informations about the monitor in a simple way even in the + absence of quorum. + + :param mon_id: the ID portion of the monitor's name (i.e., mon.<ID>) + :type mon_id: str + :returns: the string reply from the monitor + """ + + self.require_state("configuring", "connected") + + outstrp = pointer(pointer(c_char())) + outstrlen = c_long() + + ret = run_in_thread(self.librados.rados_ping_monitor, + (self.cluster, c_char_p(mon_id), + outstrp, byref(outstrlen))) + + my_outstr = outstrp.contents[:(outstrlen.value)] + if outstrlen.value: + run_in_thread(self.librados.rados_buffer_free, (outstrp.contents,)) + + if ret != 0: + raise make_ex(ret, "error calling ping_monitor") + return my_outstr + def connect(self, timeout=0): """ Connect to the cluster. |