ipaddrs = monmap.get_addrs(g_conf()->name.get_id());
// print helpful warning if the conf file doesn't match
- std::vector <std::string> my_sections;
- g_conf().get_my_sections(my_sections);
+ std::vector<std::string> my_sections = g_conf().get_my_sections();
std::string mon_addr_str;
if (g_conf().get_val_from_conf_file(my_sections, "mon addr",
mon_addr_str, true) == 0) {
}
}
- std::vector <std::string> my_sections;
- _get_my_sections(values, my_sections);
+ std::vector<std::string> my_sections = get_my_sections(values);
for (const auto &i : schema) {
const auto &opt = i.second;
std::string val;
* looking. The lowest priority section is the one we look in only if all
* others had nothing. This should always be the global section.
*/
-void md_config_t::get_my_sections(const ConfigValues& values,
- std::vector <std::string> §ions) const
+std::vector <std::string>
+md_config_t::get_my_sections(const ConfigValues& values) const
{
- _get_my_sections(values, sections);
-}
-
-void md_config_t::_get_my_sections(const ConfigValues& values,
- std::vector <std::string> §ions) const
-{
- sections.push_back(values.name.to_str());
-
- sections.push_back(values.name.get_type_name().data());
-
- sections.push_back("global");
+ return {values.name.to_str(),
+ values.name.get_type_name().data(),
+ "global"};
}
// Return a list of all sections
void get_all_keys(std::vector<std::string> *keys) const;
// Return a list of all the sections that the current entity is a member of.
- void get_my_sections(const ConfigValues& values,
- std::vector <std::string> §ions) const;
+ std::vector<std::string> get_my_sections(const ConfigValues& values) const;
// Return a list of all sections
int get_all_sections(std::vector <std::string> §ions) const;
void _show_config(const ConfigValues& values,
std::ostream *out, ceph::Formatter *f) const;
- void _get_my_sections(const ConfigValues& values,
- std::vector<std::string> §ions) const;
-
int _get_val_from_conf_file(const std::vector<std::string> §ions,
const std::string_view key, std::string &out) const;
std::lock_guard l{lock};
return config.diff(values, f, name);
}
- void get_my_sections(std::vector <std::string> §ions) const {
+ std::vector<std::string> get_my_sections() const {
std::lock_guard l{lock};
- config.get_my_sections(values, sections);
+ return config.get_my_sections(values);
}
int get_all_sections(std::vector<std::string>& sections) const {
std::lock_guard l{lock};
static int lookup(const std::deque<std::string> §ions,
const std::string &key, bool resolve_search)
{
- std::vector <std::string> my_sections;
- for (deque<string>::const_iterator s = sections.begin(); s != sections.end(); ++s) {
- my_sections.push_back(*s);
+ std::vector<std::string> my_sections{sections.begin(), sections.end()};
+ for (auto& section : g_conf().get_my_sections()) {
+ my_sections.push_back(section);
}
- g_conf().get_my_sections(my_sections);
std::string val;
int ret = g_conf().get_val_from_conf_file(my_sections, key.c_str(), val, true);
if (ret == -ENOENT)