From: Kefu Chai Date: Wed, 27 Jan 2021 04:58:45 +0000 (+0800) Subject: mgr/zabbix: cast port to int X-Git-Tag: v17.1.0~3148^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5cf5540250fa67068e2e3c0f36d67f0fa6cbbbb4;p=ceph.git mgr/zabbix: cast port to int to appease mypy Signed-off-by: Kefu Chai --- diff --git a/src/pybind/mgr/zabbix/module.py b/src/pybind/mgr/zabbix/module.py index c16b98cfb10b..c4f19f38c8b2 100644 --- a/src/pybind/mgr/zabbix/module.py +++ b/src/pybind/mgr/zabbix/module.py @@ -157,8 +157,11 @@ class Module(MgrModule): for server in servers: uri = re.match("(?:(?:\[?)([a-z0-9-\.]+|[a-f0-9:\.]+)(?:\]?))(?:((?::))([0-9]{1,5}))?$", server) if uri: - zabbix_host, sep, zabbix_port = uri.groups() - zabbix_port = zabbix_port if sep == ':' else self.config['zabbix_port'] + zabbix_host, sep, opt_zabbix_port = uri.groups() + if sep == ':': + zabbix_port = int(opt_zabbix_port) + else: + zabbix_port = cast(int, self.config['zabbix_port']) self._zabbix_hosts.append({'zabbix_host': zabbix_host, 'zabbix_port': zabbix_port}) else: self.log.error('Zabbix host "%s" is not valid', server)