19 #include <libxml/tree.h> 25 static GMainLoop *mainloop = NULL;
36 } async_fence_data = { NULL, };
42 const char *node = NULL;
43 const char *pattern = NULL;
44 const char *
name = NULL;
54 value = strchr(
target,
'=');
58 }
else if (*
target ==
'@') {
67 name, value, fence_level,
71 name, value, fence_level);
95 for (np =
new; ; np = np->
next) {
131 g_main_loop_quit(mainloop);
141 g_main_loop_quit(mainloop);
145 async_fence_helper(gpointer user_data)
153 g_main_loop_quit(mainloop);
164 async_fence_data.target,
165 async_fence_data.action,
166 async_fence_data.timeout/1000,
167 async_fence_data.tolerance/1000,
168 async_fence_data.delay);
171 g_main_loop_quit(mainloop);
177 timeout = async_fence_data.timeout / 1000;
178 if (async_fence_data.delay > 0) {
179 timeout += async_fence_data.delay;
182 NULL,
"callback", fence_callback);
194 async_fence_data.st =
st;
195 async_fence_data.name = strdup(
name);
196 async_fence_data.target =
target;
197 async_fence_data.action =
action;
198 async_fence_data.timeout =
timeout;
200 async_fence_data.delay =
delay;
207 mainloop = g_main_loop_new(NULL, FALSE);
208 g_main_loop_run(mainloop);
210 free(async_fence_data.name);
212 if (reason != NULL) {
214 *reason = async_fence_data.result.exit_reason;
215 async_fence_data.result.exit_reason = NULL;
222 #ifdef BUILD_PUBLIC_LIBPACEMAKER 235 unsigned int timeout,
int verbose,
bool broadcast,
243 out->
info(out,
"cleaning up fencing-history%s%s",
247 out->
info(out,
"gather fencing-history from all nodes");
268 out->
begin_list(out,
"event",
"events",
"Fencing history");
271 for (hp = history; hp; hp = hp->
next) {
276 if (out->
is_quiet(out) || !verbose) {
280 out->
message(out,
"stonith-event", hp,
true,
false,
288 out->
message(out,
"stonith-event", latest,
false,
true, NULL,
290 }
else if (!verbose) {
291 out->
message(out,
"stonith-event", latest,
false,
false, NULL,
303 #ifdef BUILD_PUBLIC_LIBPACEMAKER 306 unsigned int timeout,
bool quiet,
int verbose,
307 bool broadcast,
bool cleanup)
341 out->
begin_list(out,
"fence device",
"fence devices",
342 "Installed fence devices");
344 out->
list_item(out,
"device",
"%s", iter->value);
352 #ifdef BUILD_PUBLIC_LIBPACEMAKER 390 #ifdef BUILD_PUBLIC_LIBPACEMAKER 392 pcmk_fence_last(xmlNodePtr *xml,
const char *
target,
bool as_nodeid)
412 const char *device_id,
unsigned int timeout)
414 GList *targets = NULL;
425 out->
begin_list(out,
"fence target",
"fence targets",
"Fence Targets");
426 while (targets != NULL) {
427 out->
list_item(out, NULL,
"%s", (
const char *) targets->data);
428 targets = targets->next;
436 #ifdef BUILD_PUBLIC_LIBPACEMAKER 438 pcmk_fence_list_targets(xmlNodePtr *xml,
stonith_t *
st,
const char *device_id,
474 #ifdef BUILD_PUBLIC_LIBPACEMAKER 476 pcmk_fence_metadata(xmlNodePtr *xml,
stonith_t *
st,
const char *agent,
508 out->
begin_list(out,
"fence device",
"fence devices",
509 "Registered fence devices");
511 out->
list_item(out,
"device",
"%s", iter->value);
523 #ifdef BUILD_PUBLIC_LIBPACEMAKER 548 return handle_level(
st,
target, fence_level, devices,
true);
551 #ifdef BUILD_PUBLIC_LIBPACEMAKER 563 return handle_level(
st,
target, fence_level, NULL,
false);
566 #ifdef BUILD_PUBLIC_LIBPACEMAKER 580 char *error_output = NULL;
584 timeout/1000, &output, &error_output);
585 out->
message(out,
"validate", agent,
id, output, error_output, rc);
589 #ifdef BUILD_PUBLIC_LIBPACEMAKER 591 pcmk_fence_validate(xmlNodePtr *xml,
stonith_t *
st,
const char *agent,
630 *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_validate(pcmk__output_t *out, stonith_t *st, const char *agent, const char *id, const stonith_key_value_t *params, unsigned int timeout)
Validate a fence device configuration.
Control output from tools.
void stonith__register_messages(pcmk__output_t *out)
int stonith__event_execution_status(const stonith_event_t *event)
int(* message)(pcmk__output_t *out, const char *message_id,...)
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 stonith__execution_status(const stonith_callback_data_t *data)
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
const char * stonith__event_exit_reason(const stonith_event_t *event)
Wrappers for and extensions to glib mainloop.
int pcmk__fence_register_level(stonith_t *st, const char *target, int fence_level, const stonith_key_value_t *devices)
Register a fencing level for a specific node, node regex, or attribute.
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.
struct trigger_s crm_trigger_t
GList * stonith__parse_targets(const char *hosts)
int(* validate)(stonith_t *st, int call_options, const char *rsc_id, const char *namespace_s, const char *agent, const stonith_key_value_t *params, int timeout, char **output, char **error_output)
Validate an arbitrary stonith device configuration.
Formatted output for pacemaker tools.
int pcmk__fence_installed(pcmk__output_t *out, stonith_t *st, unsigned int timeout)
List all installed fence agents.
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)
#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.
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_registered(pcmk__output_t *out, stonith_t *st, const char *target, unsigned int timeout)
List registered fence devices.
Function and executable result codes.
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.
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.
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)
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(* 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)
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)