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

Method _handle_command

src/mgr/DaemonServer.cc:1560–3166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1558}
1559
1560bool DaemonServer::_handle_command(
1561 std::shared_ptr<CommandContext>& cmdctx)
1562{
1563 MessageRef m;
1564 bool admin_socket_cmd = false;
1565 if (cmdctx->m_tell) {
1566 m = cmdctx->m_tell;
1567 // a blank fsid in MCommand signals a legacy client sending a "mon-mgr" CLI
1568 // command.
1569 admin_socket_cmd = (cmdctx->m_tell->fsid != uuid_d());
1570 } else {
1571 m = cmdctx->m_mgr;
1572 }
1573 auto priv = m->get_connection()->get_priv();
1574 auto session = static_cast<MgrSession*>(priv.get());
1575 if (!session) {
1576 return true;
1577 }
1578 if (session->inst.name == entity_name_t()) {
1579 session->inst.name = m->get_source();
1580 }
1581
1582 std::map<string,string> param_str_map;
1583 std::stringstream ss;
1584 int r = 0;
1585
1586 if (!cmdmap_from_json(cmdctx->cmd, &(cmdctx->cmdmap), ss)) {
1587 cmdctx->reply(-EINVAL, ss);
1588 return true;
1589 }
1590
1591 string prefix;
1592 cmd_getval(cmdctx->cmdmap, "prefix", prefix);
1593 dout(10) << "decoded-size=" << cmdctx->cmdmap.size() << " prefix=" << prefix << dendl;
1594
1595 boost::scoped_ptr<Formatter> f;
1596 {
1597 std::string format;
1598 if (boost::algorithm::ends_with(prefix, "_json")) {
1599 format = "json";
1600 } else {
1601 format = cmd_getval_or<string>(cmdctx->cmdmap, "format", "plain");
1602 }
1603 f.reset(Formatter::create(format));
1604 }
1605
1606 // this is just for mgr commands - admin socket commands will fall
1607 // through and use the admin socket version of
1608 // get_command_descriptions
1609 if (prefix == "get_command_descriptions" && !admin_socket_cmd) {
1610 dout(10) << "reading commands from python modules" << dendl;
1611 const auto py_commands = py_modules.get_commands();
1612
1613 int cmdnum = 0;
1614 JSONFormatter f;
1615 f.open_object_section("command_descriptions");
1616
1617 auto dump_cmd = [&cmdnum, &f, m](const MonCommand &mc){

Callers

nothing calls this directly

Calls 15

cmdmap_from_jsonFunction · 0.85
ends_withFunction · 0.85
dump_cmddesc_to_jsonFunction · 0.85
cmddesc_get_prefixFunction · 0.85
assertFunction · 0.85
replaceFunction · 0.85
print_osd_utilizationFunction · 0.85
stringifyFunction · 0.85
ceph_conf_level_nameFunction · 0.85
ceph_clock_nowFunction · 0.85
process_pg_map_commandFunction · 0.85

Tested by

no test coverage detected