summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoao Eduardo Luis <joao.luis@inktank.com>2013-10-23 03:04:23 +0100
committerJoao Eduardo Luis <joao.luis@inktank.com>2013-10-23 03:04:23 +0100
commit7ba4bc4ab751eb11fd57bb500cb484995e485c23 (patch)
tree19357d5d3dce7012a931a2beedd02ec725a619f6
parent400cb18bbc4202168286f3c5347ad51471eebf0d (diff)
downloadceph-7ba4bc4ab751eb11fd57bb500cb484995e485c23.tar.gz
cli: ceph: add support to ping monitors
Signed-off-by: Joao Eduardo Luis <joao.luis@inktank.com>
-rwxr-xr-xsrc/ceph.in20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ceph.in b/src/ceph.in
index 56422f6ed82..72c58541b0f 100755
--- a/src/ceph.in
+++ b/src/ceph.in
@@ -476,6 +476,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.<id>"'
+ 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.<id>"'
+ 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'