summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2016-04-15 14:49:13 -0400
committerScott Moser <smoser@ubuntu.com>2016-04-15 14:49:13 -0400
commit14053fc79737f6ec6904021f3f6cdfd262c3b17e (patch)
tree99ca3b541ff1e973e405203088551f229a3631ea /cloudinit
parent53f035122dffd5b821e29fe9af9a72276d9728b4 (diff)
downloadvyos-cloud-init-14053fc79737f6ec6904021f3f6cdfd262c3b17e.tar.gz
vyos-cloud-init-14053fc79737f6ec6904021f3f6cdfd262c3b17e.zip
sync with curtin on render_interfaces
This picks up newline cleanup and some bond fixes from curtin at rev 374. - Cleanup newline logic so we always have a clean '\n\n' between stanza - Add a unittest to validate bonding network config render, specifically when to emit auto $iface for dependent bond slaves.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/net/__init__.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py
index a765b75a..7a6ec3a4 100644
--- a/cloudinit/net/__init__.py
+++ b/cloudinit/net/__init__.py
@@ -528,14 +528,16 @@ def render_interfaces(network_state):
if len(value):
content += " dns-{} {}\n".format(dnskey, " ".join(value))
- content += "\n"
for iface in sorted(interfaces.values(),
key=lambda k: (order[k['type']], k['name'])):
- content += "auto {name}\n".format(**iface)
+ if content[-2:] != "\n\n":
+ content += "\n"
subnets = iface.get('subnets', {})
if subnets:
for index, subnet in zip(range(0, len(subnets)), subnets):
+ if content[-2:] != "\n\n":
+ content += "\n"
iface['index'] = index
iface['mode'] = subnet['type']
if iface['mode'].endswith('6'):
@@ -546,27 +548,28 @@ def render_interfaces(network_state):
iface['mode'] = 'dhcp'
if index == 0:
+ if subnet['type'] != 'manual':
+ content += "auto {name}\n".format(**iface)
content += "iface {name} {inet} {mode}\n".format(**iface)
else:
- content += "auto {name}:{index}\n".format(**iface)
+ if subnet['type'] != 'manual':
+ content += "auto {name}:{index}\n".format(**iface)
content += \
"iface {name}:{index} {inet} {mode}\n".format(**iface)
content += iface_add_subnet(iface, subnet)
content += iface_add_attrs(iface)
- for route in subnet.get('routes', []):
- content += render_route(route, indent=" ")
- content += "\n"
else:
+ if 'bond-master' in iface:
+ content += "auto {name}\n".format(**iface)
content += "iface {name} {inet} {mode}\n".format(**iface)
content += iface_add_attrs(iface)
- content += "\n"
for route in network_state.get('routes'):
content += render_route(route)
# global replacements until v2 format
- content = content.replace('mac_address', 'hwaddress ether')
+ content = content.replace('mac_address', 'hwaddress')
return content