From: Kefu Chai Date: Tue, 1 Sep 2020 08:10:54 +0000 (+0800) Subject: pybind/ceph_argparse.py: pass a str not a list to mon_command() X-Git-Tag: v16.1.0~1112^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b59dde535a0a57fa923f289303606356c5225cca;p=ceph.git pybind/ceph_argparse.py: pass a str not a list to mon_command() no need to construct a list as the cmd. and more importantly, the document of Rados.mon_command() reads: Rados.mon_command(self, cmd, inbuf, timeout=0, target=None): ... :param cmd: JSON formatted string. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index ab112e794c55..ac985e5113e1 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -1402,11 +1402,11 @@ def send_command(cluster, target=('mon', ''), cmd=None, inbuf=b'', timeout=0, # pgid will already be in the command for the pg # form, but for tell , we need to put it in if cmd: - cmddict = json.loads(cmd[0]) + cmddict = json.loads(cmd) cmddict['pgid'] = pgid else: cmddict = dict(pgid=pgid) - cmd = [json.dumps(cmddict)] + cmd = json.dumps(cmddict) if verbose: print('submit {0} for pgid {1}'.format(cmd, pgid), file=sys.stderr) @@ -1488,7 +1488,7 @@ def json_command(cluster, target=('mon', ''), prefix=None, argdict=None, # use the target we were originally given pass ret, outbuf, outs = send_command_retry(cluster, - target, [json.dumps(cmddict)], + target, json.dumps(cmddict), inbuf, timeout, verbose) except Exception as e: diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index 04acc51dbdd3..e5e0711c8496 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -1444,7 +1444,7 @@ Rados object in state %s." % self.state) cdef: int _osdid = osdid char **_cmd = to_bytes_array(cmds) - size_t _cmdlen = len(cmd) + size_t _cmdlen = len(cmds) char *_inbuf = inbuf size_t _inbuf_len = len(inbuf) @@ -1535,14 +1535,14 @@ Rados object in state %s." % self.state) # timeout argument, but we keep it for backward compat with old python binding self.require_state("connected") - pgid = cstr(pgid, 'pgid') - cmd = cstr_list(cmd, 'cmd') + pgid_raw = cstr(pgid, 'pgid') + cmds = [cstr(cmd, 'cmd')] inbuf = cstr(inbuf, 'inbuf') cdef: - char *_pgid = pgid - char **_cmd = to_bytes_array(cmd) - size_t _cmdlen = len(cmd) + char *_pgid = pgid_raw + char **_cmd = to_bytes_array(cmds) + size_t _cmdlen = len(cmds) char *_inbuf = inbuf size_t _inbuf_len = len(inbuf)