12 typedef struct notify_entry_s {
18 sort_notify_entries(gconstpointer a, gconstpointer b)
24 if (entry_a == NULL && entry_b == NULL) {
27 if (entry_a == NULL) {
30 if (entry_b == NULL) {
34 if (entry_a->rsc == NULL && entry_b->rsc == NULL) {
37 if (entry_a->rsc == NULL) {
40 if (entry_b->rsc == NULL) {
44 tmp = strcmp(entry_a->rsc->id, entry_b->rsc->id);
49 if (entry_a->node == NULL && entry_b->node == NULL) {
52 if (entry_a->node == NULL) {
55 if (entry_b->node == NULL) {
59 return strcmp(entry_a->node->details->id, entry_b->node->details->id);
67 dup->rsc = entry->rsc;
68 dup->node = entry->node;
76 char *node_list = NULL;
77 char *metal_list = NULL;
88 for (gIter = list; gIter != NULL; gIter = gIter->next) {
99 existing_len = strlen(node_list);
102 node_list = realloc_safe(node_list, len + existing_len);
103 sprintf(node_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ", node->
details->
uname);
108 existing_len = strlen(metal_list);
121 metal_list = realloc_safe(metal_list, len + existing_len);
122 sprintf(metal_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ", node->
details->
uname);
133 expand_list(
GListPtr list,
char **rsc_list,
char **node_list)
136 const char *
uname = NULL;
137 const char *rsc_id = NULL;
138 const char *last_rsc_id = NULL;
146 *rsc_list = strdup(
" ");
149 *node_list = strdup(
" ");
158 for (gIter = list; gIter != NULL; gIter = gIter->next) {
164 if(entry == NULL || entry->rsc == NULL) {
170 if(node_list != NULL && entry->node == NULL) {
175 rsc_id = entry->rsc->id;
182 last_rsc_id = rsc_id;
184 if (rsc_list != NULL) {
185 int existing_len = 0;
186 int len = 2 + strlen(rsc_id);
189 existing_len = strlen(*rsc_list);
192 crm_trace(
"Adding %s (%dc) at offset %d", rsc_id, len - 2, existing_len);
193 *rsc_list = realloc_safe(*rsc_list, len + existing_len);
194 sprintf(*rsc_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ", rsc_id);
197 if (entry->node != NULL) {
198 uname = entry->node->details->uname;
201 if (node_list != NULL &&
uname) {
202 int existing_len = 0;
203 int len = 2 + strlen(
uname);
206 existing_len = strlen(*node_list);
209 crm_trace(
"Adding %s (%dc) at offset %d",
uname, len - 2, existing_len);
210 *node_list = realloc_safe(*node_list, len + existing_len);
211 sprintf(*node_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ",
uname);
218 dup_attr(gpointer key, gpointer value, gpointer user_data)
226 for (GSList *item = n_data->
keys; item; item = item->next) {
239 const char *value = NULL;
240 const char *task = NULL;
242 if (op == NULL || confirm == NULL) {
251 pe_rsc_trace(rsc,
"Skipping notification for %s: node offline", rsc->
id);
258 value = g_hash_table_lookup(op->
meta,
"notify_type");
259 task = g_hash_table_lookup(op->
meta,
"notify_operation");
261 pe_rsc_trace(rsc,
"Creating notify actions for %s: %s (%s-%s)", op->
uuid, rsc->
id, value, task);
266 g_hash_table_foreach(op->
meta, dup_attr, trigger->
meta);
267 add_notify_data_to_action_meta(n_data, trigger);
285 if (n_data->
post == NULL) {
289 notify = pe_notify(rsc, node, n_data->
post, n_data->
post_done, n_data, data_set);
291 if (notify != NULL) {
298 for (; gIter != NULL; gIter = gIter->next) {
300 const char *interval_ms_s = g_hash_table_lookup(mon->
meta,
303 if ((interval_ms_s == NULL) ||
safe_str_eq(interval_ms_s,
"0")) {
437 for (; gIter != NULL; gIter = gIter->next) {
465 n_data->
slave = g_list_prepend(n_data->
slave, entry);
467 dup_notify_entry(entry));
472 dup_notify_entry(entry));
475 crm_err(
"Unsupported notify role");
487 for (; gIter != NULL; gIter = gIter->next) {
500 entry->node = op->
node;
505 n_data->
start = g_list_prepend(n_data->
start, entry);
508 n_data->
stop = g_list_prepend(n_data->
stop, entry);
525 #define add_notify_env(n_data, key, value) do { \
526 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \
529 #define add_notify_env_free(n_data, key, value) do { \
530 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \
531 free(value); value = NULL; \
540 gboolean required = FALSE;
541 char *rsc_list = NULL;
542 char *node_list = NULL;
543 char *metal_list = NULL;
544 const char *source = NULL;
548 n_data->
stop = g_list_sort(n_data->
stop, sort_notify_entries);
550 expand_list(n_data->
stop, &rsc_list, &node_list);
560 n_data->
start = g_list_sort(n_data->
start, sort_notify_entries);
565 expand_list(n_data->
start, &rsc_list, &node_list);
570 n_data->
demote = g_list_sort(n_data->
demote, sort_notify_entries);
576 expand_list(n_data->
demote, &rsc_list, &node_list);
581 n_data->
promote = g_list_sort(n_data->
promote, sort_notify_entries);
586 expand_list(n_data->
promote, &rsc_list, &node_list);
591 n_data->
active = g_list_sort(n_data->
active, sort_notify_entries);
593 expand_list(n_data->
active, &rsc_list, &node_list);
598 n_data->
slave = g_list_sort(n_data->
slave, sort_notify_entries);
600 expand_list(n_data->
slave, &rsc_list, &node_list);
605 n_data->
master = g_list_sort(n_data->
master, sort_notify_entries);
607 expand_list(n_data->
master, &rsc_list, &node_list);
614 expand_list(n_data->
inactive, &rsc_list, NULL);
625 expand_node_list(nodes, &node_list, NULL);
631 expand_node_list(data_set->
nodes, &node_list, &metal_list);
634 expand_node_list(data_set->
nodes, &node_list, NULL);
638 if (required && n_data->
pre) {
643 if (required && n_data->
post) {
661 if (action && action->
node) {
682 for (; gIter != NULL; gIter = gIter->next) {
692 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
703 add_notify_data_to_action_meta(n_data, op);
713 if(g_list_length(n_data->
start) == 0) {
714 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
720 if(g_list_length(n_data->
promote) == 0) {
721 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
727 if(g_list_length(n_data->
demote) == 0) {
728 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
740 pe_rsc_trace(rsc,
"Creating notifications for: %s.%s (%s->%s)",
750 for (; gIter != NULL; gIter = gIter->next) {
763 pe_notify(rsc, current_node, n_data->
pre, n_data->
pre_done, n_data, data_set);
766 pe_post_notify(rsc, current_node, n_data, data_set);
781 pe_action_t *remote_start = find_remote_start(start);
796 pe_post_notify(rsc, rsc->
allocated_to, n_data, data_set);
804 if (n_data == NULL) {
808 g_list_free_full(n_data->
stop, free);
809 g_list_free_full(n_data->
start, free);
810 g_list_free_full(n_data->
demote, free);
811 g_list_free_full(n_data->
promote, free);
812 g_list_free_full(n_data->
master, free);
813 g_list_free_full(n_data->
slave, free);
814 g_list_free_full(n_data->
active, free);
815 g_list_free_full(n_data->
inactive, free);
827 crm_info(
"Creating secondary notification for %s", action->
uuid);