From 681baff19dc16ef2efdfb8499ad74aea0efbe467 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 21 Jul 2017 16:50:27 -0400 Subject: sysconfig: support subnet type of 'manual'. The subnet type 'manual' was used as a way to declare a device and set an MTU for it but not assign network addresses. This updates the manual example config to handle that case and provides expected rendered output for sysconfig, eni, and netplan. --- cloudinit/net/sysconfig.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'cloudinit/net/sysconfig.py') diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py index 9184bce6..a550f97c 100644 --- a/cloudinit/net/sysconfig.py +++ b/cloudinit/net/sysconfig.py @@ -61,6 +61,9 @@ class ConfigMap(object): def __getitem__(self, key): return self._conf[key] + def __contains__(self, key): + return key in self._conf + def drop(self, key): self._conf.pop(key, None) @@ -298,14 +301,16 @@ class Renderer(renderer.Renderer): if subnet_is_ipv6(subnet): mtu_key = 'IPV6_MTU' iface_cfg['IPV6INIT'] = True - if 'mtu' in subnet: iface_cfg[mtu_key] = subnet['mtu'] + elif subnet_type == 'manual': + # If the subnet has an MTU setting, then ONBOOT=True + # to apply the setting + iface_cfg['ONBOOT'] = mtu_key in iface_cfg else: raise ValueError("Unknown subnet type '%s' found" " for interface '%s'" % (subnet_type, iface_cfg.name)) - if subnet.get('control') == 'manual': iface_cfg['ONBOOT'] = False -- cgit v1.2.3