"the type of the frontend followed by an optional space delimited set of "
"key=value config parameters."),
+ Option("rgw_frontend_defaults", Option::TYPE_STR, Option::LEVEL_ADVANCED)
+ .set_default("beast ssl_certificate=config://rgw/cert/$realm/$zone.crt ssl_private_key=config://rgw/cert/$realm/$zone.key")
+ .set_description("RGW frontends default configuration")
+ .set_long_description(
+ "A comma delimited list of default frontends configuration."),
+
Option("rgw_user_quota_bucket_sync_interval", Option::TYPE_INT, Option::LEVEL_ADVANCED)
.set_default(180)
.set_description("User quota bucket sync interval")
return 0;
}
+void RGWFrontendConfig::set_default_config(RGWFrontendConfig& def_conf)
+{
+ const auto& def_conf_map = def_conf.get_config_map();
+
+ for (auto& entry : def_conf_map) {
+ if (config_map.find(entry.first) == config_map.end()) {
+ config_map.emplace(entry.first, entry.second);
+ }
+ }
+}
+
+std::optional<string> RGWFrontendConfig::get_val(const std::string& key)
+{
+ auto iter = config_map.find(key);
+ if (iter == config_map.end()) {
+ return std::nullopt;
+ }
+
+ return iter->second;
+}
+
bool RGWFrontendConfig::get_val(const string& key, const string& def_val,
string *out)
{
return ret < 0 ? ret : 0;
}
+ void set_default_config(RGWFrontendConfig& def_conf);
+
+ std::optional<string> get_val(const std::string& key);
+
bool get_val(const std::string& key,
const std::string& def_val,
std::string* out);
list<RGWFrontend *> fes;
+ string frontend_defs_str = g_conf().get_val<string>("rgw_frontend_defaults");
+
+ list<string> frontends_def;
+ get_str_list(frontend_defs_str, ",", frontends_def);
+
+ map<string, std::unique_ptr<RGWFrontendConfig> > fe_def_map;
+ for (auto& f : frontends_def) {
+ RGWFrontendConfig *config = new RGWFrontendConfig(f);
+ int r = config->init();
+ if (r < 0) {
+ delete config;
+ cerr << "ERROR: failed to init default config: " << f << std::endl;
+ return EINVAL;
+ }
+
+ fe_def_map[config->get_framework()].reset(config);
+ }
+
int fe_count = 0;
for (multimap<string, RGWFrontendConfig *>::iterator fiter = fe_map.begin();
fiter != fe_map.end(); ++fiter, ++fe_count) {
RGWFrontendConfig *config = fiter->second;
string framework = config->get_framework();
+
+ auto def_iter = fe_def_map.find(framework);
+ if (def_iter != fe_def_map.end()) {
+ config->set_default_config(*def_iter->second);
+ }
+
RGWFrontend *fe = NULL;
if (framework == "civetweb" || framework == "mongoose") {