Skip to content

Commit 147f7ca

Browse files
Add hostname field to _parse_node_line (#3343)
Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
1 parent 76bf989 commit 147f7ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

redis/_parsers/helpers.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,11 @@ def parse_cluster_info(response, **options):
445445
def _parse_node_line(line):
446446
line_items = line.split(" ")
447447
node_id, addr, flags, master_id, ping, pong, epoch, connected = line.split(" ")[:8]
448-
addr = addr.split("@")[0]
448+
ip = addr.split("@")[0]
449+
hostname = addr.split("@")[1].split(",")[1] if "@" in addr and "," in addr else ""
449450
node_dict = {
450451
"node_id": node_id,
452+
"hostname": hostname,
451453
"flags": flags,
452454
"master_id": master_id,
453455
"last_ping_sent": ping,
@@ -460,7 +462,7 @@ def _parse_node_line(line):
460462
if len(line_items) >= 9:
461463
slots, migrations = _parse_slots(line_items[8:])
462464
node_dict["slots"], node_dict["migrations"] = slots, migrations
463-
return addr, node_dict
465+
return ip, node_dict
464466

465467

466468
def _parse_slots(slot_ranges):

0 commit comments

Comments
 (0)