20 #include <sys/types.h> 30 static regex_t *notify_migrate_re = NULL;
45 pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms)
52 static inline gboolean
53 convert_interval(
const char *s, guint *interval_ms)
58 l = strtoul(s, NULL, 10);
64 *interval_ms = (guint) l;
69 try_fast_match(
const char *key,
const char *underbar1,
const char *underbar2,
70 char **rsc_id,
char **op_type, guint *interval_ms)
73 if (!convert_interval(underbar2+1, interval_ms)) {
79 *rsc_id =
strndup(key, underbar1-key);
83 *op_type =
strndup(underbar1+1, underbar2-underbar1-1);
90 try_basic_match(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
92 char *interval_sep = NULL;
93 char *type_sep = NULL;
96 interval_sep = strrchr(key,
'_');
97 if (interval_sep == NULL) {
102 if (!convert_interval(interval_sep+1, interval_ms)) {
107 type_sep = interval_sep-1;
110 if (*type_sep ==
'_') {
112 }
else if (type_sep == key) {
126 *op_type =
strndup(type_sep+1, interval_sep-type_sep-1);
131 *rsc_id =
strndup(key, type_sep-key);
138 try_migrate_notify_match(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
142 regmatch_t pmatch[nmatch];
144 if (notify_migrate_re == NULL) {
146 notify_migrate_re = calloc(1,
sizeof(regex_t));
147 rc = regcomp(notify_migrate_re,
"^(.*)_(migrate_(from|to)|(pre|post)_notify_([a-z]+|migrate_(from|to)))_([0-9]+)$",
152 rc = regexec(notify_migrate_re, key, nmatch, pmatch, 0);
153 if (rc == REG_NOMATCH) {
158 *rsc_id =
strndup(key+pmatch[1].rm_so, pmatch[1].rm_eo-pmatch[1].rm_so);
162 *op_type =
strndup(key+pmatch[2].rm_so, pmatch[2].rm_eo-pmatch[2].rm_so);
166 if (!convert_interval(key+pmatch[7].rm_so, interval_ms)) {
185 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
187 char *underbar1 = NULL;
188 char *underbar2 = NULL;
189 char *underbar3 = NULL;
206 underbar1 = strchr(key,
'_');
211 underbar2 = strchr(underbar1+1,
'_');
216 underbar3 = strchr(underbar2+1,
'_');
219 return try_fast_match(key, underbar1, underbar2,
220 rsc_id, op_type, interval_ms);
221 }
else if (try_migrate_notify_match(key, rsc_id, op_type, interval_ms)) {
224 return try_basic_match(key, rsc_id, op_type, interval_ms);
234 CRM_CHECK(notify_type != NULL,
return NULL);
236 rsc_id, notify_type, op_type);
256 int *
op_status,
int *op_rc,
int *target_rc)
261 int local_op_status = -1;
262 int local_op_rc = -1;
267 res = sscanf(magic,
"%d:%d;%ms", &local_op_status, &local_op_rc, &key);
269 key = calloc(1, strlen(magic) - 3);
271 res = sscanf(magic,
"%d:%d;%s", &local_op_status, &local_op_rc, key);
274 crm_err(
"Could not decode transition information '%s': %s",
277 }
else if (res < 3) {
278 crm_warn(
"Transition information '%s' incomplete (%d of 3 expected items)",
286 *op_rc = local_op_rc;
301 action_id, transition_id, target_rc, 36, node);
321 int local_transition_id = -1;
322 int local_action_id = -1;
323 int local_target_rc = -1;
324 char local_uuid[37] = {
'\0' };
341 if (sscanf(key,
"%d:%d:%d:%36s", &local_action_id, &local_transition_id,
342 &local_target_rc, local_uuid) != 4) {
343 crm_err(
"Invalid transition key '%s'", key);
346 if (strlen(local_uuid) != 36) {
347 crm_warn(
"Invalid UUID '%s' in transition key '%s'", local_uuid, key);
350 *uuid = strdup(local_uuid);
354 *transition_id = local_transition_id;
357 *action_id = local_action_id;
360 *target_rc = local_target_rc;
367 should_filter_for_digest(xmlAttrPtr a,
void *user_data)
369 if (strncmp((
const char *) a->name,
CRM_META "_",
394 guint interval_ms = 0;
396 if (param_set == NULL) {
409 if (interval_ms != 0) {
454 if (target_rc != op->
rc) {
475 const char *interval_spec,
const char *
timeout)
479 CRM_CHECK(prefix && task && interval_spec,
return NULL);
508 CRM_CHECK((rsc_class != NULL) || (op != NULL),
return false);
510 if ((rsc_class != NULL)
#define CRM_CHECK(expr, failure_action)
#define CRMD_ACTION_MIGRATED
No connection to executor.
gboolean did_rsc_op_fail(lrmd_event_data_t *op, int target_rc)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
bool pcmk__is_fencing_action(const char *action)
#define CRMD_ACTION_NOTIFY
#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 CRMD_ACTION_PROMOTE
Necessary CIB secrets are unavailable.
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.
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.
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
char * strndup(const char *str, size_t len)
No fence device is configured for target.
char * crm_meta_name(const char *field)
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
#define CRMD_ACTION_START
#define XML_LRM_ATTR_TASK
#define crm_warn(fmt, args...)
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
#define CRMD_ACTION_RELOAD_AGENT
#define CRMD_ACTION_DEMOTE
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
Wrappers for and extensions to libxml2.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
void pcmk__filter_op_for_digest(xmlNode *param_set)
Dependencies not available locally.
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
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.
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
#define CRMD_ACTION_RELOAD
bool pcmk_xe_is_probe(xmlNode *xml_op)
#define XML_LRM_ATTR_TARGET_UUID
int rsc_op_expected_rc(lrmd_event_data_t *op)
bool pcmk_xe_mask_probe_failure(xmlNode *xml_op)
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 XML_LRM_ATTR_INTERVAL_MS
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
#define CRMD_ACTION_MIGRATE
#define XML_LRM_ATTR_OPSTATUS
#define XML_ATTR_CRM_VERSION
Agent or dependency not available locally.
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
#define XML_LRM_ATTR_TARGET
Action cannot be attempted (e.g. shutdown)
Execution failed, may be retried.
#define CRMD_ACTION_STATUS