Commit 7cf2c93a authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Make device matching work for unknown device kinds

parent 0325467f
......@@ -28,25 +28,32 @@ class Network(object):
self._tun = {}
self._connection = {}
# Get devices from network manager
def is_kind(device, kind):
device_class = getattr(NetworkManager, kind, None)
if device_class == None:
print('%s not defined in this version of NetworkManager' % kind)
return False
return isinstance(device, device_class)
for d in NetworkManager.NetworkManager.AllDevices:
if isinstance(d, NetworkManager.Generic):
if is_kind(d, 'Generic'):
pass
elif isinstance(d, NetworkManager.Dummy):
elif is_kind(d, 'Dummy'):
pass
elif isinstance(d, NetworkManager.Wireless):
elif is_kind(d, 'Wireless'):
pass
elif isinstance(d, NetworkManager.WireGuard):
elif is_kind(d, 'WireGuard'):
pass
elif isinstance(d, NetworkManager.Wired):
elif is_kind(d, 'Wired'):
self._wired[d.HwAddress.lower()] = d
pass
elif isinstance(d, NetworkManager.Bridge):
elif is_kind(d, 'Bridge'):
self._bridge[d.HwAddress.lower()] = d
pass
elif isinstance(d, NetworkManager.IPTunnel):
elif is_kind(d, 'IPTunnel'):
self._ip_tunnel[d.Interface] = d
pass
elif isinstance(d, NetworkManager.Tun):
elif is_kind(d, 'Tun'):
self._tun[d.Interface] = d
pass
else:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment