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: v18.0.0~1517^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44669%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 --- diff --git a/src/tools/rbd/ArgumentTypes.h b/src/tools/rbd/ArgumentTypes.h index 57473f31c656..39d374c64c3c 100644 --- a/src/tools/rbd/ArgumentTypes.h +++ b/src/tools/rbd/ArgumentTypes.h @@ -87,7 +87,8 @@ static const std::string SKIP_QUIESCE("skip-quiesce"); static const std::string IGNORE_QUIESCE_ERROR("ignore-quiesce-error"); static const std::set SWITCH_ARGUMENTS = { - WHOLE_OBJECT, NO_PROGRESS, PRETTY_FORMAT, VERBOSE, NO_ERR, SKIP_QUIESCE, + WHOLE_OBJECT, IMAGE_SHARED, IMAGE_THICK_PROVISION, IMAGE_FLATTEN, + NO_PROGRESS, PRETTY_FORMAT, VERBOSE, NO_ERR, SKIP_QUIESCE, IGNORE_QUIESCE_ERROR }; diff --git a/src/tools/rbd/action/Children.cc b/src/tools/rbd/action/Children.cc index f459e92b761c..58e861b6928b 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 20cff569f9b6..bfe60c273df7 100644 --- a/src/tools/rbd/action/Device.cc +++ b/src/tools/rbd/action/Device.cc @@ -247,7 +247,9 @@ int execute_detach(const po::variables_map &vm, return (*get_device_operations(vm)->execute_detach)(vm, ceph_global_init_args); } -Shell::SwitchArguments switched_arguments({"read-only", "exclusive"}); +Shell::SwitchArguments switched_arguments({"exclusive", "force", "quiesce", + "read-only", "show-cookie"}); + 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 3729469c50da..838ef6cc5109 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 dff10c97e1ac..ddcf0f2c30ce 100644 --- a/src/tools/rbd/action/Export.cc +++ b/src/tools/rbd/action/Export.cc @@ -311,7 +311,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/Migration.cc b/src/tools/rbd/action/Migration.cc index 05b15f1869cc..1ce6201d9648 100644 --- a/src/tools/rbd/action/Migration.cc +++ b/src/tools/rbd/action/Migration.cc @@ -406,6 +406,8 @@ int execute_commit(const po::variables_map &vm, return 0; } +Shell::SwitchArguments switched_arguments({"import-only"}); + Shell::Action action_prepare( {"migration", "prepare"}, {}, "Prepare image migration.", at::get_long_features_help(), &get_prepare_arguments, &execute_prepare); diff --git a/src/tools/rbd/action/Nbd.cc b/src/tools/rbd/action/Nbd.cc index f36537430c83..68345f43dd6c 100644 --- a/src/tools/rbd/action/Nbd.cc +++ b/src/tools/rbd/action/Nbd.cc @@ -415,8 +415,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 cb4c8b8a93e5..538318508570 100644 --- a/src/tools/rbd/action/Trash.cc +++ b/src/tools/rbd/action/Trash.cc @@ -518,7 +518,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); @@ -531,7 +530,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 f090754c4b97..0f92e762bc2f 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); diff --git a/src/tools/rbd/action/Wnbd.cc b/src/tools/rbd/action/Wnbd.cc index 4da6be33b5d5..ae40fe538e3c 100644 --- a/src/tools/rbd/action/Wnbd.cc +++ b/src/tools/rbd/action/Wnbd.cc @@ -224,8 +224,6 @@ int execute_detach(const po::variables_map &vm, return -EOPNOTSUPP; } -Shell::SwitchArguments switched_arguments({"read-only", "exclusive"}); - } // namespace wnbd } // namespace action } // namespace rbd