summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorRyan Harper <ryan.harper@canonical.com>2017-06-09 15:33:37 -0500
committerScott Moser <smoser@brickies.net>2017-07-19 16:03:37 -0400
commit97abd83513bee191b58f095f4d683b18acce0b49 (patch)
tree7a99486512ce8b86197ce9d4ec7a48938f41fd80 /cloudinit
parentc0060fe4892197179a5cfbfd3239cf3b6c3e5029 (diff)
downloadvyos-cloud-init-97abd83513bee191b58f095f4d683b18acce0b49.tar.gz
vyos-cloud-init-97abd83513bee191b58f095f4d683b18acce0b49.zip
sysconfig: ipv6 and default gateway fixes.
With this change, entries in IPV6ADDR and IPV6ADDR_SECONDARIES will now always be in format addr/prefix. When a subnet has a gateway will be written. If the gateway is ipv6, use the key IPV6_DEFAULTGW rather than GATEWAY. LP: #1704872
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/net/sysconfig.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index ad8c268e..de6601af 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -10,7 +10,8 @@ from cloudinit.distros.parsers import resolv_conf
from cloudinit import util
from . import renderer
-from .network_state import subnet_is_ipv6, net_prefix_to_ipv4_mask
+from .network_state import (
+ is_ipv6_addr, net_prefix_to_ipv4_mask, subnet_is_ipv6)
def _make_header(sep='#'):
@@ -308,20 +309,13 @@ class Renderer(renderer.Renderer):
elif subnet_type == 'static':
if subnet_is_ipv6(subnet):
ipv6_index = ipv6_index + 1
- if 'netmask' in subnet and str(subnet['netmask']) != "":
- ipv6_cidr = (subnet['address'] +
- '/' +
- str(subnet['netmask']))
- else:
- ipv6_cidr = subnet['address']
+ ipv6_cidr = "%s/%s" % (subnet['address'], subnet['prefix'])
if ipv6_index == 0:
iface_cfg['IPV6ADDR'] = ipv6_cidr
elif ipv6_index == 1:
iface_cfg['IPV6ADDR_SECONDARIES'] = ipv6_cidr
else:
- iface_cfg['IPV6ADDR_SECONDARIES'] = (
- iface_cfg['IPV6ADDR_SECONDARIES'] +
- " " + ipv6_cidr)
+ iface_cfg['IPV6ADDR_SECONDARIES'] += " " + ipv6_cidr
else:
ipv4_index = ipv4_index + 1
suff = "" if ipv4_index == 0 else str(ipv4_index)
@@ -330,7 +324,11 @@ class Renderer(renderer.Renderer):
net_prefix_to_ipv4_mask(subnet['prefix'])
if 'gateway' in subnet:
- iface_cfg['GATEWAY'] = subnet['gateway']
+ iface_cfg['DEFROUTE'] = True
+ if is_ipv6_addr(subnet['gateway']):
+ iface_cfg['IPV6_DEFAULTGW'] = subnet['gateway']
+ else:
+ iface_cfg['GATEWAY'] = subnet['gateway']
@classmethod
def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):