]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: implement --show-config and --show-config-value <option>
authorSage Weil <sage@newdream.net>
Thu, 5 Apr 2012 20:25:52 +0000 (13:25 -0700)
committerSage Weil <sage@newdream.net>
Thu, 5 Apr 2012 20:25:52 +0000 (13:25 -0700)
Dump internal config value(s) to stdout and then exit.

Signed-off-by: Sage Weil <sage@newdream.net>
src/common/config.cc
src/common/config.h

index 23dfe1e62cbc11573bf196c4e149e37ff80f865f..62f61c25c9b6e99df3fdf662aa8f99909eacc09b 100644 (file)
@@ -276,6 +276,17 @@ void md_config_t::parse_env()
   }
 }
 
+void md_config_t::show_config(std::ostream& out)
+{
+  out << "name = " << name << std::endl;
+  for (int i = 0; i < NUM_CONFIG_OPTIONS; i++) {
+    config_option *opt = config_optionsp + i;
+    char *buf;
+    _get_val(opt->name, &buf, -1);
+    out << opt->name << " = " << buf << std::endl;
+  }
+}
+
 int md_config_t::parse_argv(std::vector<const char*>& args)
 {
   Mutex::Locker l(lock);
@@ -298,6 +309,17 @@ int md_config_t::parse_argv(std::vector<const char*>& args)
       cerr << cf << std::endl;
       _exit(0);
     }
+    else if (ceph_argparse_flag(args, i, "--show_config", (char*)NULL)) {
+      show_config(cout);
+      _exit(0);
+    }
+    else if (ceph_argparse_witharg(args, i, &val, "--show_config_value", (char*)NULL)) {
+      char *buf = 0;
+      _get_val(val.c_str(), &buf, -1);
+      if (buf)
+       std::cout << buf << std::endl;
+      _exit(0);
+    }
     else if (ceph_argparse_flag(args, i, "--foreground", "-f", (char*)NULL)) {
       set_val_or_die("daemonize", "false");
       set_val_or_die("pid_file", "");
index df835f8be3a997c71b437e6af417e95801a6d17c..6a166e70ed08d7d0610a252ff9d20fc6a111cfb5 100644 (file)
@@ -140,6 +140,8 @@ public:
   int get_val_from_conf_file(const std::vector <std::string> &sections,
                   const char *key, std::string &out, bool emeta) const;
 
+  void show_config(std::ostream& out);
+
 private:
   int parse_option(std::vector<const char*>& args,
                   std::vector<const char*>::iterator& i,