]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
config: add distinct UUID type
authorSage Weil <sage@newdream.net>
Thu, 5 Apr 2012 20:35:07 +0000 (13:35 -0700)
committerSage Weil <sage@newdream.net>
Thu, 5 Apr 2012 20:35:07 +0000 (13:35 -0700)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/common/config.cc
src/common/config.h

index 762c9a569b586e0b55f16ab6453e942d05eed652..80b6e199954996cf9c7b92c8a0080ba925dce86d 100644 (file)
@@ -422,7 +422,8 @@ int md_config_t::parse_option(std::vector<const char*>& args,
     else if (ceph_argparse_witharg(args, i, &val,
                                   as_option.c_str(), (char*)NULL)) {
       if (oss && (
-                 ((opt->type == OPT_STR) || (opt->type == OPT_ADDR)) &&
+                 ((opt->type == OPT_STR) || (opt->type == OPT_ADDR) ||
+                  (opt->type == OPT_UUID)) &&
                  (observers.find(opt->name) == observers.end()))) {
        *oss << "You cannot change " << opt->name << " using injectargs.\n";
        ret = -ENOSYS;
@@ -595,7 +596,8 @@ int md_config_t::set_val(const char *key, const char *val)
     if (strcmp(opt->name, k.c_str()) == 0) {
       if (internal_safe_to_start_threads) {
        // If threads have been started...
-       if ((opt->type == OPT_STR) || (opt->type == OPT_ADDR)) {
+       if ((opt->type == OPT_STR) || (opt->type == OPT_ADDR) ||
+           (opt->type == OPT_UUID)) {
          // And this is NOT an integer valued variable....
          if (observers.find(opt->name) == observers.end()) {
            // And there is no observer to safely change it...
@@ -662,10 +664,12 @@ int md_config_t::_get_val(const char *key, char **buf, int len) const
       case OPT_U64:
         oss << *(uint64_t*)opt->conf_ptr(this);
         break;
-      case OPT_ADDR: {
+      case OPT_ADDR:
         oss << *(entity_addr_t*)opt->conf_ptr(this);
         break;
-      }
+      case OPT_UUID:
+       oss << *(uuid_d*)opt->conf_ptr(this);
+        break;
     }
     string str(oss.str());
     int l = strlen(str.c_str()) + 1;
@@ -801,6 +805,12 @@ int md_config_t::set_val_raw(const char *val, const config_option *opt)
       }
       return 0;
     }
+    case OPT_UUID: {
+      uuid_d *u = (uuid_d*)opt->conf_ptr(this);
+      if (!u->parse(val))
+       return -EINVAL;
+      return 0;
+    }
   }
   return -ENOSYS;
 }
index 262f4201fa9edeeceab77f06aa2c5ed4d1e4df71..274a4c81756561286faa4d866d5a2eba4d672e13 100644 (file)
@@ -183,6 +183,7 @@ public:
 #define OPTION_OPT_ADDR(name) const entity_addr_t name;
 #define OPTION_OPT_U32(name) const uint32_t name;
 #define OPTION_OPT_U64(name) const uint64_t name;
+#define OPTION_OPT_UUID(name) const uuid_d name;
 #define OPTION(name, ty, init) OPTION_##ty(name)
 #define SUBSYS(name, log, gather)
 #define DEFAULT_SUBSYS(log, gather)
@@ -196,6 +197,7 @@ public:
 #undef OPTION_OPT_ADDR
 #undef OPTION_OPT_U32
 #undef OPTION_OPT_U64
+#undef OPTION_OPT_UUID
 #undef OPTION
 #undef SUBSYS
 #undef DEFAULT_SUBSYS
@@ -209,7 +211,7 @@ public:
 
 typedef enum {
        OPT_INT, OPT_LONGLONG, OPT_STR, OPT_DOUBLE, OPT_FLOAT, OPT_BOOL,
-       OPT_ADDR, OPT_U32, OPT_U64
+       OPT_ADDR, OPT_U32, OPT_U64, OPT_UUID
 } opt_type_t;
 
 bool ceph_resolve_file_search(const std::string& filename_list,