| 957 | } |
| 958 | |
| 959 | gboolean |
| 960 | corosync_initialize_nodelist(void *cluster, gboolean force_member, xmlNode *xml_parent) |
| 961 | { |
| 962 | int lpc = 0; |
| 963 | int rc = CS_OK; |
| 964 | int retries = 0; |
| 965 | gboolean any = FALSE; |
| 966 | cmap_handle_t cmap_handle; |
| 967 | |
| 968 | do { |
| 969 | rc = cmap_initialize(&cmap_handle); |
| 970 | if(rc != CS_OK) { |
| 971 | retries++; |
| 972 | crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc), retries); |
| 973 | sleep(retries); |
| 974 | } |
| 975 | |
| 976 | } while(retries < 5 && rc != CS_OK); |
| 977 | |
| 978 | if (rc != CS_OK) { |
| 979 | crm_warn("Could not connect to Cluster Configuration Database API, error %d", rc); |
| 980 | return FALSE; |
| 981 | } |
| 982 | |
| 983 | crm_peer_init(); |
| 984 | crm_trace("Initializing corosync nodelist"); |
| 985 | for(lpc = 0; ; lpc++) { |
| 986 | uint32_t nodeid = 0; |
| 987 | char *name = NULL; |
| 988 | char *key = NULL; |
| 989 | |
| 990 | key = g_strdup_printf("nodelist.node.%d.nodeid", lpc); |
| 991 | rc = cmap_get_uint32(cmap_handle, key, &nodeid); |
| 992 | g_free(key); |
| 993 | |
| 994 | if(rc != CS_OK) { |
| 995 | break; |
| 996 | } |
| 997 | |
| 998 | name = corosync_node_name(cmap_handle, nodeid); |
| 999 | if (name != NULL) { |
| 1000 | crm_node_t *node = g_hash_table_lookup(crm_peer_cache, name); |
| 1001 | if(node && node->id != nodeid) { |
| 1002 | crm_crit("Nodes %u and %u share the same name '%s': shutting down", node->id, nodeid, name); |
| 1003 | crm_exit(100); |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | if(nodeid > 0 || name != NULL) { |
| 1008 | crm_trace("Initializing node[%d] %u = %s", lpc, nodeid, name); |
| 1009 | crm_get_peer(nodeid, name); |
| 1010 | } |
| 1011 | |
| 1012 | if(nodeid > 0 && name != NULL) { |
| 1013 | any = TRUE; |
| 1014 | |
| 1015 | if(xml_parent) { |
| 1016 | xmlNode *node = create_xml_node(xml_parent, XML_CIB_TAG_NODE); |
no test coverage detected