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)
203 static inline gboolean
204 convert_interval(
const char *s, guint *interval_ms)
209 l = strtoul(s, NULL, 10);
215 *interval_ms = (guint) l;
231 match_before(
const char *key,
size_t position,
const char **matches)
233 for (
int i = 0; matches[i] != NULL; ++i) {
234 const size_t match_len = strlen(matches[i]);
237 if (position > (match_len + 1)) {
238 const size_t possible = position - match_len - 1;
240 if ((key[possible] ==
'_')
241 && (strncmp(key + possible + 1, matches[i], match_len) == 0)) {
250 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
252 guint local_interval_ms = 0;
253 const size_t key_len = (key == NULL)? 0 : strlen(key);
256 size_t action_underbar = 0;
257 size_t interval_underbar = 0;
263 const char *actions_with_underbars[] = {
268 const char *action_prefixes_with_underbars[] = {
293 interval_underbar = key_len - 2;
294 while ((interval_underbar > 2) && (key[interval_underbar] !=
'_')) {
297 if ((interval_underbar == 2)
298 || !convert_interval(key + interval_underbar + 1, &local_interval_ms)) {
303 action_underbar = match_before(key, interval_underbar,
304 actions_with_underbars);
305 if (action_underbar == 0) {
306 action_underbar = interval_underbar - 2;
307 while ((action_underbar > 0) && (key[action_underbar] !=
'_')) {
310 if (action_underbar == 0) {
314 possible = match_before(key, action_underbar,
315 action_prefixes_with_underbars);
317 action_underbar = possible;
321 if (rsc_id != NULL) {
322 *rsc_id = strndup(key, action_underbar);
325 if (op_type != NULL) {
326 *op_type = strndup(key + action_underbar + 1,
327 interval_underbar - action_underbar - 1);
330 if (interval_ms != NULL) {
331 *interval_ms = local_interval_ms;
342 CRM_CHECK(notify_type != NULL,
return NULL);
344 rsc_id, notify_type, op_type);
364 int *
op_status,
int *op_rc,
int *target_rc)
369 int local_op_status = -1;
370 int local_op_rc = -1;
375 res = sscanf(magic,
"%d:%d;%ms", &local_op_status, &local_op_rc, &key);
379 res = sscanf(magic,
"%d:%d;%s", &local_op_status, &local_op_rc, key);
382 crm_err(
"Could not decode transition information '%s': %s",
385 }
else if (res < 3) {
386 crm_warn(
"Transition information '%s' incomplete (%d of 3 expected items)",
394 *op_rc = local_op_rc;
409 action_id, transition_id, target_rc, 36, node);
429 int local_transition_id = -1;
430 int local_action_id = -1;
431 int local_target_rc = -1;
432 char local_uuid[37] = {
'\0' };
449 if (sscanf(key,
"%d:%d:%d:%36s", &local_action_id, &local_transition_id,
450 &local_target_rc, local_uuid) != 4) {
451 crm_err(
"Invalid transition key '%s'", key);
454 if (strlen(local_uuid) != 36) {
455 crm_warn(
"Invalid UUID '%s' in transition key '%s'", local_uuid, key);
461 *transition_id = local_transition_id;
464 *action_id = local_action_id;
467 *target_rc = local_target_rc;
501 if (target_rc != op->
rc) {
522 const char *interval_spec,
const char *
timeout)
526 CRM_CHECK(prefix && task && interval_spec,
return NULL);
554 CRM_CHECK((rsc_class != NULL) || (op != NULL),
return false);
556 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_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