From 484073ee9c89e0e7da43321d7d5845a8e803b91e Mon Sep 17 00:00:00 2001 From: Ghanshyam Mann Date: Tue, 30 Jul 2019 08:31:10 +0000 Subject: [PATCH] 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] https://github.com/openstack/oslo.utils/blob/1b8bafb391b82665b99b3da8205402ec2cd495d1/oslo_utils/netutils.py#L37 Change-Id: Ie7a3bd3074c02430c754deaebfde6d174563b31e --- monasca_notification/conf/types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monasca_notification/conf/types.py b/monasca_notification/conf/types.py index 44b5b44..f92c2d7 100644 --- a/monasca_notification/conf/types.py +++ b/monasca_notification/conf/types.py @@ -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)