Skip to content

Commit

Permalink
Merge pull request ceph#3560 from XinzeChi/wip-pmon-all
Browse files Browse the repository at this point in the history
ceph.in: add ceph ping mon.* for ping all monitor

Reviewed-by: Loic Dachary <[email protected]>
Reviewed-by: Kefu Chai <[email protected]>
  • Loading branch information
liewegas committed Apr 6, 2015
2 parents 6c070ac + 2165d05 commit a074a14
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
10 changes: 10 additions & 0 deletions qa/workunits/cephtool/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,15 @@ EOF
ceph osd setcrushmap -i $map
}

function test_mon_ping()
{
ceph ping mon.a
ceph ping mon.b
expect_false ceph ping mon.foo

ceph ping mon.*
}

#
# New tests should be added to the TESTS array below
#
Expand Down Expand Up @@ -1476,6 +1485,7 @@ MON_TESTS+=" mon_osd_misc"
MON_TESTS+=" mon_heap_profiler"
MON_TESTS+=" mon_tell"
MON_TESTS+=" mon_crushmap_validation"
MON_TESTS+=" mon_ping"

OSD_TESTS+=" osd_bench"

Expand Down
14 changes: 10 additions & 4 deletions src/ceph.in
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,20 @@ def complete(sigdict, args, target):
###
# ping a monitor
###
def ping_monitor(cluster_handle, name):
def ping_monitor(cluster_handle, name, timeout):
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
if (mon_id == '*') :
cluster_handle.connect(timeout=timeout)
for m in monids() :
s = cluster_handle.ping_monitor(m)
print "mon.{0}".format(m) + '\n' + s
else :
s = cluster_handle.ping_monitor(mon_id)
print s
return 0

###
Expand Down Expand Up @@ -639,7 +645,7 @@ def main():

try:
if childargs and childargs[0] == 'ping':
return ping_monitor(cluster_handle, childargs[1])
return ping_monitor(cluster_handle, childargs[1], timeout)
cluster_handle.connect(timeout=timeout)
except KeyboardInterrupt:
print >> sys.stderr, 'Cluster connection aborted'
Expand Down
14 changes: 10 additions & 4 deletions src/ceph.in.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -479,14 +479,20 @@ def complete(sigdict, args, target):
###
# ping a monitor
###
def ping_monitor(cluster_handle, name):
def ping_monitor(cluster_handle, name, timeout):
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
if (mon_id == '*') :
cluster_handle.connect(timeout=timeout)
for m in monids() :
s = cluster_handle.ping_monitor(m)
print "mon.{0}".format(m) + '\n' + s
else :
s = cluster_handle.ping_monitor(mon_id)
print s
return 0

###
Expand Down Expand Up @@ -624,7 +630,7 @@ def main():

try:
if childargs and childargs[0] == 'ping':
return ping_monitor(cluster_handle, childargs[1])
return ping_monitor(cluster_handle, childargs[1], timeout)
cluster_handle.connect(timeout=timeout)
except KeyboardInterrupt:
print >> sys.stderr, 'Cluster connection aborted'
Expand Down

0 comments on commit a074a14

Please sign in to comment.