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

Method preprocess_command

src/mon/OSDMonitor.cc:5501–7224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5499
5500
5501bool OSDMonitor::preprocess_command(MonOpRequestRef op)
5502{
5503 op->mark_osdmon_event(__func__);
5504 auto m = op->get_req<MMonCommand>();
5505 int r = 0;
5506 bufferlist rdata;
5507 stringstream ss, ds;
5508
5509 cmdmap_t cmdmap;
5510 if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) {
5511 string rs = ss.str();
5512 mon.reply_command(op, -EINVAL, rs, get_last_committed());
5513 return true;
5514 }
5515
5516 MonSession *session = op->get_session();
5517 if (!session) {
5518 derr << __func__ << " no session" << dendl;
5519 mon.reply_command(op, -EACCES, "access denied", get_last_committed());
5520 return true;
5521 }
5522
5523 string prefix;
5524 cmd_getval(cmdmap, "prefix", prefix);
5525
5526 string format = cmd_getval_or<string>(cmdmap, "format", "plain");
5527 boost::scoped_ptr<Formatter> f(Formatter::create(format));
5528
5529 if (prefix == "osd stat") {
5530 if (f) {
5531 f->open_object_section("osdmap");
5532 osdmap.print_summary(f.get(), ds, "", true);
5533 f->close_section();
5534 f->flush(rdata);
5535 } else {
5536 osdmap.print_summary(nullptr, ds, "", true);
5537 rdata.append(ds);
5538 }
5539 }
5540 else if (prefix == "osd dump" ||
5541 prefix == "osd tree" ||
5542 prefix == "osd tree-from" ||
5543 prefix == "osd ls" ||
5544 prefix == "osd getmap" ||
5545 prefix == "osd getcrushmap" ||
5546 prefix == "osd ls-tree" ||
5547 prefix == "osd info") {
5548
5549 epoch_t epoch = cmd_getval_or<int64_t>(cmdmap, "epoch", osdmap.get_epoch());
5550 bufferlist osdmap_bl;
5551 int err = get_version_full(epoch, osdmap_bl);
5552 if (err == -ENOENT) {
5553 r = -ENOENT;
5554 ss << "there is no map for epoch " << epoch;
5555 goto reply;
5556 }
5557 ceph_assert(err == 0);
5558 ceph_assert(osdmap_bl.length());

Callers

nothing calls this directly

Calls 15

cmdmap_from_jsonFunction · 0.85
make_scope_guardFunction · 0.85
cmd_vartype_stringifyFunction · 0.85
dump_cpu_listFunction · 0.85
stringifyFunction · 0.85
pg_vector_stringFunction · 0.85
parse_pgidFunction · 0.85
si_u_tClass · 0.85
byte_u_tClass · 0.85
mark_osdmon_eventMethod · 0.80

Tested by

no test coverage detected