summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Castets <castets.j@gmail.com>2017-05-16 09:19:11 +0000
committerScott Moser <smoser@brickies.net>2017-05-16 11:44:11 -0400
commit9d437489b8ce1f8cd9d34cd9ff4994ca18bd2d78 (patch)
tree7eb47a15176fae40475c0bdcfd20f84bbd2e5b5c
parentdd03bb411c9a6f10854a3bbc3223b204c3d4d174 (diff)
downloadvyos-cloud-init-9d437489b8ce1f8cd9d34cd9ff4994ca18bd2d78.tar.gz
vyos-cloud-init-9d437489b8ce1f8cd9d34cd9ff4994ca18bd2d78.zip
Add address to config entry generated by _klibc_to_config_entry.
If /run/net-<name>.cfg contains an IPV4ADDR or an IPV6ADDR, the config file generated by _klibc_to_config_entry now contains the "address". LP: #1691135
-rwxr-xr-xcloudinit/net/cmdline.py5
-rw-r--r--tests/unittests/test_net.py3
2 files changed, 7 insertions, 1 deletions
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index 7c5d11a7..61e23697 100755
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -100,6 +100,11 @@ def _klibc_to_config_entry(content, mac_addrs=None):
cur_proto = data.get(pre + 'PROTO', proto)
subnet = {'type': cur_proto, 'control': 'manual'}
+ # only populate address for static types. While the rendered config
+ # may have an address for dhcp, that is not really expected.
+ if cur_proto == 'static':
+ subnet['address'] = data[pre + 'ADDR']
+
# these fields go right on the subnet
for key in ('NETMASK', 'BROADCAST', 'GATEWAY'):
if pre + key in data:
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index 7c5dc4ef..052c4016 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -100,7 +100,8 @@ STATIC_EXPECTED_1 = {
'gateway': '10.0.0.1',
'dns_search': ['foo.com'], 'type': 'static',
'netmask': '255.255.255.0',
- 'dns_nameservers': ['10.0.1.1']}],
+ 'dns_nameservers': ['10.0.1.1'],
+ 'address': '10.0.0.2'}],
}
# Examples (and expected outputs for various renderers).