46 parse_op_key(
const char *key,
char **rsc_id,
char **op_type,
int *interval)
49 char *mutable_key = NULL;
50 char *mutable_key_ptr = NULL;
51 int len = 0, offset = 0, ch = 0;
61 while (offset > 0 && isdigit(key[offset])) {
62 int digits = len - offset;
64 ch = key[offset] -
'0';
76 CRM_CHECK(key[offset] ==
'_',
return FALSE);
78 mutable_key = strdup(key);
79 mutable_key[offset] = 0;
82 while (offset > 0 && key[offset] !=
'_') {
86 CRM_CHECK(key[offset] ==
'_', free(mutable_key);
89 mutable_key_ptr = mutable_key + offset + 1;
91 crm_trace(
" Action: %s", mutable_key_ptr);
93 *op_type = strdup(mutable_key_ptr);
95 mutable_key[offset] = 0;
98 CRM_CHECK(mutable_key != mutable_key_ptr, free(mutable_key);
101 notify = strstr(mutable_key,
"_post_notify");
102 if (notify &&
safe_str_eq(notify,
"_post_notify")) {
106 notify = strstr(mutable_key,
"_pre_notify");
107 if (notify &&
safe_str_eq(notify,
"_pre_notify")) {
112 *rsc_id = mutable_key;
125 CRM_CHECK(notify_type != NULL,
return NULL);
127 len += strlen(op_type);
128 len += strlen(rsc_id);
129 len += strlen(notify_type);
134 sprintf(op_id,
"%s_%s_notify_%s_0", rsc_id, notify_type, op_type);
143 char *fail_state = NULL;
145 CRM_CHECK(transition_key != NULL,
return NULL);
147 len += strlen(transition_key);
149 fail_state = malloc(len);
150 if (fail_state != NULL) {
151 snprintf(fail_state, len,
"%d:%s", op_status, transition_key);
160 char *fail_state = NULL;
162 CRM_CHECK(transition_key != NULL,
return NULL);
164 len += strlen(transition_key);
166 fail_state = malloc(len);
167 if (fail_state != NULL) {
168 snprintf(fail_state, len,
"%d:%d;%s", op_status, op_rc, transition_key);
175 int *
op_status,
int *op_rc,
int *target_rc)
179 gboolean result = TRUE;
183 CRM_CHECK(op_status != NULL,
return FALSE);
185 key = calloc(1, strlen(magic) + 1);
186 res = sscanf(magic,
"%d:%d;%s", op_status, op_rc, key);
188 crm_warn(
"Only found %d items in: '%s'", res, magic);
203 char *fail_state = NULL;
209 fail_state = malloc(len);
210 if (fail_state != NULL) {
211 snprintf(fail_state, len,
"%d:%d:%d:%-*s", action_id, transition_id, target_rc, 36, node);
221 gboolean done = FALSE;
224 CRM_CHECK(target_rc != NULL,
return FALSE);
225 CRM_CHECK(action_id != NULL,
return FALSE);
226 CRM_CHECK(transition_id != NULL,
return FALSE);
228 *uuid = calloc(1, 37);
229 res = sscanf(key,
"%d:%d:%d:%36s", action_id, transition_id, target_rc, *uuid);
242 res = sscanf(key,
"%d:%d:%36s", action_id, transition_id, *uuid);
245 res = sscanf(key,
"%d:%36s", transition_id, *uuid);
248 }
else if (res != 3) {
258 res = sscanf(key,
"%d:%36s", transition_id, *uuid);
262 crm_crit(
"Unhandled sscanf result (%d) for %s", res, key);
265 if (strlen(*uuid) != 36) {
266 crm_warn(
"Bad UUID (%s) in sscanf result (%d) for %s", *uuid, res, key);
270 crm_err(
"Cannot decode '%s' rc=%d", key, res);
286 char *timeout = NULL;
287 char *interval = NULL;
289 const char *attr_filter[] = {
298 gboolean do_delete = FALSE;
300 static int meta_len = 0;
306 if (param_set == NULL) {
310 for (lpc = 0; lpc <
DIMOF(attr_filter); lpc++) {
322 xmlAttrPtr xIter = param_set->properties;
325 const char *prop_name = (
const char *)xIter->name;
329 if (strncasecmp(prop_name,
CRM_META, meta_len) == 0) {
341 if (timeout != NULL) {
351 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
361 xmlNode *args_xml = NULL;
377 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
378 digest,
ID(update), magic, digest_source);
419 if (target_rc != op->
rc) {
440 const char *interval,
const char *timeout)
444 CRM_CHECK(prefix && task && interval,
return NULL);
458 int target_rc,
const char * node,
const char * origin,
int level)
463 char *op_id_additional = NULL;
464 char *local_user_data = NULL;
465 const char *exit_reason = NULL;
467 xmlNode *xml_op = NULL;
468 const char *task = NULL;
469 gboolean dc_munges_migrate_ops = (
compare_version(caller_version,
"3.0.3") < 0);
470 gboolean dc_needs_unique_ops = (
compare_version(caller_version,
"3.0.6") < 0);
473 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%d)",
477 crm_trace(
"DC version: %s", caller_version);
498 }
else if (dc_munges_migrate_ops
505 if (dc_needs_unique_ops && op->
interval > 0) {
537 if (xml_op == NULL) {
542 crm_debug(
"Generating fake transition key for:"
543 " %s_%s_%d %d from %s",
570 crm_trace(
"Timing data (%s_%s_%d): last=%u change=%u exec=%u queue=%u",
606 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
608 if (op_id_additional) {
610 op_id = op_id_additional;
611 op_id_additional = NULL;
615 if (local_user_data) {
616 free(local_user_data);
642 CRM_CHECK(rsc_class || op,
return FALSE);
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
char * generate_transition_magic(const char *transition_key, int op_status, int op_rc)
#define CRMD_ACTION_MIGRATED
#define crm_crit(fmt, args...)
#define XML_ATTR_TRANSITION_MAGIC
int rsc_op_expected_rc(lrmd_event_data_t *event)
#define CRMD_ACTION_NOTIFY
long long crm_get_msec(const char *input)
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
#define XML_RSC_OP_T_EXEC
char * generate_transition_magic_v202(const char *transition_key, int op_status)
const char * crm_meta_value(GHashTable *hash, const char *field)
#define XML_LRM_ATTR_INTERVAL
#define XML_LRM_ATTR_OP_DIGEST
#define CRMD_ACTION_PROMOTE
char * crm_element_value_copy(xmlNode *data, const char *name)
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
#define CRM_LOG_ASSERT(expr)
char * generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
void filter_action_parameters(xmlNode *param_set, const char *version)
#define XML_RSC_OP_T_QUEUE
char * crm_meta_name(const char *field)
gboolean decode_transition_key(const char *key, char **uuid, int *action, int *transition_id, int *target_rc)
#define CRMD_ACTION_START
#define XML_LRM_ATTR_TASK_KEY
#define XML_LRM_ATTR_TASK
void hash2field(gpointer key, gpointer value, gpointer user_data)
char * generate_transition_key(int action, int transition_id, int target_rc, const char *node)
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
#define crm_warn(fmt, args...)
#define CRMD_ACTION_DEMOTE
#define PCMK_RESOURCE_CLASS_OCF
#define crm_debug(fmt, args...)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
xmlNode * crm_create_op_xml(xmlNode *parent, const char *prefix, const char *task, const char *interval, const char *timeout)
Create a CIB XML element for an operation.
Wrappers for and extensions to libxml2.
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define XML_LRM_ATTR_MIGRATE_TARGET
#define XML_LRM_ATTR_EXIT_REASON
void free_xml(xmlNode *child)
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
#define CRMD_ACTION_RELOAD
#define XML_LRM_ATTR_TARGET_UUID
#define XML_ATTR_TRANSITION_KEY
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
#define PCMK_RESOURCE_CLASS_STONITH
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
unsigned int get_crm_log_level(void)
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, int *interval)
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
#define crm_err(fmt, args...)
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
void xml_remove_prop(xmlNode *obj, const char *name)
int compare_version(const char *version1, const char *version2)
char * dump_xml_unformatted(xmlNode *msg)
#define XML_LRM_ATTR_CALLID
#define CRMD_ACTION_MIGRATE
xmlNode * create_operation_update(xmlNode *parent, lrmd_event_data_t *event, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
#define XML_LRM_ATTR_OPSTATUS
#define XML_ATTR_CRM_VERSION
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
#define XML_LRM_ATTR_TARGET
#define XML_LRM_TAG_RSC_OP
#define XML_RSC_OP_LAST_RUN
char * generate_op_key(const char *rsc_id, const char *op_type, int interval)
Generate an operation key.
#define safe_str_eq(a, b)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define XML_LRM_ATTR_MIGRATE_SOURCE
#define CRMD_ACTION_STATUS