mirror of
https://github.com/ceph/ceph
synced 2025-01-04 10:12:30 +00:00
tools/rbd: make 'children' command support --image-id
Fixes: https://tracker.ceph.com/issues/64376 Signed-off-by: Mykola Golub <mykola.golub@clyso.com>
This commit is contained in:
parent
bab43e83ad
commit
5442f7eb21
@ -133,6 +133,8 @@ CephFS: Disallow delegating preallocated inode ranges to clients. Config
|
|||||||
notifications to topics owned by other users. A new configuration parameter:
|
notifications to topics owned by other users. A new configuration parameter:
|
||||||
``rgw_topic_require_publish_policy`` can be enabled to deny ``sns:Publish``
|
``rgw_topic_require_publish_policy`` can be enabled to deny ``sns:Publish``
|
||||||
permissions unless explicitly granted by topic policy.
|
permissions unless explicitly granted by topic policy.
|
||||||
|
* RBD: The option ``--image-id`` has been added to `rbd children` CLI command,
|
||||||
|
so it can be run for images in the trash.
|
||||||
|
|
||||||
>=18.0.0
|
>=18.0.0
|
||||||
|
|
||||||
|
@ -432,6 +432,7 @@ test_trash() {
|
|||||||
rbd trash mv test2
|
rbd trash mv test2
|
||||||
ID=`rbd trash ls | cut -d ' ' -f 1`
|
ID=`rbd trash ls | cut -d ' ' -f 1`
|
||||||
rbd info --image-id $ID | grep "rbd image 'test2'"
|
rbd info --image-id $ID | grep "rbd image 'test2'"
|
||||||
|
rbd children --image-id $ID | wc -l | grep 0
|
||||||
|
|
||||||
rbd trash restore $ID
|
rbd trash restore $ID
|
||||||
rbd ls | grep test2
|
rbd ls | grep test2
|
||||||
@ -449,6 +450,7 @@ test_trash() {
|
|||||||
rbd create $RBD_CREATE_ARGS -s 1 test1
|
rbd create $RBD_CREATE_ARGS -s 1 test1
|
||||||
rbd snap create test1@snap1
|
rbd snap create test1@snap1
|
||||||
rbd snap protect test1@snap1
|
rbd snap protect test1@snap1
|
||||||
|
rbd clone test1@snap1 clone
|
||||||
rbd trash mv test1
|
rbd trash mv test1
|
||||||
|
|
||||||
rbd trash ls | grep test1
|
rbd trash ls | grep test1
|
||||||
@ -459,7 +461,10 @@ test_trash() {
|
|||||||
ID=`rbd trash ls | cut -d ' ' -f 1`
|
ID=`rbd trash ls | cut -d ' ' -f 1`
|
||||||
rbd snap ls --image-id $ID | grep -v 'SNAPID' | wc -l | grep 1
|
rbd snap ls --image-id $ID | grep -v 'SNAPID' | wc -l | grep 1
|
||||||
rbd snap ls --image-id $ID | grep '.*snap1.*'
|
rbd snap ls --image-id $ID | grep '.*snap1.*'
|
||||||
|
rbd children --image-id $ID | wc -l | grep 1
|
||||||
|
rbd children --image-id $ID | grep 'clone'
|
||||||
|
|
||||||
|
rbd rm clone
|
||||||
rbd snap unprotect --image-id $ID --snap snap1
|
rbd snap unprotect --image-id $ID --snap snap1
|
||||||
rbd snap rm --image-id $ID --snap snap1
|
rbd snap rm --image-id $ID --snap snap1
|
||||||
rbd snap ls --image-id $ID | grep -v 'SNAPID' | wc -l | grep 0
|
rbd snap ls --image-id $ID | grep -v 'SNAPID' | wc -l | grep 0
|
||||||
|
@ -195,9 +195,9 @@
|
|||||||
|
|
||||||
rbd help children
|
rbd help children
|
||||||
usage: rbd children [--pool <pool>] [--namespace <namespace>]
|
usage: rbd children [--pool <pool>] [--namespace <namespace>]
|
||||||
[--image <image>] [--snap <snap>] [--snap-id <snap-id>]
|
[--image <image>] [--snap <snap>] [--image-id <image-id>]
|
||||||
[--all] [--descendants] [--format <format>]
|
[--snap-id <snap-id>] [--all] [--descendants]
|
||||||
[--pretty-format]
|
[--format <format>] [--pretty-format]
|
||||||
<image-or-snap-spec>
|
<image-or-snap-spec>
|
||||||
|
|
||||||
Display children of an image or its snapshot.
|
Display children of an image or its snapshot.
|
||||||
@ -212,6 +212,7 @@
|
|||||||
--namespace arg namespace name
|
--namespace arg namespace name
|
||||||
--image arg image name
|
--image arg image name
|
||||||
--snap arg snapshot name
|
--snap arg snapshot name
|
||||||
|
--image-id arg image id
|
||||||
--snap-id arg snapshot id
|
--snap-id arg snapshot id
|
||||||
-a [ --all ] list all children (include trash)
|
-a [ --all ] list all children (include trash)
|
||||||
--descendants include all descendants
|
--descendants include all descendants
|
||||||
|
@ -84,6 +84,7 @@ void get_arguments(po::options_description *positional,
|
|||||||
po::options_description *options) {
|
po::options_description *options) {
|
||||||
at::add_image_or_snap_spec_options(positional, options,
|
at::add_image_or_snap_spec_options(positional, options,
|
||||||
at::ARGUMENT_MODIFIER_NONE);
|
at::ARGUMENT_MODIFIER_NONE);
|
||||||
|
at::add_image_id_option(options);
|
||||||
at::add_snap_id_option(options);
|
at::add_snap_id_option(options);
|
||||||
options->add_options()
|
options->add_options()
|
||||||
("all,a", po::bool_switch(), "list all children (include trash)");
|
("all,a", po::bool_switch(), "list all children (include trash)");
|
||||||
@ -104,14 +105,26 @@ int execute(const po::variables_map &vm,
|
|||||||
std::string namespace_name;
|
std::string namespace_name;
|
||||||
std::string image_name;
|
std::string image_name;
|
||||||
std::string snap_name;
|
std::string snap_name;
|
||||||
|
std::string image_id;
|
||||||
|
|
||||||
|
if (vm.count(at::IMAGE_ID)) {
|
||||||
|
image_id = vm[at::IMAGE_ID].as<std::string>();
|
||||||
|
}
|
||||||
|
|
||||||
int r = utils::get_pool_image_snapshot_names(
|
int r = utils::get_pool_image_snapshot_names(
|
||||||
vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &namespace_name,
|
vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &namespace_name,
|
||||||
&image_name, &snap_name, true, utils::SNAPSHOT_PRESENCE_PERMITTED,
|
&image_name, &snap_name, image_id.empty(),
|
||||||
utils::SPEC_VALIDATION_NONE);
|
utils::SNAPSHOT_PRESENCE_PERMITTED, utils::SPEC_VALIDATION_NONE);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!image_id.empty() && !image_name.empty()) {
|
||||||
|
std::cerr << "rbd: trying to access image using both name and id."
|
||||||
|
<< std::endl;
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (snap_id != LIBRADOS_SNAP_HEAD && !snap_name.empty()) {
|
if (snap_id != LIBRADOS_SNAP_HEAD && !snap_name.empty()) {
|
||||||
std::cerr << "rbd: trying to access snapshot using both name and id."
|
std::cerr << "rbd: trying to access snapshot using both name and id."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -127,8 +140,8 @@ int execute(const po::variables_map &vm,
|
|||||||
librados::Rados rados;
|
librados::Rados rados;
|
||||||
librados::IoCtx io_ctx;
|
librados::IoCtx io_ctx;
|
||||||
librbd::Image image;
|
librbd::Image image;
|
||||||
r = utils::init_and_open_image(pool_name, namespace_name, image_name, "", "",
|
r = utils::init_and_open_image(pool_name, namespace_name, image_name,
|
||||||
true, &rados, &io_ctx, &image);
|
image_id, "", true, &rados, &io_ctx, &image);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user