19 #include <sys/types.h> 175 return "restart-container";
178 return "reset-remote";
196 pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms)
202 static inline gboolean
203 convert_interval(
const char *s, guint *interval_ms)
208 l = strtoul(s, NULL, 10);
214 *interval_ms = (guint) l;
230 match_before(
const char *key,
size_t position,
const char **matches)
232 for (
int i = 0; matches[i] != NULL; ++i) {
233 const size_t match_len = strlen(matches[i]);
236 if (position > (match_len + 1)) {
237 const size_t possible = position - match_len - 1;
239 if ((key[possible] ==
'_')
240 && (strncmp(key + possible + 1, matches[i], match_len) == 0)) {
249 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
251 guint local_interval_ms = 0;
252 const size_t key_len = (key == NULL)? 0 : strlen(key);
255 size_t action_underbar = 0;
256 size_t interval_underbar = 0;
262 const char *actions_with_underbars[] = {
267 const char *action_prefixes_with_underbars[] = {
292 interval_underbar = key_len - 2;
293 while ((interval_underbar > 2) && (key[interval_underbar] !=
'_')) {
296 if ((interval_underbar == 2)
297 || !convert_interval(key + interval_underbar + 1, &local_interval_ms)) {
302 action_underbar = match_before(key, interval_underbar,
303 actions_with_underbars);
304 if (action_underbar == 0) {
305 action_underbar = interval_underbar - 2;
306 while ((action_underbar > 0) && (key[action_underbar] !=
'_')) {
309 if (action_underbar == 0) {
313 possible = match_before(key, action_underbar,
314 action_prefixes_with_underbars);
316 action_underbar = possible;
320 if (rsc_id != NULL) {
321 *rsc_id = strndup(key, action_underbar);
324 if (op_type != NULL) {
325 *op_type = strndup(key + action_underbar + 1,
326 interval_underbar - action_underbar - 1);
329 if (interval_ms != NULL) {
330 *interval_ms = local_interval_ms;
341 CRM_CHECK(notify_type != NULL,
return NULL);
343 rsc_id, notify_type, op_type);
363 int *
op_status,
int *op_rc,
int *target_rc)
368 int local_op_status = -1;
369 int local_op_rc = -1;
374 res = sscanf(magic,
"%d:%d;%ms", &local_op_status, &local_op_rc, &key);
378 res = sscanf(magic,
"%d:%d;%s", &local_op_status, &local_op_rc, key);
381 crm_err(
"Could not decode transition information '%s': %s",
384 }
else if (res < 3) {
385 crm_warn(
"Transition information '%s' incomplete (%d of 3 expected items)",
393 *op_rc = local_op_rc;
408 action_id, transition_id, target_rc, 36, node);
428 int local_transition_id = -1;
429 int local_action_id = -1;
430 int local_target_rc = -1;
431 char local_uuid[37] = {
'\0' };
448 if (sscanf(key,
"%d:%d:%d:%36s", &local_action_id, &local_transition_id,
449 &local_target_rc, local_uuid) != 4) {
450 crm_err(
"Invalid transition key '%s'", key);
453 if (strlen(local_uuid) != 36) {
454 crm_warn(
"Invalid UUID '%s' in transition key '%s'", local_uuid, key);
460 *transition_id = local_transition_id;
463 *action_id = local_action_id;
466 *target_rc = local_target_rc;
500 if (target_rc != op->
rc) {
521 const char *interval_spec,
const char *
timeout)
525 CRM_CHECK(prefix && task && interval_spec,
return NULL);
553 CRM_CHECK((rsc_class != NULL) || (op != NULL),
return false);
555 if ((rsc_class != NULL)
#define CRM_CHECK(expr, failure_action)
No connection to executor.
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
enum action_tasks pcmk_parse_action(const char *action_name)
Parse an action type from an action name.
#define PCMK__OP_FMT
printf-style format to create operation key from resource, action, interval
#define PCMK_ACTION_MONITOR
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK_ACTION_MIGRATE_TO
#define PCMK_ACTION_DO_SHUTDOWN
Necessary CIB secrets are unavailable.
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
#define PCMK_ACTION_RELOAD
gboolean did_rsc_op_fail(lrmd_event_data_t *op, int target_rc)
xmlNode * crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval_spec, const char *timeout)
Create a CIB XML element for an operation.
Action did not complete in time.
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
No fence device is configured for target.
#define PCMK_ACTION_RELOAD_AGENT
#define PCMK_ACTION_DEMOTE
#define PCMK_ACTION_REBOOT
#define crm_warn(fmt, args...)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
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.
void crm_xml_set_id(xmlNode *xml, const char *format,...) G_GNUC_PRINTF(2
gboolean decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc)
Parse a transition key into its constituent parts.
#define PCMK_ACTION_START
Wrappers for and extensions to libxml2.
int rsc_op_expected_rc(const lrmd_event_data_t *op)
#define PCMK_ACTION_STONITH
#define PCMK_ACTION_NOTIFIED
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
#define PCMK__ACTION_POWEROFF
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
const char * pcmk_action_text(enum action_tasks action)
Get string equivalent of an action type.
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define pcmk__str_copy(str)
#define PCMK_META_TIMEOUT
const char * pcmk_on_fail_text(enum action_fail_response on_fail)
Get string equivalent of a failure handling type.
#define pcmk__assert(expr)
#define PCMK_META_INTERVAL
Agent does not implement requested action.
pcmk__action_result_t result
#define crm_err(fmt, args...)
#define PCMK_ACTION_STOPPED
#define PCMK_ACTION_MIGRATE_FROM
#define pcmk__mem_assert(ptr)
#define PCMK_ACTION_PROMOTE
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
Parse a transition magic string into its constituent parts.
#define PCMK_ACTION_PROMOTED
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
#define PCMK_ACTION_RUNNING
Action cannot be attempted (e.g. shutdown)
#define PCMK_ACTION_DEMOTED
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
#define pcmk__assert_alloc(nmemb, size)
bool pcmk__is_fencing_action(const char *action)
Execution failed, may be retried.
#define PCMK_ACTION_NOTIFY