mirror of
https://github.com/samba-team/samba.git
synced 2024-12-21 09:34:19 +03:00
ctdb-conf: add boolean arg for verbosity when loading config
In a future commit we will add support for loading the config file from the `ctdb` command line tool. Prior to this change the config file load func always called D_NOTICE that causes the command to emit new text and thus break all the tests that rely on the specific test output (not to mention something users could notice). This change plumbs a new `verbose` argument into some of the config file loading functions. Generally, all existing functions will have verbose set to true to match the existing behavior. Future callers of this function can set it to false in order to avoid emitting the extra text. Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
parent
a0e8304ccf
commit
ac926a506d
@ -1176,7 +1176,8 @@ done:
|
||||
|
||||
int conf_load(struct conf_context *conf,
|
||||
const char *filename,
|
||||
bool ignore_unknown)
|
||||
bool ignore_unknown,
|
||||
bool verbose)
|
||||
{
|
||||
conf->filename = talloc_strdup(conf, filename);
|
||||
if (conf->filename == NULL) {
|
||||
@ -1185,7 +1186,9 @@ int conf_load(struct conf_context *conf,
|
||||
|
||||
conf->ignore_unknown = ignore_unknown;
|
||||
|
||||
D_NOTICE("Reading config file %s\n", filename);
|
||||
if (verbose) {
|
||||
D_NOTICE("Reading config file %s\n", filename);
|
||||
}
|
||||
|
||||
return conf_load_internal(conf);
|
||||
}
|
||||
|
@ -306,7 +306,8 @@ void conf_set_defaults(struct conf_context *conf);
|
||||
*/
|
||||
int conf_load(struct conf_context *conf,
|
||||
const char *filename,
|
||||
bool ignore_unknown);
|
||||
bool ignore_unknown,
|
||||
bool verbose);
|
||||
|
||||
/**
|
||||
* @brief Reload the values for configuration options
|
||||
|
@ -57,7 +57,7 @@ static int conf_tool_dump(TALLOC_CTX *mem_ctx,
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = conf_load(ctx->conf, ctx->conf_file, true);
|
||||
ret = conf_load(ctx->conf, ctx->conf_file, true, true);
|
||||
if (ret != 0 && ret != ENOENT) {
|
||||
D_ERR("Failed to load config file %s\n", ctx->conf_file);
|
||||
return ret;
|
||||
@ -97,7 +97,7 @@ static int conf_tool_get(TALLOC_CTX *mem_ctx,
|
||||
return ENOENT;
|
||||
}
|
||||
|
||||
ret = conf_load(ctx->conf, ctx->conf_file, true);
|
||||
ret = conf_load(ctx->conf, ctx->conf_file, true, true);
|
||||
if (ret != 0 && ret != ENOENT) {
|
||||
D_ERR("Failed to load config file %s\n", ctx->conf_file);
|
||||
return ret;
|
||||
@ -169,7 +169,7 @@ static int conf_tool_validate(TALLOC_CTX *mem_ctx,
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = conf_load(ctx->conf, ctx->conf_file, false);
|
||||
ret = conf_load(ctx->conf, ctx->conf_file, false, true);
|
||||
if (ret != 0) {
|
||||
D_ERR("Failed to load config file %s\n", ctx->conf_file);
|
||||
return ret;
|
||||
|
@ -138,7 +138,8 @@ static void setup_config_pointers(struct conf_context *conf)
|
||||
}
|
||||
|
||||
int ctdb_config_load(TALLOC_CTX *mem_ctx,
|
||||
struct conf_context **result)
|
||||
struct conf_context **result,
|
||||
bool verbose)
|
||||
{
|
||||
struct conf_context *conf = NULL;
|
||||
int ret = 0;
|
||||
@ -169,7 +170,7 @@ int ctdb_config_load(TALLOC_CTX *mem_ctx,
|
||||
ret = ENOMEM;
|
||||
goto fail;
|
||||
}
|
||||
ret = conf_load(conf, conf_file, true);
|
||||
ret = conf_load(conf, conf_file, true, verbose);
|
||||
/* Configuration file does not need to exist */
|
||||
if (ret != 0 && ret != ENOENT) {
|
||||
D_ERR("Failed to load configuration file %s\n", conf_file);
|
||||
|
@ -55,6 +55,7 @@ struct ctdb_config {
|
||||
|
||||
extern struct ctdb_config ctdb_config;
|
||||
|
||||
int ctdb_config_load(TALLOC_CTX *mem_ctx, struct conf_context **conf);
|
||||
int ctdb_config_load(TALLOC_CTX *mem_ctx, struct conf_context **conf,
|
||||
bool verbose);
|
||||
|
||||
#endif /* __CTDB_CONFIG_H__ */
|
||||
|
@ -85,7 +85,7 @@ int event_config_init(TALLOC_CTX *mem_ctx, struct event_config **result)
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
ret = conf_load(config->conf, config->config_file, true);
|
||||
ret = conf_load(config->conf, config->config_file, true, true);
|
||||
if (ret != 0 && ret != ENOENT) {
|
||||
talloc_free(config);
|
||||
return ret;
|
||||
|
@ -233,7 +233,7 @@ int main(int argc, const char *argv[])
|
||||
* Configuration file handling
|
||||
*/
|
||||
|
||||
ret = ctdb_config_load(ctdb, &conf);
|
||||
ret = ctdb_config_load(ctdb, &conf, true);
|
||||
if (ret != 0) {
|
||||
/* ctdb_config_load() logs the failure */
|
||||
goto fail;
|
||||
|
@ -373,7 +373,7 @@ static void test8(const char *filename)
|
||||
status = conf_valid(conf);
|
||||
assert(status == true);
|
||||
|
||||
ret = conf_load(conf, filename, true);
|
||||
ret = conf_load(conf, filename, true, true);
|
||||
conf_dump(conf, stdout);
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
@ -402,7 +402,7 @@ static void test9(const char *filename, bool ignore_unknown)
|
||||
|
||||
conf_set_boolean(conf, "section1", "key3", false);
|
||||
|
||||
ret = conf_load(conf, filename, ignore_unknown);
|
||||
ret = conf_load(conf, filename, ignore_unknown, true);
|
||||
conf_dump(conf, stdout);
|
||||
|
||||
talloc_free(mem_ctx);
|
||||
@ -433,7 +433,7 @@ static void test11(const char *filename)
|
||||
status = conf_valid(conf);
|
||||
assert(status == true);
|
||||
|
||||
ret = conf_load(conf, filename, false);
|
||||
ret = conf_load(conf, filename, false, true);
|
||||
assert(ret == 0);
|
||||
|
||||
ret = rename(reload, filename);
|
||||
|
Loading…
Reference in New Issue
Block a user