 |
pacemaker
2.0.1-9e909a5bdd
Scalable High-Availability cluster resource manager
|
Go to the documentation of this file.
45 parse_op_key(
const char *key,
char **rsc_id,
char **op_type, guint *interval_ms)
48 char *mutable_key = NULL;
49 char *mutable_key_ptr = NULL;
50 size_t len = 0, offset = 0;
51 unsigned long long ch = 0;
52 guint local_interval_ms = 0;
70 while ((offset > 0) && isdigit(key[offset])) {
71 ch = key[offset] -
'0';
72 for (
int digits = len - offset; digits > 1; --digits) {
75 local_interval_ms += ch;
78 crm_trace(
"Operation key '%s' has interval %ums", key, local_interval_ms);
80 *interval_ms = local_interval_ms;
83 CRM_CHECK((offset != (len - 1)) && (key[offset] ==
'_'),
return FALSE);
85 mutable_key =
strndup(key, offset);
88 while (offset > 0 && key[offset] !=
'_') {
93 free(mutable_key);
return FALSE);
95 mutable_key_ptr = mutable_key + offset + 1;
97 crm_trace(
" Action: %s", mutable_key_ptr);
99 *op_type = strdup(mutable_key_ptr);
102 mutable_key[offset] = 0;
105 notify = strstr(mutable_key,
"_post_notify");
106 if (notify &&
safe_str_eq(notify,
"_post_notify")) {
110 notify = strstr(mutable_key,
"_pre_notify");
111 if (notify &&
safe_str_eq(notify,
"_pre_notify")) {
117 *rsc_id = mutable_key;
130 CRM_CHECK(notify_type != NULL,
return NULL);
132 rsc_id, notify_type, op_type);
138 CRM_CHECK(transition_key != NULL,
return NULL);
144 int *
op_status,
int *op_rc,
int *target_rc)
148 gboolean result = TRUE;
154 key = calloc(1, strlen(magic) + 1);
155 res = sscanf(magic,
"%d:%d;%s",
op_status, op_rc, key);
157 crm_warn(
"Only found %d items in: '%s'", res, magic);
173 action_id, transition_id, target_rc, 36, node);
181 CRM_CHECK(target_rc != NULL,
return FALSE);
182 CRM_CHECK(action_id != NULL,
return FALSE);
183 CRM_CHECK(transition_id != NULL,
return FALSE);
185 *uuid = calloc(37,
sizeof(
char));
186 if (sscanf(key,
"%d:%d:%d:%36s",
187 action_id, transition_id, target_rc, *uuid) != 4) {
188 crm_err(
"Invalid transition key '%s'", key);
196 if (strlen(*uuid) != 36) {
197 crm_warn(
"Invalid UUID '%s' in transition key '%s'", *uuid, key);
206 char *timeout = NULL;
207 char *interval_ms_s = NULL;
209 const char *attr_filter[] = {
218 gboolean do_delete = FALSE;
220 static int meta_len = 0;
226 if (param_set == NULL) {
230 for (lpc = 0; lpc <
DIMOF(attr_filter); lpc++) {
242 xmlAttrPtr xIter = param_set->properties;
245 const char *prop_name = (
const char *)xIter->name;
249 if (strncasecmp(prop_name,
CRM_META, meta_len) == 0) {
259 if (interval_ms_s && strcmp(interval_ms_s,
"0")) {
261 if (timeout != NULL) {
271 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
281 xmlNode *args_xml = NULL;
297 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
298 digest,
ID(update), magic, digest_source);
339 if (target_rc != op->
rc) {
360 const char *interval_spec,
const char *timeout)
364 CRM_CHECK(prefix && task && interval_spec,
return NULL);
378 int target_rc,
const char * node,
const char * origin,
int level)
383 char *op_id_additional = NULL;
384 char *local_user_data = NULL;
385 const char *exit_reason = NULL;
387 xmlNode *xml_op = NULL;
388 const char *task = NULL;
391 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%u)",
395 crm_trace(
"DC version: %s", caller_version);
446 if (xml_op == NULL) {
515 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
517 if (op_id_additional) {
519 op_id = op_id_additional;
520 op_id_additional = NULL;
524 if (local_user_data) {
525 free(local_user_data);
551 CRM_CHECK(rsc_class || op,
return FALSE);
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
#define XML_LRM_ATTR_MIGRATE_SOURCE
#define XML_RSC_OP_T_EXEC
#define XML_LRM_ATTR_TASK_KEY
gboolean crm_str_eq(const char *a, const char *b, gboolean use_case)
bool crm_op_needs_metadata(const char *rsc_class, const char *op)
Check whether an operation requires resource agent meta-data.
char * dump_xml_unformatted(xmlNode *msg)
#define XML_LRM_ATTR_OPSTATUS
xmlNode * create_operation_update(xmlNode *parent, lrmd_event_data_t *op, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
#define XML_LRM_ATTR_TARGET_UUID
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.
#define CRMD_ACTION_NOTIFY
#define XML_ATTR_TRANSITION_KEY
xmlNode * create_xml_node(xmlNode *parent, const char *name)
#define CRM_CHECK(expr, failure_action)
int compare_version(const char *version1, const char *version2)
#define crm_err(fmt, args...)
#define XML_LRM_ATTR_INTERVAL
#define crm_trace(fmt, args...)
#define safe_str_eq(a, b)
#define crm_warn(fmt, args...)
void free_xml(xmlNode *child)
gboolean did_rsc_op_fail(lrmd_event_data_t *op, int target_rc)
#define XML_ATTR_CRM_VERSION
Wrappers for and extensions to libxml2.
@ PCMK_LRM_OP_NOTSUPPORTED
#define XML_RSC_OP_T_QUEUE
xmlNode * find_entity(xmlNode *parent, const char *node_name, const char *id)
void crm_xml_set_id(xmlNode *xml, const char *format,...) __attribute__((__format__(__printf__
#define XML_RSC_OP_LAST_RUN
#define CRM_LOG_ASSERT(expr)
#define CRMD_ACTION_MIGRATED
#define XML_LRM_ATTR_TASK
unsigned int get_crm_log_level(void)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define CRMD_ACTION_START
#define crm_debug(fmt, args...)
#define CRMD_ACTION_MIGRATE
#define XML_RSC_OP_LAST_CHANGE
#define do_crm_log(level, fmt, args...)
Log a message.
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_TAG_RSC_OP
char * generate_transition_key(int transition_id, int action_id, int target_rc, const char *node)
const char * crm_meta_value(GHashTable *hash, const char *field)
void filter_action_parameters(xmlNode *param_set, const char *version)
#define XML_LRM_ATTR_EXIT_REASON
#define CRMD_ACTION_RELOAD
#define XML_LRM_ATTR_OP_DIGEST
int rsc_op_expected_rc(lrmd_event_data_t *op)
#define XML_LRM_ATTR_MIGRATE_TARGET
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
void xml_remove_prop(xmlNode *obj, const char *name)
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
#define XML_ATTR_TRANSITION_MAGIC
#define XML_LRM_ATTR_TARGET
char * generate_transition_magic(const char *transition_key, int op_status, int op_rc)
#define CRMD_ACTION_DEMOTE
#define CRMD_ACTION_STATUS
#define XML_LRM_ATTR_INTERVAL_MS
char * generate_op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key.
gboolean decode_transition_key(const char *key, char **uuid, int *transition_id, int *action_id, int *target_rc)
#define XML_LRM_ATTR_CALLID
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
uint32_t pcmk_get_ra_caps(const char *standard)
Get capabilities of a resource agent standard.
char * strndup(const char *str, size_t len)
const char * crm_xml_add_ms(xmlNode *node, const char *name, guint ms)
Create an XML attribute with specified name and unsigned value.
gboolean decode_transition_magic(const char *magic, char **uuid, int *transition_id, int *action_id, int *op_status, int *op_rc, int *target_rc)
char * crm_meta_name(const char *field)
#define CRMD_ACTION_PROMOTE
char * generate_notify_key(const char *rsc_id, const char *notify_type, const char *op_type)