2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-23 01:53:28 +00:00

Non-linux fallback for list_interface_indexes()

When errors suggest we are not in linux, make a best
effort using netifaces.
This commit is contained in:
Jarrod Johnson 2017-06-29 10:33:10 -04:00
parent 1116fed1e7
commit fa6650a072

View File

@ -37,7 +37,14 @@ def list_interface_indexes():
yield intidx
except (IOError, OSError):
# Probably situation is non-Linux, just do limited support for
# such platforms until other people come alonge
# such platforms until other people come along
for iface in netifaces.interfaces():
addrinfo = netifaces.ifaddresses(iface).get(socket.AF_INET6, [])
for addr in addrinfo:
v6addr = addr.get('addr', '').partition('%')[2]
if v6addr:
yield(int(v6addr))
break
return