From: Kefu Chai Date: Thu, 15 Jun 2017 07:48:39 +0000 (+0800) Subject: mgr: raise python exception on failure in send_command() X-Git-Tag: v12.1.0~118^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a1c9f69c648b82915ef504a2b2c8b7e1f273e580;p=ceph.git mgr: raise python exception on failure in send_command() Signed-off-by: Kefu Chai --- diff --git a/src/mgr/PyState.cc b/src/mgr/PyState.cc index 9b03867e1b2c..ce71dcd3f700 100644 --- a/src/mgr/PyState.cc +++ b/src/mgr/PyState.cc @@ -19,6 +19,7 @@ #include "Mgr.h" #include "mon/MonClient.h" +#include "common/errno.h" #include "common/version.h" #include "PyState.h" @@ -120,7 +121,10 @@ ceph_send_command(PyObject *self, PyObject *args) std::string err; uint64_t osd_id = strict_strtoll(name, 10, &err); if (!err.empty()) { - // TODO: raise exception + delete c; + string msg("invalid osd_id: "); + msg.append("\"").append(name).append("\""); + PyErr_SetString(PyExc_ValueError, msg.c_str()); return nullptr; } @@ -142,14 +146,18 @@ ceph_send_command(PyObject *self, PyObject *args) &c->outs, c); if (r != 0) { - // TODO: raise exception + string msg("failed to send command to mds: "); + msg.append(cpp_strerror(r)); + PyErr_SetString(PyExc_RuntimeError, msg.c_str()); return nullptr; } } else if (std::string(type) == "pg") { // TODO: expose objecter::pg_command return nullptr; } else { - // TODO: raise exception + string msg("unknown service type: "); + msg.append(type); + PyErr_SetString(PyExc_ValueError, msg.c_str()); return nullptr; }