2013-07-19 22:16:16 +00:00
|
|
|
from cStringIO import StringIO
|
|
|
|
import logging
|
|
|
|
import json
|
|
|
|
|
|
|
|
from teuthology import misc as teuthology
|
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
2013-07-22 17:38:28 +00:00
|
|
|
def rgwadmin(ctx, client, cmd, stdin=StringIO(), check_status=False):
|
2013-07-19 22:16:16 +00:00
|
|
|
log.info('radosgw-admin: %s' % cmd)
|
|
|
|
testdir = teuthology.get_testdir(ctx)
|
|
|
|
pre = [
|
|
|
|
'{tdir}/adjust-ulimits'.format(tdir=testdir),
|
|
|
|
'ceph-coverage'.format(tdir=testdir),
|
|
|
|
'{tdir}/archive/coverage'.format(tdir=testdir),
|
|
|
|
'radosgw-admin'.format(tdir=testdir),
|
|
|
|
'--log-to-stderr',
|
|
|
|
'--format', 'json',
|
|
|
|
]
|
|
|
|
pre.extend(cmd)
|
|
|
|
(remote,) = ctx.cluster.only(client).remotes.iterkeys()
|
|
|
|
proc = remote.run(
|
|
|
|
args=pre,
|
2013-07-22 17:38:28 +00:00
|
|
|
check_status=check_status,
|
2013-07-19 22:16:16 +00:00
|
|
|
stdout=StringIO(),
|
|
|
|
stderr=StringIO(),
|
|
|
|
stdin=stdin,
|
|
|
|
)
|
|
|
|
r = proc.exitstatus
|
|
|
|
out = proc.stdout.getvalue()
|
|
|
|
j = None
|
|
|
|
if not r and out != '':
|
|
|
|
try:
|
|
|
|
j = json.loads(out)
|
|
|
|
log.info(' json result: %s' % j)
|
|
|
|
except ValueError:
|
|
|
|
j = out
|
|
|
|
log.info(' raw result: %s' % j)
|
|
|
|
return (r, j)
|