14 typedef struct notify_entry_s {
20 sort_notify_entries(gconstpointer a, gconstpointer b)
26 if (entry_a == NULL && entry_b == NULL) {
29 if (entry_a == NULL) {
32 if (entry_b == NULL) {
36 if (entry_a->rsc == NULL && entry_b->rsc == NULL) {
39 if (entry_a->rsc == NULL) {
42 if (entry_b->rsc == NULL) {
46 tmp = strcmp(entry_a->rsc->id, entry_b->rsc->id);
51 if (entry_a->node == NULL && entry_b->node == NULL) {
54 if (entry_a->node == NULL) {
57 if (entry_b->node == NULL) {
61 return strcmp(entry_a->node->details->id, entry_b->node->details->id);
69 dup->rsc = entry->rsc;
70 dup->node = entry->node;
78 char *node_list = NULL;
79 char *metal_list = NULL;
80 size_t node_list_len = 0;
81 size_t metal_list_len = 0;
92 for (gIter = list; gIter != NULL; gIter = gIter->next) {
98 pcmk__add_word(&node_list, &node_list_len, node->
details->
uname);
109 pcmk__add_word(&metal_list, &metal_list_len, node->
details->
uname);
130 expand_list(GList *list,
char **rsc_list,
char **node_list)
132 const char *last_rsc_id = NULL;
133 size_t rsc_list_len = 0;
134 size_t node_list_len = 0;
136 CRM_CHECK(rsc_list != NULL,
return list);
140 *rsc_list = strdup(
" ");
142 *node_list = strdup(
" ");
154 list = g_list_sort(list, sort_notify_entries);
156 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
161 && (entry->rsc->id != NULL));
162 if ((entry == NULL) || (entry->rsc == NULL)
163 || (entry->rsc->id == NULL)) {
169 if ((node_list != NULL) && (entry->node == NULL)) {
177 last_rsc_id = entry->rsc->id;
178 pcmk__add_word(rsc_list, &rsc_list_len, entry->rsc->id);
179 if ((node_list != NULL) && (entry->node->details->uname != NULL)) {
180 pcmk__add_word(node_list, &node_list_len,
181 entry->node->details->uname);
188 dup_attr(gpointer key, gpointer value, gpointer user_data)
196 for (GSList *item = n_data->
keys; item; item = item->next) {
209 const char *value = NULL;
210 const char *task = NULL;
212 if (op == NULL || confirm == NULL) {
221 pe_rsc_trace(rsc,
"Skipping notification for %s: node offline", rsc->
id);
228 value = g_hash_table_lookup(op->
meta,
"notify_type");
229 task = g_hash_table_lookup(op->
meta,
"notify_operation");
231 pe_rsc_trace(rsc,
"Creating notify actions for %s: %s (%s-%s)", op->
uuid, rsc->
id, value, task);
237 g_hash_table_foreach(op->
meta, dup_attr, trigger->
meta);
238 add_notify_data_to_action_meta(n_data, trigger);
256 if (n_data->
post == NULL) {
260 notify = pe_notify(rsc, node, n_data->
post, n_data->
post_done, n_data, data_set);
262 if (notify != NULL) {
269 for (; gIter != NULL; gIter = gIter->next) {
271 const char *interval_ms_s = g_hash_table_lookup(mon->
meta,
418 for (; gIter != NULL; gIter = gIter->next) {
446 n_data->
slave = g_list_prepend(n_data->
slave, entry);
448 dup_notify_entry(entry));
453 dup_notify_entry(entry));
456 crm_err(
"Unsupported notify role");
468 for (; gIter != NULL; gIter = gIter->next) {
472 && (op->
node != NULL)) {
483 entry->node = op->
node;
488 n_data->
start = g_list_prepend(n_data->
start, entry);
491 n_data->
stop = g_list_prepend(n_data->
stop, entry);
508 #define add_notify_env(n_data, key, value) do { \ 509 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 512 #define add_notify_env_free(n_data, key, value) do { \ 513 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 514 free(value); value = NULL; \ 530 bool required =
false;
531 char *rsc_list = NULL;
532 char *node_list = NULL;
533 char *metal_list = NULL;
534 const char *source = NULL;
537 n_data->
stop = expand_list(n_data->
stop, &rsc_list, &node_list);
545 if ((n_data->
start != NULL)
549 n_data->
start = expand_list(n_data->
start, &rsc_list, &node_list);
553 if ((n_data->
demote != NULL)
557 n_data->
demote = expand_list(n_data->
demote, &rsc_list, &node_list);
565 n_data->
promote = expand_list(n_data->
promote, &rsc_list, &node_list);
569 n_data->
active = expand_list(n_data->
active, &rsc_list, &node_list);
573 n_data->
slave = expand_list(n_data->
slave, &rsc_list, &node_list);
577 n_data->
master = expand_list(n_data->
master, &rsc_list, &node_list);
592 expand_node_list(nodes, &node_list, NULL);
598 expand_node_list(data_set->
nodes, &node_list, &metal_list);
601 expand_node_list(data_set->
nodes, &node_list, NULL);
605 if (required && n_data->
pre) {
612 if (required && n_data->
post) {
652 for (; gIter != NULL; gIter = gIter->next) {
662 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
666 && (op->
node != NULL)) {
675 add_notify_data_to_action_meta(n_data, op);
685 if (n_data->
start == NULL) {
686 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
693 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
699 if (n_data->
demote == NULL) {
700 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
712 pe_rsc_trace(rsc,
"Creating notifications for: %s.%s (%s->%s)",
722 for (; gIter != NULL; gIter = gIter->next) {
734 pe_notify(rsc, current_node, n_data->
pre, n_data->
pre_done, n_data, data_set);
737 pe_post_notify(rsc, current_node, n_data, data_set);
752 pe_action_t *remote_start = find_remote_start(start);
764 if ((task !=
start_rsc) || (start == NULL)
769 pe_post_notify(rsc, rsc->
allocated_to, n_data, data_set);
777 if (n_data == NULL) {
781 g_list_free_full(n_data->
stop, free);
782 g_list_free_full(n_data->
start, free);
783 g_list_free_full(n_data->
demote, free);
784 g_list_free_full(n_data->
promote, free);
785 g_list_free_full(n_data->
master, free);
786 g_list_free_full(n_data->
slave, free);
787 g_list_free_full(n_data->
active, free);
788 g_list_free_full(n_data->
inactive, free);
#define CRM_CHECK(expr, failure_action)
void pcmk_free_nvpairs(GSList *nvpairs)
Free a list of name/value pairs.
GHashTable * allowed_nodes
pe_resource_t * container
enum rsc_role_e next_role
pe_resource_t * remote_rsc
enum action_tasks text2task(const char *task)
#define CRM_LOG_ASSERT(expr)
#define XML_RSC_ATTR_TARGET
#define pe_proc_err(fmt...)
gboolean remote_requires_reset
const char * role2text(enum rsc_role_e role)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
pe_resource_t * uber_parent(pe_resource_t *rsc)
void pcmk__create_notification_keys(pe_resource_t *rsc, notify_data_t *n_data, pe_working_set_t *data_set)
#define add_notify_env_free(n_data, key, value)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
gboolean update_action_flags(pe_action_t *action, enum pe_action_flags flags, const char *source, int line)
struct notify_entry_s notify_entry_t
notify_data_t * create_notification_boundaries(pe_resource_t *rsc, const char *action, pe_action_t *start, pe_action_t *end, pe_working_set_t *data_set)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define crm_err(fmt, args...)
void create_notifications(pe_resource_t *rsc, notify_data_t *n_data, pe_working_set_t *data_set)
#define add_notify_env(n_data, key, value)
#define XML_LRM_ATTR_INTERVAL_MS
enum pe_action_flags flags
#define pe_rsc_trace(rsc, fmt, args...)
pe_action_t * find_first_action(GListPtr input, const char *uuid, const char *task, pe_node_t *on_node)
gint sort_node_uname(gconstpointer a, gconstpointer b)
#define crm_info(fmt, args...)
void free_notification_data(notify_data_t *n_data)
void collect_notification_data(pe_resource_t *rsc, gboolean state, gboolean activity, notify_data_t *n_data)
GHashTable * allowed_nodes
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
void create_secondary_notification(pe_action_t *action, pe_resource_t *rsc, pe_action_t *stonith_op, pe_working_set_t *data_set)