This way it can be used to fast cancel/undo the last command.
Also make the tip message a litter bit nicer..
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
if "$@"; then return 1; else return 0; fi
}
+# some of the commands are just not idempotent.
+function without_test_dup_command()
+{
+ if [ -z ${CEPH_CLI_TEST_DUP_COMMAND+x} ]; then
+ $@
+ else
+ local saved=${CEPH_CLI_TEST_DUP_COMMAND}
+ unset CEPH_CLI_TEST_DUP_COMMAND
+ $@
+ CEPH_CLI_TEST_DUP_COMMAND=saved
+ fi
+}
+
ceph config dump
# value validation
ceph config rm mon debug_asok
ceph config get mon.a debug_asok | grep 33
ceph config rm global debug_asok
+without_test_dup_command ceph config reset
+ceph config get mon.a debug_asok | grep 33
+without_test_dup_command ceph config reset
# help
ceph config help debug_asok | grep debug_asok
}
goto update;
} else if (prefix == "config reset") {
- int64_t num;
- if (!cmd_getval(g_ceph_context, cmdmap, "num", num)) {
- err = -EINVAL;
- ss << "must specify what to revert to";
- goto reply;
- }
- if (num < 0 ||
- (num > 0 && num > (int64_t)version)) {
+ int64_t num = -1;
+ cmd_getval(g_ceph_context, cmdmap, "num", num);
+ int64_t revert_to = num;
+ if (revert_to < 0) // revert to last version
+ revert_to = version - 1;
+ if (revert_to > (int64_t)version) {
err = -EINVAL;
- ss << "must specify a valid version to revert to";
+ ss << "must specify a valid historical version to revert to; "
+ << "see 'ceph config log' for a list of avialable configuration "
+ << "historical versions";
goto reply;
}
- if (num == (int64_t)version) {
+ if (revert_to == (int64_t)version) {
err = 0;
goto reply;
}
- ceph_assert((version_t)num < version);
- for (int64_t v = version; v > num; --v) {
+ for (int64_t v = version; v > revert_to; --v) {
ConfigChangeSet ch;
load_changeset(v, &ch);
for (auto& i : ch.diff) {
}
}
}
- pending_description = string("reset to ") + stringify(num);
+ pending_description = string("reset to ") + stringify(revert_to);
goto update;
} else if (prefix == "config assimilate-conf") {
ConfFile cf;
COMMAND("config log name=num,type=CephInt,req=False",
"Show recent history of config changes",
"config", "r")
-COMMAND("config reset" \
- " name=num,type=CephInt",
- "Revert configuration to previous state",
+COMMAND("config reset " \
+ "name=num,type=CephInt,range=0,req=False",
+ "Revert configuration to a historical version specified by <num>, "
+ "or simply revert to last version",
"config", "rw")
COMMAND("config generate-minimal-conf",
"Generate a minimal ceph.conf file",