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_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_integer_pointer(conf
,
62 CLUSTER_CONF_LEADER_TIMEOUT
,
63 &ctdb_config
.leader_timeout
);
64 conf_assign_boolean_pointer(conf
,
66 CLUSTER_CONF_LEADER_CAPABILITY
,
67 &ctdb_config
.leader_capability
);
73 conf_assign_string_pointer(conf
,
74 DATABASE_CONF_SECTION
,
75 DATABASE_CONF_VOLATILE_DB_DIR
,
76 &ctdb_config
.dbdir_volatile
);
77 conf_assign_string_pointer(conf
,
78 DATABASE_CONF_SECTION
,
79 DATABASE_CONF_PERSISTENT_DB_DIR
,
80 &ctdb_config
.dbdir_persistent
);
81 conf_assign_string_pointer(conf
,
82 DATABASE_CONF_SECTION
,
83 DATABASE_CONF_STATE_DB_DIR
,
84 &ctdb_config
.dbdir_state
);
85 conf_assign_string_pointer(conf
,
86 DATABASE_CONF_SECTION
,
87 DATABASE_CONF_LOCK_DEBUG_SCRIPT
,
88 &ctdb_config
.lock_debug_script
);
89 conf_assign_boolean_pointer(conf
,
90 DATABASE_CONF_SECTION
,
91 DATABASE_CONF_TDB_MUTEXES
,
92 &ctdb_config
.tdb_mutexes
);
97 conf_assign_string_pointer(conf
,
99 EVENT_CONF_DEBUG_SCRIPT
,
100 &ctdb_config
.event_debug_script
);
105 conf_assign_boolean_pointer(conf
,
106 FAILOVER_CONF_SECTION
,
107 FAILOVER_CONF_DISABLED
,
108 &ctdb_config
.failover_disabled
);
114 conf_assign_boolean_pointer(conf
,
116 LEGACY_CONF_REALTIME_SCHEDULING
,
117 &ctdb_config
.realtime_scheduling
);
118 conf_assign_boolean_pointer(conf
,
120 LEGACY_CONF_LMASTER_CAPABILITY
,
121 &ctdb_config
.lmaster_capability
);
122 conf_assign_boolean_pointer(conf
,
124 LEGACY_CONF_START_AS_STOPPED
,
125 &ctdb_config
.start_as_stopped
);
126 conf_assign_boolean_pointer(conf
,
128 LEGACY_CONF_START_AS_DISABLED
,
129 &ctdb_config
.start_as_disabled
);
130 conf_assign_string_pointer(conf
,
132 LEGACY_CONF_SCRIPT_LOG_LEVEL
,
133 &ctdb_config
.script_log_level
);
136 int ctdbd_config_load(TALLOC_CTX
*mem_ctx
,
137 struct conf_context
**result
)
139 struct conf_context
*conf
= NULL
;
141 char *conf_file
= NULL
;
143 ret
= conf_init(mem_ctx
, &conf
);
148 logging_conf_init(conf
, NULL
);
149 cluster_conf_init(conf
);
150 database_conf_init(conf
);
151 event_conf_init(conf
);
152 failover_conf_init(conf
);
153 legacy_conf_init(conf
);
155 setup_config_pointers(conf
);
157 if (! conf_valid(conf
)) {
162 conf_file
= path_config(conf
);
163 if (conf_file
== NULL
) {
164 D_ERR("Memory allocation error\n");
168 ret
= conf_load(conf
, conf_file
, true);
169 /* Configuration file does not need to exist */
170 if (ret
!= 0 && ret
!= ENOENT
) {
171 D_ERR("Failed to load configuration file %s\n", conf_file
);
175 talloc_free(conf_file
);