14 typedef struct notify_entry_s {
33 compare_notify_entries(gconstpointer a, gconstpointer b)
40 if ((entry_a == NULL) && (entry_b == NULL)) {
43 if (entry_a == NULL) {
46 if (entry_b == NULL) {
51 if ((entry_a->rsc == NULL) && (entry_b->rsc == NULL)) {
54 if (entry_a->rsc == NULL) {
57 if (entry_b->rsc == NULL) {
62 tmp = strcmp(entry_a->rsc->id, entry_b->rsc->id);
68 if ((entry_a->node == NULL) && (entry_b->node == NULL)) {
71 if (entry_a->node == NULL) {
74 if (entry_b->node == NULL) {
79 return strcmp(entry_a->node->details->id, entry_b->node->details->id);
97 dup->rsc = entry->rsc;
98 dup->node = entry->node;
116 get_node_names(GList *list, GString **all_node_names, GString **host_node_names)
118 if (all_node_names != NULL) {
119 *all_node_names = NULL;
121 if (host_node_names != NULL) {
122 *host_node_names = NULL;
125 for (GList *iter = list; iter != NULL; iter = iter->next) {
133 if (all_node_names != NULL) {
134 pcmk__add_word(all_node_names, 1024, node->
details->
uname);
138 if (host_node_names != NULL) {
146 pcmk__add_word(host_node_names, 1024, node->
details->
uname);
150 if ((all_node_names != NULL) && (*all_node_names == NULL)) {
151 *all_node_names = g_string_new(
" ");
153 if ((host_node_names != NULL) && (*host_node_names == NULL)) {
154 *host_node_names = g_string_new(
" ");
173 notify_entries_to_strings(GList *list, GString **rsc_names,
174 GString **node_names)
176 const char *last_rsc_id = NULL;
179 if (rsc_names != NULL) {
182 if (node_names != NULL) {
187 list = g_list_sort(list, compare_notify_entries);
189 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
194 && (entry->rsc->id != NULL));
195 if ((entry == NULL) || (entry->rsc == NULL)
196 || (entry->rsc->id == NULL)) {
202 if ((node_names != NULL) && (entry->node == NULL)) {
210 last_rsc_id = entry->rsc->id;
212 if (rsc_names != NULL) {
213 pcmk__add_word(rsc_names, 1024, entry->rsc->id);
215 if ((node_names != NULL) && (entry->node->details->uname != NULL)) {
216 pcmk__add_word(node_names, 1024, entry->node->details->uname);
221 if ((rsc_names != NULL) && (*rsc_names == NULL)) {
222 *rsc_names = g_string_new(
" ");
224 if ((node_names != NULL) && (*node_names == NULL)) {
225 *node_names = g_string_new(
" ");
240 copy_meta_to_notify(gpointer key, gpointer value, gpointer user_data)
247 if (g_hash_table_lookup(notify->
meta, (
const char *) key) != NULL) {
251 g_hash_table_insert(notify->
meta, strdup((
const char *) key),
252 strdup((
const char *) value));
258 for (GSList *item = n_data->
keys; item; item = item->next) {
278 const char *notif_action,
const char *notif_type)
311 const char *value = NULL;
312 const char *task = NULL;
313 const char *skip_reason = NULL;
315 CRM_CHECK((rsc != NULL) && (node != NULL),
return NULL);
319 skip_reason =
"no action";
320 }
else if (notify_done == NULL) {
321 skip_reason =
"no parent notification";
323 skip_reason =
"node offline";
325 skip_reason =
"original action not runnable";
327 if (skip_reason != NULL) {
328 pe_rsc_trace(rsc,
"Skipping notify action for %s on %s: %s",
329 rsc->
id, pe__node_name(node), skip_reason);
333 value = g_hash_table_lookup(op->
meta,
"notify_type");
334 task = g_hash_table_lookup(op->
meta,
"notify_operation");
336 pe_rsc_trace(rsc,
"Creating notify action for %s on %s (%s-%s)",
337 rsc->
id, pe__node_name(node), value, task);
346 g_hash_table_foreach(op->
meta, copy_meta_to_notify, notify_action);
347 add_notify_data_to_action_meta(n_data, notify_action);
352 return notify_action;
372 notify = new_notify_action(rsc, node, n_data->
post, n_data->
post_done,
374 if (notify != NULL) {
382 for (GList *iter = rsc->
actions; iter != NULL; iter = iter->next) {
384 const char *interval_ms_s = NULL;
386 interval_ms_s = g_hash_table_lookup(mon->
meta,
456 "notify_operation", n_data->
action);
463 if (complete != NULL) {
466 n_data->
post = new_notify_pseudo_action(rsc, complete,
RSC_NOTIFY,
478 n_data->
post_done = new_notify_pseudo_action(rsc, complete,
489 "notify_operation", n_data->
action);
497 if ((
action != NULL) && (complete != NULL)) {
539 if (n_data == NULL) {
549 for (iter = rsc->
children; iter != NULL; iter = iter->next) {
552 collect_resource_data(child, activity, n_data);
562 entry = new_notify_entry(rsc, node);
577 dup_notify_entry(entry));
583 dup_notify_entry(entry));
587 crm_err(
"Resource %s role on %s (%s) is not supported for " 588 "notifications (bug?)",
599 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
611 entry = new_notify_entry(rsc, op->
node);
615 n_data->
start = g_list_prepend(n_data->
start, entry);
618 n_data->
stop = g_list_prepend(n_data->
stop, entry);
635 #define add_notify_env(n_data, key, value) do { \ 636 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 640 #define add_notify_env_gs(n_data, key, value) do { \ 641 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, \ 642 (const char *) value->str); \ 646 #define add_notify_env_free_gs(n_data, key, value) do { \ 647 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, \ 648 (const char *) value->str); \ 649 g_string_free(value, TRUE); value = NULL; \ 662 bool required =
false;
663 GString *rsc_list = NULL;
664 GString *node_list = NULL;
665 GString *metal_list = NULL;
666 const char *source = NULL;
669 n_data->
stop = notify_entries_to_strings(n_data->
stop,
670 &rsc_list, &node_list);
671 if ((strcmp(
" ", (
const char *) rsc_list->str) != 0)
678 if ((n_data->
start != NULL)
682 n_data->
start = notify_entries_to_strings(n_data->
start,
683 &rsc_list, &node_list);
687 if ((n_data->
demote != NULL)
691 n_data->
demote = notify_entries_to_strings(n_data->
demote,
692 &rsc_list, &node_list);
701 &rsc_list, &node_list);
705 n_data->
active = notify_entries_to_strings(n_data->
active,
706 &rsc_list, &node_list);
711 &rsc_list, &node_list);
720 &rsc_list, &node_list);
740 get_node_names(nodes, &node_list, NULL);
746 get_node_names(rsc->
cluster->
nodes, &node_list, &metal_list);
753 if (required && (n_data->
pre != NULL)) {
758 if (required && (n_data->
post != NULL)) {
778 if (remote_rsc != NULL) {
803 g_list_foreach(rsc->
children, (GFunc) create_notify_actions, n_data);
808 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
817 add_notify_data_to_action_meta(n_data, op);
828 if (n_data->
start == NULL) {
844 if (n_data->
demote == NULL) {
865 for (iter = rsc->
running_on; iter != NULL; iter = iter->next) {
877 new_notify_action(rsc, current_node, n_data->
pre,
882 new_post_notify_action(rsc, current_node, n_data);
893 pe_action_t *remote_start = find_remote_start(start);
895 if ((remote_start != NULL)
906 pe_proc_err(
"Next role '%s' but %s is not allocated",
910 if ((task !=
start_rsc) || (start == NULL)
930 if ((rsc == NULL) || (n_data == NULL)) {
933 collect_resource_data(rsc,
true, n_data);
934 add_notif_keys(rsc, n_data);
935 create_notify_actions(rsc, n_data);
947 if (n_data == NULL) {
950 g_list_free_full(n_data->
stop, free);
951 g_list_free_full(n_data->
start, free);
952 g_list_free_full(n_data->
demote, free);
953 g_list_free_full(n_data->
promote, free);
954 g_list_free_full(n_data->
promoted, free);
956 g_list_free_full(n_data->
active, free);
957 g_list_free_full(n_data->
inactive, free);
982 crm_info(
"Ordering notifications for implied %s after fencing", stop->
uuid);
985 if (n_data != NULL) {
986 collect_resource_data(rsc,
false, n_data);
#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
gint pe__cmp_node_name(gconstpointer a, gconstpointer b)
#define add_notify_env_free_gs(n_data, key, value)
enum rsc_role_e next_role
pe_action_t * find_first_action(const GList *input, const char *uuid, const char *task, const pe_node_t *on_node)
pe_resource_t * remote_rsc
void pe__order_notifs_after_fencing(pe_action_t *stop, pe_resource_t *rsc, pe_action_t *stonith_op)
enum action_tasks text2task(const char *task)
void pe__create_notifications(pe_resource_t *rsc, notify_data_t *n_data)
#define CRM_LOG_ASSERT(expr)
#define add_notify_env_gs(n_data, key, value)
#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)
bool pe__is_guest_node(const pe_node_t *node)
void pe__free_notification_data(notify_data_t *n_data)
#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
notify_data_t * pe__clone_notif_pseudo_ops(pe_resource_t *rsc, const char *task, pe_action_t *action, pe_action_t *complete)
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define crm_err(fmt, args...)
#define XML_LRM_ATTR_INTERVAL_MS
enum pe_action_flags flags
pe_working_set_t * cluster
struct notify_entry_s notify_entry_t
#define pe_rsc_trace(rsc, fmt, args...)
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, const pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
Create or update an action object.
#define crm_info(fmt, args...)
#define add_notify_env(n_data, key, value)
GHashTable * allowed_nodes