From 7f4cc1d21b2dbda60e5ffa96f905b858d56e9303 Mon Sep 17 00:00:00 2001 From: Marcus Watts Date: Sat, 4 Aug 2018 00:42:38 -0400 Subject: [PATCH] Add "--bucket-new-name" option to radosgw-admin. This just adds the command line option and related bits. Underlying functionality will be a later commit. Fixes: http://tracker.ceph.com/issues/35885 Signed-off-by: Marcus Watts --- doc/man/8/radosgw-admin.rst | 6 ++++++ src/rgw/rgw_admin.cc | 6 ++++++ src/rgw/rgw_bucket.h | 4 ++++ src/test/cli/radosgw-admin/help.t | 2 ++ 4 files changed, 18 insertions(+) diff --git a/doc/man/8/radosgw-admin.rst b/doc/man/8/radosgw-admin.rst index 136c8a96b3557..a9a1e2f7ebcbe 100644 --- a/doc/man/8/radosgw-admin.rst +++ b/doc/man/8/radosgw-admin.rst @@ -546,6 +546,12 @@ Options Specify the bucket id. +.. option:: --bucket-new-name=[tenant-id/] + + Optional for `bucket link`; use to rename a bucket. + When using implicit tenants, prefix the name + with the desired tenant-id. + .. option:: --shard-id= Optional for mdlog list, data sync status. Required for ``mdlog trim``. diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index fd38b4af4e90b..384b3549e9f54 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -265,6 +265,8 @@ void usage() cout << " --start-date= start date in the format yyyy-mm-dd\n"; cout << " --end-date= end date in the format yyyy-mm-dd\n"; cout << " --bucket-id= bucket id\n"; + cout << " --bucket-new-name=\n"; + cout << " for bucket link: optional new name\n"; cout << " --shard-id= optional for: \n"; cout << " mdlog list\n"; cout << " data sync status\n"; @@ -2784,6 +2786,7 @@ int main(int argc, const char **argv) bool set_temp_url_key = false; map temp_url_keys; string bucket_id; + string new_bucket_name; Formatter *formatter = NULL; int purge_data = false; int pretty_format = false; @@ -3044,6 +3047,8 @@ int main(int argc, const char **argv) cerr << "bad bucket-id" << std::endl; exit(1); } + } else if (ceph_argparse_witharg(args, i, &val, "--bucket-new-name", (char*)NULL)) { + new_bucket_name = val; } else if (ceph_argparse_witharg(args, i, &val, "--format", (char*)NULL)) { format = val; } else if (ceph_argparse_witharg(args, i, &val, "--categories", (char*)NULL)) { @@ -5529,6 +5534,7 @@ int main(int argc, const char **argv) if (opt_cmd == OPT_BUCKET_LINK) { bucket_op.set_bucket_id(bucket_id); + bucket_op.set_new_bucket_name(new_bucket_name); string err; int r = RGWBucketAdminOp::link(store, bucket_op, &err); if (r < 0) { diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 9e7dce4e595b8..3892a76e70ff3 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -227,6 +227,7 @@ struct RGWBucketAdminOpState { std::string bucket_name; std::string bucket_id; std::string object_name; + std::string new_bucket_name; bool list_buckets; bool stat_buckets; @@ -257,6 +258,9 @@ struct RGWBucketAdminOpState { void set_object(std::string& object_str) { object_name = object_str; } + void set_new_bucket_name(std::string& new_bucket_str) { + new_bucket_name = new_bucket_str; + } void set_quota(RGWQuotaInfo& value) { quota = value; } diff --git a/src/test/cli/radosgw-admin/help.t b/src/test/cli/radosgw-admin/help.t index b1fddccc865ad..cb8f46ca46843 100644 --- a/src/test/cli/radosgw-admin/help.t +++ b/src/test/cli/radosgw-admin/help.t @@ -185,6 +185,8 @@ --start-date= start date in the format yyyy-mm-dd --end-date= end date in the format yyyy-mm-dd --bucket-id= bucket id + --bucket-new-name= + for bucket link: optional new name --shard-id= optional for: mdlog list data sync status -- 2.39.5