ctdb-daemon: Switch banning code to use ctdb_node_become_inactive()
[amitay/samba.git] / ctdb / server / legacy_conf.c
1 /*
2    CTDB legacy config handling
3
4    Copyright (C) Martin Schwenke  2018
5
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.
10
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.
15
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/>.
18 */
19
20 #include "replace.h"
21
22 #include "lib/util/debug.h"
23
24 #include "common/conf.h"
25 #include "common/logging.h"
26
27 #include "legacy_conf.h"
28
29 #define LEGACY_SCRIPT_LOG_LEVEL_DEFAULT "ERROR"
30
31 static bool legacy_conf_validate_script_log_level(const char *key,
32                                                   const char *old_loglevel,
33                                                   const char *new_loglevel,
34                                                   enum conf_update_mode mode)
35 {
36         int log_level;
37         bool ok;
38
39         ok = debug_level_parse(new_loglevel, &log_level);
40         if (!ok) {
41                 D_ERR("Invalid value for [%s] -> %s = %s\n",
42                       LEGACY_CONF_SECTION,
43                       key,
44                       new_loglevel);
45                 return false;
46         }
47
48         return true;
49 }
50
51 void legacy_conf_init(struct conf_context *conf)
52 {
53         conf_define_section(conf, LEGACY_CONF_SECTION, NULL);
54
55         conf_define_boolean(conf,
56                             LEGACY_CONF_SECTION,
57                             LEGACY_CONF_REALTIME_SCHEDULING,
58                             true,
59                             NULL);
60         conf_define_boolean(conf,
61                             LEGACY_CONF_SECTION,
62                             LEGACY_CONF_RECMASTER_CAPABILITY,
63                             true,
64                             NULL);
65         conf_define_boolean(conf,
66                             LEGACY_CONF_SECTION,
67                             LEGACY_CONF_LMASTER_CAPABILITY,
68                             true,
69                             NULL);
70         conf_define_boolean(conf,
71                             LEGACY_CONF_SECTION,
72                             LEGACY_CONF_START_AS_STOPPED,
73                             false,
74                             NULL);
75         conf_define_boolean(conf,
76                             LEGACY_CONF_SECTION,
77                             LEGACY_CONF_START_AS_DISABLED,
78                             false,
79                             NULL);
80         conf_define_string(conf,
81                            LEGACY_CONF_SECTION,
82                            LEGACY_CONF_SCRIPT_LOG_LEVEL,
83                            LEGACY_SCRIPT_LOG_LEVEL_DEFAULT,
84                            legacy_conf_validate_script_log_level);
85 }