]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw-admin: zone[group] modify can change realm id 10477/head
authorCasey Bodley <cbodley@redhat.com>
Thu, 28 Jul 2016 13:55:05 +0000 (09:55 -0400)
committerCasey Bodley <cbodley@redhat.com>
Thu, 28 Jul 2016 14:17:05 +0000 (10:17 -0400)
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>
src/rgw/rgw_admin.cc
src/rgw/rgw_rados.h

index ef3ff32383fca27dcead51db42f937cbb4d9fc89..099a2359cb7aec5ddad33ce6cd0862f4b62f2d52 100644 (file)
@@ -3079,6 +3079,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();
@@ -3546,6 +3560,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 4af138f04836ecc9824263f6877586137db66225..b0a0f089f89a3fbe7f5c326dee6f96f9e4b6717c 100644 (file)
@@ -1340,6 +1340,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);