18 #include <libxml/tree.h> 24 static GMainLoop *mainloop = NULL;
35 } async_fence_data = { NULL, };
52 value = strchr(
target,
'=');
56 }
else if (*
target ==
'@') {
65 name, value, fence_level,
69 name, value, fence_level);
93 for (np =
new; ; np = np->
next) {
128 g_main_loop_quit(mainloop);
138 g_main_loop_quit(mainloop);
142 async_fence_helper(gpointer user_data)
149 g_main_loop_quit(mainloop);
159 async_fence_data.target,
160 async_fence_data.action,
161 async_fence_data.timeout/1000,
162 async_fence_data.tolerance/1000,
163 async_fence_data.delay);
166 g_main_loop_quit(mainloop);
174 async_fence_data.timeout/1000,
188 async_fence_data.st =
st;
189 async_fence_data.name = strdup(
name);
190 async_fence_data.target =
target;
191 async_fence_data.action =
action;
192 async_fence_data.timeout =
timeout;
194 async_fence_data.delay =
delay;
201 mainloop = g_main_loop_new(NULL, FALSE);
202 g_main_loop_run(mainloop);
204 free(async_fence_data.name);
206 if (reason != NULL) {
208 *reason = async_fence_data.result.exit_reason;
209 async_fence_data.result.exit_reason = NULL;
216 #ifdef BUILD_PUBLIC_LIBPACEMAKER 229 unsigned int timeout,
int verbose,
bool broadcast,
236 out->
info(out,
"cleaning up fencing-history%s%s",
240 out->
info(out,
"gather fencing-history from all nodes");
260 out->
begin_list(out,
"event",
"events",
"Fencing history");
263 for (hp = history; hp; hp = hp->
next) {
268 if (out->
is_quiet(out) || !verbose) {
279 }
else if (!verbose) {
280 out->
message(out,
"stonith-event", latest, 0, FALSE);
291 #ifdef BUILD_PUBLIC_LIBPACEMAKER 294 bool quiet,
int verbose,
bool broadcast,
bool cleanup) {
324 out->
begin_list(out,
"fence device",
"fence devices",
"Installed fence devices");
326 out->
list_item(out,
"device",
"%s", dIter->value);
334 #ifdef BUILD_PUBLIC_LIBPACEMAKER 370 #ifdef BUILD_PUBLIC_LIBPACEMAKER 372 pcmk_fence_last(xmlNodePtr *xml,
const char *
target,
bool as_nodeid) {
391 const char *device_id,
unsigned int timeout) {
392 GList *targets = NULL;
403 out->
begin_list(out,
"fence target",
"fence targets",
"Fence Targets");
404 while (targets != NULL) {
405 out->
list_item(out, NULL,
"%s", (
const char *) targets->data);
406 targets = targets->next;
414 #ifdef BUILD_PUBLIC_LIBPACEMAKER 416 pcmk_fence_list_targets(xmlNodePtr *xml,
stonith_t *
st,
const char *device_id,
450 #ifdef BUILD_PUBLIC_LIBPACEMAKER 452 pcmk_fence_metadata(xmlNodePtr *xml,
stonith_t *
st,
char *agent,
482 out->
begin_list(out,
"fence device",
"fence devices",
"Registered fence devices");
484 out->
list_item(out,
"device",
"%s", dIter->value);
496 #ifdef BUILD_PUBLIC_LIBPACEMAKER 519 return handle_level(
st,
target, fence_level, devices,
true);
522 #ifdef BUILD_PUBLIC_LIBPACEMAKER 532 return handle_level(
st,
target, fence_level, NULL,
false);
535 #ifdef BUILD_PUBLIC_LIBPACEMAKER 547 char *error_output = NULL;
551 timeout/1000, &output, &error_output);
552 out->
message(out,
"validate", agent,
id, output, error_output, rc);
556 #ifdef BUILD_PUBLIC_LIBPACEMAKER 558 pcmk_fence_validate(xmlNodePtr *xml,
stonith_t *
st,
const char *agent,
595 *stonith_history = reduce_fence_history(*stonith_history);
void(* end_list)(pcmk__output_t *out)
struct stonith_history_s * next
int(* register_level_full)(stonith_t *st, int options, const char *node, const char *pattern, const char *attr, const char *value, int level, stonith_key_value_t *device_list)
Register fencing level for specified node, pattern or attribute.
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?
void stonith__register_messages(pcmk__output_t *out)
int stonith__event_exit_status(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(* query)(stonith_t *st, int options, const char *node, stonith_key_value_t **devices, int timeout)
Retrieve a list of registered stonith devices.
int pcmk__fence_history(pcmk__output_t *out, stonith_t *st, char *target, unsigned int timeout, int verbose, bool broadcast, bool cleanup)
List the fencing operations that have occurred for a specific node.
bool(* is_quiet)(pcmk__output_t *out)
stonith_history_t * stonith__sort_history(stonith_history_t *history)
struct stonith_key_value_s * next
int stonith__result2rc(const pcmk__action_result_t *result)
void mainloop_set_trigger(crm_trigger_t *source)
int(*) void(*) void(* output_xml)(pcmk__output_t *out, const char *name, const char *buf)
int(* info)(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
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.
void void void pcmk__formatted_printf(pcmk__output_t *out, const char *format,...) G_GNUC_PRINTF(2
struct trigger_s crm_trigger_t
int pcmk__out_prologue(pcmk__output_t **out, xmlNodePtr *xml)
GList * stonith__parse_targets(const char *hosts)
const char * stonith__exit_reason(stonith_callback_data_t *data)
Formatted output for pacemaker tools.
int pcmk__fence_installed(pcmk__output_t *out, stonith_t *st, unsigned int timeout)
List all installed STONITH agents.
Used only to initialize variables.
int(* metadata)(stonith_t *st, int options, const char *device, const char *provider, char **output, int timeout)
Get the metadata documentation for a resource.
bool quiet
Should this formatter supress most output?
int(* register_callback)(stonith_t *st, int call_id, int timeout, int options, void *userdata, const char *callback_name, void(*callback)(stonith_t *st, stonith_callback_data_t *data))
Register a callback to receive the result of an asynchronous call.
#define stonith__set_call_options(st_call_opts, call_for, flags_to_set)
const char * stonith__event_exit_reason(stonith_event_t *event)
gboolean stonith__later_succeeded(stonith_history_t *event, stonith_history_t *top_history)
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 pcmk__fence_unregister_level(stonith_t *st, char *target, int fence_level)
Unregister a fencing level for a specific node, node regex, or attribute.
void stonith_key_value_freeall(stonith_key_value_t *kvp, int keys, int values)
int(* list)(stonith_t *st, int options, const char *id, char **list_output, int timeout)
Retrieve string listing hosts and port assignments from a local stonith device.
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(* list_agents)(stonith_t *stonith, int call_options, const char *provider, stonith_key_value_t **devices, int timeout)
Retrieve a list of installed stonith agents.
int(* fence_with_delay)(stonith_t *st, int options, const char *node, const char *action, int timeout, int tolerance, int delay)
Issue a fencing action against a node with requested fencing delay.
void pcmk__out_epilogue(pcmk__output_t *out, xmlNodePtr *xml, int retval)
Function and executable result codes.
int pcmk__fence_register_level(stonith_t *st, char *target, int fence_level, stonith_key_value_t *devices)
Register a fencing level for a specific node, node regex, or attribute.
int(* register_notification)(stonith_t *st, const char *event, void(*notify)(stonith_t *st, stonith_event_t *e))
int(* validate)(stonith_t *st, int call_options, const char *rsc_id, const char *namespace_s, const char *agent, stonith_key_value_t *params, int timeout, char **output, char **error_output)
Validate an arbitrary stonith device configuration.
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__execution_status(stonith_callback_data_t *data)
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)
int pcmk__fence_validate(pcmk__output_t *out, stonith_t *st, const char *agent, const char *id, stonith_key_value_t *params, unsigned int timeout)
Validate a STONITH device configuration.
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
int pcmk__fence_metadata(pcmk__output_t *out, stonith_t *st, char *agent, unsigned int timeout)
Get metadata for a resource.
int pcmk__fence_registered(pcmk__output_t *out, stonith_t *st, char *target, unsigned int timeout)
List registered fence devices.
time_t stonith_api_time(uint32_t nodeid, const char *uname, bool in_progress)
int stonith__exit_status(stonith_callback_data_t *data)
int pcmk__get_fencing_history(stonith_t *st, stonith_history_t **stonith_history, enum pcmk__fence_history fence_history)
Fetch STONITH history, optionally reducing it.
#define T_STONITH_NOTIFY_FENCE
void pcmk__set_result(pcmk__action_result_t *result, int exit_status, enum pcmk_exec_status exec_status, const char *exit_reason)
int stonith__event_execution_status(stonith_event_t *event)
void pcmk__reset_result(pcmk__action_result_t *result)
Execution failed, may be retried.
void(*) void(*) void(* increment_list)(pcmk__output_t *out)
int(* history)(stonith_t *st, int options, const char *node, stonith_history_t **output, int timeout)
Retrieve a list of fencing operations that have occurred for a specific node.