]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common: admin sock output XML elements whitespace 3031/head
authorLoic Dachary <ldachary@redhat.com>
Fri, 28 Nov 2014 15:08:49 +0000 (16:08 +0100)
committerLoic Dachary <ldachary@redhat.com>
Fri, 28 Nov 2014 16:59:15 +0000 (17:59 +0100)
Replace white space with underscore in XML elements displayed from admin
socket commands. <config get>...</config get> becomes
<config_get>...</config_get>

http://tracker.ceph.com/issues/10199 Fixes: #10199

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/common/ceph_context.cc
src/test/common/test_context.cc

index 4816acb334d7e8a9328882485fd8de682afd8678..a8633b1520d000df167e740a2c5445c8fb0617ad 100644 (file)
@@ -14,6 +14,8 @@
 
 #include <time.h>
 
+#include <boost/algorithm/string.hpp>
+
 #include "common/admin_socket.h"
 #include "common/perf_counters.h"
 #include "common/Thread.h"
@@ -191,7 +193,9 @@ void CephContext::do_command(std::string command, cmdmap_t& cmdmap,
     _perf_counters_collection->dump_formatted(f, true);
   }
   else {
-    f->open_object_section(command.c_str());
+    string section = command;
+    boost::replace_all(section, " ", "_");
+    f->open_object_section(section.c_str());
     if (command == "config show") {
       _conf->show_config(f);
     }
index ca745c9a89bd1bfc958efad24f236781519d232c..cb513051af84b0a6720731d6e56982f965f0a98a 100644 (file)
@@ -39,7 +39,7 @@ TEST(CephContext, do_command)
     bufferlist out;
     cct->do_command("config get", cmdmap, "xml", &out);
     string s(out.c_str(), out.length());
-    EXPECT_EQ("<config get><key>" + value + "</key></config get>", s);
+    EXPECT_EQ("<config_get><key>" + value + "</key></config_get>", s);
   }
 
   {