Use api of the distinct list

This commit is contained in:
Bo Maryniuk 2016-06-03 16:23:32 +02:00
parent cf1433b8e1
commit 043ae8bd92

View File

@ -114,13 +114,13 @@ def generate_minion_id():
hosts = DistinctList().append(socket.getfqdn()).append(socket.gethostname()).append(platform.node()) hosts = DistinctList().append(socket.getfqdn()).append(socket.gethostname()).append(platform.node())
if hosts: if hosts:
try: try:
for a_nfo in socket.getaddrinfo(hosts[0], socket.AF_UNSPEC, socket.SOCK_STREAM, for a_nfo in socket.getaddrinfo(hosts.first(), socket.AF_UNSPEC, socket.SOCK_STREAM,
socket.SOL_TCP, socket.AI_CANONNAME): socket.SOL_TCP, socket.AI_CANONNAME):
if len(a_nfo) > 3: if len(a_nfo) > 3:
hosts.append(a_nfo[3]) hosts.append(a_nfo[3])
except socket.gaierror: except socket.gaierror:
log.warn('Cannot resolve address {addr} info via socket: {message}'.format( log.warn('Cannot resolve address {addr} info via socket: {message}'.format(
addr=hosts[0], message=socket.gaierror) addr=hosts.first(), message=socket.gaierror)
) )
# Universal method for everywhere (Linux, Slowlaris, Windows etc) # Universal method for everywhere (Linux, Slowlaris, Windows etc)