diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-02-20 17:03:10 -0800 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-02-20 17:03:10 -0800 |
commit | 8fb3ce949a31bd79f41367d7f26b414fa8bd59c5 (patch) | |
tree | 500811faf81521b3cce51fcbecd31f0092abfd4e | |
parent | 8fc23a84265a1571f041a40d71fb6fd345b65909 (diff) | |
download | ceph-8fb3ce949a31bd79f41367d7f26b414fa8bd59c5.tar.gz |
rgw: set region info, default region
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_admin.cc | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 2c206a50881..5d07e877b4e 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -60,6 +60,8 @@ void _usage() cerr << " object rm remove object\n"; cerr << " region info show region info\n"; cerr << " region list list all regions\n"; + cerr << " region set set region info\n"; + cerr << " region default set default region\n"; cerr << " zone info show zone params info\n"; cerr << " pool add add an existing pool for data placement\n"; cerr << " pool rm remove an existing pool from data placement set\n"; @@ -164,6 +166,8 @@ enum { OPT_GC_PROCESS, OPT_REGION_INFO, OPT_REGION_LIST, + OPT_REGION_SET, + OPT_REGION_DEFAULT, OPT_ZONE_INFO, OPT_ZONE_SET, OPT_CAPS_ADD, @@ -290,6 +294,10 @@ static int get_cmd(const char *cmd, const char *prev_cmd, bool *need_more) return OPT_REGION_INFO; if (strcmp(cmd, "list") == 0) return OPT_REGION_LIST; + if (strcmp(cmd, "set") == 0) + return OPT_REGION_SET; + if (strcmp(cmd, "default") == 0) + return OPT_REGION_DEFAULT; } else if (strcmp(prev_cmd, "zone") == 0) { if (strcmp(cmd, "info") == 0) return OPT_ZONE_INFO; @@ -854,7 +862,8 @@ int main(int argc, char **argv) return usage(); } - bool raw_storage_op = (opt_cmd == OPT_REGION_INFO || opt_cmd == OPT_REGION_LIST); + bool raw_storage_op = (opt_cmd == OPT_REGION_INFO || opt_cmd == OPT_REGION_LIST || + opt_cmd == OPT_REGION_SET || opt_cmd == OPT_REGION_DEFAULT); user_modify_op = (opt_cmd == OPT_USER_MODIFY || opt_cmd == OPT_SUBUSER_MODIFY || @@ -890,6 +899,10 @@ int main(int argc, char **argv) if (opt_cmd == OPT_REGION_LIST) { RGWRegion region; int ret = region.init(g_ceph_context, store, false); + if (ret < 0) { + cerr << "failed to init region: " << cpp_strerror(-ret) << std::endl; + return -ret; + } list<string> regions; ret = store->list_regions(regions); @@ -909,6 +922,41 @@ int main(int argc, char **argv) formatter->flush(cout); cout << std::endl; } + if (opt_cmd == OPT_REGION_SET) { + RGWRegion region; + int ret = region.init(g_ceph_context, store, false); + if (ret < 0) { + cerr << "failed to init region: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + ret = read_decode_json(infile, region); + if (ret < 0) { + return 1; + } + + ret = region.store_info(false); + if (ret < 0) { + cerr << "ERROR: couldn't store zone info: " << cpp_strerror(-ret) << std::endl; + return 1; + } + + encode_json("region", region, formatter); + formatter->flush(cout); + } + if (opt_cmd == OPT_REGION_DEFAULT) { + RGWRegion region; + int ret = region.init(g_ceph_context, store); + if (ret < 0) { + cerr << "failed to init region: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + + ret = region.set_as_default(); + if (ret < 0) { + cerr << "failed to set region as default: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + } return 0; } |