mirror of
https://github.com/ceph/ceph
synced 2025-01-04 10:12:30 +00:00
rbd: add option to list all descendant images
Signed-off-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
parent
f765245d57
commit
d10d40fd49
@ -555,6 +555,7 @@ test_clone_v2() {
|
||||
rbd clone --rbd-default-clone-format=1 test1@1 test4
|
||||
|
||||
rbd children test1@1 | sort | tr '\n' ' ' | grep -E "test2.*test3.*test4"
|
||||
rbd children --descendants test1 | sort | tr '\n' ' ' | grep -E "test2.*test3.*test4"
|
||||
|
||||
rbd remove test4
|
||||
rbd snap unprotect test1@1
|
||||
|
@ -173,7 +173,8 @@
|
||||
rbd help children
|
||||
usage: rbd children [--pool <pool>] [--namespace <namespace>]
|
||||
[--image <image>] [--snap <snap>] [--snap-id <snap-id>]
|
||||
[--all] [--format <format>] [--pretty-format]
|
||||
[--all] [--descendants] [--format <format>]
|
||||
[--pretty-format]
|
||||
<image-or-snap-spec>
|
||||
|
||||
Display children of an image or its snapshot.
|
||||
@ -190,6 +191,7 @@
|
||||
--snap arg snapshot name
|
||||
--snap-id arg snapshot id
|
||||
-a [ --all ] list all children (include trash)
|
||||
--descendants include all descendants
|
||||
--format arg output format (plain, json, or xml) [default: plain]
|
||||
--pretty-format pretty formatting (json and xml)
|
||||
|
||||
|
@ -17,11 +17,16 @@ namespace at = argument_types;
|
||||
namespace po = boost::program_options;
|
||||
|
||||
int do_list_children(librados::IoCtx &io_ctx, librbd::Image &image,
|
||||
bool all_flag, Formatter *f)
|
||||
bool all_flag, bool descendants_flag, Formatter *f)
|
||||
{
|
||||
std::vector<librbd::linked_image_spec_t> children;
|
||||
librbd::RBD rbd;
|
||||
int r = image.list_children3(&children);
|
||||
int r;
|
||||
if (descendants_flag) {
|
||||
r = image.list_descendants(&children);
|
||||
} else {
|
||||
r = image.list_children3(&children);
|
||||
}
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -74,6 +79,8 @@ void get_arguments(po::options_description *positional,
|
||||
at::add_snap_id_option(options);
|
||||
options->add_options()
|
||||
("all,a", po::bool_switch(), "list all children (include trash)");
|
||||
options->add_options()
|
||||
("descendants", po::bool_switch(), "include all descendants");
|
||||
at::add_format_options(options);
|
||||
}
|
||||
|
||||
@ -132,7 +139,8 @@ int execute(const po::variables_map &vm,
|
||||
return r;
|
||||
}
|
||||
|
||||
r = do_list_children(io_ctx, image, vm["all"].as<bool>(), formatter.get());
|
||||
r = do_list_children(io_ctx, image, vm["all"].as<bool>(),
|
||||
vm["descendants"].as<bool>(), formatter.get());
|
||||
if (r < 0) {
|
||||
std::cerr << "rbd: listing children failed: " << cpp_strerror(r)
|
||||
<< std::endl;
|
||||
|
Loading…
Reference in New Issue
Block a user