diff options
author | Dimitri John Ledkov <xnox@ubuntu.com> | 2020-01-30 17:15:49 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 12:15:49 -0500 |
commit | 2bedc44092ec94faebfb2f55c6d7c6bdd754df23 (patch) | |
tree | 49f015315e3e840edbee0a0fc23fb168fda7912d | |
parent | 5f8f85bb38cc972d3d2c705a1ec73db3f690f323 (diff) | |
download | vyos-cloud-init-2bedc44092ec94faebfb2f55c6d7c6bdd754df23.tar.gz vyos-cloud-init-2bedc44092ec94faebfb2f55c6d7c6bdd754df23.zip |
net/cmdline: correctly handle static ip= config (#201)
It is proto 'none', not 'static' as was mistakenly implemented in
initramfs-tools/cloud-init in the past, yet was never the case in the
klibc ipconfig state file output.
LP: #1861412
-rwxr-xr-x | cloudinit/net/cmdline.py | 12 | ||||
-rw-r--r-- | tests/unittests/test_net.py | 2 |
2 files changed, 10 insertions, 4 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py index bfb40aae..64e1c699 100755 --- a/cloudinit/net/cmdline.py +++ b/cloudinit/net/cmdline.py @@ -101,9 +101,12 @@ def _klibc_to_config_entry(content, mac_addrs=None): provided here. There is no good documentation on this unfortunately. DEVICE=<name> is expected/required and PROTO should indicate if - this is 'static' or 'dhcp' or 'dhcp6' (LP: #1621507). + this is 'none' (static) or 'dhcp' or 'dhcp6' (LP: #1621507). note that IPV6PROTO is also written by newer code to address the possibility of both ipv4 and ipv6 getting addresses. + + Full syntax is documented at: + https://git.kernel.org/pub/scm/libs/klibc/klibc.git/plain/usr/kinit/ipconfig/README.ipconfig """ if mac_addrs is None: @@ -122,9 +125,9 @@ def _klibc_to_config_entry(content, mac_addrs=None): if data.get('filename'): proto = 'dhcp' else: - proto = 'static' + proto = 'none' - if proto not in ('static', 'dhcp', 'dhcp6'): + if proto not in ('none', 'dhcp', 'dhcp6'): raise ValueError("Unexpected value for PROTO: %s" % proto) iface = { @@ -144,6 +147,9 @@ def _klibc_to_config_entry(content, mac_addrs=None): # PROTO for ipv4, IPV6PROTO for ipv6 cur_proto = data.get(pre + 'PROTO', proto) + # ipconfig's 'none' is called 'static' + if cur_proto == 'none': + cur_proto = 'static' subnet = {'type': cur_proto, 'control': 'manual'} # only populate address for static types. While the rendered config diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py index 01119e0a..001ad010 100644 --- a/tests/unittests/test_net.py +++ b/tests/unittests/test_net.py @@ -81,7 +81,7 @@ DHCP6_EXPECTED_1 = { STATIC_CONTENT_1 = """ DEVICE='eth1' -PROTO='static' +PROTO='none' IPV4ADDR='10.0.0.2' IPV4BROADCAST='10.0.0.255' IPV4NETMASK='255.255.255.0' |