]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools: ceph-objectstore-tool: Allow target level as first positional param 23989/head
authorDavid Zafman <dzafman@redhat.com>
Fri, 7 Sep 2018 22:07:16 +0000 (15:07 -0700)
committerDavid Zafman <dzafman@redhat.com>
Wed, 12 Sep 2018 00:33:03 +0000 (17:33 -0700)
Maintain compatibility with --arg1 specification

Fixes: http://tracker.ceph.com/issues/35846
Signed-off-by: David Zafman <dzafman@redhat.com>
src/tools/ceph_objectstore_tool.cc

index 3125facf415b580bd40907aa61ed8d65ac78cfcb..85526a1aa67269f2fd0d89254fdaf6a5437eb6fe 100644 (file)
@@ -3186,8 +3186,7 @@ int main(int argc, char **argv)
   positional.add_options()
     ("object", po::value<string>(&object), "'' for pgmeta_oid, object name or ghobject in json")
     ("objcmd", po::value<string>(&objcmd), "command [(get|set)-bytes, (get|set|rm)-(attr|omap), (get|set)-omaphdr, list-attrs, list-omap, remove]")
-    ("arg1", po::value<string>(&arg1), "arg1 based on cmd, "
-     "for apply-layout-settings: target hash level split to")
+    ("arg1", po::value<string>(&arg1), "arg1 based on cmd")
     ("arg2", po::value<string>(&arg2), "arg2 based on cmd")
     ;
 
@@ -3299,7 +3298,7 @@ int main(int argc, char **argv)
     usage(desc);
     return 1;
   }
-  if (op != "list" &&
+  if (op != "list" && op != "apply-layout-settings" &&
       vm.count("op") && vm.count("object")) {
     cerr << "Can't specify both --op and object command syntax" << std::endl;
     usage(desc);
@@ -3311,7 +3310,7 @@ int main(int argc, char **argv)
     usage(desc);
     return 1;
   }
-  if (op != "list" && vm.count("object") && !vm.count("objcmd")) {
+  if (op != "list" && op != "apply-layout-settings" && vm.count("object") && !vm.count("objcmd")) {
     cerr << "Invalid syntax, missing command" << std::endl;
     usage(desc);
     return 1;
@@ -3580,7 +3579,14 @@ int main(int argc, char **argv)
 
   if (op == "apply-layout-settings") {
     int target_level = 0;
-    if (vm.count("arg1") && isdigit(arg1[0])) {
+    // Single positional argument with apply-layout-settings
+    // for target_level.
+    if (vm.count("object") && isdigit(object[0])) {
+      target_level = atoi(object.c_str());
+    // This requires --arg1 to be specified since
+    // this is the third positional argument and normally
+    // used with object operations.
+    } else if (vm.count("arg1") && isdigit(arg1[0])) {
       target_level = atoi(arg1.c_str());
     }
     ret = apply_layout_settings(fs, superblock, pool, pgid, dry_run, target_level);