19 #include <sys/types.h> 42 pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms)
49 static inline gboolean
50 convert_interval(
const char *s, guint *interval_ms)
55 l = strtoul(s, NULL, 10);
61 *interval_ms = (guint) l;
77 match_before(
const char *key,
size_t position,
const char **matches)
79 for (
int i = 0; matches[i] != NULL; ++i) {
80 const size_t match_len = strlen(matches[i]);
83 if (position > (match_len + 1)) {
84 const size_t possible = position - match_len - 1;
86 if ((key[possible] ==
'_')
87 && (strncmp(key + possible + 1, matches[i], match_len) == 0)) {
96 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
98 guint local_interval_ms = 0;
99 const size_t key_len = (key == NULL)? 0 : strlen(key);
102 size_t action_underbar = 0;
103 size_t interval_underbar = 0;
109 const char *actions_with_underbars[] = {
114 const char *action_prefixes_with_underbars[] = {
139 interval_underbar = key_len - 2;
140 while ((interval_underbar > 2) && (key[interval_underbar] !=
'_')) {
143 if ((interval_underbar == 2)
144 || !convert_interval(key + interval_underbar + 1, &local_interval_ms)) {
149 action_underbar = match_before(key, interval_underbar,
150 actions_with_underbars);
151 if (action_underbar == 0) {
152 action_underbar = interval_underbar - 2;
153 while ((action_underbar > 0) && (key[action_underbar] !=
'_')) {
156 if (action_underbar == 0) {
160 possible = match_before(key, action_underbar,
161 action_prefixes_with_underbars);
163 action_underbar = possible;
167 if (rsc_id != NULL) {
168 *rsc_id = strndup(key, action_underbar);
171 if (op_type != NULL) {
172 *op_type = strndup(key + action_underbar + 1,
173 interval_underbar - action_underbar - 1);
176 if (interval_ms != NULL) {
177 *interval_ms = local_interval_ms;
188 CRM_CHECK(notify_type != NULL,
return NULL);
190 rsc_id, notify_type, op_type);
210 int *
op_status,
int *op_rc,
int *target_rc)
215 int local_op_status = -1;
216 int local_op_rc = -1;
221 res = sscanf(magic,
"%d:%d;%ms", &local_op_status, &local_op_rc, &key);
223 key = calloc(1, strlen(magic) - 3);
225 res = sscanf(magic,
"%d:%d;%s", &local_op_status, &local_op_rc, key);
228 crm_err(
"Could not decode transition information '%s': %s",
231 }
else if (res < 3) {
232 crm_warn(
"Transition information '%s' incomplete (%d of 3 expected items)",
240 *op_rc = local_op_rc;
255 action_id, transition_id, target_rc, 36, node);
275 int local_transition_id = -1;
276 int local_action_id = -1;
277 int local_target_rc = -1;
278 char local_uuid[37] = {
'\0' };
295 if (sscanf(key,
"%d:%d:%d:%36s", &local_action_id, &local_transition_id,
296 &local_target_rc, local_uuid) != 4) {
297 crm_err(
"Invalid transition key '%s'", key);
300 if (strlen(local_uuid) != 36) {
301 crm_warn(
"Invalid UUID '%s' in transition key '%s'", local_uuid, key);
304 *uuid = strdup(local_uuid);
308 *transition_id = local_transition_id;
311 *action_id = local_action_id;
314 *target_rc = local_target_rc;
321 should_filter_for_digest(xmlAttrPtr a,
void *user_data)
323 if (strncmp((
const char *) a->name,
CRM_META "_",
348 guint interval_ms = 0;
350 if (param_set == NULL) {
363 if (interval_ms != 0) {
408 if (target_rc != op->
rc) {
429 const char *interval_spec,
const char *
timeout)
433 CRM_CHECK(prefix && task && interval_spec,
return NULL);
461 CRM_CHECK((rsc_class != NULL) || (op != NULL),
return false);
463 if ((rsc_class != NULL)
502 return (interval == 0)
#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)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
#define PCMK__OP_FMT
printf-style format to create operation key from resource, action, interval
#define PCMK_ACTION_MONITOR
#define XML_LRM_ATTR_INTERVAL
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define XML_LRM_ATTR_OP_DIGEST
#define PCMK_ACTION_MIGRATE_TO
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.
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
No fence device is configured for target.
char * crm_meta_name(const char *field)
void pcmk__filter_op_for_digest(xmlNode *param_set)
#define XML_LRM_ATTR_TASK
#define PCMK_ACTION_RELOAD_AGENT
#define PCMK_ACTION_DEMOTE
#define PCMK_ACTION_REBOOT
#define crm_warn(fmt, args...)
bool pcmk_xe_is_probe(const xmlNode *xml_op)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
int crm_element_value_ms(const xmlNode *data, const char *name, guint *dest)
Retrieve the millisecond value of an XML attribute.
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
Used only to initialize variables.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
Parameter invalid (in local context)
void pcmk__xe_remove_matching_attrs(xmlNode *element, bool(*match)(xmlAttrPtr, void *), void *user_data)
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)
xmlNode * create_xml_node(xmlNode *parent, const char *name)
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.
Dependencies not available locally.
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define XML_LRM_ATTR_TARGET_UUID
Agent does not implement requested action.
pcmk__action_result_t result
#define crm_err(fmt, args...)
bool pcmk_is_probe(const char *task, guint interval)
#define PCMK_ACTION_MIGRATE_FROM
#define XML_LRM_ATTR_INTERVAL_MS
#define XML_LRM_ATTR_OPSTATUS
#define XML_ATTR_CRM_VERSION
#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.
Agent or dependency not available locally.
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
bool pcmk_xe_mask_probe_failure(const xmlNode *xml_op)
#define XML_LRM_ATTR_TARGET
Action cannot be attempted (e.g. shutdown)
bool pcmk__is_fencing_action(const char *action)
Execution failed, may be retried.
#define PCMK_ACTION_NOTIFY