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;
90 for (gIter = list; gIter != NULL; gIter = gIter->next) {
101 existing_len = strlen(node_list);
104 node_list = realloc_safe(node_list, len + existing_len);
105 sprintf(node_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ", node->
details->
uname);
110 existing_len = strlen(metal_list);
123 metal_list = realloc_safe(metal_list, len + existing_len);
124 sprintf(metal_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ", node->
details->
uname);
135 expand_list(
GListPtr list,
char **rsc_list,
char **node_list)
138 const char *
uname = NULL;
139 const char *rsc_id = NULL;
140 const char *last_rsc_id = NULL;
148 *rsc_list = strdup(
" ");
151 *node_list = strdup(
" ");
160 for (gIter = list; gIter != NULL; gIter = gIter->next) {
166 if(entry == NULL || entry->rsc == NULL) {
172 if(node_list != NULL && entry->node == NULL) {
177 rsc_id = entry->rsc->id;
184 last_rsc_id = rsc_id;
186 if (rsc_list != NULL) {
187 int existing_len = 0;
188 int len = 2 + strlen(rsc_id);
191 existing_len = strlen(*rsc_list);
194 crm_trace(
"Adding %s (%dc) at offset %d", rsc_id, len - 2, existing_len);
195 *rsc_list = realloc_safe(*rsc_list, len + existing_len);
196 sprintf(*rsc_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ", rsc_id);
199 if (entry->node != NULL) {
200 uname = entry->node->details->uname;
203 if (node_list != NULL &&
uname) {
204 int existing_len = 0;
205 int len = 2 + strlen(
uname);
208 existing_len = strlen(*node_list);
211 crm_trace(
"Adding %s (%dc) at offset %d",
uname, len - 2, existing_len);
212 *node_list = realloc_safe(*node_list, len + existing_len);
213 sprintf(*node_list + existing_len,
"%s%s", existing_len == 0 ?
"":
" ",
uname);
220 dup_attr(gpointer key, gpointer value, gpointer user_data)
228 for (GSList *item = n_data->
keys; item; item = item->next) {
241 const char *value = NULL;
242 const char *task = NULL;
244 if (op == NULL || confirm == NULL) {
253 pe_rsc_trace(rsc,
"Skipping notification for %s: node offline", rsc->
id);
260 value = g_hash_table_lookup(op->
meta,
"notify_type");
261 task = g_hash_table_lookup(op->
meta,
"notify_operation");
263 pe_rsc_trace(rsc,
"Creating notify actions for %s: %s (%s-%s)", op->
uuid, rsc->
id, value, task);
268 g_hash_table_foreach(op->
meta, dup_attr, trigger->
meta);
269 add_notify_data_to_action_meta(n_data, trigger);
287 if (n_data->
post == NULL) {
291 notify = pe_notify(rsc, node, n_data->
post, n_data->
post_done, n_data, data_set);
293 if (notify != NULL) {
300 for (; gIter != NULL; gIter = gIter->next) {
302 const char *interval_ms_s = g_hash_table_lookup(mon->
meta,
305 if ((interval_ms_s == NULL) ||
safe_str_eq(interval_ms_s,
"0")) {
439 for (; gIter != NULL; gIter = gIter->next) {
467 n_data->
slave = g_list_prepend(n_data->
slave, entry);
469 dup_notify_entry(entry));
474 dup_notify_entry(entry));
477 crm_err(
"Unsupported notify role");
489 for (; gIter != NULL; gIter = gIter->next) {
502 entry->node = op->
node;
507 n_data->
start = g_list_prepend(n_data->
start, entry);
510 n_data->
stop = g_list_prepend(n_data->
stop, entry);
527 #define add_notify_env(n_data, key, value) do { \
528 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \
531 #define add_notify_env_free(n_data, key, value) do { \
532 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \
533 free(value); value = NULL; \
542 gboolean required = FALSE;
543 char *rsc_list = NULL;
544 char *node_list = NULL;
545 char *metal_list = NULL;
546 const char *source = NULL;
550 n_data->
stop = g_list_sort(n_data->
stop, sort_notify_entries);
552 expand_list(n_data->
stop, &rsc_list, &node_list);
562 n_data->
start = g_list_sort(n_data->
start, sort_notify_entries);
567 expand_list(n_data->
start, &rsc_list, &node_list);
572 n_data->
demote = g_list_sort(n_data->
demote, sort_notify_entries);
578 expand_list(n_data->
demote, &rsc_list, &node_list);
583 n_data->
promote = g_list_sort(n_data->
promote, sort_notify_entries);
588 expand_list(n_data->
promote, &rsc_list, &node_list);
593 n_data->
active = g_list_sort(n_data->
active, sort_notify_entries);
595 expand_list(n_data->
active, &rsc_list, &node_list);
600 n_data->
slave = g_list_sort(n_data->
slave, sort_notify_entries);
602 expand_list(n_data->
slave, &rsc_list, &node_list);
607 n_data->
master = g_list_sort(n_data->
master, sort_notify_entries);
609 expand_list(n_data->
master, &rsc_list, &node_list);
616 expand_list(n_data->
inactive, &rsc_list, NULL);
627 expand_node_list(nodes, &node_list, NULL);
633 expand_node_list(data_set->
nodes, &node_list, &metal_list);
636 expand_node_list(data_set->
nodes, &node_list, NULL);
640 if (required && n_data->
pre) {
645 if (required && n_data->
post) {
684 for (; gIter != NULL; gIter = gIter->next) {
694 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
705 add_notify_data_to_action_meta(n_data, op);
715 if (n_data->
start == NULL) {
716 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
723 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
729 if (n_data->
demote == NULL) {
730 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
742 pe_rsc_trace(rsc,
"Creating notifications for: %s.%s (%s->%s)",
752 for (; gIter != NULL; gIter = gIter->next) {
765 pe_notify(rsc, current_node, n_data->
pre, n_data->
pre_done, n_data, data_set);
768 pe_post_notify(rsc, current_node, n_data, data_set);
783 pe_action_t *remote_start = find_remote_start(start);
798 pe_post_notify(rsc, rsc->
allocated_to, n_data, data_set);
806 if (n_data == NULL) {
810 g_list_free_full(n_data->
stop, free);
811 g_list_free_full(n_data->
start, free);
812 g_list_free_full(n_data->
demote, free);
813 g_list_free_full(n_data->
promote, free);
814 g_list_free_full(n_data->
master, free);
815 g_list_free_full(n_data->
slave, free);
816 g_list_free_full(n_data->
active, free);
817 g_list_free_full(n_data->
inactive, free);