]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
config: accept list of possible conf file locations; include ./ceph.conf
authorSage Weil <sage@newdream.net>
Fri, 13 Nov 2009 18:47:52 +0000 (10:47 -0800)
committerSage Weil <sage@newdream.net>
Fri, 13 Nov 2009 18:47:52 +0000 (10:47 -0800)
This makes './ceph -w' work with './vstart.sh -x'.

src/config.cc
src/mon/MonClient.cc

index 3753660c336a5bb4ffaabf86bb8d92b0dde85ede..1493c984006d206ae5773e6b0c4123539ba02ea7 100644 (file)
@@ -32,6 +32,7 @@
 stringtable g_stab;
 
 #include "include/atomic.h"
+#include "include/str_list.h"
 
 #include "osd/osd_types.h"
 
@@ -315,7 +316,7 @@ static struct config_option config_optionsp[] = {
        OPTION(log_sym_dir, 0, OPT_STR, 0),
        OPTION(log_to_stdout, 0, OPT_BOOL, true),
        OPTION(pid_file, 0, OPT_STR, "/var/run/ceph/$type.$id.pid"),
-       OPTION(conf, 'c', OPT_STR, "/etc/ceph/ceph.conf"),
+       OPTION(conf, 'c', OPT_STR, "/etc/ceph/ceph.conf, ~/ceph/config, ceph.conf"),
        OPTION(chdir, 0, OPT_STR, "/"),
        OPTION(fake_clock, 0, OPT_BOOL, false),
        OPTION(fakemessenger_serialize, 0, OPT_BOOL, true),
@@ -1011,12 +1012,21 @@ void parse_startup_config_options(std::vector<const char*>& args, bool isdaemon,
   if (cf)
        delete cf;
 
-  cf = new ConfFile(g_conf.conf);
-
-  int ret = parse_config_file(cf, true);
+  // open new conf
+  string fn = g_conf.conf;
+  list<string> ls;
+  get_str_list(fn, ls);
+  bool read_conf = false;
+  for (list<string>::iterator p = ls.begin(); p != ls.end(); p++) {
+    cf = new ConfFile(p->c_str());
+    read_conf = parse_config_file(cf, true);
+    if (read_conf)
+      break;
+    delete cf;
+  }
 
-  if (conf_specified && !ret) {
-    cerr << "error reading config file " << g_conf.conf << std::endl;
+  if (conf_specified && !read_conf) {
+    cerr << "error reading config file(s) " << g_conf.conf << std::endl;
     exit(1);
   }
 
index 5aab9a41ba03321eabd0825a20394363a3d68592..3c2d8963260aad26cece506beb72aa5da88c7817 100644 (file)
@@ -74,31 +74,32 @@ int MonClient::build_initial_monmap()
   }
 
   // config file?
-  ConfFile a(g_conf.conf);
-  ConfFile b("ceph.conf");
-  ConfFile *c = 0;
-  
-  if (a.parse())
-    c = &a;
-  else if (b.parse())
-    c = &b;
-  if (c) {
-    static string monstr;
-    for (int i=0; i<15; i++) {
-      char monname[20];
-      char *val = 0;
-      sprintf(monname, "mon%d", i);
-      c->read(monname, "mon addr", &val, 0);
-      if (!val || !val[0])
+  string conf = g_conf.conf;
+  list<string> ls;
+  get_str_list(conf, ls);
+  if (!ls.empty()) {
+    for (list<string>::iterator p = ls.begin(); p != ls.end(); p++) {
+      ConfFile c(p->c_str());
+      if (c.parse()) {
+       static string monstr;
+       for (int i=0; i<15; i++) {
+         char monname[20];
+         char *val = 0;
+         sprintf(monname, "mon%d", i);
+         c.read(monname, "mon addr", &val, 0);
+         if (!val || !val[0])
+           break;
+         
+         entity_inst_t inst;
+         if (!parse_ip_port(val, inst.addr)) {
+           cerr << "unable to parse conf's addr for " << monname << " (" << val << ")" << std::endl;
+           continue;
+         }
+         inst.name = entity_name_t::MON(monmap.mon_inst.size());
+         monmap.add_mon(inst);
+       }
        break;
-      
-      entity_inst_t inst;
-      if (!parse_ip_port(val, inst.addr)) {
-       cerr << "unable to parse conf's addr for " << monname << " (" << val << ")" << std::endl;
-       continue;
       }
-      inst.name = entity_name_t::MON(monmap.mon_inst.size());
-      monmap.add_mon(inst);
     }
     if (monmap.size())
       return 0;