| 174 | } |
| 175 | |
| 176 | bool 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) { |
nothing calls this directly
no test coverage detected