18#include <libxml/xpath.h>
37rhcs_agent_filter(
const struct dirent *entry)
49 if ((stat(buf, &sb) != 0) || !S_ISREG(sb.st_mode)) {
71 struct dirent **namelist = NULL;
73 rhcs_agent_filter, alphasort);
83 for (
int i = 0; i < file_num; i++) {
92stonith_rhcs_parameter_not_required(xmlNode *metadata,
const char *parameter)
95 xmlXPathObject *xpathObj = NULL;
105 if (pcmk__xpath_num_results(xpathObj) > 0) {
112 xmlXPathFreeObject(xpathObj);
124stonith__rhcs_get_metadata(
const char *agent,
int timeout_sec,
128 xmlNode *actions = NULL;
129 xmlXPathObject *xpathObj = NULL;
132 NULL, timeout_sec, NULL,
139 crm_warn(
"Could not execute metadata action for %s: %s "
147 crm_warn(
"Could not execute metadata action for %s: %s",
154 if (!pcmk__result_ok(
result)) {
155 crm_warn(
"Metadata action for %s returned error code %d",
163 crm_warn(
"Metadata action for %s returned no data", agent);
172 crm_warn(
"Metadata for %s is invalid", agent);
177 if (pcmk__xpath_num_results(xpathObj) > 0) {
180 xmlXPathFreeObject(xpathObj);
186 if (pcmk__xpath_num_results(xpathObj) == 0) {
188 const char *timeout_str = NULL;
200 xmlXPathFreeObject(xpathObj);
204 stonith_rhcs_parameter_not_required(xml,
"plug");
205 stonith_rhcs_parameter_not_required(xml,
"port");
227 GString *buffer = NULL;
230 int rc = stonith__rhcs_get_metadata(agent, timeout_sec, &xml);
236 buffer = g_string_sized_new(1024);
239 if (pcmk__str_empty(buffer->str)) {
244 if (output != NULL) {
249 if (buffer != NULL) {
250 g_string_free(buffer, TRUE);
261 int rc = stat(buffer, &prop);
264 return (rc >= 0) && S_ISREG(prop.st_mode);
269 const char *agent, GHashTable *params,
270 const char * host_arg,
int timeout,
271 char **output,
char **error_output)
274 int remaining_timeout =
timeout;
275 xmlNode *metadata = NULL;
279 if (host_arg == NULL) {
280 time_t start_time = time(NULL);
282 rc = stonith__rhcs_get_metadata(agent, remaining_timeout, &metadata);
293 remaining_timeout -= time(NULL) - start_time;
295 if (rc == -
ETIME || remaining_timeout <= 0 ) {
304 remaining_timeout, params, NULL, host_arg);
313 if (output != NULL) {
317 if (error_output != NULL) {
#define PCMK_ACTION_METADATA
#define PCMK_ACTION_START
#define PCMK_DEFAULT_ACTION_TIMEOUT_MS
Default timeout (in milliseconds) for non-metadata actions.
#define PCMK_ACTION_VALIDATE_ALL
#define PCMK_STONITH_HOST_ARGUMENT
#define PCMK__FENCE_BINDIR
const char * stonith__default_host_arg(xmlNode *metadata)
void stonith__destroy_action(stonith_action_t *action)
stonith_key_value_t * stonith__key_value_add(stonith_key_value_t *head, const char *key, const char *value)
pcmk__action_result_t * stonith__action_result(stonith_action_t *action)
struct stonith_action_s stonith_action_t
int stonith__result2rc(const pcmk__action_result_t *result)
#define STONITH_ATTR_ACTION_OP
stonith_action_t * stonith__action_create(const char *agent, const char *action_name, const char *target, int timeout_sec, GHashTable *device_args, GHashTable *port_map, const char *host_arg)
G_GNUC_INTERNAL int stonith__execute(stonith_action_t *action)
const char * pcmk__readable_interval(guint interval_ms)
#define crm_warn(fmt, args...)
#define CRM_CHECK(expr, failure_action)
#define crm_err(fmt, args...)
#define crm_trace(fmt, args...)
#define PCMK_META_TIMEOUT
pcmk__action_result_t result
const char * pcmk_strerror(int rc)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
#define pcmk_err_schema_validation
int pcmk_rc2legacy(int rc)
@ PCMK_EXEC_DONE
Action completed, result is known.
bool stonith__agent_is_rhcs(const char *agent)
int stonith__rhcs_validate(stonith_t *st, int call_options, const char *target, const char *agent, GHashTable *params, const char *host_arg, int timeout, char **output, char **error_output)
int stonith__rhcs_metadata(const char *agent, int timeout_sec, char **output)
Retrieve metadata for RHCS-compatible fence agent.
int stonith__list_rhcs_agents(stonith_key_value_t **devices)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
void pcmk__str_update(char **str, const char *value)
enum pcmk_exec_status execution_status
Key-value pair list node.
Fencer API connection object.
Wrappers for and extensions to libxml2.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
@ pcmk__xml_fmt_pretty
Include indentation and newlines.
@ pcmk__xml_fmt_text
Include XML text nodes.
void pcmk__xml_free(xmlNode *xml)
void pcmk__xml_string(const xmlNode *data, uint32_t options, GString *buffer, int depth)
xmlNode * pcmk__xml_parse(const char *input)
#define PCMK_XE_PARAMETER
xmlXPathObject * pcmk__xpath_search(xmlDoc *doc, const char *path)
xmlNode * pcmk__xpath_result(xmlXPathObject *xpath_obj, int index)