From da5b1ecd161751e00cc9ddf30abeba338c129fa8 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Mon, 15 Jan 2024 17:50:57 +0300 Subject: [PATCH] tools/ceph-bluestore-tool: aliases for --path and --command options. Introduce --data-path and --op respectively to match ceph-objectstore-tool options. Signed-off-by: Igor Fedotov (cherry picked from commit c0983e9c98903b7f91907c9d46c8497323fd4238) --- src/os/bluestore/bluestore_tool.cc | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/os/bluestore/bluestore_tool.cc b/src/os/bluestore/bluestore_tool.cc index 2126c436d17..9f19b5c17cc 100644 --- a/src/os/bluestore/bluestore_tool.cc +++ b/src/os/bluestore/bluestore_tool.cc @@ -278,8 +278,8 @@ int main(int argc, char **argv) vector devs; vector devs_source; string dev_target; - string path; - string action; + string path, path_aux; + string action, action_aux; string log_file; string input_file; string dest_file; @@ -295,6 +295,8 @@ int main(int argc, char **argv) ("help,h", "produce help message") (",i", po::value(&osd_instance), "OSD instance. Requires access to monitor/ceph.conf") ("path", po::value(&path), "bluestore path") + ("data-path", po::value(&path_aux), + "--path alias, ignored if the latter is present") ("out-dir", po::value(&out_dir), "output directory") ("input-file", po::value(&input_file), "import file") ("dest-file", po::value(&dest_file), "destination file") @@ -310,6 +312,8 @@ int main(int argc, char **argv) ("yes-i-really-really-mean-it", "additional confirmation for dangerous commands") ("sharding", po::value(&new_sharding), "new sharding to apply") ("resharding-ctrl", po::value(&resharding_ctrl), "gives control over resharding procedure details") + ("op", po::value(&action_aux), + "--command alias, ignored if the latter is present") ; po::options_description po_positional("Positional options"); po_positional.add_options() @@ -361,6 +365,26 @@ int main(int argc, char **argv) std::cerr << e.what() << std::endl; exit(EXIT_FAILURE); } + if (action != action_aux && !action.empty() && !action_aux.empty()) { + std::cerr + << " Ambiguous --op and --command options, please provide a single one." + << std::endl; + exit(EXIT_FAILURE); + } + if (action.empty()) { + action.swap(action_aux); + } + if (!path_aux.empty()) { + if (path.empty()) { + path.swap(path_aux); + } else if (path != path_aux) { + std::cerr + << " Ambiguous --data-path and --path options, please provide a single one." + << std::endl; + exit(EXIT_FAILURE); + } + }; + // normalize path (remove ending '/' if any) if (path.size() > 1 && *(path.end() - 1) == '/') { path.resize(path.size() - 1); -- 2.39.5