From: "Fabio M. Di Nitto" <fdinitto@xxxxxxxxxx> when requesting nodename in ring0_addr, and reverse dns lookup is not available, quorumtool output becomes inconsistent. quorum { provider: corosync_votequorum } nodelist { node { ring0_addr: fedora-master-node1 nodeid: 1 } node { ring0_addr: fedora-master-node2 nodeid: 2 } } [fabbione@daikengo corosync]$ nslookup fedora-master-node1 .. Address: 192.168.2.193 [fabbione@daikengo corosync]$ nslookup 192.168.2.193 .. ** server can't find 193.2.168.192.in-addr.arpa.: NXDOMAIN [root@fedora-master-node1 tools]# corosync-quorumtool -s ... Membership information ---------------------- Nodeid Votes Qdevice Name 1 1 NR fedora-master-node1.int.fabbione.net 2 1 NR 192.168.2.194 (similar on the other node) With this patch, when nodelist is available, we simply return ring0_addr name for a node, fixing the output to be: Membership information ---------------------- Nodeid Votes Qdevice Name 1 1 NR fedora-master-node1 2 1 NR fedora-master-node2 that also removes possible inconsistencies between nodename, FQDN and so on, by using what user requested in corosync.conf In case ring0_addr is not available or numeric output is requested, behavior remains as before. Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> --- tools/corosync-quorumtool.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/tools/corosync-quorumtool.c b/tools/corosync-quorumtool.c index 327669b..9582950 100644 --- a/tools/corosync-quorumtool.c +++ b/tools/corosync-quorumtool.c @@ -219,6 +219,60 @@ static int set_expected(int expected_votes) } /* + * node name by nodelist + */ + +static const char *node_name_by_nodelist(uint32_t nodeid) +{ + cmap_iter_handle_t iter; + char key_name[CMAP_KEYNAME_MAXLEN]; + char tmp_key[CMAP_KEYNAME_MAXLEN]; + static char ret_buf[4096]; /* FIX ME */ + char *str = NULL; + uint32_t node_pos, cur_nodeid; + int res = 0; + + if (cmap_iter_init(cmap_handle, "nodelist.node.", &iter) != CS_OK) { + return ""; + } + + memset(ret_buf, 0, sizeof(ret_buf)); + + while ((cmap_iter_next(cmap_handle, iter, key_name, NULL, NULL)) == CS_OK) { + + res = sscanf(key_name, "nodelist.node.%u.%s", &node_pos, tmp_key); + if (res != 2) { + continue; + } + + if (strcmp(tmp_key, "ring0_addr") != 0) { + continue; + } + + snprintf(tmp_key, CMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos); + if (cmap_get_uint32(cmap_handle, tmp_key, &cur_nodeid) != CS_OK) { + continue; + } + if (cur_nodeid != nodeid) { + continue; + } + snprintf(tmp_key, CMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos); + if (cmap_get_string(cmap_handle, tmp_key, &str) != CS_OK) { + continue; + } + if (!str) { + continue; + } + strncpy(ret_buf, str, sizeof(ret_buf) - 1); + free(str); + break; + } + cmap_iter_finalize(cmap_handle, iter); + + return ret_buf; +} + +/* * This resolves the first address assigned to a node * and returns the name or IP address. Use cfgtool if you need more information. */ @@ -228,9 +282,19 @@ static const char *node_name(uint32_t nodeid, name_format_t name_format) int numaddrs; corosync_cfg_node_address_t addrs[INTERFACE_MAX]; static char buf[INET6_ADDRSTRLEN]; + const char *nodelist_name = NULL; socklen_t addrlen; struct sockaddr_storage *ss; + if (name_format == ADDRESS_FORMAT_NAME) { + nodelist_name = node_name_by_nodelist(nodeid); + } + + if ((nodelist_name) && + (strlen(nodelist_name) > 0)) { + return nodelist_name; + } + err = corosync_cfg_get_node_addrs(c_handle, nodeid, INTERFACE_MAX, &numaddrs, addrs); if (err != CS_OK) { fprintf(stderr, "Unable to get node address for nodeid %u: %s\n", nodeid, cs_strerror(err)); -- 1.7.7.6 _______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss