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
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.
--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)
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;
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);
}
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;