| 322 | } |
| 323 | |
| 324 | action_t * |
| 325 | custom_action(resource_t * rsc, char *key, const char *task, |
| 326 | node_t * on_node, gboolean optional, gboolean save_action, |
| 327 | pe_working_set_t * data_set) |
| 328 | { |
| 329 | action_t *action = NULL; |
| 330 | GListPtr possible_matches = NULL; |
| 331 | |
| 332 | CRM_CHECK(key != NULL, return NULL); |
| 333 | CRM_CHECK(task != NULL, return NULL); |
| 334 | |
| 335 | if (save_action && rsc != NULL) { |
| 336 | possible_matches = find_actions(rsc->actions, key, on_node); |
| 337 | } |
| 338 | |
| 339 | if (possible_matches != NULL) { |
| 340 | if (g_list_length(possible_matches) > 1) { |
| 341 | pe_warn("Action %s for %s on %s exists %d times", |
| 342 | task, rsc ? rsc->id : "<NULL>", |
| 343 | on_node ? on_node->details->uname : "<NULL>", g_list_length(possible_matches)); |
| 344 | } |
| 345 | |
| 346 | action = g_list_nth_data(possible_matches, 0); |
| 347 | pe_rsc_trace(rsc, "Found existing action (%d) %s for %s on %s", |
| 348 | action->id, task, rsc ? rsc->id : "<NULL>", |
| 349 | on_node ? on_node->details->uname : "<NULL>"); |
| 350 | g_list_free(possible_matches); |
| 351 | } |
| 352 | |
| 353 | if (action == NULL) { |
| 354 | if (save_action) { |
| 355 | pe_rsc_trace(rsc, "Creating%s action %d: %s for %s on %s", |
| 356 | optional ? "" : " manditory", data_set->action_id, key, |
| 357 | rsc ? rsc->id : "<NULL>", on_node ? on_node->details->uname : "<NULL>"); |
| 358 | } |
| 359 | |
| 360 | action = calloc(1, sizeof(action_t)); |
| 361 | if (save_action) { |
| 362 | action->id = data_set->action_id++; |
| 363 | } else { |
| 364 | action->id = 0; |
| 365 | } |
| 366 | action->rsc = rsc; |
| 367 | CRM_ASSERT(task != NULL); |
| 368 | action->task = strdup(task); |
| 369 | if (on_node) { |
| 370 | action->node = node_copy(on_node); |
| 371 | } |
| 372 | action->uuid = strdup(key); |
| 373 | |
| 374 | pe_set_action_bit(action, pe_action_failure_is_fatal); |
| 375 | pe_set_action_bit(action, pe_action_runnable); |
| 376 | if (optional) { |
| 377 | pe_set_action_bit(action, pe_action_optional); |
| 378 | } else { |
| 379 | pe_clear_action_bit(action, pe_action_optional); |
| 380 | } |
| 381 |
no test coverage detected