From: Ilya Dryomov Date: Wed, 19 Jan 2022 11:54:23 +0000 (+0100) Subject: rbd: add missing switch arguments for recognition by get_command_spec() X-Git-Tag: v15.2.16~15^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44741%2Fhead;p=ceph.git 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 ] --- diff --git a/src/tools/rbd/ArgumentTypes.h b/src/tools/rbd/ArgumentTypes.h index 0554acceee9..5cc6955fe50 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 f459e92b761..58e861b6928 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 3fdf2ef50aa..11edeab2750 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 3729469c50d..838ef6cc510 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 b5b82f4c0dc..c0843856d03 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 5c55adea4e7..55f8e36a78c 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 b3e6d19168e..a887f0d31da 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 f090754c4b9..0f92e762bc2 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);