6 { :package_ensure => 'present',
9 :core_plugin => 'linuxbridge',
10 :rabbit_host => '127.0.0.1',
12 :rabbit_hosts => false,
13 :rabbit_user => 'guest',
14 :rabbit_password => 'guest',
15 :rabbit_virtual_host => '/',
16 :kombu_reconnect_delay => '1.0',
17 :log_dir => '/var/log/neutron',
18 :report_interval => '30',
22 shared_examples_for 'neutron' do
24 context 'and if rabbit_host parameter is provided' do
25 it_configures 'a neutron base installation'
28 context 'and if rabbit_hosts parameter is provided' do
30 params.delete(:rabbit_host)
31 params.delete(:rabbit_port)
34 context 'with one server' do
35 before { params.merge!( :rabbit_hosts => ['127.0.0.1:5672'] ) }
36 it_configures 'a neutron base installation'
37 it_configures 'rabbit HA with a single virtual host'
40 context 'with multiple servers' do
41 before { params.merge!( :rabbit_hosts => ['rabbit1:5672', 'rabbit2:5672'] ) }
42 it_configures 'a neutron base installation'
43 it_configures 'rabbit HA with multiple hosts'
46 it 'configures logging' do
47 should contain_neutron_config('DEFAULT/log_file').with_ensure('absent')
48 should contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir])
53 it_configures 'with SSL enabled with kombu'
54 it_configures 'with SSL enabled without kombu'
55 it_configures 'with SSL disabled'
56 it_configures 'with SSL wrongly configured'
57 it_configures 'with SSL and kombu wrongly configured'
58 it_configures 'with SSL socket options set'
59 it_configures 'with SSL socket options set with wrong parameters'
60 it_configures 'with SSL socket options set to false'
61 it_configures 'with syslog disabled'
62 it_configures 'with syslog enabled'
63 it_configures 'with syslog enabled and custom settings'
64 it_configures 'with log_file specified'
65 it_configures 'with logging disabled'
66 it_configures 'without service_plugins'
67 it_configures 'with service_plugins'
70 shared_examples_for 'a neutron base installation' do
72 it { should contain_class('neutron::params') }
74 it 'configures neutron configuration folder' do
75 should contain_file('/etc/neutron/').with(
76 :ensure => 'directory',
80 :require => 'Package[neutron]'
84 it 'configures neutron configuration file' do
85 should contain_file('/etc/neutron/neutron.conf').with(
89 :require => 'Package[neutron]'
93 it 'installs neutron package' do
94 should contain_package('neutron').with(
96 :name => platform_params[:common_package_name]
100 it 'configures credentials for rabbit' do
101 should contain_neutron_config('DEFAULT/rabbit_userid').with_value( params[:rabbit_user] )
102 should contain_neutron_config('DEFAULT/rabbit_password').with_value( params[:rabbit_password] )
103 should contain_neutron_config('DEFAULT/rabbit_password').with_secret( true )
104 should contain_neutron_config('DEFAULT/rabbit_virtual_host').with_value( params[:rabbit_virtual_host] )
105 should contain_neutron_config('DEFAULT/kombu_reconnect_delay').with_value( params[:kombu_reconnect_delay] )
108 it 'configures neutron.conf' do
109 should contain_neutron_config('DEFAULT/verbose').with_value( params[:verbose] )
110 should contain_neutron_config('DEFAULT/bind_host').with_value('0.0.0.0')
111 should contain_neutron_config('DEFAULT/bind_port').with_value('9696')
112 should contain_neutron_config('DEFAULT/auth_strategy').with_value('keystone')
113 should contain_neutron_config('DEFAULT/core_plugin').with_value( params[:core_plugin] )
114 should contain_neutron_config('DEFAULT/base_mac').with_value('fa:16:3e:00:00:00')
115 should contain_neutron_config('DEFAULT/mac_generation_retries').with_value(16)
116 should contain_neutron_config('DEFAULT/dhcp_lease_duration').with_value(86400)
117 should contain_neutron_config('DEFAULT/dhcp_agents_per_network').with_value(1)
118 should contain_neutron_config('DEFAULT/network_device_mtu').with_ensure('absent')
119 should contain_neutron_config('DEFAULT/dhcp_agent_notification').with_value(true)
120 should contain_neutron_config('DEFAULT/allow_bulk').with_value(true)
121 should contain_neutron_config('DEFAULT/allow_pagination').with_value(false)
122 should contain_neutron_config('DEFAULT/allow_sorting').with_value(false)
123 should contain_neutron_config('DEFAULT/allow_overlapping_ips').with_value(false)
124 should contain_neutron_config('DEFAULT/api_extensions_path').with_value(nil)
125 should contain_neutron_config('DEFAULT/control_exchange').with_value('neutron')
126 should contain_neutron_config('agent/root_helper').with_value('sudo neutron-rootwrap /etc/neutron/rootwrap.conf')
127 should contain_neutron_config('agent/report_interval').with_value('30')
131 shared_examples_for 'rabbit HA with a single virtual host' do
132 it 'in neutron.conf' do
133 should_not contain_neutron_config('DEFAULT/rabbit_host')
134 should_not contain_neutron_config('DEFAULT/rabbit_port')
135 should contain_neutron_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts] )
136 should contain_neutron_config('DEFAULT/rabbit_ha_queues').with_value(true)
140 shared_examples_for 'rabbit HA with multiple hosts' do
141 it 'in neutron.conf' do
142 should_not contain_neutron_config('DEFAULT/rabbit_host')
143 should_not contain_neutron_config('DEFAULT/rabbit_port')
144 should contain_neutron_config('DEFAULT/rabbit_hosts').with_value( params[:rabbit_hosts].join(',') )
145 should contain_neutron_config('DEFAULT/rabbit_ha_queues').with_value(true)
149 shared_examples_for 'with SSL socket options set' do
153 :cert_file => '/path/to/cert',
154 :key_file => '/path/to/key',
155 :ca_file => '/path/to/ca'
159 it { should contain_neutron_config('DEFAULT/use_ssl').with_value('true') }
160 it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') }
161 it { should contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') }
162 it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') }
165 shared_examples_for 'with SSL socket options set with wrong parameters' do
169 :key_file => '/path/to/key',
170 :ca_file => '/path/to/ca'
174 it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/
177 shared_examples_for 'with SSL socket options set to false' do
187 it { should contain_neutron_config('DEFAULT/use_ssl').with_value('false') }
188 it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_ensure('absent') }
189 it { should contain_neutron_config('DEFAULT/ssl_key_file').with_ensure('absent') }
190 it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') }
193 shared_examples_for 'with SSL socket options set and no ca_file' do
197 :cert_file => '/path/to/cert',
198 :key_file => '/path/to/key'
202 it { should contain_neutron_config('DEFAULT/use_ssl').with_value('true') }
203 it { should contain_neutron_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') }
204 it { should contain_neutron_config('DEFAULT/ssl_key_file').with_value('/path/to/key') }
205 it { should contain_neutron_config('DEFAULT/ssl_ca_file').with_ensure('absent') }
208 shared_examples_for 'with SSL socket options disabled with ca_file' do
212 :ca_file => '/path/to/ca'
216 it_raises 'a Puppet::Error', /The ca_file parameter requires that use_ssl to be set to true/
219 shared_examples_for 'with syslog disabled' do
220 it { should contain_neutron_config('DEFAULT/use_syslog').with_value(false) }
223 shared_examples_for 'with SSL enabled with kombu' do
226 :rabbit_use_ssl => true,
227 :kombu_ssl_ca_certs => '/path/to/ssl/ca/certs',
228 :kombu_ssl_certfile => '/path/to/ssl/cert/file',
229 :kombu_ssl_keyfile => '/path/to/ssl/keyfile',
230 :kombu_ssl_version => 'TLSv1'
235 should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true')
236 should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_value('/path/to/ssl/ca/certs')
237 should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_value('/path/to/ssl/cert/file')
238 should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_value('/path/to/ssl/keyfile')
239 should contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('TLSv1')
243 shared_examples_for 'with SSL enabled without kombu' do
246 :rabbit_use_ssl => true
251 should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('true')
252 should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
253 should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
254 should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
255 should contain_neutron_config('DEFAULT/kombu_ssl_version').with_value('TLSv1')
259 shared_examples_for 'with SSL disabled' do
262 :rabbit_use_ssl => false,
263 :kombu_ssl_version => 'TLSv1'
268 should contain_neutron_config('DEFAULT/rabbit_use_ssl').with_value('false')
269 should contain_neutron_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
270 should contain_neutron_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
271 should contain_neutron_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
272 should contain_neutron_config('DEFAULT/kombu_ssl_version').with_ensure('absent')
276 shared_examples_for 'with SSL wrongly configured' do
279 :rabbit_use_ssl => false
283 context 'with SSL disabled' do
285 context 'with kombu_ssl_ca_certs parameter' do
286 before { params.merge!(:kombu_ssl_ca_certs => '/path/to/ssl/ca/certs') }
287 it_raises 'a Puppet::Error', /The kombu_ssl_ca_certs parameter requires rabbit_use_ssl to be set to true/
290 context 'with kombu_ssl_certfile parameter' do
291 before { params.merge!(:kombu_ssl_certfile => '/path/to/ssl/cert/file') }
292 it_raises 'a Puppet::Error', /The kombu_ssl_certfile parameter requires rabbit_use_ssl to be set to true/
295 context 'with kombu_ssl_keyfile parameter' do
296 before { params.merge!(:kombu_ssl_keyfile => '/path/to/ssl/keyfile') }
297 it_raises 'a Puppet::Error', /The kombu_ssl_keyfile parameter requires rabbit_use_ssl to be set to true/
303 shared_examples_for 'with SSL and kombu wrongly configured' do
306 :rabbit_use_ssl => true,
307 :kombu_ssl_certfile => '/path/to/ssl/cert/file',
308 :kombu_ssl_keyfile => '/path/to/ssl/keyfile'
312 context 'without required parameters' do
314 context 'without kombu_ssl_keyfile parameter' do
315 before { params.delete(:kombu_ssl_keyfile) }
316 it_raises 'a Puppet::Error', /The kombu_ssl_certfile and kombu_ssl_keyfile parameters must be used together/
322 shared_examples_for 'with syslog enabled' do
325 :use_syslog => 'true'
330 should contain_neutron_config('DEFAULT/use_syslog').with_value(true)
331 should contain_neutron_config('DEFAULT/syslog_log_facility').with_value('LOG_USER')
335 shared_examples_for 'with syslog enabled and custom settings' do
338 :use_syslog => 'true',
339 :log_facility => 'LOG_LOCAL0'
344 should contain_neutron_config('DEFAULT/use_syslog').with_value(true)
345 should contain_neutron_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0')
349 shared_examples_for 'with log_file specified' do
352 :log_file => '/var/log/neutron/server.log',
353 :log_dir => '/tmp/log/neutron'
356 it 'configures logging' do
357 should contain_neutron_config('DEFAULT/log_file').with_value(params[:log_file])
358 should contain_neutron_config('DEFAULT/log_dir').with_value(params[:log_dir])
362 shared_examples_for 'with logging disabled' do
363 before { params.merge!(
368 should contain_neutron_config('DEFAULT/log_file').with_ensure('absent')
369 should contain_neutron_config('DEFAULT/log_dir').with_ensure('absent')
373 shared_examples_for 'without service_plugins' do
374 it { should_not contain_neutron_config('DEFAULT/service_plugins') }
377 shared_examples_for 'with service_plugins' do
380 :service_plugins => ['router','firewall','lbaas','vpnaas','metering']
385 should contain_neutron_config('DEFAULT/service_plugins').with_value('router,firewall,lbaas,vpnaas,metering')
390 shared_examples_for 'with network_device_mtu defined' do
393 :network_device_mtu => 9000
398 should contina_neutron_config('DEFAULT/network_device_mtu').with_value(params[:newtork_device_mtu])
402 context 'on Debian platforms' do
404 { :osfamily => 'Debian' }
407 let :platform_params do
408 { :common_package_name => 'neutron-common' }
411 it_configures 'neutron'
414 context 'on RedHat platforms' do
416 { :osfamily => 'RedHat' }
419 let :platform_params do
420 { :common_package_name => 'openstack-neutron' }
423 it_configures 'neutron'