From e20dbcf7a85ce291655994effcec6c7e8c6f614e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alfonso=20Mart=C3=ADnez?= Date: Tue, 2 Mar 2021 16:10:16 +0100 Subject: [PATCH] mgr/BaseMgrModule: add optional inbuf param to ceph_send_command. BaseMgrModule.cc: ceph_send_command: add inbuf param for handling input file content. Fixes: https://tracker.ceph.com/issues/48355 Signed-off-by: Ernesto Puerta (cherry picked from commit dc37e0fdb1ea5187aea42303f0bfe27aadd8d64d) --- src/mgr/BaseMgrModule.cc | 22 +++++++++++++++------- src/pybind/mgr/ceph_module.pyi | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 3ac66e9a9e775..54d555a41f91c 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -125,12 +125,20 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) char *cmd_json = nullptr; char *tag = nullptr; + char *inbuf_ptr = nullptr; + Py_ssize_t inbuf_len = 0; + bufferlist inbuf = {}; + PyObject *completion = nullptr; - if (!PyArg_ParseTuple(args, "Ossss:ceph_send_command", - &completion, &type, &name, &cmd_json, &tag)) { + if (!PyArg_ParseTuple(args, "Ossssz#:ceph_send_command", + &completion, &type, &name, &cmd_json, &tag, &inbuf_ptr, &inbuf_len)) { return nullptr; } + if (inbuf_ptr) { + inbuf.append(inbuf_ptr, (unsigned)inbuf_len); + } + auto set_fn = PyObject_GetAttrString(completion, "complete"); if (set_fn == nullptr) { ceph_abort(); // TODO raise python exception instead @@ -164,7 +172,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) self->py_modules->get_monc().start_mon_command( name, {cmd_json}, - {}, + inbuf, &command_c->outbl, &command_c->outs, new C_OnFinisher(c, &self->py_modules->cmd_finisher)); @@ -184,7 +192,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) self->py_modules->get_objecter().osd_command( osd_id, {cmd_json}, - {}, + inbuf, &tid, &command_c->outbl, &command_c->outs, @@ -193,7 +201,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) int r = self->py_modules->get_client().mds_command( name, {cmd_json}, - {}, + inbuf, &command_c->outbl, &command_c->outs, new C_OnFinisher(command_c, &self->py_modules->cmd_finisher)); @@ -219,7 +227,7 @@ ceph_send_command(BaseMgrModule *self, PyObject *args) self->py_modules->get_objecter().pg_command( pgid, {cmd_json}, - {}, + inbuf, &tid, &command_c->outbl, &command_c->outs, @@ -349,7 +357,7 @@ ceph_set_health_checks(BaseMgrModule *self, PyObject *args) self->py_modules->set_health_checks(self->this_module->get_name(), std::move(out_checks)); PyEval_RestoreThread(tstate); - + Py_RETURN_NONE; } diff --git a/src/pybind/mgr/ceph_module.pyi b/src/pybind/mgr/ceph_module.pyi index d71259c0dadee..009c1f2eafd1e 100644 --- a/src/pybind/mgr/ceph_module.pyi +++ b/src/pybind/mgr/ceph_module.pyi @@ -49,7 +49,7 @@ class BaseMgrModule(object): def _ceph_get_latest_counter(self, svc_type, svc_name, path):... def _ceph_get_metadata(self, svc_type, svc_id):... def _ceph_get_daemon_status(self, svc_type, svc_id):... - def _ceph_send_command(self, *args, **kwargs):... + def _ceph_send_command(self, result, svc_type, svc_id, command, tag, inbuf):... def _ceph_set_health_checks(self, checks):... def _ceph_get_mgr_id(self):... def _ceph_get_option(self, key):... -- 2.39.5