24#define RH_STONITH_PREFIX "fence_"
40 struct dirent **namelist;
43#if _POSIX_C_SOURCE < 200809L && !(defined(O_SEARCH) || defined(O_PATH))
44 char buffer[FILENAME_MAX + 1];
45#elif defined(O_SEARCH)
51 for (i = 0; i < file_num; i++) {
55#if _POSIX_C_SOURCE < 200809L && !(defined(O_SEARCH) || defined(O_PATH))
58 if (stat(buffer, &prop) == 0 && S_ISREG(prop.st_mode)) {
71 if (fstatat(dirfd, namelist[i]->d_name, &prop, 0) == 0
72 && S_ISREG(prop.st_mode)) {
84#if _POSIX_C_SOURCE >= 200809L || defined(O_SEARCH) || defined(O_PATH)
93stonith_rhcs_parameter_not_required(xmlNode *metadata,
const char *parameter)
96 xmlXPathObject *xpathObj = NULL;
105 if (numXpathResults(xpathObj) > 0) {
122stonith__rhcs_get_metadata(
const char *agent,
int timeout_sec,
126 xmlNode *actions = NULL;
127 xmlXPathObject *xpathObj = NULL;
129 0, timeout_sec, NULL,
136 crm_warn(
"Could not execute metadata action for %s: %s "
144 crm_warn(
"Could not execute metadata action for %s: %s",
151 if (!pcmk__result_ok(
result)) {
152 crm_warn(
"Metadata action for %s returned error code %d",
160 crm_warn(
"Metadata action for %s returned no data", agent);
169 crm_warn(
"Metadata for %s is invalid", agent);
174 if (numXpathResults(xpathObj) > 0) {
181 if (numXpathResults(xpathObj) <= 0) {
195 stonith_rhcs_parameter_not_required(xml,
"action");
196 stonith_rhcs_parameter_not_required(xml,
"plug");
197 stonith_rhcs_parameter_not_required(xml,
"port");
222 int rc = stonith__rhcs_get_metadata(agent, timeout_sec, &xml);
231 if (buffer == NULL) {
247 int rc = stat(buffer, &prop);
250 return (rc >= 0) && S_ISREG(prop.st_mode);
255 const char *agent, GHashTable *params,
256 const char * host_arg,
int timeout,
257 char **output,
char **error_output)
260 int remaining_timeout =
timeout;
261 xmlNode *metadata = NULL;
265 if (host_arg == NULL) {
266 time_t start_time = time(NULL);
268 rc = stonith__rhcs_get_metadata(agent, remaining_timeout, &metadata);
271 uint32_t device_flags = 0;
285 remaining_timeout -= time(NULL) - start_time;
287 if (rc == -
ETIME || remaining_timeout <= 0 ) {
296 remaining_timeout, params, NULL, host_arg);
305 if (output != NULL) {
309 if (error_output != NULL) {
#define CRM_DEFAULT_OP_TIMEOUT_S
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define PCMK__FENCE_BINDIR
@ st_device_supports_parameter_port
@ st_device_supports_parameter_plug
void stonith__destroy_action(stonith_action_t *action)
void stonith__device_parameter_flags(uint32_t *device_flags, const char *device_name, xmlNode *metadata)
stonith_action_t * stonith__action_create(const char *agent, const char *action_name, const char *target, uint32_t target_nodeid, int timeout_sec, GHashTable *device_args, GHashTable *port_map, const char *host_arg)
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)
G_GNUC_INTERNAL int stonith__execute(stonith_action_t *action)
#define crm_warn(fmt, args...)
#define crm_notice(fmt, args...)
#define CRM_CHECK(expr, failure_action)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pcmk__action_result_t result
int alphasort(const void *dirent1, const void *dirent2)
const char * pcmk_strerror(int rc)
#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)
#define RH_STONITH_PREFIX
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)
stonith_key_value_t * stonith_key_value_add(stonith_key_value_t *kvp, const char *key, const char *value)
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
enum pcmk_exec_status execution_status
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
char * dump_xml_formatted_with_text(xmlNode *msg)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
void freeXpathObject(xmlXPathObjectPtr xpathObj)
xmlNode * string2xml(const char *input)
void free_xml(xmlNode *child)
xmlNode * create_xml_node(xmlNode *parent, const char *name)