From 12cbfff24f60a6fd0a60fd9019d7bec786af28e1 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 5 Sep 2017 09:19:15 -0400 Subject: [PATCH] Fix for unexpected entries in /sys/class/net For example, in a bonding configuration there is a file there, not just directories with ifindex entries. --- confluent_server/confluent/util.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/confluent_server/confluent/util.py b/confluent_server/confluent/util.py index 3e41bd86..8f42e715 100644 --- a/confluent_server/confluent/util.py +++ b/confluent_server/confluent/util.py @@ -31,6 +31,8 @@ def list_interface_indexes(): # For now be linux specific try: for iface in os.listdir('/sys/class/net/'): + if not os.path.exists('/sys/class/net/{0}/ifindex'.format(iface)): + continue ifile = open('/sys/class/net/{0}/ifindex'.format(iface), 'r') intidx = int(ifile.read()) ifile.close()