From 0912617731123ab97ff3e7e38b0895a29d98c192 Mon Sep 17 00:00:00 2001 From: Chuck Short Date: Thu, 30 Aug 2018 09:19:53 -0400 Subject: [PATCH] Simplify hostname lookup When we are trying to resolve the hostname to an IP address we only care about the IP address so remove the rest of the unused variables. This popped up in a pylint run. Change-Id: I8e3b6cfd80be3d872f3bfc0ee5ac581fae5f45af Signed-off-by: Chuck Short --- cinder/utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cinder/utils.py b/cinder/utils.py index cd537bc9a63..6c96ca52ba8 100644 --- a/cinder/utils.py +++ b/cinder/utils.py @@ -1005,11 +1005,10 @@ def resolve_hostname(hostname): :param hostname: Host name to resolve. :returns: IP Address for Host name. """ - result = socket.getaddrinfo(hostname, None)[0] - (family, socktype, proto, canonname, sockaddr) = result + ip = socket.getaddrinfo(hostname, None)[0][4][0] LOG.debug('Asked to resolve hostname %(host)s and got IP %(ip)s.', - {'host': hostname, 'ip': sockaddr[0]}) - return sockaddr[0] + {'host': hostname, 'ip': ip}) + return ip def build_or_str(elements, str_format=None):