Merge ~jcastets/cloud-init:fix-net-cfg into cloud-init:master

Proposed by Julien Castets
Status: Merged
Approved by: Scott Moser
Approved revision: 2728c9de628ef88527e7725606271333455fd710
Merged at revision: 9d437489b8ce1f8cd9d34cd9ff4994ca18bd2d78
Proposed branch: ~jcastets/cloud-init:fix-net-cfg
Merge into: cloud-init:master
Diff against target: 30 lines (+7/-1)
2 files modified
cloudinit/net/cmdline.py (+5/-0)
tests/unittests/test_net.py (+2/-1)
Reviewer Review Type Date Requested Status
Server Team CI bot continuous-integration Approve
cloud-init Commiters Pending
Review via email: mp+324114@code.launchpad.net

Description of the change

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

To post a comment you must log in.
Revision history for this message
Server Team CI bot (server-team-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Scott Moser (smoser) wrote :

My only comments here is with respect to dhcp.
If the configuration type was dhcp, then i think its more correct to not include 'address', as most dhcp stanzas for network config are not going to have an address so that is at very least confusing.

How about this diff :
  http://paste.ubuntu.com/24587345/

Revision history for this message
Julien Castets (jcastets) wrote :

I pushed --force with your modifications

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
2index 7c5d11a..61e2369 100755
3--- a/cloudinit/net/cmdline.py
4+++ b/cloudinit/net/cmdline.py
5@@ -100,6 +100,11 @@ def _klibc_to_config_entry(content, mac_addrs=None):
6 cur_proto = data.get(pre + 'PROTO', proto)
7 subnet = {'type': cur_proto, 'control': 'manual'}
8
9+ # only populate address for static types. While the rendered config
10+ # may have an address for dhcp, that is not really expected.
11+ if cur_proto == 'static':
12+ subnet['address'] = data[pre + 'ADDR']
13+
14 # these fields go right on the subnet
15 for key in ('NETMASK', 'BROADCAST', 'GATEWAY'):
16 if pre + key in data:
17diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
18index 7c5dc4e..052c401 100644
19--- a/tests/unittests/test_net.py
20+++ b/tests/unittests/test_net.py
21@@ -100,7 +100,8 @@ STATIC_EXPECTED_1 = {
22 'gateway': '10.0.0.1',
23 'dns_search': ['foo.com'], 'type': 'static',
24 'netmask': '255.255.255.0',
25- 'dns_nameservers': ['10.0.1.1']}],
26+ 'dns_nameservers': ['10.0.1.1'],
27+ 'address': '10.0.0.2'}],
28 }
29
30 # Examples (and expected outputs for various renderers).

Subscribers

People subscribed via source and target branches