From 8956ff304cba3cca4401537700e00d8678f1a660 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alfonso=20Mart=C3=ADnez?= Date: Tue, 15 Dec 2020 09:29:53 +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) Conflicts: src/pybind/mgr/ceph_module.pyi - Remove this file as it does not exist in nautilus. --- src/mgr/BaseMgrModule.cc | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index a2610517ab288..0f8f0b6de10f3 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -123,12 +123,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 @@ -162,7 +170,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)); @@ -182,7 +190,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, @@ -191,7 +199,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)); @@ -217,7 +225,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, @@ -337,7 +345,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; } -- 2.39.5