Skip to content

Commit

Permalink
Add hostname field to _parse_node_line (#3343)
Browse files Browse the repository at this point in the history
Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
  • Loading branch information
dudizimber and vladvildanov committed Sep 27, 2024
1 parent e8e5b1d commit 39d1e83
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions redis/_parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,11 @@ def parse_cluster_info(response, **options):
def _parse_node_line(line):
line_items = line.split(" ")
node_id, addr, flags, master_id, ping, pong, epoch, connected = line.split(" ")[:8]
addr = addr.split("@")[0]
ip = addr.split("@")[0]
hostname = addr.split("@")[1].split(",")[1] if "@" in addr and "," in addr else ""
node_dict = {
"node_id": node_id,
"hostname": hostname,
"flags": flags,
"master_id": master_id,
"last_ping_sent": ping,
Expand All @@ -460,7 +462,7 @@ def _parse_node_line(line):
if len(line_items) >= 9:
slots, migrations = _parse_slots(line_items[8:])
node_dict["slots"], node_dict["migrations"] = slots, migrations
return addr, node_dict
return ip, node_dict


def _parse_slots(slot_ranges):
Expand Down

0 comments on commit 39d1e83

Please sign in to comment.