ceph.in: make osdids() (and mon, mds) work on old mons

Signed-off-by: Dan Mick <dan.mick@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Dan Mick 2013-07-26 16:25:26 -07:00 committed by Sage Weil
parent 4b739005a5
commit 3f93691bf3

View File

@ -64,6 +64,9 @@ cluster_handle = None
def osdids():
ret, outbuf, outs = json_command(cluster_handle, prefix='osd ls')
if ret == -errno.EINVAL:
# try old mon
ret, outbuf, outs = send_command(cluster_handle, cmd=['osd', 'ls'])
if ret:
raise RuntimeError('Can\'t contact mon for osd list')
return [i for i in outbuf.split('\n') if i != '']
@ -71,6 +74,10 @@ def osdids():
def monids():
ret, outbuf, outs = json_command(cluster_handle, prefix='mon dump',
argdict={'format':'json'})
if ret == -errno.EINVAL:
# try old mon
ret, outbuf, outs = send_command(cluster_handle,
cmd=['mon', 'dump', '--format=json'])
if ret:
raise RuntimeError('Can\'t contact mon for mon list')
d = json.loads(outbuf)
@ -79,6 +86,10 @@ def monids():
def mdsids():
ret, outbuf, outs = json_command(cluster_handle, prefix='mds dump',
argdict={'format':'json'})
if ret == -errno.EINVAL:
# try old mon
ret, outbuf, outs = send_command(cluster_handle,
cmd=['mds', 'dump', '--format=json'])
if ret:
raise RuntimeError('Can\'t contact mon for mds list')
d = json.loads(outbuf)