]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/asok: pass vector<string> to parse_cmd()
authorKefu Chai <kchai@redhat.com>
Tue, 10 Mar 2020 05:56:48 +0000 (13:56 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 15 Mar 2020 12:56:47 +0000 (20:56 +0800)
prepare for the tell command, as the payload of MCommand is a
`vector<string>`, and `cmdmap_from_json()` expects a `vector<string>`

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/crimson/admin/admin_socket.cc
src/crimson/admin/admin_socket.h

index 1c677ff10795784fab7f29e01317b87fb62c6ab9..afbffa3d6dad1d30e13868b2925e7bf3e5c95bc5 100644 (file)
@@ -51,8 +51,8 @@ AdminSocket::register_command(std::unique_ptr<AdminSocketHook>&& hook)
 /*
  * Note: parse_cmd() is executed with servers_tbl_rwlock held as shared
  */
-AdminSocket::maybe_parsed_t AdminSocket::parse_cmd(std::string cmd,
-                                                  ceph::bufferlist& out)
+AdminSocket::maybe_parsed_t
+AdminSocket::parse_cmd(const std::vector<std::string>& cmd, ceph::bufferlist& out)
 {
   // preliminaries:
   //   - create the formatter specified by the cmd parameters
@@ -63,7 +63,7 @@ AdminSocket::maybe_parsed_t AdminSocket::parse_cmd(std::string cmd,
   try {
     stringstream errss;
     //  note that cmdmap_from_json() may throw on syntax issues
-    if (!cmdmap_from_json({cmd}, &cmdmap, errss)) {
+    if (!cmdmap_from_json(cmd, &cmdmap, errss)) {
       logger().error("{}: incoming command error: {}", __func__, errss.str());
       out.append("error:"s);
       out.append(errss.str());
@@ -142,7 +142,7 @@ seastar::future<> AdminSocket::execute_line(std::string cmdline,
   return seastar::with_shared(servers_tbl_rwlock,
                              [this, cmdline, &out]() mutable {
     ceph::bufferlist err;
-    auto parsed = parse_cmd(cmdline, err);
+    auto parsed = parse_cmd({cmdline}, err);
     if (!parsed.has_value() ||
        !validate_command(*parsed, cmdline, err)) {
       return finalize_response(out, std::move(err));
index 4b57b68ad40af04e8dd1e5254724b94661788df4..a6358d4acec7121da316ac1903e632103365ee05 100644 (file)
@@ -146,11 +146,11 @@ class AdminSocket : public seastar::enable_lw_shared_from_this<AdminSocket> {
   seastar::gate stop_gate;
 
   /**
-   *  parse the incoming command line into the sequence of words that identifies
+   *  parse the incoming command into the sequence of words that identifies
    *  the API, and into its arguments. Locate the command string in the
    *  registered blocks.
    */
-  maybe_parsed_t parse_cmd(std::string command_text, bufferlist& out);
+  maybe_parsed_t parse_cmd(const std::vector<std::string>& cmd, bufferlist& out);
 
   /**
    *  The servers table is protected by a rw-lock, to be acquired exclusively