From a865f26e68a991eaf55dc5f105b7fd7cb4634bc3 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 28 Jul 2016 09:55:05 -0400 Subject: [PATCH] radosgw-admin: zone[group] modify can change realm id allows the default zone and zonegroup (created with empty realm_id) to be later added to a realm. the 'modify' command now accepts either --realm_id=id or --rgw-realm=name Fixes: http://tracker.ceph.com/issues/16839 Signed-off-by: Casey Bodley (cherry picked from commit 064b7e953dd6ace2c32b94150e70959e95a01761) --- src/rgw/rgw_admin.cc | 28 ++++++++++++++++++++++++++++ src/rgw/rgw_rados.h | 2 ++ 2 files changed, 30 insertions(+) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index f6de39f7e5cf4..99d045dcb02c2 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -3040,6 +3040,20 @@ int main(int argc, char **argv) need_update = true; } + if (!realm_id.empty()) { + zonegroup.realm_id = realm_id; + need_update = true; + } else if (!realm_name.empty()) { + // get realm id from name + RGWRealm realm{g_ceph_context, store}; + ret = realm.read_id(realm_name, zonegroup.realm_id); + if (ret < 0) { + cerr << "failed to find realm by name " << realm_name << std::endl; + return -ret; + } + need_update = true; + } + if (need_update) { zonegroup.post_process_params(); ret = zonegroup.update(); @@ -3513,6 +3527,20 @@ int main(int argc, char **argv) need_zone_update = true; } + if (!realm_id.empty()) { + zone.realm_id = realm_id; + need_zone_update = true; + } else if (!realm_name.empty()) { + // get realm id from name + RGWRealm realm{g_ceph_context, store}; + ret = realm.read_id(realm_name, zone.realm_id); + if (ret < 0) { + cerr << "failed to find realm by name " << realm_name << std::endl; + return -ret; + } + need_zone_update = true; + } + if (need_zone_update) { ret = zone.update(); if (ret < 0) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 9704fb6d1d61b..774d9c3a40598 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -1334,6 +1334,8 @@ public: const string& get_info_oid_prefix(bool old_format = false); const string& get_predefined_name(CephContext *cct); + using RGWSystemMetaObj::read_id; // expose as public for radosgw-admin + void dump(Formatter *f) const; void decode_json(JSONObj *obj); -- 2.39.5