| 604 | } |
| 605 | |
| 606 | static mi_response_t *clusterer_set_status(const mi_params_t *params, |
| 607 | struct mi_handler *async_hdl) |
| 608 | { |
| 609 | int cluster_id, node_id; |
| 610 | int state; |
| 611 | int rc; |
| 612 | |
| 613 | if (get_mi_int_param(params, "cluster_id", &cluster_id) < 0) |
| 614 | return init_mi_param_error(); |
| 615 | if (cluster_id < 1) |
| 616 | return init_mi_error(400, MI_SSTR("Bad value for 'cluster_id'")); |
| 617 | |
| 618 | switch (try_get_mi_int_param(params, "node_id", &node_id)) { |
| 619 | case -1: |
| 620 | node_id = current_id; |
| 621 | /* fallback */ |
| 622 | case 0: |
| 623 | if (node_id < 1) |
| 624 | return init_mi_error(400, MI_SSTR("Bad value for 'node_id'")); |
| 625 | break; |
| 626 | default: |
| 627 | return init_mi_param_error(); |
| 628 | } |
| 629 | |
| 630 | if (get_mi_int_param(params, "status", &state) < 0) |
| 631 | return init_mi_param_error(); |
| 632 | if (state != STATE_DISABLED && state != STATE_ENABLED) |
| 633 | return init_mi_error(400, MI_SSTR("Bad value for 'status'")); |
| 634 | |
| 635 | rc = cl_set_state(cluster_id, node_id, state); |
| 636 | if (rc == -1) |
| 637 | return init_mi_error(404, MI_SSTR("Cluster id not found")); |
| 638 | if (rc == 1) |
| 639 | return init_mi_error(404, MI_SSTR("Node id not found")); |
| 640 | |
| 641 | return init_mi_result_ok(); |
| 642 | } |
| 643 | |
| 644 | static mi_response_t *clusterer_set_cap_status(const mi_params_t *params, |
| 645 | struct mi_handler *async_hdl) |
nothing calls this directly
no test coverage detected