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

Method handle_command

src/mon/Monitor.cc:3453–4180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3451}
3452
3453void Monitor::handle_command(MonOpRequestRef op)
3454{
3455 ceph_assert(op->is_type_command());
3456 auto m = op->get_req<MMonCommand>();
3457 if (m->fsid != monmap->fsid) {
3458 dout(0) << "handle_command on fsid " << m->fsid << " != " << monmap->fsid
3459 << dendl;
3460 reply_command(op, -EPERM, "wrong fsid", 0);
3461 return;
3462 }
3463
3464 MonSession *session = op->get_session();
3465 if (!session) {
3466 dout(5) << __func__ << " dropping stray message " << *m << dendl;
3467 return;
3468 }
3469
3470 if (m->cmd.empty()) {
3471 reply_command(op, -EINVAL, "no command specified", 0);
3472 return;
3473 }
3474
3475 string prefix;
3476 vector<string> fullcmd;
3477 cmdmap_t cmdmap;
3478 stringstream ss, ds;
3479 bufferlist rdata;
3480 string rs;
3481 int r = -EINVAL;
3482 rs = "unrecognized command";
3483
3484 if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) {
3485 // ss has reason for failure
3486 r = -EINVAL;
3487 rs = ss.str();
3488 if (!m->get_source().is_mon()) // don't reply to mon->mon commands
3489 reply_command(op, r, rs, 0);
3490 return;
3491 }
3492
3493 // check return value. If no prefix parameter provided,
3494 // return value will be false, then return error info.
3495 if (!cmd_getval(cmdmap, "prefix", prefix)) {
3496 reply_command(op, -EINVAL, "command prefix not found", 0);
3497 return;
3498 }
3499
3500 // check prefix is empty
3501 if (prefix.empty()) {
3502 reply_command(op, -EINVAL, "command prefix must not be empty", 0);
3503 return;
3504 }
3505
3506 if (prefix == "get_command_descriptions") {
3507 bufferlist rdata;
3508 Formatter *f = Formatter::create("json");
3509
3510 std::vector<MonCommand> commands = static_cast<MgrMonitor*>(

Callers

nothing calls this directly

Calls 15

cmdmap_from_jsonFunction · 0.85
get_epochFunction · 0.85
ceph_version_to_strFunction · 0.85
git_version_to_strFunction · 0.85
ceph_clock_nowFunction · 0.85
cpp_strerrorFunction · 0.85
stringifyFunction · 0.85
pretty_version_to_strFunction · 0.85
is_type_commandMethod · 0.80
is_noforwardMethod · 0.80
is_compatMethod · 0.80
is_obsoleteMethod · 0.80

Tested by

no test coverage detected