switch (m->get_type()) {
// READs
case MSG_MON_COMMAND:
- return preprocess_command(op);
+ try {
+ return preprocess_command(op);
+ }
+ catch (const bad_cmd_get& e) {
+ bufferlist bl;
+ mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed());
+ return true;
+ }
case MSG_MON_JOIN:
return preprocess_join(op);
default:
}
string prefix;
- cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
+ cmd_getval_throws(g_ceph_context, cmdmap, "prefix", prefix);
MonSession *session = m->get_session();
if (!session) {
}
string format;
- cmd_getval(g_ceph_context, cmdmap, "format", format, string("plain"));
+ cmd_getval_throws(g_ceph_context, cmdmap, "format", format, string("plain"));
boost::scoped_ptr<Formatter> f(Formatter::create(format));
if (prefix == "mon stat") {
epoch_t epoch;
int64_t epochnum;
- cmd_getval(g_ceph_context, cmdmap, "epoch", epochnum, (int64_t)0);
+ cmd_getval_throws(g_ceph_context, cmdmap, "epoch", epochnum, (int64_t)0);
epoch = epochnum;
MonMap *p = mon->monmap;
bool list_with_value = false;
string with_value;
- if (cmd_getval(g_ceph_context, cmdmap, "with_value", with_value) &&
+ if (cmd_getval_throws(g_ceph_context, cmdmap, "with_value", with_value) &&
with_value == "--with-value") {
list_with_value = true;
}
switch (m->get_type()) {
case MSG_MON_COMMAND:
- return prepare_command(op);
+ try {
+ return prepare_command(op);
+ }
+ catch (const bad_cmd_get& e) {
+ bufferlist bl;
+ mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed());
+ return true;
+ }
case MSG_MON_JOIN:
return prepare_join(op);
default:
}
string prefix;
- cmd_getval(g_ceph_context, cmdmap, "prefix", prefix);
+ cmd_getval_throws(g_ceph_context, cmdmap, "prefix", prefix);
MonSession *session = m->get_session();
if (!session) {
bool propose = false;
if (prefix == "mon add") {
string name;
- cmd_getval(g_ceph_context, cmdmap, "name", name);
+ cmd_getval_throws(g_ceph_context, cmdmap, "name", name);
string addrstr;
- cmd_getval(g_ceph_context, cmdmap, "addr", addrstr);
+ cmd_getval_throws(g_ceph_context, cmdmap, "addr", addrstr);
entity_addr_t addr;
bufferlist rdata;
} else if (prefix == "mon remove" ||
prefix == "mon rm") {
string name;
- cmd_getval(g_ceph_context, cmdmap, "name", name);
+ cmd_getval_throws(g_ceph_context, cmdmap, "name", name);
if (!monmap.contains(name)) {
err = 0;
ss << "mon." << name << " does not exist or has already been removed";
* 'mon flag set/unset'.
*/
string feature_name;
- if (!cmd_getval(g_ceph_context, cmdmap, "feature_name", feature_name)) {
+ if (!cmd_getval_throws(g_ceph_context, cmdmap, "feature_name", feature_name)) {
ss << "missing required feature name";
err = -EINVAL;
goto reply;
}
string sure;
- if (!cmd_getval(g_ceph_context, cmdmap, "sure", sure) ||
+ if (!cmd_getval_throws(g_ceph_context, cmdmap, "sure", sure) ||
sure != "--yes-i-really-mean-it") {
ss << "please specify '--yes-i-really-mean-it' if you "
<< "really, **really** want to set feature '"
<< "persistent = " << pending_map.persistent_features
// output optional nevertheless, for auditing purposes.
<< ", optional = " << pending_map.optional_features << dendl;
-
} else {
ss << "unknown command " << prefix;
err = -EINVAL;