Use common escape_ipv6 utility to escape IPv6 addresses

The oslo.utils library provides the netutils.escape_ipv6 method to
escape IPv6 address to create <server>:<port> format easily.

Change-Id: I7a6d11eebf961f12e29214b00647dfc356e9e999
This commit is contained in:
Takashi Kajinami 2024-10-05 23:14:39 +09:00
parent b65d730316
commit e8c849f421

View File

@ -15,6 +15,7 @@ import contextlib
from oslo_config import cfg
from oslo_log import log
from oslo_utils import netutils
from oslo_utils import strutils
from taskflow.jobs import backends as job_backends
from taskflow.persistence import backends as persistence_backends
@ -90,11 +91,6 @@ class RedisTaskFlowDriver(JobboardTaskFlowDriver):
def job_board(self, persistence):
def _format_server(host, port):
if ':' in host:
return '[%s]:%d' % (host, port)
return '%s:%d' % (host, port)
jobboard_backend_conf = {
'board': 'redis',
'host': CONF.task_flow.jobboard_backend_hosts[0],
@ -102,7 +98,8 @@ class RedisTaskFlowDriver(JobboardTaskFlowDriver):
'namespace': CONF.task_flow.jobboard_backend_namespace,
'sentinel': CONF.task_flow.jobboard_redis_sentinel,
'sentinel_fallbacks': [
_format_server(host, CONF.task_flow.jobboard_backend_port)
'%s:%d' % (netutils.escape_ipv6(host),
CONF.task_flow.jobboard_backend_port)
for host in CONF.task_flow.jobboard_backend_hosts[1:]
]
}