19 #include <libxml/tree.h> 27 static GMainLoop *mainloop = NULL;
38 } async_fence_data = { NULL, };
44 const char *node = NULL;
45 const char *pattern = NULL;
46 const char *
name = NULL;
56 value = strchr(
target,
'=');
60 }
else if (*
target ==
'@') {
70 for (GList *iter = devices; iter != NULL; iter = iter->next) {
75 value, fence_level, kvs);
79 name, value, fence_level);
103 for (np =
new; ; np = np->
next) {
139 g_main_loop_quit(mainloop);
149 g_main_loop_quit(mainloop);
153 async_fence_helper(gpointer user_data)
161 g_main_loop_quit(mainloop);
172 async_fence_data.target,
173 async_fence_data.action,
176 async_fence_data.delay);
179 g_main_loop_quit(mainloop);
186 if (async_fence_data.delay > 0) {
187 timeout += async_fence_data.delay;
190 NULL,
"callback", fence_callback);
202 async_fence_data.st =
st;
203 async_fence_data.name = strdup(
name);
204 async_fence_data.target =
target;
205 async_fence_data.action =
action;
206 async_fence_data.timeout =
timeout;
208 async_fence_data.delay =
delay;
215 mainloop = g_main_loop_new(NULL, FALSE);
216 g_main_loop_run(mainloop);
218 free(async_fence_data.name);
220 if (reason != NULL) {
222 *reason = async_fence_data.result.exit_reason;
223 async_fence_data.result.exit_reason = NULL;
255 unsigned int timeout,
int verbose,
bool broadcast,
264 out->
info(out,
"cleaning up fencing-history%s%s",
269 out->
info(out,
"gather fencing-history from all nodes");
294 out->
begin_list(out,
"event",
"events",
"Fencing history");
302 if (out->
is_quiet(out) || !verbose) {
306 out->
message(out,
"stonith-event", hp,
true,
false,
314 out->
message(out,
"stonith-event", latest,
false,
true, NULL,
316 }
else if (!verbose) {
317 out->
message(out,
"stonith-event", latest,
false,
false, NULL,
331 bool quiet,
int verbose,
bool broadcast,
bool cleanup)
366 out->
begin_list(out,
"fence device",
"fence devices",
367 "Installed fence devices");
369 out->
list_item(out,
"device",
"%s", iter->value);
435 const char *device_id,
unsigned int timeout)
437 GList *targets = NULL;
448 out->
begin_list(out,
"fence target",
"fence targets",
"Fence Targets");
449 while (targets != NULL) {
450 out->
list_item(out, NULL,
"%s", (
const char *) targets->data);
451 targets = targets->next;
529 out->
begin_list(out,
"fence device",
"fence devices",
530 "Registered fence devices");
532 out->
list_item(out,
"device",
"%s", iter->value);
568 return handle_level(
st,
target, fence_level, devices,
true);
595 return handle_level(
st,
target, fence_level, NULL,
false);
620 const char *
id, GHashTable *params,
unsigned int timeout)
623 char *error_output = NULL;
628 out->
message(out,
"validate", agent,
id, output, error_output, rc);
634 GHashTable *params,
unsigned int timeout)
672 *stonith_history = reduce_fence_history(*stonith_history);
void(* end_list)(pcmk__output_t *out)
int(* fence_with_delay)(stonith_t *stonith, int call_options, const char *node, const char *action, int timeout, int tolerance, int delay)
Request delayed fencing of a target.
struct stonith_history_s * next
const char * pcmk_strerror(int rc)
No connection to executor.
int pcmk__fence_last(pcmk__output_t *out, const char *target, bool as_nodeid)
When was a device last fenced?
int pcmk_fence_last(xmlNodePtr *xml, const char *target, bool as_nodeid)
When was a device last fenced?
Control output from tools.
void stonith__register_messages(pcmk__output_t *out)
int stonith__event_execution_status(const stonith_event_t *event)
int pcmk_fence_register_level(xmlNodePtr *xml, const char *target, int fence_level, GList *devices)
Register a fencing topology level.
int(* message)(pcmk__output_t *out, const char *message_id,...)
G_GNUC_INTERNAL int pcmk__setup_output_fencing(pcmk__output_t **out, stonith_t **st, xmlNode **xml)
pcmk__fence_history
Control how much of the fencing history is output.
int(* register_level_full)(stonith_t *st, int options, const char *node, const char *pattern, const char *attr, const char *value, int level, const stonith_key_value_t *device_list)
Register fencing level for specified node, pattern or attribute.
bool(* is_quiet)(pcmk__output_t *out)
stonith_history_t * stonith__sort_history(stonith_history_t *history)
int(* register_callback)(stonith_t *stonith, int call_id, int timeout, int options, void *user_data, const char *callback_name, void(*callback)(stonith_t *st, stonith_callback_data_t *data))
Register a callback for an asynchronous fencing result.
struct stonith_key_value_s * next
crm_exit_t pcmk_rc2exitc(int rc)
Map a function return code to the most similar exit code.
int stonith__result2rc(const pcmk__action_result_t *result)
int stonith__exit_status(const stonith_callback_data_t *data)
void mainloop_set_trigger(crm_trigger_t *source)
int pcmk_fence_registered(xmlNodePtr *xml, const char *target, unsigned int timeout)
List registered fence devices.
int stonith__execution_status(const stonith_callback_data_t *data)
int pcmk_fence_list_targets(xmlNodePtr *xml, const char *device_id, unsigned int timeout)
List nodes that can be fenced.
int(* register_notification)(stonith_t *stonith, const char *event, void(*callback)(stonith_t *st, stonith_event_t *e))
Register a callback for fence notifications.
void pcmk__xml_output_finish(pcmk__output_t *out, crm_exit_t exit_status, xmlNodePtr *xml)
int pcmk__fence_history(pcmk__output_t *out, stonith_t *st, const char *target, unsigned int timeout, int verbose, bool broadcast, bool cleanup)
List the fencing operations that have occurred for a specific node.
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
The fencing target is allowed to execute the request.
const char * stonith__event_exit_reason(const stonith_event_t *event)
Wrappers for and extensions to glib mainloop.
int stonith_api_connect_retry(stonith_t *st, const char *name, int max_attempts)
Make a blocking connection attempt to the fencer.
int(* list_agents)(stonith_t *stonith, int call_options, const char *namespace_s, stonith_key_value_t **devices, int timeout)
Retrieve a list of installed fence agents.
int pcmk_fence_validate(xmlNodePtr *xml, const char *agent, const char *id, GHashTable *params, unsigned int timeout)
Validate a fence device configuration.
struct trigger_s crm_trigger_t
stonith_key_value_t * stonith_key_value_add(stonith_key_value_t *kvp, const char *key, const char *value)
GList * stonith__parse_targets(const char *hosts)
Formatted output for pacemaker tools.
For a fence history request, broadcast the request to all nodes.
int pcmk__fence_installed(pcmk__output_t *out, stonith_t *st, unsigned int timeout)
List all installed fence agents.
For a fence history request, request that the history be cleared.
Used only to initialize variables.
const char * stonith__later_succeeded(const stonith_history_t *event, const stonith_history_t *top_history)
int pcmk__fence_unregister_level(stonith_t *st, const char *target, int fence_level)
Unregister a fencing level for specific node, node regex, or attribute.
int pcmk__xml_output_new(pcmk__output_t **out, xmlNodePtr *xml)
bool quiet
Should this formatter supress most output?
int(*) int(*) void(*) void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
int pcmk_fence_installed(xmlNodePtr *xml, unsigned int timeout)
List all installed fence agents.
#define stonith__set_call_options(st_call_opts, call_for, flags_to_set)
crm_trigger_t * mainloop_add_trigger(int priority, int(*dispatch)(gpointer user_data), gpointer userdata)
Create a trigger to be used as a mainloop source.
int(* disconnect)(stonith_t *st)
Disconnect from the local stonith daemon.
void stonith_key_value_freeall(stonith_key_value_t *kvp, int keys, int values)
int pcmk_legacy2rc(int legacy_rc)
int pcmk__request_fencing(stonith_t *st, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay, char **reason)
Ask the cluster to perform fencing.
int pcmk__fence_metadata(pcmk__output_t *out, stonith_t *st, const char *agent, unsigned int timeout)
Get metadata for a fence agent.
int(* metadata)(stonith_t *stonith, int call_options, const char *agent, const char *namespace_s, char **output, int timeout_sec)
Retrieve a fence agent's metadata.
int pcmk__fence_register_level(stonith_t *st, const char *target, int fence_level, GList *devices)
Register a fencing level for a specific node, node regex, or attribute.
int pcmk__fence_registered(pcmk__output_t *out, stonith_t *st, const char *target, unsigned int timeout)
List registered fence devices.
Function and executable result codes.
int pcmk_fence_metadata(xmlNodePtr *xml, const char *agent, unsigned int timeout)
Get metadata for a fence agent.
Wait for request to be completed before returning.
int pcmk_request_fencing(xmlNodePtr *xml, const char *target, const char *action, const char *name, unsigned int timeout, unsigned int tolerance, int delay, char **reason)
Ask the cluster to perform fencing.
int(* history)(stonith_t *stonith, int call_options, const char *node, stonith_history_t **history, int timeout)
List fencing actions that have occurred for a target.
int pcmk__fence_validate(pcmk__output_t *out, stonith_t *st, const char *agent, const char *id, GHashTable *params, unsigned int timeout)
Validate a fence device configuration.
void stonith_api_delete(stonith_t *st)
pcmk__action_result_t result
int pcmk__fence_list_targets(pcmk__output_t *out, stonith_t *st, const char *device_id, unsigned int timeout)
List nodes that can be fenced.
int stonith__validate(stonith_t *st, int call_options, const char *rsc_id, const char *namespace_s, const char *agent, GHashTable *params, int timeout_sec, char **output, char **error_output)
void(*) void(* list_item)(pcmk__output_t *out, const char *name, const char *format,...) G_GNUC_PRINTF(3
int(* remove_level_full)(stonith_t *st, int options, const char *node, const char *pattern, const char *attr, const char *value, int level)
Unregister fencing level for specified node, pattern or attribute.
stonith_api_operations_t * cmds
void stonith_history_free(stonith_history_t *history)
Request that server send an update with optimal callback timeout.
guint pcmk__timeout_ms2s(guint timeout_ms)
This structure contains everything that makes up a single output formatter.
void(* begin_list)(pcmk__output_t *out, const char *singular_noun, const char *plural_noun, const char *format,...) G_GNUC_PRINTF(4
#define PCMK__VALUE_ST_NOTIFY_FENCE
int pcmk_fence_history(xmlNodePtr *xml, const char *target, unsigned int timeout, bool quiet, int verbose, bool broadcast, bool cleanup)
List the fencing operations that have occurred for a specific node.
int(* query)(stonith_t *stonith, int call_options, const char *target, stonith_key_value_t **devices, int timeout)
List registered fence devices.
time_t stonith_api_time(uint32_t nodeid, const char *uname, bool in_progress)
int pcmk__get_fencing_history(stonith_t *st, stonith_history_t **stonith_history, enum pcmk__fence_history fence_history)
Fetch fencing history, optionally reducing it.
int(* list)(stonith_t *stonith, int call_options, const char *id, char **list_info, int timeout)
Get the output of a fence device's list action.
void pcmk__set_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *exit_reason)
const char * stonith__exit_reason(const stonith_callback_data_t *data)
int pcmk_fence_unregister_level(xmlNodePtr *xml, const char *target, int fence_level)
Unregister a fencing topology level.
void pcmk__reset_result(pcmk__action_result_t *result)
Execution failed, may be retried.
void(*) void(*) void(* increment_list)(pcmk__output_t *out)
int stonith__event_exit_status(const stonith_event_t *event)