| 2085 | } |
| 2086 | |
| 2087 | void |
| 2088 | create_notifications(resource_t * rsc, notify_data_t * n_data, pe_working_set_t * data_set) |
| 2089 | { |
| 2090 | GListPtr gIter = NULL; |
| 2091 | action_t *stop = NULL; |
| 2092 | action_t *start = NULL; |
| 2093 | enum action_tasks task = text2task(n_data->action); |
| 2094 | |
| 2095 | if (rsc->children) { |
| 2096 | gIter = rsc->children; |
| 2097 | for (; gIter != NULL; gIter = gIter->next) { |
| 2098 | resource_t *child = (resource_t *) gIter->data; |
| 2099 | |
| 2100 | create_notifications(child, n_data, data_set); |
| 2101 | } |
| 2102 | return; |
| 2103 | } |
| 2104 | |
| 2105 | /* Copy notification details into standard ops */ |
| 2106 | |
| 2107 | gIter = rsc->actions; |
| 2108 | for (; gIter != NULL; gIter = gIter->next) { |
| 2109 | action_t *op = (action_t *) gIter->data; |
| 2110 | |
| 2111 | if (is_set(op->flags, pe_action_optional) == FALSE && op->node != NULL) { |
| 2112 | enum action_tasks t = text2task(op->task); |
| 2113 | |
| 2114 | switch (t) { |
| 2115 | case start_rsc: |
| 2116 | case stop_rsc: |
| 2117 | case action_promote: |
| 2118 | case action_demote: |
| 2119 | g_hash_table_foreach(n_data->keys, dup_attr, op->meta); |
| 2120 | break; |
| 2121 | default: |
| 2122 | break; |
| 2123 | } |
| 2124 | } |
| 2125 | } |
| 2126 | |
| 2127 | pe_rsc_trace(rsc, "Creating notificaitons for: %s.%s (%s->%s)", |
| 2128 | n_data->action, rsc->id, role2text(rsc->role), role2text(rsc->next_role)); |
| 2129 | |
| 2130 | stop = find_first_action(rsc->actions, NULL, RSC_STOP, NULL); |
| 2131 | start = find_first_action(rsc->actions, NULL, RSC_START, NULL); |
| 2132 | |
| 2133 | /* stop / demote */ |
| 2134 | if (rsc->role != RSC_ROLE_STOPPED) { |
| 2135 | if (task == stop_rsc || task == action_demote) { |
| 2136 | gIter = rsc->running_on; |
| 2137 | for (; gIter != NULL; gIter = gIter->next) { |
| 2138 | node_t *current_node = (node_t *) gIter->data; |
| 2139 | |
| 2140 | pe_notify(rsc, current_node, n_data->pre, n_data->pre_done, n_data, data_set); |
| 2141 | if (task == action_demote || stop == NULL |
| 2142 | || is_set(stop->flags, pe_action_optional)) { |
| 2143 | pe_post_notify(rsc, current_node, n_data, data_set); |
| 2144 | } |
no test coverage detected