20 #include <sys/types.h>
29 static regex_t *notify_migrate_re = NULL;
44 pcmk__op_key(
const char *rsc_id,
const char *op_type, guint interval_ms)
51 static inline gboolean
52 convert_interval(
const char *s, guint *interval_ms)
57 l = strtoul(s, NULL, 10);
63 *interval_ms = (guint) l;
68 try_fast_match(
const char *key,
const char *underbar1,
const char *underbar2,
69 char **rsc_id,
char **op_type, guint *interval_ms)
72 if (!convert_interval(underbar2+1, interval_ms)) {
78 *rsc_id =
strndup(key, underbar1-key);
82 *op_type =
strndup(underbar1+1, underbar2-underbar1-1);
89 try_basic_match(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
91 char *interval_sep = NULL;
92 char *type_sep = NULL;
95 interval_sep = strrchr(key,
'_');
96 if (interval_sep == NULL) {
101 if (!convert_interval(interval_sep+1, interval_ms)) {
106 type_sep = interval_sep-1;
109 if (*type_sep ==
'_') {
111 }
else if (type_sep == key) {
125 *op_type =
strndup(type_sep+1, interval_sep-type_sep-1);
130 *rsc_id =
strndup(key, type_sep-key);
137 try_migrate_notify_match(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
141 regmatch_t pmatch[nmatch];
143 if (notify_migrate_re == NULL) {
145 notify_migrate_re = calloc(1,
sizeof(regex_t));
146 rc = regcomp(notify_migrate_re,
"^(.*)_(migrate_(from|to)|(pre|post)_notify_([a-z]+|migrate_(from|to)))_([0-9]+)$",
151 rc = regexec(notify_migrate_re, key, nmatch, pmatch, 0);
152 if (
rc == REG_NOMATCH) {
157 *rsc_id =
strndup(key+pmatch[1].rm_so, pmatch[1].rm_eo-pmatch[1].rm_so);
161 *op_type =
strndup(key+pmatch[2].rm_so, pmatch[2].rm_eo-pmatch[2].rm_so);
165 if (!convert_interval(key+pmatch[7].rm_so, interval_ms)) {
184 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
186 char *underbar1 = NULL;
187 char *underbar2 = NULL;
188 char *underbar3 = NULL;
205 underbar1 = strchr(key,
'_');
210 underbar2 = strchr(underbar1+1,
'_');
215 underbar3 = strchr(underbar2+1,
'_');
218 return try_fast_match(key, underbar1, underbar2,
219 rsc_id, op_type, interval_ms);
220 }
else if (try_migrate_notify_match(key, rsc_id, op_type, interval_ms)) {
223 return try_basic_match(key, rsc_id, op_type, interval_ms);
233 CRM_CHECK(notify_type != NULL,
return NULL);
235 rsc_id, notify_type, op_type);
255 int *
op_status,
int *op_rc,
int *target_rc)
259 gboolean result = TRUE;
260 int local_op_status = -1;
261 int local_op_rc = -1;
266 res = sscanf(magic,
"%d:%d;%ms", &local_op_status, &local_op_rc, &key);
268 key = calloc(1, strlen(magic) - 3);
270 res = sscanf(magic,
"%d:%d;%s", &local_op_status, &local_op_rc, key);
273 crm_err(
"Could not decode transition information '%s': %s",
276 }
else if (res < 3) {
277 crm_warn(
"Transition information '%s' incomplete (%d of 3 expected items)",
285 *op_rc = local_op_rc;
300 action_id, transition_id, target_rc, 36, node);
320 int local_transition_id = -1;
321 int local_action_id = -1;
322 int local_target_rc = -1;
323 char local_uuid[37] = {
'\0' };
340 if (sscanf(key,
"%d:%d:%d:%36s", &local_action_id, &local_transition_id,
341 &local_target_rc, local_uuid) != 4) {
342 crm_err(
"Invalid transition key '%s'", key);
345 if (strlen(local_uuid) != 36) {
346 crm_warn(
"Invalid UUID '%s' in transition key '%s'", local_uuid, key);
349 *uuid = strdup(local_uuid);
353 *transition_id = local_transition_id;
356 *action_id = local_action_id;
359 *target_rc = local_target_rc;
375 guint interval_ms = 0;
377 const char *attr_filter[] = {
386 const int meta_len = strlen(
CRM_META);
388 if (param_set == NULL) {
393 for (
int lpc = 0; lpc <
DIMOF(attr_filter); lpc++) {
407 for (xmlAttrPtr xIter = param_set->properties; xIter != NULL; ) {
408 const char *prop_name = (
const char *) (xIter->name);
413 if (strncasecmp(prop_name,
CRM_META, meta_len) == 0) {
418 if ((interval_ms != 0) && (
timeout != NULL)) {
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)