From: David Zafman Date: Fri, 7 Sep 2018 22:07:16 +0000 (-0700) Subject: tools: ceph-objectstore-tool: Allow target level as first positional param X-Git-Tag: v14.0.1~291^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f6394d8892d9c1f77ef5c82341bb4ee9c416182e;p=ceph-ci.git tools: ceph-objectstore-tool: Allow target level as first positional param Maintain compatibility with --arg1 specification Fixes: http://tracker.ceph.com/issues/35846 Signed-off-by: David Zafman --- diff --git a/src/tools/ceph_objectstore_tool.cc b/src/tools/ceph_objectstore_tool.cc index 3125facf415..85526a1aa67 100644 --- a/src/tools/ceph_objectstore_tool.cc +++ b/src/tools/ceph_objectstore_tool.cc @@ -3186,8 +3186,7 @@ int main(int argc, char **argv) positional.add_options() ("object", po::value(&object), "'' for pgmeta_oid, object name or ghobject in json") ("objcmd", po::value(&objcmd), "command [(get|set)-bytes, (get|set|rm)-(attr|omap), (get|set)-omaphdr, list-attrs, list-omap, remove]") - ("arg1", po::value(&arg1), "arg1 based on cmd, " - "for apply-layout-settings: target hash level split to") + ("arg1", po::value(&arg1), "arg1 based on cmd") ("arg2", po::value(&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);