From d72afdfcbf3bac34238eb0f1d6825dcbc5854506 Mon Sep 17 00:00:00 2001 From: Ilya Dryomov Date: Wed, 19 Jan 2022 12:54:23 +0100 Subject: [PATCH] rbd: add missing switch arguments for recognition by get_command_spec() Currently this $ rbd --all children img doesn't work, while this $ rbd children --all img or this $ rbd children img --all does. The issue is that -a/--all isn't on the list of known switch arguments. The "rbd children" example may seem contrived but for more complicated commands such as "rbd device map" mixing switches and positional arguments occurs naturally: $ rbd device --device-type nbd --options try-netlink --show-cookie map img Fixes: https://tracker.ceph.com/issues/53935 Signed-off-by: Ilya Dryomov (cherry picked from commit e1b4811bc324236892e43a6bb841d6278fe1584e) Conflicts: src/tools/rbd/ArgumentTypes.h [ snapshot quiesce support not in octopus ] src/tools/rbd/action/Device.cc [ nbd cookie support not in octopus ] src/tools/rbd/action/Migration.cc [ import-only migration not supported in octopus ] src/tools/rbd/action/Wnbd.cc [ wnbd support not in octopus ] --- src/tools/rbd/ArgumentTypes.h | 4 +++- src/tools/rbd/action/Children.cc | 1 + src/tools/rbd/action/Device.cc | 3 ++- src/tools/rbd/action/Diff.cc | 1 - src/tools/rbd/action/Export.cc | 1 - src/tools/rbd/action/Nbd.cc | 2 -- src/tools/rbd/action/Trash.cc | 2 -- src/tools/rbd/action/TrashPurgeSchedule.cc | 2 ++ 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/tools/rbd/ArgumentTypes.h b/src/tools/rbd/ArgumentTypes.h index 0554acceee967..5cc6955fe5096 100644 --- a/src/tools/rbd/ArgumentTypes.h +++ b/src/tools/rbd/ArgumentTypes.h @@ -84,7 +84,9 @@ static const std::string NO_ERROR("no-error"); static const std::string LIMIT("limit"); static const std::set SWITCH_ARGUMENTS = { - WHOLE_OBJECT, NO_PROGRESS, PRETTY_FORMAT, VERBOSE, NO_ERROR}; + WHOLE_OBJECT, IMAGE_SHARED, IMAGE_THICK_PROVISION, IMAGE_FLATTEN, + NO_PROGRESS, PRETTY_FORMAT, VERBOSE, NO_ERROR +}; struct ImageSize {}; struct ImageOrder {}; diff --git a/src/tools/rbd/action/Children.cc b/src/tools/rbd/action/Children.cc index f459e92b761c3..58e861b6928bc 100644 --- a/src/tools/rbd/action/Children.cc +++ b/src/tools/rbd/action/Children.cc @@ -157,6 +157,7 @@ int execute(const po::variables_map &vm, return 0; } +Shell::SwitchArguments switched_arguments({"all", "a", "descendants"}); Shell::Action action( {"children"}, {}, "Display children of an image or its snapshot.", "", &get_arguments, &execute); diff --git a/src/tools/rbd/action/Device.cc b/src/tools/rbd/action/Device.cc index 3fdf2ef50aab6..11edeab27500f 100644 --- a/src/tools/rbd/action/Device.cc +++ b/src/tools/rbd/action/Device.cc @@ -163,7 +163,8 @@ int execute_unmap(const po::variables_map &vm, return (*get_device_operations(vm)->execute_unmap)(vm, ceph_global_init_args); } -Shell::SwitchArguments switched_arguments({"read-only", "exclusive"}); +Shell::SwitchArguments switched_arguments({"exclusive", "force", "read-only"}); + Shell::Action action_list( {"device", "list"}, {"showmapped"}, "List mapped rbd images.", "", &get_list_arguments, &execute_list); diff --git a/src/tools/rbd/action/Diff.cc b/src/tools/rbd/action/Diff.cc index 3729469c50dad..838ef6cc5109c 100644 --- a/src/tools/rbd/action/Diff.cc +++ b/src/tools/rbd/action/Diff.cc @@ -132,7 +132,6 @@ int execute(const po::variables_map &vm, return 0; } -Shell::SwitchArguments switched_arguments({at::WHOLE_OBJECT}); Shell::Action action( {"diff"}, {}, "Print extents that differ since a previous snap, or image creation.", "", diff --git a/src/tools/rbd/action/Export.cc b/src/tools/rbd/action/Export.cc index b5b82f4c0dcac..c0843856d03f7 100644 --- a/src/tools/rbd/action/Export.cc +++ b/src/tools/rbd/action/Export.cc @@ -308,7 +308,6 @@ int execute_diff(const po::variables_map &vm, return 0; } -Shell::SwitchArguments switched_arguments({at::WHOLE_OBJECT}); Shell::Action action_diff( {"export-diff"}, {}, "Export incremental diff to file.", "", &get_arguments_diff, &execute_diff); diff --git a/src/tools/rbd/action/Nbd.cc b/src/tools/rbd/action/Nbd.cc index 5c55adea4e765..55f8e36a78cb0 100644 --- a/src/tools/rbd/action/Nbd.cc +++ b/src/tools/rbd/action/Nbd.cc @@ -267,8 +267,6 @@ int execute_unmap_deprecated(const po::variables_map &vm, return execute_unmap(vm, ceph_global_args); } -Shell::SwitchArguments switched_arguments({"read-only", "exclusive"}); - Shell::Action action_show_deprecated( {"nbd", "list"}, {"nbd", "ls"}, "List the nbd devices already used.", "", &get_list_arguments_deprecated, &execute_list_deprecated, false); diff --git a/src/tools/rbd/action/Trash.cc b/src/tools/rbd/action/Trash.cc index b3e6d19168e69..a887f0d31da6c 100644 --- a/src/tools/rbd/action/Trash.cc +++ b/src/tools/rbd/action/Trash.cc @@ -514,7 +514,6 @@ int execute_restore(const po::variables_map &vm, return r; } - Shell::Action action_move( {"trash", "move"}, {"trash", "mv"}, "Move an image to the trash.", "", &get_move_arguments, &execute_move); @@ -527,7 +526,6 @@ Shell::Action action_purge( {"trash", "purge"}, {}, "Remove all expired images from trash.", "", &get_purge_arguments, &execute_purge); -Shell::SwitchArguments switched_arguments({"long", "l"}); Shell::Action action_list( {"trash", "list"}, {"trash", "ls"}, "List trash images.", "", &get_list_arguments, &execute_list); diff --git a/src/tools/rbd/action/TrashPurgeSchedule.cc b/src/tools/rbd/action/TrashPurgeSchedule.cc index f090754c4b971..0f92e762bc2fd 100644 --- a/src/tools/rbd/action/TrashPurgeSchedule.cc +++ b/src/tools/rbd/action/TrashPurgeSchedule.cc @@ -332,6 +332,8 @@ int execute_status(const po::variables_map &vm, return 0; } +Shell::SwitchArguments switched_arguments({"recursive", "R"}); + Shell::Action add_action( {"trash", "purge", "schedule", "add"}, {}, "Add trash purge schedule.", "", &get_arguments_add, &execute_add); -- 2.39.5