22 #define RH_STONITH_PREFIX "fence_"
38 struct dirent **namelist;
41 #if _POSIX_C_SOURCE < 200809L && !(defined(O_SEARCH) || defined(O_PATH))
42 char buffer[FILENAME_MAX + 1];
43 #elif defined(O_SEARCH)
49 for (i = 0; i < file_num; i++) {
53 #if _POSIX_C_SOURCE < 200809L && !(defined(O_SEARCH) || defined(O_PATH))
56 if (stat(buffer, &prop) == 0 && S_ISREG(prop.st_mode)) {
69 if (fstatat(dirfd, namelist[i]->d_name, &prop, 0) == 0
70 && S_ISREG(prop.st_mode)) {
82 #if _POSIX_C_SOURCE >= 200809L || defined(O_SEARCH) || defined(O_PATH)
91 stonith_rhcs_parameter_not_required(xmlNode *metadata,
const char *parameter)
94 xmlXPathObject *xpathObj = NULL;
103 if (numXpathResults(xpathObj) > 0) {
122 stonith__rhcs_get_metadata(
const char *agent,
int timeout, xmlNode **metadata)
126 xmlNode *actions = NULL;
127 xmlXPathObject *xpathObj = NULL;
129 5, NULL, NULL, NULL);
133 crm_warn(
"Could not execute metadata action for %s: %s "
148 if (buffer == NULL) {
149 crm_warn(
"Metadata action for %s returned no data", agent);
157 crm_warn(
"Metadata for %s is invalid", agent);
162 if (numXpathResults(xpathObj) > 0) {
169 if (numXpathResults(xpathObj) <= 0) {
183 stonith_rhcs_parameter_not_required(xml,
"action");
184 stonith_rhcs_parameter_not_required(xml,
"plug");
185 stonith_rhcs_parameter_not_required(xml,
"port");
212 int rc = stonith__rhcs_get_metadata(agent, timeout, &xml);
221 if (buffer == NULL) {
237 int rc = stat(buffer, &prop);
240 return (rc >= 0) && S_ISREG(prop.st_mode);
245 const char *agent, GHashTable *params,
246 const char * host_arg,
int timeout,
247 char **output,
char **error_output)
250 int remaining_timeout =
timeout;
251 xmlNode *metadata = NULL;
254 if (host_arg == NULL) {
255 time_t start_time = time(NULL);
257 rc = stonith__rhcs_get_metadata(agent, remaining_timeout, &metadata);
260 uint32_t device_flags = 0;
274 remaining_timeout -= time(NULL) - start_time;
276 if (rc == -
ETIME || remaining_timeout <= 0 ) {
285 target, 0, remaining_timeout, params,
void stonith__destroy_action(stonith_action_t *action)
#define CRM_CHECK(expr, failure_action)
struct stonith_action_s stonith_action_t
#define pcmk_err_schema_validation
#define crm_notice(fmt, args...)
const char * pcmk_strerror(int rc)
void stonith__action_result(stonith_action_t *action, int *rc, char **output, char **error_output)
#define PCMK__FENCE_BINDIR
int stonith__rhcs_metadata(const char *agent, int timeout, char **output)
Execute RHCS-compatible agent's meta-data action.
int stonith__execute(stonith_action_t *action)
int alphasort(const void *dirent1, const void *dirent2)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
stonith_action_t * stonith_action_create(const char *agent, const char *_action, const char *victim, uint32_t victim_nodeid, int timeout, GHashTable *device_args, GHashTable *port_map, const char *host_arg)
xmlNode * string2xml(const char *input)
stonith_key_value_t * stonith_key_value_add(stonith_key_value_t *kvp, const char *key, const char *value)
#define crm_warn(fmt, args...)
bool stonith__agent_is_rhcs(const char *agent)
void stonith__device_parameter_flags(uint32_t *device_flags, const char *device_name, xmlNode *metadata)
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.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
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 CRM_DEFAULT_OP_TIMEOUT_S
void free_xml(xmlNode *child)
#define RH_STONITH_PREFIX
int stonith__list_rhcs_agents(stonith_key_value_t **devices)
xmlXPathObjectPtr xpath_search(xmlNode *xml_top, const char *path)
xmlNode * getXpathResult(xmlXPathObjectPtr xpathObj, int index)
bool pcmk__starts_with(const char *str, const char *prefix)
Check whether a string starts with a certain sequence.
void freeXpathObject(xmlXPathObjectPtr xpathObj)
char * dump_xml_formatted_with_text(xmlNode *msg)