]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: rest api to read zone config params
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 5 Jan 2017 21:47:24 +0000 (13:47 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 30 Jun 2017 23:44:11 +0000 (16:44 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit a220a2efbfd675e6abf14ae33c21005bcbf6dadf)

src/rgw/rgw_rest_config.cc
src/rgw/rgw_rest_config.h

index 2c0f5e46e9c258c08162acb51d0de519546d6be8..260082013f97db1c85989df876edd869cc16e96f 100644 (file)
@@ -52,12 +52,28 @@ void RGWOp_ZoneGroupMap_Get::send_response() {
   flusher.flush();
 }
 
+void RGWOp_ZoneConfig_Get::send_response() {
+  const RGWZoneParams& zone_params = store->get_zone_params();
+
+  set_req_state_err(s, http_ret);
+  dump_errno(s);
+  end_header(s);
+
+  if (http_ret < 0)
+    return;
+
+  encode_json("zone_params", zone_params, s->formatter);
+  flusher.flush();
+}
+
 RGWOp* RGWHandler_Config::op_get() {
   bool exists;
   string type = s->info.args.get("type", &exists);
 
   if (type.compare("zonegroup-map") == 0) {
     return new RGWOp_ZoneGroupMap_Get(false);
+  } else if (type.compare("zone") == 0) {
+    return new RGWOp_ZoneConfig_Get();
   } else {
     return new RGWOp_ZoneGroupMap_Get(true);
   }
index e9fcfd79ca6c9c7835d9d077bafc09a8b9bb610f..8835c1a821fdb705c90344fc83c78eef7da27289 100644 (file)
@@ -36,6 +36,24 @@ public:
   }
 };
 
+class RGWOp_ZoneConfig_Get : public RGWRESTOp {
+  RGWZoneParams zone_params;
+public:
+  RGWOp_ZoneConfig_Get() {}
+
+  int check_caps(RGWUserCaps& caps) {
+    return caps.check_cap("admin", RGW_CAP_READ);
+  }
+  int verify_permission() {
+    return check_caps(s->user->caps);
+  }
+  void execute() {} /* store already has the info we need, just need to send response */
+  void send_response();
+  const string name() {
+    return "get_zone_config";
+  }
+};
+
 class RGWHandler_Config : public RGWHandler_Auth_S3 {
 protected:
   RGWOp *op_get();