:command:`group ls` [-p | --pool *pool-name*]
List rbd groups.
+:command:`group rename` *src-group-spec* *dest-group-spec*
+ Rename a group. Note: rename across pools is not supported.
+
:command:`group rm` *group-spec*
Delete a group.
rbd group remove $group_name
}
+rename_group()
+{
+ local src_name=$1
+ local dest_name=$2
+
+ rbd group rename $src_name $dest_name
+}
+
check_group_does_not_exist()
{
local group_name=$1
echo "TEST: create remove consistency group"
group="test_consistency_group"
+new_group="test_new_consistency_group"
create_group $group
check_group_exists $group
-remove_group $group
-check_group_does_not_exist $group
+rename_group $group $new_group
+check_group_exists $new_group
+remove_group $new_group
+check_group_does_not_exist $new_group
echo "PASSED"
echo "TEST: add remove images to consistency group"
int rbd_group_create(rados_ioctx_t p, const char *name)
int rbd_group_remove(rados_ioctx_t p, const char *name)
int rbd_group_list(rados_ioctx_t p, char *names, size_t *size)
+ int rbd_group_rename(rados_ioctx_t p, const char *src, const char *dest)
void rbd_group_info_cleanup(rbd_group_info_t *group_info,
size_t group_info_size)
int rbd_group_image_add(rados_ioctx_t group_p, const char *group_name,
finally:
free(c_names)
+ def group_rename(self, ioctx, src, dest):
+ """
+ Rename an RBD group.
+
+ :param ioctx: determines which RADOS pool the group is in
+ :type ioctx: :class:`rados.Ioctx`
+ :param src: the current name of the group
+ :type src: str
+ :param dest: the new name of the group
+ :type dest: str
+ :raises: :class:`ObjectExists`
+ :raises: :class:`ObjectNotFound`
+ :raises: :class:`InvalidArgument`
+ :raises: :class:`FunctionNotSupported`
+ """
+ src = cstr(src, 'src')
+ dest = cstr(dest, 'dest')
+ cdef:
+ rados_ioctx_t _ioctx = convert_ioctx(ioctx)
+ char *_src = src
+ char *_dest = dest
+ with nogil:
+ ret = rbd_group_rename(_ioctx, _src, _dest)
+ if ret != 0:
+ raise make_ex(ret, 'error renaming group')
+
cdef class MirrorPeerIterator(object):
"""
Iterator over mirror peer info for a pool.
group image remove (group image rm) Remove an image from a group.
group list (group ls) List rbd groups.
group remove (group rm) Delete a group.
+ group rename Rename a group within pool.
group snap create Make a snapshot of a group.
group snap list (group snap ls) List snapshots of a group.
group snap remove (group snap rm) Remove a snapshot from a group.
-p [ --pool ] arg pool name
--group arg group name
+ rbd help group rename
+ usage: rbd group rename [--pool <pool>] [--group <group>]
+ [--dest-pool <dest-pool>] [--dest-group <dest-group>]
+ <source-group-spec> <dest-group-spec>
+
+ Rename a group within pool.
+
+ Positional arguments
+ <source-group-spec> source group specification
+ (example: [<pool-name>/]<group-name>)
+ <dest-group-spec> destination group specification
+ (example: [<pool-name>/]<group-name>)
+
+ Optional arguments
+ -p [ --pool ] arg source pool name
+ --group arg source group name
+ --dest-pool arg destination pool name
+ --dest-group arg destination group name
+
rbd help group snap create
usage: rbd group snap create [--pool <pool>] [--group <group>] [--snap <snap>]
<group-snap-spec>
if group_name is not None:
RBD().group_remove(ioctx, group_name)
+def rename_group():
+ new_group_name = "new" + group_name
+ RBD().group_rename(ioctx, group_name, new_group_name)
+
def require_new_format():
def wrapper(fn):
def _require_new_format(*args, **kwargs):
create_group()
remove_group()
+def test_rename_group():
+ create_group()
+ if group_name is not None:
+ rename_group()
+ eq(["new" + group_name], RBD().group_list(ioctx))
+ RBD().group_remove(ioctx, "new" + group_name)
+ else:
+ remove_group()
+
def test_list_groups_empty():
eq([], RBD().group_list(ioctx))
return 0;
}
+int execute_rename(const po::variables_map &vm,
+ const std::vector<std::string> &ceph_global_init_args) {
+ size_t arg_index = 0;
+
+ std::string group_name;
+ std::string pool_name;
+
+ int r = utils::get_pool_group_names(vm, at::ARGUMENT_MODIFIER_NONE,
+ &arg_index, &pool_name, &group_name,
+ nullptr);
+ if (r < 0) {
+ return r;
+ }
+
+ std::string dest_group_name;
+ std::string dest_pool_name;
+
+ r = utils::get_pool_group_names(vm, at::ARGUMENT_MODIFIER_NONE,
+ &arg_index, &dest_pool_name,
+ &dest_group_name, nullptr);
+ if (r < 0) {
+ return r;
+ }
+
+ if (pool_name != dest_pool_name) {
+ std::cerr << "rbd: group rename across pools not supported" << std::endl
+ << "source pool: " << pool_name<< ", dest pool: " << dest_pool_name
+ << std::endl;
+ return -EINVAL;
+ }
+
+ librados::Rados rados;
+ librados::IoCtx io_ctx;
+ r = utils::init(pool_name, &rados, &io_ctx);
+ if (r < 0) {
+ return r;
+ }
+
+ librbd::RBD rbd;
+ r = rbd.group_rename(io_ctx, group_name.c_str(),
+ dest_group_name.c_str());
+
+ if (r < 0) {
+ std::cerr << "rbd: failed to rename group: "
+ << cpp_strerror(r) << std::endl;
+ return r;
+ }
+
+ return 0;
+}
+
int execute_add(const po::variables_map &vm,
const std::vector<std::string> &ceph_global_init_args) {
size_t arg_index = 0;
at::add_format_options(options);
}
+void get_rename_arguments(po::options_description *positional,
+ po::options_description *options) {
+ at::add_group_spec_options(positional, options, at::ARGUMENT_MODIFIER_SOURCE,
+ false);
+ at::add_group_spec_options(positional, options, at::ARGUMENT_MODIFIER_DEST,
+ false);
+}
+
void get_add_arguments(po::options_description *positional,
po::options_description *options) {
positional->add_options()
Shell::Action action_list(
{"group", "list"}, {"group", "ls"}, "List rbd groups.",
"", &get_list_arguments, &execute_list);
+Shell::Action action_rename(
+ {"group", "rename"}, {}, "Rename a group within pool.",
+ "", &get_rename_arguments, &execute_rename);
Shell::Action action_add(
{"group", "image", "add"}, {}, "Add an image to a group.",
"", &get_add_arguments, &execute_add);