Commit fa952f19 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Add route handling to --networkmanager action

parent 80c9c1d4
......@@ -113,8 +113,8 @@ class Network(object):
def address_data(self, ip):
a = util.address(ip)
if a:
if ip.prefixlen[0]:
return dict(address=a.compressed, prefix=int(ip.prefixlen[0]))
if ip.prefix[0]:
return dict(address=a.compressed, prefix=int(ip.prefix[0]))
else:
for n in self._networks:
if a in n:
......@@ -124,6 +124,10 @@ class Network(object):
pass
return None
def route_data(self, route):
return dict(dest=util.address(route.dest[0]).compressed,
prefix=int(route.prefix[0]))
def dns(self, ip):
result = []
for i in filter(None, [ util.address(i) for i in ip ]):
......@@ -222,14 +226,20 @@ def configure_networking(connection, interface, settings=None):
pass
pass
else:
ipv4a = list(filter(None, [network.address_data(i)
for i in interface._ip_]))
ipv6a = list(filter(None, [network.address_data(i)
for i in interface._ipv6_]))
ipv4a = list(filter(None, [ network.address_data(i)
for i in interface._ip_ ]))
ipv6a = list(filter(None, [ network.address_data(i)
for i in interface._ipv6_ ]))
ipv4r = list(filter(None, [ network.route_data(i)
for i in interface._route4_]))
ipv6r = list(filter(None, [ network.route_data(i)
for i in interface._route6_]))
update['ipv4', 'address-data'] = ipv4a
update['ipv4', 'route-data'] = ipv4r
update['ipv4', 'dns'] = network.dns(interface._ip_)
update['ipv4', 'method'] = ('disabled','manual')[len(ipv4a) > 0]
update['ipv6', 'address-data'] = ipv6a
update['ipv6', 'route-data'] = ipv6r
update['ipv6', 'dns'] = network.dns(interface._ipv6_)
update['ipv6', 'method'] = ('disabled','manual')[len(ipv6a) > 0]
update['ipv6', 'dhcp-duid'] = None
......@@ -263,10 +273,13 @@ def configure_networking(connection, interface, settings=None):
pass
def cleanup_deprecated(settings):
for family in [ 'ipv4', 'ipv6' ]:
if (family in settings and
'address-data' in settings[family] and
'addresses' in settings[family]):
del settings[family]['addresses']
for modern,legacy in ( ('address-data', 'addresses'),
('route-data', 'routes') ):
if (family in settings and
modern in settings[family] and
legacy in settings[family]):
del settings[family][legacy]
pass
pass
pass
return settings
......
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