]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add mon_command to C++ API
authorSage Weil <sage@inktank.com>
Thu, 10 Oct 2013 23:23:57 +0000 (16:23 -0700)
committerSage Weil <sage@inktank.com>
Fri, 6 Dec 2013 22:37:25 +0000 (14:37 -0800)
This way librados users can execute monitor commands.

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/include/rados/librados.hpp
src/librados/librados.cc
src/test/librados/cmd.cc

index dfe24784f950180903f6997dcd5a5d6f881835c0..997bb7fe7b25ccbc64717485385668b39d05f473 100644 (file)
@@ -783,6 +783,9 @@ namespace librados
 
     uint64_t get_instance_id();
 
+    int mon_command(std::string cmd, const bufferlist& inbl,
+                   bufferlist *outbl, std::string *outs);
+
     int ioctx_create(const char *name, IoCtx &pioctx);
 
     // Features useful for test cases
index 6c8e209291a3adcf0d3cfdcbaaef2377eb36d668..db2efaad64093df008112969d19e4458230fff17 100644 (file)
@@ -1492,6 +1492,14 @@ int librados::Rados::pool_reverse_lookup(int64_t id, std::string *name)
   return client->pool_get_name(id, name);
 }
 
+int librados::Rados::mon_command(string cmd, const bufferlist& inbl,
+                                bufferlist *outbl, string *outs)
+{
+  vector<string> cmdvec;
+  cmdvec.push_back(cmd);
+  return client->mon_command(cmdvec, inbl, outbl, outs);
+}
+
 int librados::Rados::ioctx_create(const char *name, IoCtx &io)
 {
   rados_ioctx_t p;
index f47cc9fc7d2717b4496bd86c708f0fffe8645fb5..79dc658a5099aa3f41c6ae5248cc65abc9c44ed0 100644 (file)
@@ -57,6 +57,21 @@ TEST(LibRadosCmd, MonDescribe) {
   ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
 }
 
+TEST(LibRadosCmd, MonDescribePP) {
+  Rados cluster;
+  std::string pool_name = get_temp_pool_name();
+  ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
+
+  bufferlist inbl, outbl;
+  string outs;
+  ASSERT_EQ(0, cluster.mon_command("{\"prefix\": \"get_command_descriptions\"}",
+                                  inbl, &outbl, &outs));
+  ASSERT_LT(0u, outbl.length());
+  ASSERT_LE(0u, outs.length());
+
+  ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
+}
+
 TEST(LibRadosCmd, OSDCmd) {
   rados_t cluster;
   std::string pool_name = get_temp_pool_name();