Fix the IPv6 address and port parsing

There can be lot of possibility for IPv6 address with port,
for example [::1]:80 or [2001:db8:85a3::8a2e:370]:7334.

Parsing that in more standard way is provided by oslo_uilts.netutils
parse_host_port() method[1].

Story: #2006309
Task: #36030

[1] 1b8bafb391/oslo_utils/netutils.py (L37)

Change-Id: Ie7a3bd3074c02430c754deaebfde6d174563b31e
This commit is contained in:
Ghanshyam Mann 2019-07-30 08:31:10 +00:00 committed by Witek Bedyk
parent e4bcb1f030
commit 484073ee9c
1 changed files with 3 additions and 1 deletions

View File

@ -16,6 +16,7 @@ from oslo_config import cfg
from oslo_config import types
from oslo_log import log
from oslo_utils import importutils
from oslo_utils import netutils
LOG = log.getLogger(__name__)
@ -77,10 +78,11 @@ class HostAddressPortType(types.HostAddress):
type_name=type_name)
def __call__(self, value):
addr, port = value.split(':')
addr, port = netutils.parse_host_port(value)
addr = self._validate_addr(addr)
port = self._validate_port(port)
LOG.debug('addr: %s port: %s' % (addr, port))
if addr and port:
return '%s:%d' % (addr, port)