mirror of
https://github.com/ceph/ceph
synced 2025-02-24 19:47:44 +00:00
rbd: allow to specify mode on mirror image enable
Signed-off-by: Mykola Golub <mgolub@suse.com>
This commit is contained in:
parent
678b53735b
commit
144c885d75
@ -1543,13 +1543,15 @@
|
||||
rbd help mirror image enable
|
||||
usage: rbd mirror image enable [--pool <pool>] [--namespace <namespace>]
|
||||
[--image <image>]
|
||||
<image-spec>
|
||||
<image-spec> <mode>
|
||||
|
||||
Enable RBD mirroring for an image.
|
||||
|
||||
Positional arguments
|
||||
<image-spec> image specification
|
||||
(example: [<pool-name>/[<namespace>/]]<image-name>)
|
||||
<mode> mirror image mode (journal or snapshot) [default:
|
||||
journal]
|
||||
|
||||
Optional arguments
|
||||
-p [ --pool ] arg pool name
|
||||
|
@ -73,6 +73,13 @@ void get_arguments(po::options_description *positional,
|
||||
at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
|
||||
}
|
||||
|
||||
void get_arguments_enable(po::options_description *positional,
|
||||
po::options_description *options) {
|
||||
at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE);
|
||||
positional->add_options()
|
||||
("mode", "mirror image mode (journal or snapshot) [default: journal]");
|
||||
}
|
||||
|
||||
void get_arguments_disable(po::options_description *positional,
|
||||
po::options_description *options) {
|
||||
options->add_options()
|
||||
@ -104,7 +111,21 @@ int execute_enable_disable(const po::variables_map &vm, bool enable,
|
||||
return r;
|
||||
}
|
||||
|
||||
r = enable ? image.mirror_image_enable() : image.mirror_image_disable(force);
|
||||
if (enable) {
|
||||
librbd::mirror_image_mode_t mode = RBD_MIRROR_IMAGE_MODE_JOURNAL;
|
||||
std::string mode_arg = utils::get_positional_argument(vm, arg_index++);
|
||||
if (mode_arg == "journal") {
|
||||
mode = RBD_MIRROR_IMAGE_MODE_JOURNAL;
|
||||
} else if (mode_arg == "snapshot") {
|
||||
mode = RBD_MIRROR_IMAGE_MODE_SNAPSHOT;
|
||||
} else if (!mode_arg.empty()) {
|
||||
std::cerr << "rbd: invalid mode name: " << mode_arg << std::endl;
|
||||
return -EINVAL;
|
||||
}
|
||||
r = image.mirror_image_enable2(mode);
|
||||
} else {
|
||||
r = image.mirror_image_disable(force);
|
||||
}
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
@ -529,7 +550,7 @@ int execute_snapshot(const po::variables_map &vm,
|
||||
Shell::Action action_enable(
|
||||
{"mirror", "image", "enable"}, {},
|
||||
"Enable RBD mirroring for an image.", "",
|
||||
&get_arguments, &execute_enable);
|
||||
&get_arguments_enable, &execute_enable);
|
||||
Shell::Action action_disable(
|
||||
{"mirror", "image", "disable"}, {},
|
||||
"Disable RBD mirroring for an image.", "",
|
||||
|
Loading…
Reference in New Issue
Block a user