diff options
author | Scott Moser <smoser@ubuntu.com> | 2016-04-15 16:08:47 -0400 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2016-04-15 16:08:47 -0400 |
commit | 8384076e77d8fa5e0f6f3639f2dddd33c64236b9 (patch) | |
tree | d40d6c813f344d7a23f61b400c32b482ddc8fe07 /cloudinit | |
parent | 5039a08032fc40c9c72afbef90184dbd1af10918 (diff) | |
download | vyos-cloud-init-8384076e77d8fa5e0f6f3639f2dddd33c64236b9.tar.gz vyos-cloud-init-8384076e77d8fa5e0f6f3639f2dddd33c64236b9.zip |
write 'allow-hotplug', but 'auto' for auto.
Diffstat (limited to 'cloudinit')
-rw-r--r-- | cloudinit/net/__init__.py | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/cloudinit/net/__init__.py b/cloudinit/net/__init__.py index 647c595b..fa5a0033 100644 --- a/cloudinit/net/__init__.py +++ b/cloudinit/net/__init__.py @@ -509,6 +509,26 @@ def render_route(route, indent=""): return content +def iface_start_entry(iface, index): + fullname = iface['name'] + if index != 0: + fullname += ":%s" % index + + control = iface['control'] + if control == "auto": + cverb = "auto" + elif control in ("hotplug",): + cverb = "allow-" + control + else: + cverb = "# control-" + control + + subst = iface.copy() + subst.update({'fullname': fullname, 'cverb': cverb}) + + return ("{cverb} {fullname}\n" + "iface {fullname} {inet} {mode}\n").format(**subst) + + def render_interfaces(network_state): ''' Given state, emit etc/network/interfaces content ''' @@ -549,16 +569,7 @@ def render_interfaces(network_state): if iface['mode'].startswith('dhcp'): iface['mode'] = 'dhcp' - if index == 0: - if iface['control'] != 'manual': - content += "allow-{control} {name}\n".format(**iface) - content += "iface {name} {inet} {mode}\n".format(**iface) - else: - if iface['control'] != 'manual': - content += "auto {name}:{index}\n".format(**iface) - content += \ - "iface {name}:{index} {inet} {mode}\n".format(**iface) - + content += iface_start_entry(iface, index) content += iface_add_subnet(iface, subnet) content += iface_add_attrs(iface) else: |