Ubuntu Pastebin

Paste from smoser at Tue, 16 May 2017 15:07:04 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/cloudinit/net/cmdline.py b/cloudinit/net/cmdline.py
index 7c5d11a7..de2e70b0 100755
--- a/cloudinit/net/cmdline.py
+++ b/cloudinit/net/cmdline.py
@@ -98,7 +98,14 @@ def _klibc_to_config_entry(content, mac_addrs=None):
 
         # PROTO for ipv4, IPV6PROTO for ipv6
         cur_proto = data.get(pre + 'PROTO', proto)
-        subnet = {'type': cur_proto, 'control': 'manual'}
+        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'):
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).
Download as text