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

Method preprocess_command

src/mon/ConfigMonitor.cc:176–476  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

174}
175
176bool ConfigMonitor::preprocess_command(MonOpRequestRef op)
177{
178 auto m = op->get_req<MMonCommand>();
179 std::stringstream ss;
180 int err = 0;
181
182 cmdmap_t cmdmap;
183 if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) {
184 string rs = ss.str();
185 mon.reply_command(op, -EINVAL, rs, get_last_committed());
186 return true;
187 }
188 string format = cmd_getval_or<string>(cmdmap, "format", "plain");
189 boost::scoped_ptr<Formatter> f(Formatter::create(format));
190
191 string prefix;
192 cmd_getval(cmdmap, "prefix", prefix);
193
194 bufferlist odata;
195 if (prefix == "config help") {
196 stringstream ss;
197 string name;
198 cmd_getval(cmdmap, "key", name);
199 name = ConfFile::normalize_key_name(name);
200 const Option *opt = g_conf().find_option(name);
201 if (!opt) {
202 opt = mon.mgrmon()->find_module_option(name);
203 }
204 if (opt) {
205 if (f) {
206 f->dump_object("option", *opt);
207 } else {
208 opt->print(&ss);
209 }
210 } else {
211 ss << "configuration option '" << name << "' not recognized";
212 err = -ENOENT;
213 goto reply;
214 }
215 if (f) {
216 f->flush(odata);
217 } else {
218 odata.append(ss.str());
219 }
220 } else if (prefix == "config ls") {
221 ostringstream ss;
222 if (f) {
223 f->open_array_section("options");
224 }
225 for (auto& i : ceph_options) {
226 if (f) {
227 f->dump_string("option", i.name);
228 } else {
229 ss << i.name << "\n";
230 }
231 }
232 for (auto& i : mon.mgrmon()->get_mgr_module_options()) {
233 if (f) {

Callers

nothing calls this directly

Calls 15

cmdmap_from_jsonFunction · 0.85
stringifyFunction · 0.85
to_strFunction · 0.85
reply_commandMethod · 0.80
find_module_optionMethod · 0.80
mgrmonMethod · 0.80
define_columnMethod · 0.80
can_update_at_runtimeMethod · 0.80
get_full_locationMethod · 0.80
osdmonMethod · 0.80
get_item_classMethod · 0.80
generate_entity_mapMethod · 0.80

Tested by

no test coverage detected