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.
@@ -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):
