MCPcopy Create free account
hub / github.com/ceph/ceph / execute_command

Method execute_command

src/crimson/admin/admin_socket.cc:182–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182auto AdminSocket::execute_command(const std::vector<std::string>& cmd,
183 ceph::bufferlist&& buf)
184 -> seastar::future<tell_result_t>
185{
186 LOG_PREFIX(AdminSocket::execute_command);
187 INFO("");
188 auto maybe_parsed = parse_cmd(cmd);
189 if (auto* parsed = std::get_if<parsed_command_t>(&maybe_parsed); parsed) {
190 DEBUG("parsed ok");
191 stringstream os;
192 string desc{parsed->hook.desc};
193 if (!validate_cmd(desc, parsed->params, os)) {
194 ERROR("failed to validate '{}': {}", cmd, os.str());
195 ceph::bufferlist out;
196 out.append(os);
197 return seastar::make_ready_future<tell_result_t>(
198 tell_result_t{-EINVAL, "invalid command json", std::move(out)});
199 }
200 DEBUG("validated {} {}", cmd, os.str());
201 auto owned = std::move(*parsed);
202 return seastar::do_with(std::move(owned), std::move(buf),
203 [](const parsed_command_t& parsed,
204 ceph::bufferlist& buf) mutable {
205 return parsed.hook.call(parsed.params, parsed.format, std::move(buf));
206 });
207 } else {
208 DEBUG("failed to parse");
209 auto& result = std::get<tell_result_t>(maybe_parsed);
210 return seastar::make_ready_future<tell_result_t>(std::move(result));
211 }
212}
213
214// an input_stream consumer that reads buffer into a std::string up to the first
215// '\0' which indicates the end of command

Callers

nothing calls this directly

Calls 4

validate_cmdFunction · 0.85
strMethod · 0.45
appendMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected