struct ctdb_script_wire scripts[1];
};
+/* different calls to event scripts. */
+enum ctdb_eventscript_call {
+ CTDB_EVENT_STARTUP, /* CTDB starting up: no args. */
+ CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
+ CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
+ CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
+ CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
+ CTDB_EVENT_STOPPED, /* This node is stopped: no args. */
+ CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
+ CTDB_EVENT_STATUS, /* Report service status: no args. */
+ CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
+ CTDB_EVENT_RELOAD, /* magic */
+ CTDB_EVENT_MAX
+};
+
+/* Mapping from enum to names. */
+extern const char *ctdb_eventscript_call_names[];
+
int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx, struct ctdb_scripts_wire **script_status);
unsigned char blob[1];
};
-/* different calls to event scripts. */
-enum ctdb_eventscript_call {
- CTDB_EVENT_STARTUP, /* CTDB starting up: no args. */
- CTDB_EVENT_START_RECOVERY, /* CTDB recovery starting: no args. */
- CTDB_EVENT_RECOVERED, /* CTDB recovery finished: no args. */
- CTDB_EVENT_TAKE_IP, /* IP taken: interface, IP address, netmask bits. */
- CTDB_EVENT_RELEASE_IP, /* IP released: interface, IP address, netmask bits. */
- CTDB_EVENT_STOPPED, /* This node is stopped: no args. */
- CTDB_EVENT_MONITOR, /* Please check if service is healthy: no args. */
- CTDB_EVENT_STATUS, /* Report service status: no args. */
- CTDB_EVENT_SHUTDOWN, /* CTDB shutting down: no args. */
- CTDB_EVENT_RELOAD, /* magic */
- CTDB_EVENT_MAX
-};
-
enum ctdb_freeze_mode {CTDB_FREEZE_NONE, CTDB_FREEZE_PENDING, CTDB_FREEZE_FROZEN};
#define CTDB_MONITORING_ACTIVE 0
const char *script_running;
} child_state;
-static const char *call_names[] = {
- "startup",
- "startrecovery",
- "recovered",
- "takeip",
- "releaseip",
- "stopped",
- "monitor",
- "status",
- "shutdown",
- "reload"
-};
-
static void ctdb_event_script_timeout(struct event_context *ev, struct timed_event *te, struct timeval t, void *p);
/*
return talloc_asprintf(ctx, "%s%s/%s %s %s",
str,
ctdb->event_script_dir,
- scriptname, call_names[call], options);
+ scriptname,
+ ctdb_eventscript_call_names[call],
+ options);
}
}
/* Aborted or finished all scripts? We're done. */
if (state->cb_status != 0 || state->current+1 == state->scripts->num_scripts) {
DEBUG(DEBUG_INFO,(__location__ " Eventscript %s %s finished with state %d\n",
- call_names[state->call], state->options, state->cb_status));
+ ctdb_eventscript_call_names[state->call], state->options, state->cb_status));
ctdb->event_script_timeouts = 0;
talloc_free(state);
struct ctdb_context *ctdb = state->ctdb;
DEBUG(DEBUG_ERR,("Event script timed out : %s %s count : %u pid : %d\n",
- call_names[state->call], state->options, ctdb->event_script_timeouts, state->child));
+ ctdb_eventscript_call_names[state->call], state->options, ctdb->event_script_timeouts, state->child));
state->cb_status = -ETIME;
}
if (!check_options(state->call, state->options)) {
DEBUG(DEBUG_ERR, ("Bad eventscript options '%s' for %s\n",
- call_names[state->call], state->options));
+ ctdb_eventscript_call_names[state->call], state->options));
talloc_free(state);
return -1;
}
}
if (i == ARRAY_SIZE(allowed_calls)) {
DEBUG(DEBUG_ERR,("Refusing to run event scripts call '%s' while in recovery\n",
- call_names[call]));
+ ctdb_eventscript_call_names[call]));
talloc_free(state);
return -1;
}
}
DEBUG(DEBUG_INFO,(__location__ " Starting eventscript %s %s\n",
- call_names[state->call], state->options));
+ ctdb_eventscript_call_names[state->call],
+ state->options));
/* This is not a child of state, since we save it in destructor. */
state->scripts = ctdb_get_script_list(ctdb, ctdb);
event_add_timed(ctdb->ev, state, timeval_current_ofs(state->timeout.tv_sec, state->timeout.tv_usec), ctdb_event_script_timeout, state);
} else {
DEBUG(DEBUG_ERR, (__location__ " eventscript %s %s called with no timeout\n",
- call_names[state->call], state->options));
+ ctdb_eventscript_call_names[state->call],
+ state->options));
}
return 0;
if (status.status == -ETIME) {
DEBUG(DEBUG_ERR, (__location__ " eventscript for '%s' timedout."
" Immediately banning ourself for %d seconds\n",
- call_names[call],
+ ctdb_eventscript_call_names[call],
ctdb->tunable.recovery_ban_period));
ctdb_ban_self(ctdb);
}
p += strspn(p, " \t");
/* See if we match any. */
- for (*call = 0; *call < ARRAY_SIZE(call_names); (*call)++) {
- len = strlen(call_names[*call]);
- if (strncmp(p, call_names[*call], len) == 0) {
+ for (*call = 0; *call < CTDB_EVENT_MAX; (*call)++) {
+ len = strlen(ctdb_eventscript_call_names[*call]);
+ if (strncmp(p, ctdb_eventscript_call_names[*call], len) == 0) {
/* If end of string or whitespace, we're done. */
if (strcspn(p + len, " \t") == 0) {
return p + len;