]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: zone[group] modify can change realm id 10658/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 28 Jul 2016 13:55:05 +0000 (09:55 -0400)
committerLoic Dachary <ldachary@redhat.com>
Wed, 10 Aug 2016 12:10:24 +0000 (14:10 +0200)
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 <cbodley@redhat.com>
(cherry picked from commit 064b7e953dd6ace2c32b94150e70959e95a01761)

src/rgw/rgw_admin.cc
src/rgw/rgw_rados.h

index f6de39f7e5cf4492f945a08862fd9b16222614a4..99d045dcb02c2428969fc7ed8b3a034a8038153b 100644 (file)
@@ -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) {
index 9704fb6d1d61ba7dd48d404715f782fdc8a21c7e..774d9c3a4059842e7f79a4cfaeae1e62a562466d 100644 (file)
@@ -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);