Commit 71eed64c authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Improved bridge handling

parent a4f8bb11
......@@ -59,18 +59,7 @@ class Network(object):
c_mac = c_mac and c_mac.lower()
self._connection[c_type, c_mac, c_id, c_uuid] = c
pass
# from pprint import pprint
# print('Wired')
# pprint(self._wired)
# print('Bridge')
# pprint(self._bridge)
# print('Tunnel')
# pprint(self._tunnel)
# print('Tun')
# pprint(self._tun)
# print('Connection')
# pprint(self._connection)
pass
def parse_tree(self, tree):
self.reload()
......@@ -170,8 +159,13 @@ def update_settings(settings, update):
for k,v in update.items():
d = result
for i in k[:-1]:
if not i in d:
d = None
break
d = d[i]
pass
if d == None:
continue
if v != None:
d[k[-1]] = v
elif k[-1] in d:
......@@ -230,7 +224,8 @@ def configure_networking(connection, interface):
pass
def cleanup_deprecated(settings):
for family in [ 'ipv4', 'ipv6' ]:
if ('address-data' in settings[family] and
if (family in settings and
'address-data' in settings[family] and
'addresses' in settings[family]):
del settings[family]['addresses']
pass
......@@ -300,7 +295,8 @@ def configure_bridge(tree, interface):
pass
# Try to find wired connections matching the specs
if bridge_connection == None:
candidates = network.get_connections(kind='bridge', id=bridge_name)
candidates = network.get_connections(kind='bridge', id=bridge_name,
mac=interface.ethernet[0])
if len(candidates):
bridge_connection = candidates[0]
# Create new connection if not found
......@@ -366,8 +362,12 @@ def activate_bridge(interface):
candidates = network.get_connections(kind='bridge', id=bridge_name)
if len(candidates):
connection = candidates[0]
NetworkManager.NetworkManager.ActivateConnection(
connection, network.get_bridge(interface.ethernet[0]), '/')
bridge = network.get_bridge(interface.ethernet[0])
if bridge == None:
print("need to create bridge for", interface)
else:
NetworkManager.NetworkManager.ActivateConnection(
connection, network.get_bridge(interface.ethernet[0]), '/')
pass
pass
......
Markdown is supported
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