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/path.h"
26 #include "conf/conf.h"
27 #include "conf/logging_conf.h"
28 #include "conf/cluster_conf.h"
29 #include "conf/database_conf.h"
30 #include "conf/event_conf.h"
31 #include "conf/failover_conf.h"
32 #include "conf/legacy_conf.h"
34 #include "conf/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_CLUSTER_LOCK
,
55 &ctdb_config
.cluster_lock
);
56 conf_assign_string_pointer(conf
,
58 CLUSTER_CONF_RECOVERY_LOCK
,
59 &ctdb_config
.recovery_lock
);
60 conf_assign_string_pointer(conf
,
62 CLUSTER_CONF_NODES_LIST
,
63 &ctdb_config
.nodes_list
);
64 conf_assign_integer_pointer(conf
,
66 CLUSTER_CONF_LEADER_TIMEOUT
,
67 &ctdb_config
.leader_timeout
);
68 conf_assign_boolean_pointer(conf
,
70 CLUSTER_CONF_LEADER_CAPABILITY
,
71 &ctdb_config
.leader_capability
);
77 conf_assign_string_pointer(conf
,
78 DATABASE_CONF_SECTION
,
79 DATABASE_CONF_VOLATILE_DB_DIR
,
80 &ctdb_config
.dbdir_volatile
);
81 conf_assign_string_pointer(conf
,
82 DATABASE_CONF_SECTION
,
83 DATABASE_CONF_PERSISTENT_DB_DIR
,
84 &ctdb_config
.dbdir_persistent
);
85 conf_assign_string_pointer(conf
,
86 DATABASE_CONF_SECTION
,
87 DATABASE_CONF_STATE_DB_DIR
,
88 &ctdb_config
.dbdir_state
);
89 conf_assign_string_pointer(conf
,
90 DATABASE_CONF_SECTION
,
91 DATABASE_CONF_LOCK_DEBUG_SCRIPT
,
92 &ctdb_config
.lock_debug_script
);
93 conf_assign_boolean_pointer(conf
,
94 DATABASE_CONF_SECTION
,
95 DATABASE_CONF_TDB_MUTEXES
,
96 &ctdb_config
.tdb_mutexes
);
101 conf_assign_string_pointer(conf
,
103 EVENT_CONF_DEBUG_SCRIPT
,
104 &ctdb_config
.event_debug_script
);
109 conf_assign_boolean_pointer(conf
,
110 FAILOVER_CONF_SECTION
,
111 FAILOVER_CONF_DISABLED
,
112 &ctdb_config
.failover_disabled
);
118 conf_assign_boolean_pointer(conf
,
120 LEGACY_CONF_REALTIME_SCHEDULING
,
121 &ctdb_config
.realtime_scheduling
);
122 conf_assign_boolean_pointer(conf
,
124 LEGACY_CONF_LMASTER_CAPABILITY
,
125 &ctdb_config
.lmaster_capability
);
126 conf_assign_boolean_pointer(conf
,
128 LEGACY_CONF_START_AS_STOPPED
,
129 &ctdb_config
.start_as_stopped
);
130 conf_assign_boolean_pointer(conf
,
132 LEGACY_CONF_START_AS_DISABLED
,
133 &ctdb_config
.start_as_disabled
);
134 conf_assign_string_pointer(conf
,
136 LEGACY_CONF_SCRIPT_LOG_LEVEL
,
137 &ctdb_config
.script_log_level
);
140 int ctdb_config_load(TALLOC_CTX
*mem_ctx
,
141 struct conf_context
**result
,
144 struct conf_context
*conf
= NULL
;
146 char *conf_file
= NULL
;
148 ret
= conf_init(mem_ctx
, &conf
);
153 logging_conf_init(conf
, NULL
);
154 cluster_conf_init(conf
);
155 database_conf_init(conf
);
156 event_conf_init(conf
);
157 failover_conf_init(conf
);
158 legacy_conf_init(conf
);
160 setup_config_pointers(conf
);
162 if (! conf_valid(conf
)) {
167 conf_file
= path_config(conf
);
168 if (conf_file
== NULL
) {
169 D_ERR("Memory allocation error\n");
173 ret
= conf_load(conf
, conf_file
, true, verbose
);
174 /* Configuration file does not need to exist */
175 if (ret
!= 0 && ret
!= ENOENT
) {
176 D_ERR("Failed to load configuration file %s\n", conf_file
);
180 talloc_free(conf_file
);