MCPcopy Create free account
hub / github.com/ClusterLabs/pacemaker / corosync_node_name

Function corosync_node_name

lib/cluster/corosync.c:73–170  ·  view source on GitHub ↗

* CFG functionality stolen from node_name() in corosync-quorumtool.c * This resolves the first address assigned to a node and returns the name or IP address. */

Source from the content-addressed store, hash-verified

71 * This resolves the first address assigned to a node and returns the name or IP address.
72 */
73char *corosync_node_name(uint64_t /*cmap_handle_t*/ cmap_handle, uint32_t nodeid)
74{
75 int lpc = 0;
76 int rc = CS_OK;
77 int retries = 0;
78 char *name = NULL;
79
80 cmap_handle_t local_handle = 0;
81
82 /* nodeid == 0 == CMAN_NODEID_US */
83 if(nodeid == 0 && pcmk_nodeid) {
84 nodeid = pcmk_nodeid;
85
86 } else if(nodeid == 0) {
87 /* Look it up */
88 int rc = -1;
89 int retries = 0;
90 cpg_handle_t handle = 0;
91 cpg_callbacks_t cb = {};
92
93 cs_repeat(retries, 5, rc = cpg_initialize(&handle, &cb));
94 if (rc == CS_OK) {
95 retries = 0;
96 cs_repeat(retries, 5, rc = cpg_local_get(handle, &pcmk_nodeid));
97 }
98
99 if (rc != CS_OK) {
100 crm_err("Could not get local node id from the CPG API: %d", rc);
101 }
102 cpg_finalize(handle);
103 }
104
105 if(cmap_handle == 0 && local_handle == 0) {
106 retries = 0;
107 crm_trace("Initializing CMAP connection");
108 do {
109 rc = cmap_initialize(&local_handle);
110 if(rc != CS_OK) {
111 retries++;
112 crm_debug("API connection setup failed: %s. Retrying in %ds", cs_strerror(rc), retries);
113 sleep(retries);
114 }
115
116 } while(retries < 5 && rc != CS_OK);
117
118 if (rc != CS_OK) {
119 crm_warn("Could not connect to Cluster Configuration Database API, error %s", cs_strerror(rc));
120 local_handle = 0;
121 }
122 }
123
124 if(cmap_handle == 0) {
125 cmap_handle = local_handle;
126 }
127
128 while(name == NULL && cmap_handle != 0) {
129 uint32_t id = 0;
130 char *key = NULL;

Callers 4

pcmk_quorum_notificationFunction · 0.85
get_local_node_nameFunction · 0.85
get_node_nameFunction · 0.85

Calls 1

node_name_is_validFunction · 0.85

Tested by

no test coverage detected