network/dhcp: allow setting & unsetting dnsmasq_dns_server

Also rename dnsmasq_dns_servers to dnsmasq_dns_server as the former is
only supported in Icehouse.

Add unit tests for the feature.
This commit is contained in:
François Charlier 2014-04-24 16:25:35 +02:00
parent 0334bea82c
commit dcee1965a2
3 changed files with 57 additions and 5 deletions

View File

@ -426,7 +426,7 @@ class os_params {
$tunnel_eth = $internal_netif_ip
$provider_vlan_ranges = ['physnet1:1000:2999']
$provider_bridge_mappings = ['physnet1:br-eth1']
$dnsmasq_dns_servers = '8.8.8.8,8.8.4.4'
$dnsmasq_dns_server = '8.8.8.8'
# Nova
$ks_nova_password = 'secrete'

View File

@ -17,9 +17,9 @@
#
class cloud::network::dhcp(
$veth_mtu = 1500,
$debug = true
$dnsmasq_dns_servers = false
$veth_mtu = 1500,
$debug = true,
$dnsmasq_dns_server = false
) {
include 'cloud::network'
@ -31,7 +31,15 @@ class cloud::network::dhcp(
neutron_dhcp_agent_config {
'DEFAULT/dnsmasq_config_file': value => '/etc/neutron/dnsmasq-neutron.conf';
'DEFAULT/enable_isolated_metadata': value => true;
'DEFAULT/dnsmasq_dns_servers': value => $dnsmasq_dns_servers;
}
if $dnsmasq_dns_server {
neutron_dhcp_agent_config { 'DEFAULT/dnsmasq_dns_server':
value => $dnsmasq_dns_server
}
} else {
neutron_dhcp_agent_config { 'DEFAULT/dnsmasq_dns_server':
ensure => absent
}
}
file { '/etc/neutron/dnsmasq-neutron.conf':

View File

@ -82,6 +82,48 @@ describe 'cloud::network::dhcp' do
should contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_config_file').with_value('/etc/neutron/dnsmasq-neutron.conf')
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(true)
should contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_dns_server').with_ensure('absent')
should contain_file('/etc/neutron/dnsmasq-neutron.conf').with(
:mode => '0755',
:owner => 'root',
:group => 'root'
)
should contain_file('/etc/neutron/dnsmasq-neutron.conf').with_content(/^dhcp-option-force=26,1400$/)
end
end
shared_examples_for 'openstack network dhcp with custom nameserver' do
let :pre_condition do
"class { 'cloud::network':
rabbit_hosts => ['10.0.0.1'],
rabbit_password => 'secrete',
tunnel_eth => '10.0.1.1',
api_eth => '10.0.0.1',
provider_vlan_ranges => ['physnet1:1000:2999'],
provider_bridge_mappings => ['physnet1:br-eth1'],
verbose => true,
debug => true,
use_syslog => true,
dhcp_lease_duration => '10',
log_facility => 'LOG_LOCAL0' }"
end
let :params do
{ :veth_mtu => '1400',
:debug => true,
:dnsmasq_dns_server => '1.2.3.4' }
end
it 'configure neutron dhcp' do
should contain_class('neutron::agents::dhcp').with(
:debug => true
)
should contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_config_file').with_value('/etc/neutron/dnsmasq-neutron.conf')
should contain_neutron_dhcp_agent_config('DEFAULT/enable_isolated_metadata').with_value(true)
should contain_neutron_dhcp_agent_config('DEFAULT/dnsmasq_dns_server').with_value('1.2.3.4')
should contain_file('/etc/neutron/dnsmasq-neutron.conf').with(
:mode => '0755',
@ -102,6 +144,7 @@ describe 'cloud::network::dhcp' do
end
it_configures 'openstack network dhcp'
it_configures 'openstack network dhcp with custom nameserver'
end
context 'on RedHat platforms' do
@ -114,6 +157,7 @@ describe 'cloud::network::dhcp' do
end
it_configures 'openstack network dhcp'
it_configures 'openstack network dhcp with custom nameserver'
end
end