]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados: Add namespace arg (--namespace, -N) to rados command
authorDavid Zafman <david.zafman@inktank.com>
Wed, 3 Jul 2013 19:32:17 +0000 (12:32 -0700)
committerDavid Zafman <david.zafman@inktank.com>
Tue, 9 Jul 2013 21:09:24 +0000 (14:09 -0700)
Signed-off-by: David Zafman <david.zafman@inktank.com>
src/rados.cc

index 7d6f2160cb4c4d068b0e28d6cc5593b411fb0406..dd9b4de179473fd06b8ba8b5296b7ef56557296f 100644 (file)
@@ -148,6 +148,9 @@ void usage(ostream& out)
 "        specify input or output file (for certain commands)\n"
 "   --create\n"
 "        create the pool or directory that was specified\n"
+"   -N namespace\n"
+"   --namespace=namespace\n"
+"        specify the namespace to use for the object\n"
 "\n"
 "BENCH OPTIONS:\n"
 "   -t N\n"
@@ -1046,7 +1049,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   bool create_pool = false;
   const char *pool_name = NULL;
   const char *target_pool_name = NULL;
-  string oloc, target_oloc;
+  string oloc, target_oloc, nspace;
   int concurrent_ios = 16;
   int op_size = 1 << 22;
   bool cleanup = true;
@@ -1178,6 +1181,10 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       return -EINVAL;
     }
   }
+  i = opts.find("namespace");
+  if (i != opts.end()) {
+    nspace = i->second;
+  }
 
 
   // open rados
@@ -1231,6 +1238,9 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   if (oloc.size()) {
     io_ctx.locator_set_key(oloc);
   }
+  if (!nspace.empty()) {
+    io_ctx.set_namespace(nspace);
+  }
   if (snapid != CEPH_NOSNAP) {
     string name;
     ret = io_ctx.snap_get_name(snapid, &name);
@@ -2321,6 +2331,8 @@ int main(int argc, const char **argv)
       opts["lock-duration"] = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--lock-type", (char*)NULL)) {
       opts["lock-type"] = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "-N", "--namespace", (char*)NULL)) {
+      opts["namespace"] = val;
     } else {
       if (val[0] == '-')
         usage_exit();