]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rados.cc: add --object-locator and object locator output to ls
authorSamuel Just <samuel.just@dreamhost.com>
Thu, 8 Dec 2011 01:06:01 +0000 (17:06 -0800)
committerSamuel Just <samuel.just@dreamhost.com>
Fri, 9 Dec 2011 21:44:37 +0000 (13:44 -0800)
--object-locator locator causes io to use the specified locator.  For
objects with non-empty locators, rados pool ls will output the locator
as well.

Signed-off-by: Samuel Just <samuel.just@dreamhost.com>
src/rados.cc

index d77aa2f4da037b330b2e75d242b9fea668416d4f..1ea886d794999afd24de72fde9222bc2bc1ede44 100644 (file)
@@ -90,6 +90,8 @@ void usage(ostream& out)
 STR(DEFAULT_NUM_RADOS_WORKER_THREADS) ")\n"
 "\n"
 "GLOBAL OPTIONS:\n"
+"   --object_locator object_locator\n"
+"        set object_locator for operation"
 "   -p pool\n"
 "   --pool=pool\n"
 "        select given pool by name\n"
@@ -563,6 +565,7 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   int ret;
   bool create_pool = false;
   const char *pool_name = NULL;
+  string oloc;
   int concurrent_ios = 16;
   int op_size = 1 << 22;
   const char *snapname = NULL;
@@ -591,6 +594,10 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
   if (i != opts.end()) {
     pool_name = i->second.c_str();
   }
+  i = opts.find("object_locator");
+  if (i != opts.end()) {
+    oloc = i->second;
+  }
   i = opts.find("category");
   if (i != opts.end()) {
     category = i->second;
@@ -713,6 +720,9 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       return 1;
     }
   }
+  if (oloc.size()) {
+    io_ctx.locator_set_key(oloc);
+  }
   if (snapid != CEPH_NOSNAP) {
     string name;
     ret = io_ctx.snap_get_name(snapid, &name);
@@ -855,7 +865,10 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts,
       librados::ObjectIterator i = io_ctx.objects_begin();
       librados::ObjectIterator i_end = io_ctx.objects_end();
       for (; i != i_end; ++i) {
-       *outstream << *i << std::endl;
+       if (i->second.size())
+         *outstream << i->first << "\t" << i->second << std::endl;
+       else
+         *outstream << i->first << std::endl;
       }
     }
     if (!stdout)
@@ -1274,6 +1287,8 @@ int main(int argc, const char **argv)
       opts["pretty-format"] = "true";
     } else if (ceph_argparse_witharg(args, i, &val, "-p", "--pool", (char*)NULL)) {
       opts["pool"] = val;
+    } else if (ceph_argparse_witharg(args, i, &val, "--object-locator" , (char *)NULL)) {
+      opts["object_locator"] = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--category", (char*)NULL)) {
       opts["category"] = val;
     } else if (ceph_argparse_witharg(args, i, &val, "-t", "--concurrent-ios", (char*)NULL)) {