]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/ceph_argparse.py: pass a str not a list to mon_command()
authorKefu Chai <kchai@redhat.com>
Tue, 1 Sep 2020 08:10:54 +0000 (16:10 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 11 Sep 2020 16:30:54 +0000 (00:30 +0800)
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 <kchai@redhat.com>
src/pybind/ceph_argparse.py
src/pybind/rados/rados.pyx

index ab112e794c55a933364f0508538b52c2cdbef677..ac985e5113e11838e53d3e71b6dee94cb9a2d6fa 100644 (file)
@@ -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 <pgid>
             # form, but for tell <pgid>, 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:
index 04acc51dbdd391fd32cdaaa4c3bf8cde39414bd3..e5e0711c8496d942feee7cb643dcb6c1bec05662 100644 (file)
@@ -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)