}
md_config_t::md_config_t()
- : cluster("ceph"),
+ : cluster(""),
#define OPTION_OPT_INT(name, def_val) name(def_val),
#define OPTION_OPT_LONGLONG(name, def_val) name((1LL) * def_val),
int flags)
{
Mutex::Locker l(lock);
+
if (internal_safe_to_start_threads)
return -ENOSYS;
+
+ if (!cluster.size() && !conf_files) {
+ /*
+ * set the cluster name to 'ceph' when neither cluster name nor
+ * configuration file are specified.
+ */
+ cluster = "ceph";
+ }
+
if (!conf_files) {
const char *c = getenv("CEPH_CONF");
if (c) {
if (c == conf_files.end())
return -EINVAL;
+ if (cluster.size() == 0) {
+ /*
+ * If cluster name is not set yet, use the prefix of the
+ * basename of configuration file as cluster name.
+ */
+ const char *fn = c->c_str();
+ std::string name(basename(fn));
+ int pos = name.find(".conf");
+ if (pos < 0) {
+ /*
+ * If the configuration file does not follow $cluster.conf
+ * convention, we do the last try and assign the cluster to
+ * 'ceph'.
+ */
+ cluster = "ceph";
+ } else {
+ cluster = name.substr(0, pos);
+ }
+ }
+
std::vector <std::string> my_sections;
_get_my_sections(my_sections);
for (int i = 0; i < NUM_CONFIG_OPTIONS; i++) {
void md_config_t::apply_changes(std::ostream *oss)
{
Mutex::Locker l(lock);
- _apply_changes(oss);
+ /*
+ * apply changes until the cluster name is assigned
+ */
+ if (cluster.size())
+ _apply_changes(oss);
}
bool md_config_t::_internal_field(const string& s)
// You can only call global_init once.
assert(!g_ceph_context);
std::string conf_file_list;
- std::string cluster = "ceph";
+ std::string cluster = "";
CephInitParameters iparams = ceph_argparse_early_args(args, module_type, flags,
&cluster, &conf_file_list);
CephContext *cct = common_preinit(iparams, code_env, flags, data_dir_option);
if (id) {
iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
}
- CephContext *cct = rados_create_cct("ceph", &iparams);
+ CephContext *cct = rados_create_cct("", &iparams);
tracepoint(librados, rados_create_enter, id);
*pcluster = reinterpret_cast<rados_t>(new librados::RadosClient(cct));
{
CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get();
+ cct->_conf->cluster = "ceph";
+
string key("key");
string value("value");
cct->_conf->set_val(key.c_str(), value.c_str(), false);
{
CephContext *cct = (new CephContext(CEPH_ENTITY_TYPE_CLIENT))->get();
+ cct->_conf->cluster = "ceph";
+
ASSERT_FALSE(cct->check_experimental_feature_enabled("foo"));
ASSERT_FALSE(cct->check_experimental_feature_enabled("bar"));
ASSERT_FALSE(cct->check_experimental_feature_enabled("baz"));