15 #include <sys/types.h> 174 return "restart-container";
177 return "reset-remote";
195 pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms)
201 static inline gboolean
202 convert_interval(
const char *s, guint *interval_ms)
207 l = strtoul(s, NULL, 10);
213 *interval_ms = (guint) l;
229 match_before(
const char *key,
size_t position,
const char **matches)
231 for (
int i = 0; matches[i] != NULL; ++i) {
232 const size_t match_len = strlen(matches[i]);
235 if (position > (match_len + 1)) {
236 const size_t possible = position - match_len - 1;
238 if ((key[possible] ==
'_')
239 && (strncmp(key + possible + 1, matches[i], match_len) == 0)) {
248 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
250 guint local_interval_ms = 0;
251 const size_t key_len = (key == NULL)? 0 : strlen(key);
254 size_t action_underbar = 0;
255 size_t interval_underbar = 0;
261 const char *actions_with_underbars[] = {
266 const char *action_prefixes_with_underbars[] = {
291 interval_underbar = key_len - 2;
292 while ((interval_underbar > 2) && (key[interval_underbar] !=
'_')) {
295 if ((interval_underbar == 2)
296 || !convert_interval(key + interval_underbar + 1, &local_interval_ms)) {
301 action_underbar = match_before(key, interval_underbar,
302 actions_with_underbars);
303 if (action_underbar == 0) {
304 action_underbar = interval_underbar - 2;
305 while ((action_underbar > 0) && (key[action_underbar] !=
'_')) {
308 if (action_underbar == 0) {
312 possible = match_before(key, action_underbar,
313 action_prefixes_with_underbars);
315 action_underbar = possible;
319 if (rsc_id != NULL) {
320 *rsc_id = strndup(key, action_underbar);
323 if (op_type != NULL) {
324 *op_type = strndup(key + action_underbar + 1,
325 interval_underbar - action_underbar - 1);
328 if (interval_ms != NULL) {
329 *interval_ms = local_interval_ms;
340 CRM_CHECK(notify_type != NULL,
return NULL);
342 rsc_id, notify_type, op_type);
362 int *op_status,
int *op_rc,
int *target_rc)
367 int local_op_status = -1;
368 int local_op_rc = -1;
373 res = sscanf(magic,
"%d:%d;%ms", &local_op_status, &local_op_rc, &key);
377 res = sscanf(magic,
"%d:%d;%s", &local_op_status, &local_op_rc, key);
380 crm_err(
"Could not decode transition information '%s': %s",
383 }
else if (res < 3) {
384 crm_warn(
"Transition information '%s' incomplete (%d of 3 expected items)",
389 *op_status = local_op_status;
392 *op_rc = local_op_rc;
407 action_id, transition_id, target_rc, 36, node);
427 int local_transition_id = -1;
428 int local_action_id = -1;
429 int local_target_rc = -1;
430 char local_uuid[37] = {
'\0' };
447 if (sscanf(key,
"%d:%d:%d:%36s", &local_action_id, &local_transition_id,
448 &local_target_rc, local_uuid) != 4) {
449 crm_err(
"Invalid transition key '%s'", key);
452 if (strlen(local_uuid) != 36) {
453 crm_warn(
"Invalid UUID '%s' in transition key '%s'", local_uuid, key);
459 *transition_id = local_transition_id;
462 *action_id = local_action_id;
465 *target_rc = local_target_rc;
499 if (target_rc != op->
rc) {
520 const char *interval_spec,
const char *
timeout)
524 CRM_CHECK(prefix && task && interval_spec,
return NULL);
552 CRM_CHECK((rsc_class != NULL) || (op != NULL),
return false);
554 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)
#define PCMK__OP_FMT
printf-style format to create operation key from resource, action, interval
#define PCMK_ACTION_MONITOR
#define PCMK_ACTION_MIGRATE_TO
#define PCMK_ACTION_DO_SHUTDOWN
enum pcmk__action_type pcmk__parse_action(const char *action_name)
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.
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
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_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)
const char * pcmk__action_text(enum pcmk__action_type action)
const char * pcmk__on_fail_text(enum pcmk__on_fail on_fail)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
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)
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define pcmk__str_copy(str)
#define PCMK_META_TIMEOUT
#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
void pcmk__xe_set_id(xmlNode *xml, const char *format,...) G_GNUC_PRINTF(2
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
#define pcmk__assert_alloc(nmemb, size)
bool pcmk__is_fencing_action(const char *action)
Execution failed, may be retried.
#define PCMK_ACTION_NOTIFY
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1