11// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
22// vim: ts=8 sw=2 smarttab ft=cpp
33#include " rgw_rest_ratelimit.h"
4+ #include " rgw_sal.h"
5+ #include " rgw_sal_config.h"
6+
47class RGWOp_Ratelimit_Info : public RGWRESTOp {
58int check_caps (const RGWUserCaps& caps) override {
69 return caps.check_cap (" ratelimit" , RGW_CAP_READ);
@@ -101,7 +104,9 @@ void RGWOp_Ratelimit_Info::execute(optional_yield y)
101104 if (global) {
102105 std::string realm_id = driver->get_zone ()->get_realm_id ();
103106 RGWPeriodConfig period_config;
104- op_ret = period_config.read (this , static_cast <rgw::sal::RadosStore*>(driver)->svc ()->sysobj , realm_id, y);
107+ auto config_store_type = g_conf ().get_val <std::string>(" rgw_config_store" );
108+ auto cfgstore = DriverManager::create_config_store (this , config_store_type);
109+ op_ret = cfgstore->read_period_config (this , y, realm_id, period_config);
105110 if (op_ret && op_ret != -ENOENT) {
106111 ldpp_dout (this , 0 ) << " Error on period config read" << dendl;
107112 return ;
@@ -302,10 +307,13 @@ void RGWOp_Ratelimit_Set::execute(optional_yield y)
302307 op_ret = bucket->merge_and_store_attrs (this , attr, y);
303308 return ;
304309 }
310+
311+ auto config_store_type = g_conf ().get_val <std::string>(" rgw_config_store" );
312+ auto cfgstore = DriverManager::create_config_store (s, config_store_type);
305313 if (global) {
306314 std::string realm_id = driver->get_zone ()->get_realm_id ();
307315 RGWPeriodConfig period_config;
308- op_ret = period_config. read (s, static_cast <rgw::sal::RadosStore*>(driver)-> svc ()-> sysobj , realm_id, y );
316+ op_ret = cfgstore-> read_period_config (s, y , realm_id, period_config );
309317 if (op_ret && op_ret != -ENOENT) {
310318 ldpp_dout (this , 0 ) << " Error on period config read" << dendl;
311319 return ;
@@ -316,7 +324,7 @@ void RGWOp_Ratelimit_Set::execute(optional_yield y)
316324 have_max_read_bytes, max_read_bytes, have_max_write_bytes, max_write_bytes,
317325 have_enabled, enabled, ratelimit_configured, ratelimit_info);
318326 period_config.bucket_ratelimit = ratelimit_info;
319- op_ret = period_config. write (s, static_cast <rgw::sal::RadosStore*>(driver)-> svc ()-> sysobj , realm_id, y );
327+ op_ret = cfgstore-> write_period_config (s, y, false , realm_id, period_config );
320328 return ;
321329 }
322330 if (ratelimit_scope == " anon" ) {
@@ -325,7 +333,7 @@ void RGWOp_Ratelimit_Set::execute(optional_yield y)
325333 have_max_read_bytes, max_read_bytes, have_max_write_bytes, max_write_bytes,
326334 have_enabled, enabled, ratelimit_configured, ratelimit_info);
327335 period_config.anon_ratelimit = ratelimit_info;
328- op_ret = period_config. write (s, static_cast <rgw::sal::RadosStore*>(driver)-> svc ()-> sysobj , realm_id, y );
336+ op_ret = cfgstore-> write_period_config (s, y, false , realm_id, period_config );
329337 return ;
330338 }
331339 if (ratelimit_scope == " user" ) {
@@ -334,7 +342,7 @@ void RGWOp_Ratelimit_Set::execute(optional_yield y)
334342 have_max_read_bytes, max_read_bytes, have_max_write_bytes, max_write_bytes,
335343 have_enabled, enabled, ratelimit_configured, ratelimit_info);
336344 period_config.user_ratelimit = ratelimit_info;
337- op_ret = period_config. write (s, static_cast <rgw::sal::RadosStore*>(driver)-> svc ()-> sysobj , realm_id, y );
345+ op_ret = cfgstore-> write_period_config (s, y, false , realm_id, period_config );
338346 return ;
339347 }
340348 }
0 commit comments