These are old bool options that never got converted to CephBool.
Signed-off-by: Sage Weil <sage@newdream.net>
return false;
}
+bool cmd_getval_compat_cephbool(
+ const cmdmap_t& cmdmap,
+ const std::string& k, bool& val)
+{
+ try {
+ return cmd_getval(cmdmap, k, val);
+ } catch (bad_cmd_get& e) {
+ // try as legacy/compat CephChoices
+ std::string t;
+ if (!cmd_getval(cmdmap, k, t)) {
+ return false;
+ }
+ std::string expected = "--"s + k;
+ std::replace(expected.begin(), expected.end(), '_', '-');
+ val = (t == expected);
+ return true;
+ }
+}
+
}
bool cmd_getval(const cmdmap_t& cmdmap,
const std::string& k, bool& val);
+bool cmd_getval_compat_cephbool(
+ const cmdmap_t& cmdmap,
+ const std::string& k, bool& val);
+
template <typename T>
bool cmd_getval(const cmdmap_t& cmdmap,
const std::string& k, T& val)
ss << "module '" << module << "' is already enabled (always-on)";
goto out;
}
- string force;
- cmd_getval(cmdmap, "force", force);
+ bool force = false;
+ cmd_getval_compat_cephbool(cmdmap, "force", force);
if (!pending_map.all_support_module(module) &&
- force != "--force") {
+ !force) {
ss << "all mgr daemons do not support module '" << module << "', pass "
<< "--force to force enablement";
r = -ENOENT;
}
std::string can_run_error;
- if (force != "--force" && !pending_map.can_run_module(module, &can_run_error)) {
+ if (!force && !pending_map.can_run_module(module, &can_run_error)) {
ss << "module '" << module << "' reports that it cannot run on the active "
"manager daemon: " << can_run_error << " (pass --force to force "
"enablement)";
"remove monitor named <name>", "mon", "rw",
FLAG(DEPRECATED))
COMMAND("mon feature ls "
- "name=with_value,type=CephChoices,strings=--with-value,req=false",
+ "name=with_value,type=CephBool,req=false",
"list available mon map features to be set/unset",
"mon", "r")
COMMAND("mon feature set "
"rename crush rule <srcname> to <dstname>",
"osd", "rw")
COMMAND("osd crush tree "
- "name=shadow,type=CephChoices,strings=--show-shadow,req=false",
+ "name=show_shadow,type=CephBool,req=false",
"dump crush buckets and items in a tree view",
"osd", "r")
COMMAND("osd crush ls name=node,type=CephString,goodchars=[A-Za-z0-9-_.]",
COMMAND("osd tier add "
"name=pool,type=CephPoolname "
"name=tierpool,type=CephPoolname "
- "name=force_nonempty,type=CephChoices,strings=--force-nonempty,req=false",
+ "name=force_nonempty,type=CephBool,req=false",
"add the tier <tierpool> (the second one) to base pool <pool> (the first one)",
"osd", "rw")
COMMAND("osd tier rm "
"mgr", "r")
COMMAND("mgr module enable "
"name=module,type=CephString "
- "name=force,type=CephChoices,strings=--force,req=false",
+ "name=force,type=CephBool,req=false",
"enable mgr module", "mgr", "rw")
COMMAND("mgr module disable "
"name=module,type=CephString",
"mon", "rwx",
FLAG(TELL))
COMMAND_WITH_FLAG("sync_force "
- "name=validate,type=CephChoices,strings=--yes-i-really-mean-it,req=false",
+ "name=yes_i_really_mean_it,type=CephBool,req=false",
"force sync of and clear monitor store",
"mon", "rw",
FLAG(TELL))
} else if (command == "quorum_status") {
_quorum_status(f, out);
} else if (command == "sync_force") {
- string validate;
- if ((!cmd_getval(cmdmap, "validate", validate)) ||
- (validate != "--yes-i-really-mean-it")) {
+ bool validate = false;
+ if (!cmd_getval(cmdmap, "yes_i_really_mean_it", validate)) {
+ std::string v;
+ if (cmd_getval(cmdmap, "validate", v) &&
+ v == "--yes-i-really-mean-it") {
+ validate = true;
+ }
+ }
+ if (!validate) {
err << "are you SURE? this will mean the monitor store will be erased "
"the next time the monitor is restarted. pass "
"'--yes-i-really-mean-it' if you really do.";
} else if (prefix == "mon feature ls") {
bool list_with_value = false;
- string with_value;
- if (cmd_getval(cmdmap, "with_value", with_value) &&
- with_value == "--with-value") {
- list_with_value = true;
- }
+ cmd_getval_compat_cephbool(cmdmap, "with_value", list_with_value);
MonMap *p = mon.monmap;
rs << "\n";
rdata.append(rs.str());
} else if (prefix == "osd crush tree") {
- string shadow;
- cmd_getval(cmdmap, "shadow", shadow);
- bool show_shadow = shadow == "--show-shadow";
+ bool show_shadow = false;
+ if (!cmd_getval_compat_cephbool(cmdmap, "show_shadow", show_shadow)) {
+ std::string shadow;
+ if (cmd_getval(cmdmap, "shadow", shadow) &&
+ shadow == "--show-shadow") {
+ show_shadow = true;
+ }
+ }
boost::scoped_ptr<Formatter> f(Formatter::create(format));
if (f) {
f->open_object_section("crush_tree");
}
// make sure new tier is empty
- string force_nonempty;
- cmd_getval(cmdmap, "force_nonempty", force_nonempty);
+ bool force_nonempty = false;
+ cmd_getval_compat_cephbool(cmdmap, "force_nonempty", force_nonempty);
const pool_stat_t *pstats = mon.mgrstatmon()->get_pool_stat(tierpool_id);
if (pstats && pstats->stats.sum.num_objects != 0 &&
- force_nonempty != "--force-nonempty") {
+ !force_nonempty) {
ss << "tier pool '" << tierpoolstr << "' is not empty; --force-nonempty to force";
err = -ENOTEMPTY;
goto reply;
goto reply;
}
if ((!tp->removed_snaps.empty() || !tp->snaps.empty()) &&
- ((force_nonempty != "--force-nonempty") ||
- (!g_conf()->mon_debug_unsafe_allow_tier_with_nonempty_snaps))) {
+ (!force_nonempty ||
+ !g_conf()->mon_debug_unsafe_allow_tier_with_nonempty_snaps)) {
ss << "tier pool '" << tierpoolstr << "' has snapshot state; it cannot be added as a tier without breaking the pool";
err = -ENOTEMPTY;
goto reply;