From 2b2c4b745f74fab39c8be85ffe124035ee001bdb Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Thu, 31 Aug 2017 08:52:49 -0700 Subject: [PATCH] Add dns-servers config option for upstream dns servers Adds a dns-servers config option for specifying the forwarding dns servers to be used by the dnsmasq services on the neutron dhcp agent. This enables services using internal dns to also specify the forwarding dns servers in order to resolve hosts outside of the neutron network space. Change-Id: I3cd608b1491a45f565d5147894b8285e638eeaa7 Implements: blueprint internal-dns Closes-Bug: #1713721 --- config.yaml | 6 ++++++ hooks/neutron_contexts.py | 1 + templates/mitaka/dhcp_agent.ini | 4 ++++ unit_tests/test_neutron_contexts.py | 3 +++ 4 files changed, 14 insertions(+) diff --git a/config.yaml b/config.yaml index c7fd774e..19c6a285 100644 --- a/config.yaml +++ b/config.yaml @@ -166,6 +166,12 @@ options: description: | Comma-separated list of key=value config flags with the additional dhcp options for neutron dnsmasq. + dns-servers: + type: string + default: + description: | + A comma-separated list of DNS servers which will be used by dnsmasq as + forwarders. enable-l3-agent: type: boolean default: True diff --git a/hooks/neutron_contexts.py b/hooks/neutron_contexts.py index fc16f88a..08444c00 100644 --- a/hooks/neutron_contexts.py +++ b/hooks/neutron_contexts.py @@ -90,6 +90,7 @@ class NeutronGatewayContext(NeutronAPIContext): 'debug': config('debug'), 'verbose': config('verbose'), 'instance_mtu': config('instance-mtu'), + 'dns_servers': config('dns-servers'), 'l2_population': api_settings['l2_population'], 'enable_dvr': api_settings['enable_dvr'], 'enable_l3ha': api_settings['enable_l3ha'], diff --git a/templates/mitaka/dhcp_agent.ini b/templates/mitaka/dhcp_agent.ini index c99d3e09..b4649430 100644 --- a/templates/mitaka/dhcp_agent.ini +++ b/templates/mitaka/dhcp_agent.ini @@ -13,6 +13,10 @@ debug = {{ debug }} dnsmasq_config_file = /etc/neutron/dnsmasq.conf {% endif -%} +{% if dns_servers -%} +dnsmasq_dns_servers = {{ dns_servers }} +{% endif -%} + {% if dns_domain -%} dns_domain = {{ dns_domain }} # Per LP#1583769, dhcp_domain needs to be configured as well. Additional diff --git a/unit_tests/test_neutron_contexts.py b/unit_tests/test_neutron_contexts.py index 5f3e25b3..98b0c290 100644 --- a/unit_tests/test_neutron_contexts.py +++ b/unit_tests/test_neutron_contexts.py @@ -162,6 +162,7 @@ class TestNeutronGatewayContext(CharmTestCase): self.test_config.set('instance-mtu', 1420) self.test_config.set('dnsmasq-flags', 'dhcp-userclass=set:ipxe,iPXE,' 'dhcp-match=set:ipxe,175') + self.test_config.set('dns-servers', '8.8.8.8,4.4.4.4') self.test_config.set('vlan-ranges', 'physnet1:1000:2000 physnet2:2001:3000') self.test_config.set('flat-network-providers', 'physnet3 physnet4') @@ -177,6 +178,7 @@ class TestNeutronGatewayContext(CharmTestCase): 'shared_secret': 'testsecret', 'enable_dvr': True, 'enable_l3ha': True, + 'dns_servers': '8.8.8.8,4.4.4.4', 'dns_domain': 'openstack.example.', 'local_ip': '10.5.0.1', 'instance_mtu': 1420, @@ -233,6 +235,7 @@ class TestNeutronGatewayContext(CharmTestCase): 'shared_secret': 'testsecret', 'enable_dvr': True, 'enable_l3ha': True, + 'dns_servers': None, 'dns_domain': 'openstack.example.', 'local_ip': '192.168.20.2', 'instance_mtu': 1420,