]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow multiple DNS forwarders for dnsmasq
authorSylvain Afchain <sylvain.afchain@enovance.com>
Thu, 12 Dec 2013 23:12:29 +0000 (00:12 +0100)
committerThomas Goirand <thomas@goirand.fr>
Thu, 13 Mar 2014 07:20:17 +0000 (15:20 +0800)
This patch change the dnsmasq_server configuration option to a ListOpt
in order to enable user to specify multiple DNS forwarders for each
dnsmasq instance.

DocImpact

Change-Id: I21963b4a6c99e4edb11040d77a6aeaa35ff44641
Closes-bug: #1240027

etc/dhcp_agent.ini
neutron/agent/linux/dhcp.py
neutron/tests/unit/test_linux_dhcp.py

index 425684b04f6cb96983256c9904f303aa813efa9d..583f136e64b8e9455b57c2ad14098dffab67a4ae 100644 (file)
@@ -62,8 +62,9 @@
 # Override the default dnsmasq settings with this file
 # dnsmasq_config_file =
 
-# Use another DNS server before any in /etc/resolv.conf.
-# dnsmasq_dns_server =
+# Comma-separated list of DNS servers which will be used by dnsmasq
+# as forwarders.
+# dnsmasq_dns_servers =
 
 # Limit number of leases to prevent a denial-of-service.
 # dnsmasq_lease_max = 16777216
index 28d0a66f4d0af8860cabf3ac10285cf0157240a0..f3d8e814609c69c13397703fdbe63942ea0a8111 100644 (file)
@@ -50,9 +50,10 @@ OPTS = [
     cfg.StrOpt('dnsmasq_config_file',
                default='',
                help=_('Override the default dnsmasq settings with this file')),
-    cfg.StrOpt('dnsmasq_dns_server',
-               help=_('Use another DNS server before any in '
-                      '/etc/resolv.conf.')),
+    cfg.ListOpt('dnsmasq_dns_servers',
+                help=_('Comma-separated list of the DNS servers which will be '
+                       'used as forwarders.'),
+                deprecated_name='dnsmasq_dns_server'),
     cfg.BoolOpt('dhcp_delete_namespaces', default=False,
                 help=_("Delete namespace after removing a dhcp server.")),
     cfg.IntOpt(
@@ -361,8 +362,10 @@ class Dnsmasq(DhcpLocalProcess):
                    min(possible_leases, self.conf.dnsmasq_lease_max))
 
         cmd.append('--conf-file=%s' % self.conf.dnsmasq_config_file)
-        if self.conf.dnsmasq_dns_server:
-            cmd.append('--server=%s' % self.conf.dnsmasq_dns_server)
+        if self.conf.dnsmasq_dns_servers:
+            cmd.extend(
+                '--server=%s' % server
+                for server in self.conf.dnsmasq_dns_servers)
 
         if self.conf.dhcp_domain:
             cmd.append('--domain=%s' % self.conf.dhcp_domain)
index 6d3cf8bd275badc2010086c90408edc7a498ff9b..146043341dedfd535a1e5c6678caacb3f66e1dc2 100644 (file)
@@ -717,11 +717,19 @@ class TestDnsmasq(TestBase):
         self._test_spawn(['--conf-file='])
 
     def test_spawn_cfg_dns_server(self):
-        self.conf.set_override('dnsmasq_dns_server', '8.8.8.8')
+        self.conf.set_override('dnsmasq_dns_servers', ['8.8.8.8'])
         self._test_spawn(['--conf-file=',
                           '--server=8.8.8.8',
                           '--domain=openstacklocal'])
 
+    def test_spawn_cfg_multiple_dns_server(self):
+        self.conf.set_override('dnsmasq_dns_servers', ['8.8.8.8',
+                                                       '9.9.9.9'])
+        self._test_spawn(['--conf-file=',
+                          '--server=8.8.8.8',
+                          '--server=9.9.9.9',
+                          '--domain=openstacklocal'])
+
     def test_spawn_max_leases_is_smaller_than_cap(self):
         self._test_spawn(
             ['--conf-file=', '--domain=openstacklocal'],