| 1156 | } |
| 1157 | |
| 1158 | void |
| 1159 | native_internal_constraints(resource_t * rsc, pe_working_set_t * data_set) |
| 1160 | { |
| 1161 | /* This function is on the critical path and worth optimizing as much as possible */ |
| 1162 | |
| 1163 | resource_t *top = uber_parent(rsc); |
| 1164 | int type = pe_order_optional | pe_order_implies_then | pe_order_restart; |
| 1165 | |
| 1166 | custom_action_order(rsc, generate_op_key(rsc->id, RSC_STOP, 0), NULL, |
| 1167 | rsc, generate_op_key(rsc->id, RSC_START, 0), NULL, type, data_set); |
| 1168 | |
| 1169 | if (top->variant == pe_master || rsc->role > RSC_ROLE_SLAVE) { |
| 1170 | custom_action_order(rsc, generate_op_key(rsc->id, RSC_DEMOTE, 0), NULL, |
| 1171 | rsc, generate_op_key(rsc->id, RSC_STOP, 0), NULL, |
| 1172 | pe_order_implies_first_master, data_set); |
| 1173 | |
| 1174 | custom_action_order(rsc, generate_op_key(rsc->id, RSC_START, 0), NULL, |
| 1175 | rsc, generate_op_key(rsc->id, RSC_PROMOTE, 0), NULL, |
| 1176 | pe_order_runnable_left, data_set); |
| 1177 | } |
| 1178 | |
| 1179 | if (is_not_set(rsc->flags, pe_rsc_managed)) { |
| 1180 | pe_rsc_trace(rsc, "Skipping fencing constraints for unmanaged resource: %s", rsc->id); |
| 1181 | return; |
| 1182 | } |
| 1183 | |
| 1184 | { |
| 1185 | action_t *all_stopped = get_pseudo_op(ALL_STOPPED, data_set); |
| 1186 | |
| 1187 | custom_action_order(rsc, stop_key(rsc), NULL, |
| 1188 | NULL, strdup(all_stopped->task), all_stopped, |
| 1189 | pe_order_implies_then | pe_order_runnable_left, data_set); |
| 1190 | } |
| 1191 | |
| 1192 | if (g_hash_table_size(rsc->utilization) > 0 |
| 1193 | && safe_str_neq(data_set->placement_strategy, "default")) { |
| 1194 | GHashTableIter iter; |
| 1195 | node_t *next = NULL; |
| 1196 | GListPtr gIter = NULL; |
| 1197 | |
| 1198 | pe_rsc_trace(rsc, "Creating utilization constraints for %s - strategy: %s", |
| 1199 | rsc->id, data_set->placement_strategy); |
| 1200 | |
| 1201 | for (gIter = rsc->running_on; gIter != NULL; gIter = gIter->next) { |
| 1202 | node_t *current = (node_t *) gIter->data; |
| 1203 | |
| 1204 | char *load_stopped_task = crm_concat(LOAD_STOPPED, current->details->uname, '_'); |
| 1205 | action_t *load_stopped = get_pseudo_op(load_stopped_task, data_set); |
| 1206 | |
| 1207 | if (load_stopped->node == NULL) { |
| 1208 | load_stopped->node = node_copy(current); |
| 1209 | update_action_flags(load_stopped, pe_action_optional | pe_action_clear); |
| 1210 | } |
| 1211 | |
| 1212 | custom_action_order(rsc, stop_key(rsc), NULL, |
| 1213 | NULL, load_stopped_task, load_stopped, pe_order_load, data_set); |
| 1214 | } |
| 1215 |
nothing calls this directly
no test coverage detected