Use oslo.utils implementation to parse sentinel address

... instead of maintaining own logic.

Change-Id: I90d65f3e5b1be6b32e8c44a018c85c01ca47d3b2
This commit is contained in:
Takashi Kajinami 2024-10-01 16:58:47 +09:00
parent 2e666107fd
commit cf6d4ecac1

View File

@ -16,11 +16,11 @@
import functools
import logging
import re
import string
import threading
from oslo_utils import encodeutils
from oslo_utils import netutils
from oslo_utils import strutils
from packaging import version
import redis
@ -426,15 +426,10 @@ return 1
@classmethod
def _parse_sentinel(cls, sentinel):
# IPv6 (eg. [::1]:6379 )
match = re.search(r'^\[(\S+)\]:(\d+)$', sentinel)
if match:
return (match[1], int(match[2]))
# IPv4 or hostname (eg. 127.0.0.1:6379 or localhost:6379)
match = re.search(r'^(\S+):(\d+)$', sentinel)
if match:
return (match[1], int(match[2]))
raise ValueError('Malformed sentinel server format')
host, port = netutils.parse_host_port(sentinel)
if host is None or port is None:
raise ValueError('Malformed sentinel server format')
return (host, port)
@classmethod
def _make_client(cls, parsed_url, options, default_socket_timeout):