Use oslo.utils implementation to parse sentinel address
... instead of maintaining own logic. Change-Id: Icda2a6ebfe779b35fa606cd6cd27ce18d47fe147
This commit is contained in:
parent
48dbe7808f
commit
2897ee8710
@ -34,7 +34,6 @@ The library has special public value for nonexistent or expired keys called
|
||||
from oslo_cache import core
|
||||
NO_VALUE = core.NO_VALUE
|
||||
"""
|
||||
import re
|
||||
import socket
|
||||
import ssl
|
||||
import urllib.parse
|
||||
@ -45,6 +44,7 @@ from dogpile.cache import proxy
|
||||
from dogpile.cache import util
|
||||
from oslo_log import log
|
||||
from oslo_utils import importutils
|
||||
from oslo_utils import netutils
|
||||
|
||||
from oslo_cache._i18n import _
|
||||
from oslo_cache import _opts
|
||||
@ -104,15 +104,10 @@ class _DebugProxy(proxy.ProxyBackend):
|
||||
|
||||
|
||||
def _parse_sentinel(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 exception.ConfigurationError('Malformed sentinel server format')
|
||||
host, port = netutils.parse_host_port(sentinel)
|
||||
if host is None or port is None:
|
||||
raise exception.ConfigurationError('Malformed sentinel server format')
|
||||
return (host, port)
|
||||
|
||||
|
||||
def _build_cache_config(conf):
|
||||
|
Loading…
x
Reference in New Issue
Block a user