18 typedef struct notify_entry_s {
37 compare_notify_entries(gconstpointer a, gconstpointer b)
44 if ((entry_a == NULL) && (entry_b == NULL)) {
47 if (entry_a == NULL) {
50 if (entry_b == NULL) {
55 if ((entry_a->rsc == NULL) && (entry_b->rsc == NULL)) {
58 if (entry_a->rsc == NULL) {
61 if (entry_b->rsc == NULL) {
66 tmp = strcmp(entry_a->rsc->id, entry_b->rsc->id);
72 if ((entry_a->node == NULL) && (entry_b->node == NULL)) {
75 if (entry_a->node == NULL) {
78 if (entry_b->node == NULL) {
83 return strcmp(entry_a->node->details->id, entry_b->node->details->id);
100 dup->rsc = entry->rsc;
101 dup->node = entry->node;
119 get_node_names(
const GList *list, GString **all_node_names,
120 GString **host_node_names)
122 if (all_node_names != NULL) {
123 *all_node_names = NULL;
125 if (host_node_names != NULL) {
126 *host_node_names = NULL;
129 for (
const GList *iter = list; iter != NULL; iter = iter->next) {
137 if (all_node_names != NULL) {
138 pcmk__add_word(all_node_names, 1024, node->
details->
uname);
142 if (host_node_names != NULL) {
143 if (pcmk__is_guest_or_bundle_node(node)
150 pcmk__add_word(host_node_names, 1024, node->
details->
uname);
154 if ((all_node_names != NULL) && (*all_node_names == NULL)) {
155 *all_node_names = g_string_new(
" ");
157 if ((host_node_names != NULL) && (*host_node_names == NULL)) {
158 *host_node_names = g_string_new(
" ");
177 notify_entries_to_strings(GList *list, GString **rsc_names,
178 GString **node_names)
180 const char *last_rsc_id = NULL;
183 if (rsc_names != NULL) {
186 if (node_names != NULL) {
191 list = g_list_sort(list, compare_notify_entries);
193 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
198 && (entry->rsc->id != NULL));
199 if ((entry == NULL) || (entry->rsc == NULL)
200 || (entry->rsc->id == NULL)) {
206 if ((node_names != NULL) && (entry->node == NULL)) {
214 last_rsc_id = entry->rsc->id;
216 if (rsc_names != NULL) {
217 pcmk__add_word(rsc_names, 1024, entry->rsc->id);
219 if ((node_names != NULL) && (entry->node->details->uname != NULL)) {
220 pcmk__add_word(node_names, 1024, entry->node->details->uname);
225 if ((rsc_names != NULL) && (*rsc_names == NULL)) {
226 *rsc_names = g_string_new(
" ");
228 if ((node_names != NULL) && (*node_names == NULL)) {
229 *node_names = g_string_new(
" ");
244 copy_meta_to_notify(gpointer key, gpointer value, gpointer user_data)
251 if (g_hash_table_lookup(notify->
meta, (
const char *) key) != NULL) {
262 for (
const GSList *item = n_data->
keys; item; item = item->next) {
282 const char *notif_action,
const char *notif_type)
316 const char *value = NULL;
317 const char *task = NULL;
318 const char *skip_reason = NULL;
320 CRM_CHECK((rsc != NULL) && (node != NULL),
return NULL);
324 skip_reason =
"no action";
325 }
else if (notify_done == NULL) {
326 skip_reason =
"no parent notification";
328 skip_reason =
"node offline";
330 skip_reason =
"original action not runnable";
332 if (skip_reason != NULL) {
334 rsc->
id, pcmk__node_name(node), skip_reason);
338 value = g_hash_table_lookup(op->
meta,
"notify_type");
339 task = g_hash_table_lookup(op->
meta,
"notify_operation");
342 rsc->
id, pcmk__node_name(node), value, task);
351 g_hash_table_foreach(op->
meta, copy_meta_to_notify, notify_action);
352 add_notify_data_to_action_meta(n_data, notify_action);
357 return notify_action;
377 notify = new_notify_action(rsc, node, n_data->
post, n_data->
post_done,
379 if (notify != NULL) {
387 for (GList *iter = rsc->
actions; iter != NULL; iter = iter->next) {
389 const char *interval_ms_s = NULL;
467 if (complete != NULL) {
470 n_data->
post = new_notify_pseudo_action(rsc, complete,
482 n_data->
post_done = new_notify_pseudo_action(rsc, complete,
493 "notify_operation", n_data->
action);
502 if ((
action != NULL) && (complete != NULL)) {
540 const GList *iter = NULL;
544 if (n_data == NULL) {
554 for (iter = rsc->
children; iter != NULL; iter = iter->next) {
557 collect_resource_data(child, activity, n_data);
567 entry = new_notify_entry(rsc, node);
582 dup_notify_entry(entry));
588 dup_notify_entry(entry));
593 "notifications (bug?)",
594 rsc->
id, pcmk__node_name(node),
605 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
609 && (op->
node != NULL)) {
618 entry = new_notify_entry(rsc, op->
node);
622 n_data->
start = g_list_prepend(n_data->
start, entry);
625 n_data->
stop = g_list_prepend(n_data->
stop, entry);
642 #define add_notify_env(n_data, key, value) do { \ 643 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 647 #define add_notify_env_gs(n_data, key, value) do { \ 648 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, \ 649 (const char *) value->str); \ 653 #define add_notify_env_free_gs(n_data, key, value) do { \ 654 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, \ 655 (const char *) value->str); \ 656 g_string_free(value, TRUE); value = NULL; \ 669 bool required =
false;
670 GString *rsc_list = NULL;
671 GString *node_list = NULL;
672 GString *metal_list = NULL;
673 const char *source = NULL;
676 n_data->
stop = notify_entries_to_strings(n_data->
stop,
677 &rsc_list, &node_list);
678 if ((strcmp(
" ", (
const char *) rsc_list->str) != 0)
685 if ((n_data->
start != NULL)
689 n_data->
start = notify_entries_to_strings(n_data->
start,
690 &rsc_list, &node_list);
694 if ((n_data->
demote != NULL)
698 n_data->
demote = notify_entries_to_strings(n_data->
demote,
699 &rsc_list, &node_list);
708 &rsc_list, &node_list);
712 n_data->
active = notify_entries_to_strings(n_data->
active,
713 &rsc_list, &node_list);
718 &rsc_list, &node_list);
727 &rsc_list, &node_list);
747 get_node_names(nodes, &node_list, NULL);
751 source = g_hash_table_lookup(rsc->
meta,
754 get_node_names(rsc->
cluster->
nodes, &node_list, &metal_list);
761 if (required && (n_data->
pre != NULL)) {
766 if (required && (n_data->
post != NULL)) {
786 if (remote_rsc != NULL) {
812 g_list_foreach(rsc->
children, (GFunc) create_notify_actions, n_data);
817 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
821 && (op->
node != NULL)) {
827 add_notify_data_to_action_meta(n_data, op);
838 if (n_data->
start == NULL) {
854 if (n_data->
demote == NULL) {
875 for (iter = rsc->
running_on; iter != NULL; iter = iter->next) {
888 new_notify_action(rsc, current_node, n_data->
pre,
893 new_post_notify_action(rsc, current_node, n_data);
906 if ((remote_start != NULL)
941 if ((rsc == NULL) || (n_data == NULL)) {
944 collect_resource_data(rsc,
true, n_data);
945 add_notif_keys(rsc, n_data);
946 create_notify_actions(rsc, n_data);
958 if (n_data == NULL) {
961 g_list_free_full(n_data->
stop, free);
962 g_list_free_full(n_data->
start, free);
963 g_list_free_full(n_data->
demote, free);
964 g_list_free_full(n_data->
promote, free);
965 g_list_free_full(n_data->
promoted, free);
967 g_list_free_full(n_data->
active, free);
968 g_list_free_full(n_data->
inactive, free);
993 crm_info(
"Ordering notifications for implied %s after fencing", stop->
uuid);
997 if (n_data != NULL) {
998 collect_resource_data(rsc,
false, n_data);
#define CRM_CHECK(expr, failure_action)
pcmk_scheduler_t * cluster
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
enum action_tasks pcmk_parse_action(const char *action_name)
Parse an action type from an action name.
void pcmk_free_nvpairs(GSList *nvpairs)
Free a list of name/value pairs.
pcmk_resource_t * uber_parent(pcmk_resource_t *rsc)
GHashTable * allowed_nodes
gint pe__cmp_node_name(gconstpointer a, gconstpointer b)
#define pcmk__rsc_trace(rsc, fmt, args...)
#define PCMK_META_CONTAINER_ATTRIBUTE_TARGET
#define add_notify_env_free_gs(n_data, key, value)
enum rsc_role_e next_role
#define pcmk__insert_meta(obj, name, value)
#define CRM_LOG_ASSERT(expr)
void pe__order_notifs_after_fencing(const pcmk_action_t *stop, pcmk_resource_t *rsc, pcmk_action_t *stonith_op)
#define add_notify_env_gs(n_data, key, value)
pcmk_resource_t * container
gboolean remote_requires_reset
#define PCMK_ACTION_DEMOTE
void pe__free_action_notification_data(notify_data_t *n_data)
Actions are ordered (optionally, if no other flags are set)
#define pcmk__clear_action_flags(action, flags_to_clear)
#define pcmk__sched_err(fmt...)
void pe__create_action_notifications(pcmk_resource_t *rsc, notify_data_t *n_data)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
#define PCMK_ACTION_START
Wrappers for and extensions to libxml2.
#define PCMK_ACTION_NOTIFIED
pcmk_action_t * post_done
gboolean order_actions(pcmk_action_t *first, pcmk_action_t *then, uint32_t flags)
#define PCMK_ACTION_CANCEL
pcmk_action_t * custom_action(pcmk_resource_t *rsc, char *key, const char *task, const pcmk_node_t *on_node, gboolean optional, pcmk_scheduler_t *scheduler)
Create or update an action object.
#define pcmk__assert(expr)
notify_data_t * pe__action_notif_pseudo_ops(pcmk_resource_t *rsc, const char *task, pcmk_action_t *action, pcmk_action_t *complete)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
#define PCMK_META_INTERVAL
pcmk_action_t * find_first_action(const GList *input, const char *uuid, const char *task, const pcmk_node_t *on_node)
pcmk_node_t * allocated_to
#define PCMK_ACTION_PROMOTE
enum pe_action_flags flags
#define pcmk__set_action_flags(action, flags_to_set)
struct notify_entry_s notify_entry_t
#define pcmk__assert_alloc(nmemb, size)
#define crm_info(fmt, args...)
#define add_notify_env(n_data, key, value)
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)
pcmk_resource_t * remote_rsc
#define PCMK_ACTION_NOTIFY
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
GHashTable * allowed_nodes