]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr: raise python exception on failure in send_command()
authorKefu Chai <kchai@redhat.com>
Thu, 15 Jun 2017 07:48:39 +0000 (15:48 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 15 Jun 2017 07:49:44 +0000 (15:49 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/PyState.cc

index 9b03867e1b2cd3368acbf326946a2f11c93d8794..ce71dcd3f7003e2e1dfcb4bddb7b2db37d559f63 100644 (file)
@@ -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;
   }