| 463 | #endif |
| 464 | |
| 465 | int |
| 466 | cib_init(void) |
| 467 | { |
| 468 | if (is_openais_cluster()) { |
| 469 | #if SUPPORT_COROSYNC |
| 470 | crm_cluster.destroy = cib_ais_destroy; |
| 471 | crm_cluster.cs_dispatch = cib_ais_dispatch; |
| 472 | #endif |
| 473 | } else if(is_heartbeat_cluster()) { |
| 474 | #if SUPPORT_HEARTBEAT |
| 475 | crm_cluster.hb_dispatch = cib_ha_peer_callback; |
| 476 | crm_cluster.destroy = cib_ha_connection_destroy; |
| 477 | #endif |
| 478 | } |
| 479 | |
| 480 | config_hash = |
| 481 | g_hash_table_new_full(crm_str_hash, g_str_equal, g_hash_destroy_str, g_hash_destroy_str); |
| 482 | |
| 483 | if (startCib("cib.xml") == FALSE) { |
| 484 | crm_crit("Cannot start CIB... terminating"); |
| 485 | crm_exit(1); |
| 486 | } |
| 487 | |
| 488 | if (stand_alone == FALSE) { |
| 489 | if (crm_cluster_connect(&crm_cluster) == FALSE) { |
| 490 | crm_crit("Cannot sign in to the cluster... terminating"); |
| 491 | crm_exit(100); |
| 492 | } |
| 493 | cib_our_uname = crm_cluster.uname; |
| 494 | if (is_openais_cluster()) { |
| 495 | crm_set_status_callback(&cib_peer_update_callback); |
| 496 | } |
| 497 | #if SUPPORT_HEARTBEAT |
| 498 | if (is_heartbeat_cluster()) { |
| 499 | |
| 500 | gboolean was_error = FALSE; |
| 501 | |
| 502 | hb_conn = crm_cluster.hb_conn; |
| 503 | if (was_error == FALSE) { |
| 504 | if (HA_OK != |
| 505 | hb_conn->llc_ops->set_cstatus_callback(hb_conn, cib_client_status_callback, |
| 506 | hb_conn)) { |
| 507 | |
| 508 | crm_err("Cannot set cstatus callback: %s", hb_conn->llc_ops->errmsg(hb_conn)); |
| 509 | was_error = TRUE; |
| 510 | } |
| 511 | } |
| 512 | |
| 513 | if (was_error == FALSE) { |
| 514 | was_error = (ccm_connect() == FALSE); |
| 515 | } |
| 516 | |
| 517 | if (was_error == FALSE) { |
| 518 | /* Async get client status information in the cluster */ |
| 519 | crm_info("Requesting the list of configured nodes"); |
| 520 | hb_conn->llc_ops->client_status(hb_conn, NULL, CRM_SYSTEM_CIB, -1); |
| 521 | } |
| 522 | } |
no test coverage detected