summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-06-21 12:26:02 -0400
committerScott Moser <smoser@ubuntu.com>2016-06-21 12:26:02 -0400
commit1f120a8f6b818ae2d56dd7297f384e0a6cf1cf9b (patch)
tree42b54caddfe0328d1812d75da72762b3297f6e45
parentf54d504f31e8065a4e71d66701b2372dd67e271e (diff)
downloadcloud-init-1f120a8f6b818ae2d56dd7297f384e0a6cf1cf9b.tar.gz
net: fix inet value for subnets, don't add interface attributes to alias
[copied from curtin revno 390] Apply two separate fixes for configuring bonding with ip aliases. Curtin re-used the interface's inet value for each subnet that might be configured. In the case where the configuration included an ipv4 address after an ipv6 one resulted in emitting 'inet6' for ipv4 address which is not correct. Resolve this issue by calculating the inet value independent of the current status of the iface, using the subnet config instead. When rendering a network_config which includes ip alias interfaces do not emit any attributes, like MTU, or bond/bridge options Including these values is almost always wrong or will result in confusing behavior on the target system.
-rw-r--r--cloudinit/net/eni.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/cloudinit/net/eni.py b/cloudinit/net/eni.py
index 5f33e177..86d2a830 100644
--- a/cloudinit/net/eni.py
+++ b/cloudinit/net/eni.py
@@ -68,8 +68,14 @@ def _iface_add_subnet(iface, subnet):
# TODO: switch to valid_map for attrs
-
-def _iface_add_attrs(iface):
+def _iface_add_attrs(iface, index):
+ # If the index is non-zero, this is an alias interface. Alias interfaces
+ # represent additional interface addresses, and should not have additional
+ # attributes. (extra attributes here are almost always either incorrect,
+ # or are applied to the parent interface.) So if this is an alias, stop
+ # right here.
+ if index != 0:
+ return []
content = []
ignore_map = [
'control',
@@ -363,17 +369,21 @@ class Renderer(renderer.Renderer):
iface['index'] = index
iface['mode'] = subnet['type']
iface['control'] = subnet.get('control', 'auto')
+ subnet_inet = 'inet'
if iface['mode'].endswith('6'):
- iface['inet'] += '6'
+ # This is a request for DHCPv6.
+ subnet_inet += '6'
elif iface['mode'] == 'static' and ":" in subnet['address']:
- iface['inet'] += '6'
+ # This is a static IPv6 address.
+ subnet_inet += '6'
+ iface['inet'] = subnet_inet
if iface['mode'].startswith('dhcp'):
iface['mode'] = 'dhcp'
lines = list(
_iface_start_entry(iface, index) +
_iface_add_subnet(iface, subnet) +
- _iface_add_attrs(iface)
+ _iface_add_attrs(iface, index)
)
for route in subnet.get('routes', []):
lines.extend(self._render_route(route, indent=" "))
@@ -390,7 +400,7 @@ class Renderer(renderer.Renderer):
if 'bond-master' in iface:
lines.append("auto {name}".format(**iface))
lines.append("iface {name} {inet} {mode}".format(**iface))
- lines.extend(_iface_add_attrs(iface))
+ lines.extend(_iface_add_attrs(iface, index=0))
sections.append(lines)
return sections