From 22e332933e78bc1c819c4f876d48620605ae813b Mon Sep 17 00:00:00 2001 From: Raphael Glon Date: Thu, 21 Mar 2019 13:38:53 +0000 Subject: net: Fix ipv6 static routes when using eni renderer When rendering ipv6 static routes in eni format the post-up/pre down commands were not correct for ipv6. LP: #1818669 --- cloudinit/net/eni.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'cloudinit/net') diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py index 64236320..b129bb62 100644 --- a/cloudinit/net/eni.py +++ b/cloudinit/net/eni.py @@ -366,8 +366,6 @@ class Renderer(renderer.Renderer): down = indent + "pre-down route del" or_true = " || true" mapping = { - 'network': '-net', - 'netmask': 'netmask', 'gateway': 'gw', 'metric': 'metric', } @@ -379,13 +377,21 @@ class Renderer(renderer.Renderer): default_gw = ' -A inet6 default' route_line = '' - for k in ['network', 'netmask', 'gateway', 'metric']: - if default_gw and k in ['network', 'netmask']: + for k in ['network', 'gateway', 'metric']: + if default_gw and k == 'network': continue if k == 'gateway': route_line += '%s %s %s' % (default_gw, mapping[k], route[k]) elif k in route: - route_line += ' %s %s' % (mapping[k], route[k]) + if k == 'network': + if ':' in route[k]: + route_line += ' -A inet6' + else: + route_line += ' -net' + if 'prefix' in route: + route_line += ' %s/%s' % (route[k], route['prefix']) + else: + route_line += ' %s %s' % (mapping[k], route[k]) content.append(up + route_line + or_true) content.append(down + route_line + or_true) return content -- cgit v1.2.3