← Back to team overview

cloud-init-dev team mailing list archive

[Merge] ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master

 

Ryan McCabe has proposed merging ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master.

Requested reviews:
  cloud-init commiters (cloud-init-dev)
  Server Team CI bot (server-team-bot): continuous-integration
Related bugs:
  Bug #1705804 in cloud-init: "sysconfig renderer should render DNSx= and GATEWAY= lines"
  https://bugs.launchpad.net/cloud-init/+bug/1705804

For more details, see:
https://code.launchpad.net/~rmccabe/cloud-init/+git/cloud-init/+merge/333759

Currently when dns and dns search info is provided, it is not rendered
when outputting to sysconfig format.
    
This patch causes the DNS and DOMAIN lines to be written out rendering
sysconfig.
    
LP: #1705804

-- 
Your team cloud-init commiters is requested to review the proposed merge of ~rmccabe/cloud-init:bug1705804-3 into cloud-init:master.
diff --git a/cloudinit/net/sysconfig.py b/cloudinit/net/sysconfig.py
index f572796..a3f23bd 100644
--- a/cloudinit/net/sysconfig.py
+++ b/cloudinit/net/sysconfig.py
@@ -347,6 +347,13 @@ class Renderer(renderer.Renderer):
                     else:
                         iface_cfg['GATEWAY'] = subnet['gateway']
 
+                if 'dns_search' in subnet:
+                    iface_cfg['DOMAIN'] = subnet['dns_search']
+
+                if 'dns_nameservers' in subnet:
+                    for i, k in enumerate(subnet['dns_nameservers'][:3], 1):
+                        iface_cfg['DNS' + str(i)] = k
+
     @classmethod
     def _render_subnet_routes(cls, iface_cfg, route_cfg, subnets):
         for i, subnet in enumerate(subnets, start=len(iface_cfg.children)):
diff --git a/tests/unittests/test_net.py b/tests/unittests/test_net.py
index bbb63cb..f3fa2a3 100644
--- a/tests/unittests/test_net.py
+++ b/tests/unittests/test_net.py
@@ -436,6 +436,9 @@ NETWORK_CONFIGS = {
                 BOOTPROTO=dhcp
                 DEFROUTE=yes
                 DEVICE=eth99
+                DNS1=8.8.8.8
+                DNS2=8.8.4.4
+                DOMAIN="barley.maas sach.maas"
                 GATEWAY=65.61.151.37
                 HWADDR=c0:d6:9f:2c:e8:80
                 IPADDR=192.168.21.3
@@ -836,6 +839,9 @@ pre-down route del -net 10.0.0.0 netmask 255.0.0.0 gw 11.0.0.1 metric 3 || true
                 BOOTPROTO=none
                 DEFROUTE=yes
                 DEVICE=eth0.101
+                DNS1=192.168.0.10
+                DNS2=10.23.23.134
+                DOMAIN="barley.maas sacchromyces.maas brettanomyces.maas"
                 GATEWAY=192.168.0.1
                 IPADDR=192.168.0.2
                 IPADDR1=192.168.2.10

Follow ups