to match the code in other daemons.
Signed-off-by: David Teigland <teigland@redhat.com>
#include "fd.h"
+#include "config.h"
#include "ccs.h"
static int ccs_handle;
+/* was a config value set on command line?, 0 or 1. */
+
+int optd_groupd_compat;
+int optd_clean_start;
+int optd_post_join_delay;
+int optd_post_fail_delay;
+int optd_override_time;
+int optd_override_path;
+
+/* actual config value from command line, cluster.conf, or default. */
+
+int cfgd_groupd_compat = DEFAULT_GROUPD_COMPAT;
+int cfgd_clean_start = DEFAULT_CLEAN_START;
+int cfgd_post_join_delay = DEFAULT_POST_JOIN_DELAY;
+int cfgd_post_fail_delay = DEFAULT_POST_FAIL_DELAY;
+int cfgd_override_time = DEFAULT_OVERRIDE_TIME;
+char *cfgd_override_path = DEFAULT_OVERRIDE_PATH;
+
int setup_ccs(void)
{
int i = 0, cd;
int read_ccs(struct fd *fd)
{
- char path[256];
+ char path[PATH_MAX];
char *str;
int error, i = 0, count = 0;
fence us. */
str = NULL;
- memset(path, 0, 256);
- snprintf(path, 256, OUR_NAME_PATH, our_name);
+ memset(path, 0, sizeof(path));
+ snprintf(path, sizeof(path), OUR_NAME_PATH, our_name);
error = ccs_get(ccs_handle, path, &str);
if (error || !str) {
if (str)
free(str);
- /* The comline config options are initially set to the defaults,
- then options are read from the command line to override the
- defaults, for options not set on command line, we look for
- values set in cluster.conf. */
-
- if (!comline.groupd_compat_opt)
- read_ccs_int(GROUPD_COMPAT_PATH, &comline.groupd_compat);
- if (!comline.clean_start_opt)
- read_ccs_int(CLEAN_START_PATH, &comline.clean_start);
- if (!comline.post_join_delay_opt)
- read_ccs_int(POST_JOIN_DELAY_PATH, &comline.post_join_delay);
- if (!comline.post_fail_delay_opt)
- read_ccs_int(POST_FAIL_DELAY_PATH, &comline.post_fail_delay);
- if (!comline.override_time_opt)
- read_ccs_int(OVERRIDE_TIME_PATH, &comline.override_time);
-
- if (!comline.override_path_opt) {
+ if (!optd_groupd_compat)
+ read_ccs_int(GROUPD_COMPAT_PATH, &cfgd_groupd_compat);
+ if (!optd_clean_start)
+ read_ccs_int(CLEAN_START_PATH, &cfgd_clean_start);
+ if (!optd_post_join_delay)
+ read_ccs_int(POST_JOIN_DELAY_PATH, &cfgd_post_join_delay);
+ if (!optd_post_fail_delay)
+ read_ccs_int(POST_FAIL_DELAY_PATH, &cfgd_post_fail_delay);
+ if (!optd_override_time)
+ read_ccs_int(OVERRIDE_TIME_PATH, &cfgd_override_time);
+
+ if (!optd_override_path) {
str = NULL;
- memset(path, 0, 256);
+ memset(path, 0, sizeof(path));
sprintf(path, OVERRIDE_PATH_PATH);
error = ccs_get(ccs_handle, path, &str);
- if (!error && str) {
- free(comline.override_path);
- comline.override_path = strdup(str);
- }
+ if (!error && str)
+ cfgd_override_path = strdup(str);
if (str)
free(str);
}
- if (comline.clean_start) {
+ if (cfgd_clean_start) {
log_debug("clean start, skipping initial nodes");
goto out;
}
for (i = 1; ; i++) {
str = NULL;
- memset(path, 0, 256);
+ memset(path, 0, sizeof(path));
sprintf(path, "/cluster/clusternodes/clusternode[%d]/@nodeid", i);
error = ccs_get(ccs_handle, path, &str);
--- /dev/null
+#ifndef __CONFIG_DOT_H__
+#define __CONFIG_DOT_H__
+
+#define DEFAULT_GROUPD_COMPAT 1
+#define DEFAULT_CLEAN_START 0
+#define DEFAULT_POST_JOIN_DELAY 6
+#define DEFAULT_POST_FAIL_DELAY 0
+#define DEFAULT_OVERRIDE_TIME 3
+#define DEFAULT_OVERRIDE_PATH "/var/run/cluster/fenced_override"
+
+extern int optd_groupd_compat;
+extern int optd_clean_start;
+extern int optd_post_join_delay;
+extern int optd_post_fail_delay;
+extern int optd_override_time;
+extern int optd_override_path;
+
+extern int cfgd_groupd_compat;
+extern int cfgd_clean_start;
+extern int cfgd_post_join_delay;
+extern int cfgd_post_fail_delay;
+extern int cfgd_override_time;
+extern char *cfgd_override_path;
+
+#endif
+
log_printf(lvl, fmt, ##args); \
} while (0)
-/* config option defaults */
-
-#define DEFAULT_GROUPD_COMPAT 1
-#define DEFAULT_CLEAN_START 0
-#define DEFAULT_POST_JOIN_DELAY 6
-#define DEFAULT_POST_FAIL_DELAY 0
-#define DEFAULT_OVERRIDE_TIME 3
-#define DEFAULT_OVERRIDE_PATH "/var/run/cluster/fenced_override"
-
-struct commandline
-{
- int groupd_compat;
- int clean_start;
- int post_join_delay;
- int post_fail_delay;
- int override_time;
- char *override_path;
-
- int8_t groupd_compat_opt;
- int8_t clean_start_opt;
- int8_t post_join_delay_opt;
- int8_t post_fail_delay_opt;
- int8_t override_time_opt;
- int8_t override_path_opt;
-};
-
-extern struct commandline comline;
-
#define FD_MSG_START 1
#define FD_MSG_VICTIM_DONE 2
#define FD_MSG_COMPLETE 3
#include "fd.h"
-#include "pthread.h"
+#include "config.h"
+#include <pthread.h>
#include "copyright.cf"
#define LOCKFILE_NAME "/var/run/fenced.pid"
group_mode = GROUP_LIBCPG;
- if (comline.groupd_compat) {
+ if (cfgd_groupd_compat) {
rv = setup_groupd();
if (rv < 0)
goto out;
group_mode = GROUP_LIBGROUP;
- if (comline.groupd_compat == 2) {
+ if (cfgd_groupd_compat == 2) {
/* set_group_mode(); */
group_mode = GROUP_LIBGROUP;
}
break;
}
out:
- if (comline.groupd_compat)
+ if (cfgd_groupd_compat)
close_groupd();
close_logging();
close_ccs();
break;
case 'g':
- comline.groupd_compat = atoi(optarg);
- comline.groupd_compat_opt = 1;
+ optd_groupd_compat = 1;
+ cfgd_groupd_compat = atoi(optarg);
break;
case 'c':
- comline.clean_start = 1;
- comline.clean_start_opt = 1;
+ optd_clean_start = 1;
+ cfgd_clean_start = 1;
break;
case 'j':
- comline.post_join_delay = atoi(optarg);
- comline.post_join_delay_opt = 1;
+ optd_post_join_delay = 1;
+ cfgd_post_join_delay = atoi(optarg);
break;
case 'f':
- comline.post_fail_delay = atoi(optarg);
- comline.post_fail_delay_opt = 1;
+ optd_post_fail_delay = 1;
+ cfgd_post_fail_delay = atoi(optarg);
break;
case 'R':
- comline.override_time = atoi(optarg);
- if (comline.override_time < 3)
- comline.override_time = 3;
- comline.override_time_opt = 1;
+ optd_override_time = 1;
+ cfgd_override_time = atoi(optarg);
+ if (cfgd_override_time < 3)
+ cfgd_override_time = 3;
break;
case 'O':
- if (comline.override_path)
- free(comline.override_path);
- comline.override_path = strdup(optarg);
- comline.override_path_opt = 1;
+ optd_override_path = 1;
+ cfgd_override_path = strdup(optarg);
break;
case 'h':
{
INIT_LIST_HEAD(&domains);
- memset(&comline, 0, sizeof(comline));
- comline.groupd_compat = DEFAULT_GROUPD_COMPAT;
- comline.clean_start = DEFAULT_CLEAN_START;
- comline.post_join_delay = DEFAULT_POST_JOIN_DELAY;
- comline.post_fail_delay = DEFAULT_POST_FAIL_DELAY;
- comline.override_time = DEFAULT_OVERRIDE_TIME;
- comline.override_path = strdup(DEFAULT_OVERRIDE_PATH);
-
init_logging();
read_arguments(argc, argv);
int dump_point;
int dump_wrap;
int group_mode;
-struct commandline comline;
#include "fd.h"
+#include "config.h"
void free_node_list(struct list_head *head)
{
return;
if (node_join) {
- delay = comline.post_join_delay;
+ delay = cfgd_post_join_delay;
delay_type = "post_join_delay";
} else {
- delay = comline.post_fail_delay;
+ delay = cfgd_post_fail_delay;
delay_type = "post_fail_delay";
}
if (victim_count < last_count) {
gettimeofday(&start, NULL);
- if (delay > 0 && comline.post_join_delay > delay) {
- delay = comline.post_join_delay;
+ if (delay > 0 && cfgd_post_join_delay > delay) {
+ delay = cfgd_post_join_delay;
delay_type = "post_join_delay (modified)";
}
}
continue;
}
- if (!comline.override_path) {
+ if (!cfgd_override_path) {
query_unlock();
sleep(5);
query_lock();
query_unlock();
/* Check for manual intervention */
- override = open_override(comline.override_path);
+ override = open_override(cfgd_override_path);
if (check_override(override, node->name,
- comline.override_time) > 0) {
+ cfgd_override_time) > 0) {
log_level(LOG_WARNING, "fence \"%s\" overridden by "
"administrator intervention", node->name);
victim_done(fd, node->nodeid, VIC_DONE_OVERRIDE);
list_del(&node->list);
free(node);
}
- close_override(&override, comline.override_path);
+ close_override(&override, cfgd_override_path);
query_lock();
}
}