From 315bc1a9ee79d150d99650930755c7eb2ec32d7e Mon Sep 17 00:00:00 2001 From: Sebastian Wagner Date: Wed, 13 Mar 2019 16:35:41 +0100 Subject: [PATCH] doc/rados/api/python: Add documentation for mon_command Co-authored-by: Nathan Cutler Signed-off-by: Sebastian Wagner --- doc/rados/api/python.rst | 12 ++++++++++++ src/pybind/rados/rados.pyx | 25 +++++++++++++++++++++---- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/doc/rados/api/python.rst b/doc/rados/api/python.rst index 977b603ff89..222a5b193e1 100644 --- a/doc/rados/api/python.rst +++ b/doc/rados/api/python.rst @@ -319,6 +319,18 @@ exists, and delete a pool. .. automethod:: Rados.delete_pool(pool_name) +CLI Commands +------------ + +The Ceph CLI command is internally using the following librados Python binding methods. + +In order to send a command, choose the correct method and choose the correct target. + +.. automethod:: Rados.mon_command +.. automethod:: Rados.osd_command +.. automethod:: Rados.mgr_command +.. automethod:: Rados.pg_command + Input/Output Context API ======================== diff --git a/src/pybind/rados/rados.pyx b/src/pybind/rados/rados.pyx index 052c491517d..b05efff7e94 100644 --- a/src/pybind/rados/rados.pyx +++ b/src/pybind/rados/rados.pyx @@ -1236,8 +1236,23 @@ Rados object in state %s." % self.state) def mon_command(self, cmd, inbuf, timeout=0, target=None): """ + Send a command to the mon. + mon_command[_target](cmd, inbuf, outbuf, outbuflen, outs, outslen) - returns (int ret, string outbuf, string outs) + + :param cmd: JSON formatted string. + :param inbuf: optional string. + :param timeout: This parameter is ignored. + :param target: name of a specific mon. Optional + :return: (int ret, string outbuf, string outs) + + Example: + + >>> import json + >>> c = Rados(conffile='/etc/ceph/ceph.conf') + >>> c.connect() + >>> cmd = json.dumps({"prefix": "osd safe-to-destroy", "ids": ["2"], "format": "json"}) + >>> c.mon_command(cmd, b'') """ # NOTE(sileht): timeout is ignored because C API doesn't provide # timeout argument, but we keep it for backward compat with old python binding @@ -1294,7 +1309,8 @@ Rados object in state %s." % self.state) def osd_command(self, osdid, cmd, inbuf, timeout=0): """ osd_command(osdid, cmd, inbuf, outbuf, outbuflen, outs, outslen) - returns (int ret, string outbuf, string outs) + + :return: (int ret, string outbuf, string outs) """ # NOTE(sileht): timeout is ignored because C API doesn't provide # timeout argument, but we keep it for backward compat with old python binding @@ -1336,7 +1352,7 @@ Rados object in state %s." % self.state) def mgr_command(self, cmd, inbuf, timeout=0): """ - returns (int ret, string outbuf, string outs) + :return: (int ret, string outbuf, string outs) """ # NOTE(sileht): timeout is ignored because C API doesn't provide # timeout argument, but we keep it for backward compat with old python binding @@ -1378,7 +1394,8 @@ Rados object in state %s." % self.state) def pg_command(self, pgid, cmd, inbuf, timeout=0): """ pg_command(pgid, cmd, inbuf, outbuf, outbuflen, outs, outslen) - returns (int ret, string outbuf, string outs) + + :return: (int ret, string outbuf, string outs) """ # NOTE(sileht): timeout is ignored because C API doesn't provide # timeout argument, but we keep it for backward compat with old python binding -- 2.39.5