From 674087ec367208e4671a9137944b7c7c9d16c020 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Wed, 23 Sep 2015 14:08:44 +0200 Subject: [PATCH] radosgw-admin: zonegroup set needs to update zonegroupmap Signed-off-by: Orit Wasserman --- src/rgw/rgw_admin.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index e3ca085f5df46..5823d705ea949 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -2288,8 +2288,15 @@ int main(int argc, char **argv) break; case OPT_ZONEGROUP_SET: { + RGWRealm realm(realm_id, realm_name); + int ret = realm.init(g_ceph_context, store); + if (ret < 0) { + cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + RGWZoneGroup zonegroup; - int ret = zonegroup.init(g_ceph_context, store, false); + ret = zonegroup.init(g_ceph_context, store, false); if (ret < 0) { cerr << "failed to init zonegroup: " << cpp_strerror(-ret) << std::endl; return -ret; @@ -2309,6 +2316,25 @@ int main(int argc, char **argv) return 1; } } + + RGWZoneGroupMap zonegroup_map; + ret = zonegroup_map.read(g_ceph_context, store); + if (ret < 0 && ret != -ENOENT) { + cerr << "ERROR: couldn't read zonegroup_map: " << cpp_strerror(-ret) << std::endl; + return ret; + } + + ret = zonegroup_map.update(g_ceph_context, store, realm, zonegroup); + if (ret < 0) { + cerr << "failed to update zonegroup_map: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + ret = zonegroup_map.store(g_ceph_context, store); + if (ret < 0) { + cerr << "failed to store zonegroup_map: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + encode_json("zonegroup", zonegroup, formatter); formatter->flush(cout); } -- 2.39.5