Add dns-nameservers 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.

Note: this option only takes effect when the
enable-local-dhcp-and-metadata flag is set to True.

Change-Id: I510d163dd9738477b15497b25266e73a50368539
Implements: blueprint internal-dns
Closes-Bug: #1713721
This commit is contained in:
Billy Olsen 2017-08-31 09:06:53 -07:00
parent d3a96e6cc6
commit 460602489d
4 changed files with 22 additions and 4 deletions

View File

@ -133,6 +133,13 @@ options:
Comma-separated list of key=value config flags with the additional dhcp
options for neutron dnsmasq. Note, this option is only valid when
enable-local-dhcp-and-metadata option is set to True.
dns-servers:
type: string
default:
description: |
A comma-separated list of DNS servers which will be used by dnsmasq as
forwarders. This option only applies when the enable-local-dhcp-and-metadata
options is set to True.
prevent-arp-spoofing:
type: boolean
default: true

View File

@ -213,6 +213,7 @@ class DHCPAgentContext(OSContextGenerator):
dnsmasq_flags = config('dnsmasq-flags')
if dnsmasq_flags:
ctxt['dnsmasq_flags'] = config_flags_parser(dnsmasq_flags)
ctxt['dns_servers'] = config('dns-servers')
neutron_api_settings = NeutronAPIContext()()
if neutron_api_settings.get('dns_domain'):

View File

@ -15,6 +15,10 @@ root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
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 in mitaka as well. Additional

View File

@ -291,7 +291,8 @@ class DHCPAgentContextTest(CharmTestCase):
self.relation_get.return_value = None
self.assertEqual(
context.DHCPAgentContext()(),
{'dns_domain': 'openstack.example.'}
{'dns_domain': 'openstack.example.',
'dns_servers': None}
)
self.relation_ids.assert_called_with('neutron-plugin')
self.relation_get.assert_called_once_with(
@ -314,13 +315,15 @@ class DHCPAgentContextTest(CharmTestCase):
'dns-domain': 'openstack.example.'
}
_rget.side_effect = lambda *args, **kwargs: rdata
self.test_config.set('dns-servers', '8.8.8.8,4.4.4.4')
self.relation_ids.return_value = ['rid1']
self.related_units.return_value = ['nova-compute/0']
self.relation_get.return_value = 'nova'
self.assertEqual(
context.DHCPAgentContext()(),
{'availability_zone': 'nova',
'dns_domain': 'openstack.example.'}
'dns_domain': 'openstack.example.',
'dns_servers': '8.8.8.8,4.4.4.4'}
)
self.relation_ids.assert_called_with('neutron-plugin')
self.relation_get.assert_called_once_with(
@ -342,12 +345,14 @@ class DHCPAgentContextTest(CharmTestCase):
'network-device-mtu': 1500,
}
_rget.side_effect = lambda *args, **kwargs: rdata
self.test_config.set('dns-servers', '8.8.8.8')
self.relation_ids.return_value = ['rid1']
self.related_units.return_value = ['nova-compute/0']
self.relation_get.return_value = 'nova'
self.assertEqual(
context.DHCPAgentContext()(),
{'availability_zone': 'nova'}
{'availability_zone': 'nova',
'dns_servers': '8.8.8.8'}
)
self.relation_ids.assert_called_with('neutron-plugin')
self.relation_get.assert_called_once_with(
@ -382,7 +387,8 @@ class DHCPAgentContextTest(CharmTestCase):
'dhcp-userclass': 'set:ipxe,iPXE',
'dhcp-match': 'set:ipxe,175',
'server': '1.2.3.4',
}
},
'dns_servers': None,
}
)