2 CTDB daemon config handling
4 Copyright (C) Martin Schwenke 2018
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "lib/util/debug.h"
24 #include "common/conf.h"
25 #include "common/logging_conf.h"
26 #include "common/path.h"
28 #include "cluster/cluster_conf.h"
29 #include "database/database_conf.h"
30 #include "event/event_conf.h"
31 #include "failover/failover_conf.h"
32 #include "legacy_conf.h"
34 #include "ctdb_config.h"
36 struct ctdb_config ctdb_config
;
38 static void setup_config_pointers(struct conf_context
*conf
)
44 conf_assign_string_pointer(conf
,
46 CLUSTER_CONF_TRANSPORT
,
47 &ctdb_config
.transport
);
48 conf_assign_string_pointer(conf
,
50 CLUSTER_CONF_NODE_ADDRESS
,
51 &ctdb_config
.node_address
);
52 conf_assign_string_pointer(conf
,
54 CLUSTER_CONF_RECOVERY_LOCK
,
55 &ctdb_config
.recovery_lock
);
61 conf_assign_string_pointer(conf
,
62 DATABASE_CONF_SECTION
,
63 DATABASE_CONF_VOLATILE_DB_DIR
,
64 &ctdb_config
.dbdir_volatile
);
65 conf_assign_string_pointer(conf
,
66 DATABASE_CONF_SECTION
,
67 DATABASE_CONF_PERSISTENT_DB_DIR
,
68 &ctdb_config
.dbdir_persistent
);
69 conf_assign_string_pointer(conf
,
70 DATABASE_CONF_SECTION
,
71 DATABASE_CONF_STATE_DB_DIR
,
72 &ctdb_config
.dbdir_state
);
73 conf_assign_string_pointer(conf
,
74 DATABASE_CONF_SECTION
,
75 DATABASE_CONF_LOCK_DEBUG_SCRIPT
,
76 &ctdb_config
.lock_debug_script
);
77 conf_assign_boolean_pointer(conf
,
78 DATABASE_CONF_SECTION
,
79 DATABASE_CONF_TDB_MUTEXES
,
80 &ctdb_config
.tdb_mutexes
);
85 conf_assign_string_pointer(conf
,
87 EVENT_CONF_DEBUG_SCRIPT
,
88 &ctdb_config
.event_debug_script
);
93 conf_assign_boolean_pointer(conf
,
94 FAILOVER_CONF_SECTION
,
95 FAILOVER_CONF_DISABLED
,
96 &ctdb_config
.failover_disabled
);
102 conf_assign_boolean_pointer(conf
,
104 LEGACY_CONF_REALTIME_SCHEDULING
,
105 &ctdb_config
.realtime_scheduling
);
106 conf_assign_boolean_pointer(conf
,
108 LEGACY_CONF_RECMASTER_CAPABILITY
,
109 &ctdb_config
.recmaster_capability
);
110 conf_assign_boolean_pointer(conf
,
112 LEGACY_CONF_LMASTER_CAPABILITY
,
113 &ctdb_config
.lmaster_capability
);
114 conf_assign_boolean_pointer(conf
,
116 LEGACY_CONF_START_AS_STOPPED
,
117 &ctdb_config
.start_as_stopped
);
118 conf_assign_boolean_pointer(conf
,
120 LEGACY_CONF_START_AS_DISABLED
,
121 &ctdb_config
.start_as_disabled
);
122 conf_assign_string_pointer(conf
,
124 LEGACY_CONF_SCRIPT_LOG_LEVEL
,
125 &ctdb_config
.script_log_level
);
128 int ctdbd_config_load(TALLOC_CTX
*mem_ctx
,
129 struct conf_context
**result
)
131 struct conf_context
*conf
= NULL
;
133 char *conf_file
= NULL
;
135 ret
= conf_init(mem_ctx
, &conf
);
140 logging_conf_init(conf
, "NOTICE");
141 cluster_conf_init(conf
);
142 database_conf_init(conf
);
143 event_conf_init(conf
);
144 failover_conf_init(conf
);
145 legacy_conf_init(conf
);
147 setup_config_pointers(conf
);
149 if (! conf_valid(conf
)) {
154 conf_file
= path_config(conf
);
155 if (conf_file
== NULL
) {
156 D_ERR("Memory allocation error\n");
160 ret
= conf_load(conf
, conf_file
, true);
161 /* Configuration file does not need to exist */
162 if (ret
!= 0 && ret
!= ENOENT
) {
163 D_ERR("Failed to load configuration file %s\n", conf_file
);
167 talloc_free(conf_file
);