}
}
+std::string Section::get_minimal_conf() const
+{
+ std::string r;
+ for (auto& i : options) {
+ if (i.second.opt->has_flag(Option::FLAG_NO_MON_UPDATE) ||
+ i.second.opt->has_flag(Option::FLAG_MINIMAL_CONF)) {
+ if (i.second.mask.empty()) {
+ r += "\t"s + i.first + " = " + i.second.raw_value + "\n";
+ } else {
+ r += "\t# masked option excluded: " + i.first + " = " +
+ i.second.raw_value + "\n";
+ }
+ }
+ }
+ return r;
+}
+
+
// ------------
void ConfigMap::dump(Formatter *f) const
std::string location_type, location_value; ///< matches crush_location
std::string device_class; ///< matches device class
+ bool empty() const {
+ return location_type.size() == 0
+ && location_value.size() == 0
+ && device_class.size() == 0;
+ }
+
std::string to_str() const {
std::string r;
if (location_type.size()) {
options.clear();
}
void dump(Formatter *f) const;
+ std::string get_minimal_conf() const;
};
struct ConfigMap {
} else {
odata.append(ds.str());
}
+ } else if (prefix == "config generate-minimal-conf") {
+ ostringstream conf;
+ conf << "# minimal ceph.conf for " << mon->monmap->get_fsid() << "\n";
+
+ // the basics
+ conf << "[global]\n";
+ conf << "\tfsid = " << mon->monmap->get_fsid() << "\n";
+ conf << "\tmon_host = ";
+ for (auto i = mon->monmap->mon_info.begin();
+ i != mon->monmap->mon_info.end();
+ ++i) {
+ if (i != mon->monmap->mon_info.begin()) {
+ conf << " ";
+ }
+ conf << i->second.public_addrs;
+ }
+ conf << "\n";
+ conf << config_map.global.get_minimal_conf();
+ for (auto m : { &config_map.by_type, &config_map.by_id }) {
+ for (auto& i : *m) {
+ auto s = i.second.get_minimal_conf();
+ if (s.size()) {
+ conf << "\n[" << i.first << "]\n" << s;
+ }
+ }
+ }
+ odata.append(conf.str());
+ err = 0;
} else {
return false;
}
" name=num,type=CephInt",
"Revert configuration to previous state",
"config", "rw")
+COMMAND("config generate-minimal-conf",
+ "Generate a minimal ceph.conf file",
+ "config", "r")
COMMAND_WITH_FLAG("smart name=devid,type=CephString,req=false",
"Query health metrics for underlying device",