16 typedef struct notify_entry_s {
22 sort_notify_entries(gconstpointer a, gconstpointer b)
28 if (entry_a == NULL && entry_b == NULL) {
31 if (entry_a == NULL) {
34 if (entry_b == NULL) {
38 if (entry_a->rsc == NULL && entry_b->rsc == NULL) {
41 if (entry_a->rsc == NULL) {
44 if (entry_b->rsc == NULL) {
48 tmp = strcmp(entry_a->rsc->id, entry_b->rsc->id);
53 if (entry_a->node == NULL && entry_b->node == NULL) {
56 if (entry_a->node == NULL) {
59 if (entry_b->node == NULL) {
63 return strcmp(entry_a->node->details->id, entry_b->node->details->id);
71 dup->rsc = entry->rsc;
72 dup->node = entry->node;
77 expand_node_list(GList *list,
char **
uname,
char **metal)
80 char *node_list = NULL;
81 char *metal_list = NULL;
82 size_t node_list_len = 0;
83 size_t metal_list_len = 0;
94 for (gIter = list; gIter != NULL; gIter = gIter->next) {
100 pcmk__add_word(&node_list, &node_list_len, node->
details->
uname);
111 pcmk__add_word(&metal_list, &metal_list_len, node->
details->
uname);
132 expand_list(GList *list,
char **rsc_list,
char **node_list)
134 const char *last_rsc_id = NULL;
135 size_t rsc_list_len = 0;
136 size_t node_list_len = 0;
138 CRM_CHECK(rsc_list != NULL,
return list);
142 *rsc_list = strdup(
" ");
144 *node_list = strdup(
" ");
156 list = g_list_sort(list, sort_notify_entries);
158 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
163 && (entry->rsc->id != NULL));
164 if ((entry == NULL) || (entry->rsc == NULL)
165 || (entry->rsc->id == NULL)) {
171 if ((node_list != NULL) && (entry->node == NULL)) {
179 last_rsc_id = entry->rsc->id;
180 pcmk__add_word(rsc_list, &rsc_list_len, entry->rsc->id);
181 if ((node_list != NULL) && (entry->node->details->uname != NULL)) {
182 pcmk__add_word(node_list, &node_list_len,
183 entry->node->details->uname);
190 dup_attr(gpointer key, gpointer value, gpointer user_data)
198 for (GSList *item = n_data->
keys; item; item = item->next) {
211 const char *value = NULL;
212 const char *task = NULL;
214 if (op == NULL || confirm == NULL) {
223 pe_rsc_trace(rsc,
"Skipping notification for %s: node offline", rsc->
id);
230 value = g_hash_table_lookup(op->
meta,
"notify_type");
231 task = g_hash_table_lookup(op->
meta,
"notify_operation");
233 pe_rsc_trace(rsc,
"Creating notify actions for %s: %s (%s-%s)", op->
uuid, rsc->
id, value, task);
239 g_hash_table_foreach(op->
meta, dup_attr, trigger->
meta);
240 add_notify_data_to_action_meta(n_data, trigger);
258 if (n_data->
post == NULL) {
262 notify = pe_notify(rsc, node, n_data->
post, n_data->
post_done, n_data, data_set);
264 if (notify != NULL) {
271 for (; gIter != NULL; gIter = gIter->next) {
273 const char *interval_ms_s = g_hash_table_lookup(mon->
meta,
420 for (; gIter != NULL; gIter = gIter->next) {
450 dup_notify_entry(entry));
455 dup_notify_entry(entry));
458 crm_err(
"Unsupported notify role");
470 for (; gIter != NULL; gIter = gIter->next) {
474 && (op->
node != NULL)) {
485 entry->node = op->
node;
490 n_data->
start = g_list_prepend(n_data->
start, entry);
493 n_data->
stop = g_list_prepend(n_data->
stop, entry);
510 #define add_notify_env(n_data, key, value) do { \
511 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \
514 #define add_notify_env_free(n_data, key, value) do { \
515 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \
516 free(value); value = NULL; \
532 bool required =
false;
533 char *rsc_list = NULL;
534 char *node_list = NULL;
535 char *metal_list = NULL;
536 const char *source = NULL;
539 n_data->
stop = expand_list(n_data->
stop, &rsc_list, &node_list);
547 if ((n_data->
start != NULL)
551 n_data->
start = expand_list(n_data->
start, &rsc_list, &node_list);
555 if ((n_data->
demote != NULL)
559 n_data->
demote = expand_list(n_data->
demote, &rsc_list, &node_list);
567 n_data->
promote = expand_list(n_data->
promote, &rsc_list, &node_list);
571 n_data->
active = expand_list(n_data->
active, &rsc_list, &node_list);
602 expand_node_list(nodes, &node_list, NULL);
608 expand_node_list(data_set->
nodes, &node_list, &metal_list);
611 expand_node_list(data_set->
nodes, &node_list, NULL);
615 if (required && n_data->
pre) {
622 if (required && n_data->
post) {
641 if (action && action->
node) {
662 for (; gIter != NULL; gIter = gIter->next) {
672 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
676 && (op->
node != NULL)) {
685 add_notify_data_to_action_meta(n_data, op);
695 if (n_data->
start == NULL) {
696 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
703 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
709 if (n_data->
demote == NULL) {
710 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
722 pe_rsc_trace(rsc,
"Creating notifications for: %s.%s (%s->%s)",
732 for (; gIter != NULL; gIter = gIter->next) {
744 pe_notify(rsc, current_node, n_data->
pre, n_data->
pre_done, n_data, data_set);
747 pe_post_notify(rsc, current_node, n_data, data_set);
762 pe_action_t *remote_start = find_remote_start(start);
774 if ((task !=
start_rsc) || (start == NULL)
779 pe_post_notify(rsc, rsc->
allocated_to, n_data, data_set);
787 if (n_data == NULL) {
791 g_list_free_full(n_data->
stop, free);
792 g_list_free_full(n_data->
start, free);
793 g_list_free_full(n_data->
demote, free);
794 g_list_free_full(n_data->
promote, free);
795 g_list_free_full(n_data->
promoted, free);
797 g_list_free_full(n_data->
active, free);
798 g_list_free_full(n_data->
inactive, free);
810 crm_info(
"Creating secondary notification for %s", action->
uuid);
#define CRM_CHECK(expr, failure_action)
void pcmk__create_notification_keys(pe_resource_t *rsc, notify_data_t *n_data, pe_working_set_t *data_set)
void pcmk_free_nvpairs(GSList *nvpairs)
Free a list of name/value pairs.
GHashTable * allowed_nodes
pe_resource_t * container
void collect_notification_data(pe_resource_t *rsc, gboolean state, gboolean activity, notify_data_t *n_data)
enum rsc_role_e next_role
pe_resource_t * remote_rsc
void create_notifications(pe_resource_t *rsc, notify_data_t *n_data, pe_working_set_t *data_set)
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
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 free_notification_data(notify_data_t *n_data)
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)
#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
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define crm_err(fmt, args...)
#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...)
gint sort_node_uname(gconstpointer a, gconstpointer b)
#define crm_info(fmt, args...)
pe_action_t * find_first_action(GList *input, const char *uuid, const char *task, pe_node_t *on_node)
void create_secondary_notification(pe_action_t *action, pe_resource_t *rsc, pe_action_t *stonith_op, pe_working_set_t *data_set)
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)