]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/config: parse --default-$option as a default value
authorSage Weil <sage@redhat.com>
Mon, 25 Mar 2019 18:40:19 +0000 (13:40 -0500)
committerSage Weil <sage@redhat.com>
Tue, 26 Mar 2019 16:00:27 +0000 (11:00 -0500)
Sometimes it is useful to specify an alternative default value for an
option via the command line such that it has a lower priority than the
mon config database, config file, the rest of the command line, or the
environment.

Signed-off-by: Sage Weil <sage@redhat.com>
qa/standalone/osd/osd-config.sh
src/common/config.cc

index c850ecd35b9c55ddadadfeda6889adaf9ab1032c..126c2f7dee295a82490c23923cc9a6cefa83dd2e 100755 (executable)
@@ -74,6 +74,22 @@ function TEST_config_track() {
     CEPH_ARGS='' ceph --admin-daemon $(get_asok_path osd.0) log reopen || return 1
 }
 
+function TEST_default_adjustment() {
+    a=$(ceph-osd --no-mon-config --show-config-value rgw_torrent_origin)
+    b=$(ceph-osd --no-mon-config --show-config-value rgw_torrent_origin --default-rgw-torrent-origin default)
+    c=$(ceph-osd --no-mon-config --show-config-value rgw_torrent_origin --default-rgw-torrent-origin arg)
+    [ "$a" != "default" ] || return 1
+    [ "$b" = "default" ] || return 1
+    [ "$c" = "arg" ] || return 1
+
+    a=$(ceph-osd --no-mon-config --show-config-value log_to_file)
+    b=$(ceph-osd --no-mon-config --show-config-value log_to_file --default-log-to-file=false)
+    c=$(ceph-osd --no-mon-config --show-config-value log_to_file --default-log-to-file=false --log-to-file)
+    [ "$a" = "true" ] || return 1
+    [ "$b" = "false" ] || return 1
+    [ "$c" = "true" ] || return 1
+}
+
 main osd-config "$@"
 
 # Local Variables:
index 10f76d1bbb78080feadd8af765f1a754f416ef8b..d1895a21c0b735d7b467835f0cae41068095e80d 100644 (file)
@@ -674,7 +674,17 @@ int md_config_t::parse_option(ConfigValues& values,
     std::string as_option("--");
     as_option += opt.name;
     option_name = opt.name;
-    if (opt.type == Option::TYPE_BOOL) {
+    if (ceph_argparse_witharg(
+         args, i, &val, err,
+         string(string("--default-") + opt.name).c_str(), (char*)NULL)) {
+      if (!err.str().empty()) {
+        error_message = err.str();
+       ret = -EINVAL;
+       break;
+      }
+      ret = _set_val(values, tracker,  val, opt, CONF_DEFAULT, &error_message);
+      break;
+    } else if (opt.type == Option::TYPE_BOOL) {
       int res;
       if (ceph_argparse_binary_flag(args, i, &res, oss, as_option.c_str(),
                                    (char*)NULL)) {