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,
408 for (; gIter != NULL; gIter = gIter->next) {
438 dup_notify_entry(entry));
443 dup_notify_entry(entry));
446 crm_err(
"Unsupported notify role");
458 for (; gIter != NULL; gIter = gIter->next) {
462 && (op->
node != NULL)) {
473 entry->node = op->
node;
478 n_data->
start = g_list_prepend(n_data->
start, entry);
481 n_data->
stop = g_list_prepend(n_data->
stop, entry);
498 #define add_notify_env(n_data, key, value) do { \ 499 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 502 #define add_notify_env_free(n_data, key, value) do { \ 503 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 504 free(value); value = NULL; \ 520 bool required =
false;
521 char *rsc_list = NULL;
522 char *node_list = NULL;
523 char *metal_list = NULL;
524 const char *source = NULL;
527 n_data->
stop = expand_list(n_data->
stop, &rsc_list, &node_list);
535 if ((n_data->
start != NULL)
539 n_data->
start = expand_list(n_data->
start, &rsc_list, &node_list);
543 if ((n_data->
demote != NULL)
547 n_data->
demote = expand_list(n_data->
demote, &rsc_list, &node_list);
555 n_data->
promote = expand_list(n_data->
promote, &rsc_list, &node_list);
559 n_data->
active = expand_list(n_data->
active, &rsc_list, &node_list);
590 expand_node_list(nodes, &node_list, NULL);
596 expand_node_list(data_set->
nodes, &node_list, &metal_list);
599 expand_node_list(data_set->
nodes, &node_list, NULL);
603 if (required && n_data->
pre) {
608 if (required && n_data->
post) {
646 for (; gIter != NULL; gIter = gIter->next) {
656 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
660 && (op->
node != NULL)) {
669 add_notify_data_to_action_meta(n_data, op);
679 if (n_data->
start == NULL) {
680 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
687 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
693 if (n_data->
demote == NULL) {
694 pe_rsc_trace(rsc,
"Skipping empty notification for: %s.%s (%s->%s)",
706 pe_rsc_trace(rsc,
"Creating notifications for: %s.%s (%s->%s)",
716 for (; gIter != NULL; gIter = gIter->next) {
728 pe_notify(rsc, current_node, n_data->
pre, n_data->
pre_done, n_data, data_set);
731 pe_post_notify(rsc, current_node, n_data, data_set);
746 pe_action_t *remote_start = find_remote_start(start);
758 if ((task !=
start_rsc) || (start == NULL)
763 pe_post_notify(rsc, rsc->
allocated_to, n_data, data_set);
771 if (n_data == NULL) {
775 g_list_free_full(n_data->
stop, free);
776 g_list_free_full(n_data->
start, free);
777 g_list_free_full(n_data->
demote, free);
778 g_list_free_full(n_data->
promote, free);
779 g_list_free_full(n_data->
promoted, free);
781 g_list_free_full(n_data->
active, free);
782 g_list_free_full(n_data->
inactive, free);
#define CRM_CHECK(expr, failure_action)
#define pe__set_action_flags(action, flags_to_set)
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 pe__clear_action_flags(action, flags_to_clear)
#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)
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...)
gint sort_node_uname(gconstpointer a, gconstpointer b)
#define crm_info(fmt, args...)
void free_notification_data(notify_data_t *n_data)
pe_action_t * find_first_action(GList *input, const char *uuid, const char *task, pe_node_t *on_node)
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)