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->priv->id, entry_b->node->priv->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->
priv->
name);
142 if (host_node_names != NULL) {
143 if (pcmk__is_guest_or_bundle_node(node)) {
148 node = pcmk__current_node(launcher);
154 pcmk__add_word(host_node_names, 1024, node->
priv->
name);
158 if ((all_node_names != NULL) && (*all_node_names == NULL)) {
159 *all_node_names = g_string_new(
" ");
161 if ((host_node_names != NULL) && (*host_node_names == NULL)) {
162 *host_node_names = g_string_new(
" ");
181 notify_entries_to_strings(GList *list, GString **rsc_names,
182 GString **node_names)
184 const char *last_rsc_id = NULL;
187 if (rsc_names != NULL) {
190 if (node_names != NULL) {
195 list = g_list_sort(list, compare_notify_entries);
197 for (GList *gIter = list; gIter != NULL; gIter = gIter->next) {
202 && (entry->rsc->id != NULL));
203 if ((entry == NULL) || (entry->rsc == NULL)
204 || (entry->rsc->id == NULL)) {
210 if ((node_names != NULL) && (entry->node == NULL)) {
218 last_rsc_id = entry->rsc->id;
220 if (rsc_names != NULL) {
221 pcmk__add_word(rsc_names, 1024, entry->rsc->id);
223 if ((node_names != NULL) && (entry->node->priv->name != NULL)) {
224 pcmk__add_word(node_names, 1024, entry->node->priv->name);
229 if ((rsc_names != NULL) && (*rsc_names == NULL)) {
230 *rsc_names = g_string_new(
" ");
232 if ((node_names != NULL) && (*node_names == NULL)) {
233 *node_names = g_string_new(
" ");
248 copy_meta_to_notify(gpointer key, gpointer value, gpointer user_data)
255 if (g_hash_table_lookup(notify->
meta, (
const char *) key) != NULL) {
266 for (
const GSList *item = n_data->
keys; item; item = item->next) {
286 const char *notif_action,
const char *notif_type)
320 const char *value = NULL;
321 const char *task = NULL;
322 const char *skip_reason = NULL;
324 CRM_CHECK((rsc != NULL) && (node != NULL),
return NULL);
328 skip_reason =
"no action";
329 }
else if (notify_done == NULL) {
330 skip_reason =
"no parent notification";
332 skip_reason =
"node offline";
334 skip_reason =
"original action not runnable";
336 if (skip_reason != NULL) {
338 rsc->
id, pcmk__node_name(node), skip_reason);
342 value = g_hash_table_lookup(op->
meta,
"notify_type");
343 task = g_hash_table_lookup(op->
meta,
"notify_operation");
346 rsc->
id, pcmk__node_name(node), value, task);
355 g_hash_table_foreach(op->
meta, copy_meta_to_notify, notify_action);
356 add_notify_data_to_action_meta(n_data, notify_action);
361 return notify_action;
381 notify = new_notify_action(rsc, node, n_data->
post, n_data->
post_done,
383 if (notify != NULL) {
391 for (GList *iter = rsc->
priv->
actions; iter != NULL; iter = iter->next) {
393 const char *interval_ms_s = NULL;
471 if (complete != NULL) {
474 n_data->
post = new_notify_pseudo_action(rsc, complete,
486 n_data->
post_done = new_notify_pseudo_action(rsc, complete,
497 "notify_operation", n_data->
action);
506 if ((
action != NULL) && (complete != NULL)) {
544 const GList *iter = NULL;
548 if (n_data == NULL) {
558 for (iter = rsc->
priv->
children; iter != NULL; iter = iter->next) {
561 collect_resource_data(child, activity, n_data);
571 entry = new_notify_entry(rsc, node);
586 dup_notify_entry(entry));
592 dup_notify_entry(entry));
597 "Resource %s role on %s (%s) is not supported for " 598 "notifications (bug?)",
599 rsc->
id, pcmk__node_name(node),
610 for (iter = rsc->
priv->
actions; iter != NULL; iter = iter->next) {
614 && (op->
node != NULL)) {
623 entry = new_notify_entry(rsc, op->
node);
627 n_data->
start = g_list_prepend(n_data->
start, entry);
630 n_data->
stop = g_list_prepend(n_data->
stop, entry);
647 #define add_notify_env(n_data, key, value) do { \ 648 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, value); \ 652 #define add_notify_env_gs(n_data, key, value) do { \ 653 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, \ 654 (const char *) value->str); \ 658 #define add_notify_env_free_gs(n_data, key, value) do { \ 659 n_data->keys = pcmk_prepend_nvpair(n_data->keys, key, \ 660 (const char *) value->str); \ 661 g_string_free(value, TRUE); value = NULL; \ 674 bool required =
false;
675 GString *rsc_list = NULL;
676 GString *node_list = NULL;
677 GString *metal_list = NULL;
678 const char *source = NULL;
681 n_data->
stop = notify_entries_to_strings(n_data->
stop,
682 &rsc_list, &node_list);
683 if ((strcmp(
" ", (
const char *) rsc_list->str) != 0)
690 if ((n_data->
start != NULL)
694 n_data->
start = notify_entries_to_strings(n_data->
start,
695 &rsc_list, &node_list);
699 if ((n_data->
demote != NULL)
703 n_data->
demote = notify_entries_to_strings(n_data->
demote,
704 &rsc_list, &node_list);
713 &rsc_list, &node_list);
717 n_data->
active = notify_entries_to_strings(n_data->
active,
718 &rsc_list, &node_list);
723 &rsc_list, &node_list);
732 &rsc_list, &node_list);
752 get_node_names(nodes, &node_list, NULL);
756 source = g_hash_table_lookup(rsc->
priv->
meta,
766 if (required && (n_data->
pre != NULL)) {
771 if (required && (n_data->
post != NULL)) {
791 if (remote_rsc != NULL) {
817 g_list_foreach(rsc->
priv->
children, (GFunc) create_notify_actions,
823 for (iter = rsc->
priv->
actions; iter != NULL; iter = iter->next) {
827 && (op->
node != NULL)) {
833 add_notify_data_to_action_meta(n_data, op);
844 if (n_data->
start == NULL) {
860 if (n_data->
demote == NULL) {
883 iter != NULL; iter = iter->next) {
898 new_notify_action(rsc, current_node, n_data->
pre,
903 new_post_notify_action(rsc, current_node, n_data);
917 if ((remote_start != NULL)
929 "Next role '%s' but %s is not allocated",
953 if ((rsc == NULL) || (n_data == NULL)) {
956 collect_resource_data(rsc,
true, n_data);
957 add_notif_keys(rsc, n_data);
958 create_notify_actions(rsc, n_data);
970 if (n_data == NULL) {
973 g_list_free_full(n_data->
stop, free);
974 g_list_free_full(n_data->
start, free);
975 g_list_free_full(n_data->
demote, free);
976 g_list_free_full(n_data->
promote, free);
977 g_list_free_full(n_data->
promoted, free);
979 g_list_free_full(n_data->
active, free);
980 g_list_free_full(n_data->
inactive, free);
1005 crm_info(
"Ordering notifications for implied %s after fencing", stop->
uuid);
1009 if (n_data != NULL) {
1010 collect_resource_data(rsc,
false, n_data);
#define CRM_CHECK(expr, failure_action)
#define pcmk__sched_err(scheduler, fmt...)
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
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)
#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__node_private_t * priv
#define PCMK_ACTION_DEMOTE
void pe__free_action_notification_data(notify_data_t *n_data)
pcmk_scheduler_t * scheduler
Actions are ordered (optionally, if no other flags are set)
#define pcmk__clear_action_flags(action, flags_to_clear)
void pe__create_action_notifications(pcmk_resource_t *rsc, notify_data_t *n_data)
pcmk_node_t * assigned_node
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define PCMK_ACTION_START
pcmk__resource_private_t * priv
Wrappers for and extensions to libxml2.
enum rsc_role_e next_role
#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
GHashTable * allowed_nodes
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)
enum pcmk__action_type pcmk__parse_action(const char *action_name)
enum rsc_role_e orig_role
pcmk_resource_t * launcher
#define PCMK_ACTION_PROMOTE
#define pcmk__set_action_flags(action, flags_to_set)
struct notify_entry_s notify_entry_t
struct pcmk__node_details * details
#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)
#define PCMK_ACTION_NOTIFY
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".