From: Yehuda Sadeh Date: Thu, 5 Jan 2017 21:47:24 +0000 (-0800) Subject: rgw: rest api to read zone config params X-Git-Tag: v12.0.1~183^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a220a2efbfd675e6abf14ae33c21005bcbf6dadf;p=ceph.git rgw: rest api to read zone config params Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rest_config.cc b/src/rgw/rgw_rest_config.cc index 645d4b855fe0..3770cec15ded 100644 --- a/src/rgw/rgw_rest_config.cc +++ b/src/rgw/rgw_rest_config.cc @@ -53,12 +53,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); } diff --git a/src/rgw/rgw_rest_config.h b/src/rgw/rgw_rest_config.h index e9fcfd79ca6c..8835c1a821fd 100644 --- a/src/rgw/rgw_rest_config.h +++ b/src/rgw/rgw_rest_config.h @@ -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();