From 7ba4bc4ab751eb11fd57bb500cb484995e485c23 Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 23 Oct 2013 03:04:23 +0100 Subject: [PATCH] cli: ceph: add support to ping monitors Signed-off-by: Joao Eduardo Luis --- src/ceph.in | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ceph.in b/src/ceph.in index 56422f6ed8208..72c58541b0f08 100755 --- a/src/ceph.in +++ b/src/ceph.in @@ -475,6 +475,19 @@ def complete(sigdict, args, target): return 0 +### +# ping a monitor +### +def ping_monitor(cluster_handle, name): + if 'mon.' not in name: + print >> sys.stderr, '"ping" expects a monitor to ping; try "ping mon."' + return 1 + + mon_id = name[len('mon.'):] + s = cluster_handle.ping_monitor(mon_id) + print s + return 0 + ### # main ### @@ -603,7 +616,14 @@ def main(): hdr('Monitor commands:') print '[Contacting monitor, timeout after %d seconds]' % timeout + if childargs[0] == 'ping': + if len(childargs) < 2: + print >> sys.stderr, '"ping" requires a monitor name as argument: "ping mon."' + return 1 + try: + if childargs[0] == 'ping': + return ping_monitor(cluster_handle, childargs[1]) cluster_handle.connect(timeout=timeout) except KeyboardInterrupt: print >> sys.stderr, 'Cluster connection aborted' -- 2.39.5