Merge "Use oslo.utils implementation to parse server format"
This commit is contained in:
commit
072e6d5f5e
@ -13,6 +13,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
|
from oslo_utils import netutils
|
||||||
from osprofiler import profiler
|
from osprofiler import profiler
|
||||||
import redis
|
import redis
|
||||||
import redis.sentinel
|
import redis.sentinel
|
||||||
@ -96,24 +97,12 @@ class ConnectionURI(object):
|
|||||||
# NOTE(kgriffs): Have to parse list of sentinel hosts ourselves
|
# NOTE(kgriffs): Have to parse list of sentinel hosts ourselves
|
||||||
# since urllib doesn't support it.
|
# since urllib doesn't support it.
|
||||||
for each_host in netloc.split(','):
|
for each_host in netloc.split(','):
|
||||||
if not each_host.endswith(']') and ':' in each_host:
|
|
||||||
name, sep, port = each_host.rpartition(':')
|
|
||||||
else:
|
|
||||||
name = each_host
|
|
||||||
port = None
|
|
||||||
|
|
||||||
if name.startswith('[') and name.endswith(']'):
|
|
||||||
name = name[1:-1]
|
|
||||||
|
|
||||||
if port:
|
|
||||||
try:
|
try:
|
||||||
port = int(port)
|
name, port = netutils.parse_host_port(
|
||||||
|
each_host, SENTINEL_DEFAULT_PORT)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
msg = _('The Redis configuration URI contains an '
|
raise errors.ConfigurationError(
|
||||||
'invalid port')
|
'invalid redis server format %s' % each_host)
|
||||||
raise errors.ConfigurationError(msg)
|
|
||||||
else:
|
|
||||||
port = SENTINEL_DEFAULT_PORT
|
|
||||||
|
|
||||||
self.sentinels.append((name, port))
|
self.sentinels.append((name, port))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user