5 shared_examples 'nova' do
7 context 'with default parameters' do
9 it 'installs packages' do
10 should contain_package('python').with_ensure('present')
11 should contain_package('python-greenlet').with(
13 :require => 'Package[python]'
15 should contain_package('python-nova').with(
17 :require => 'Package[python-greenlet]'
19 should contain_package('nova-common').with(
20 :name => platform_params[:nova_common_package],
22 :tag => ['openstack', 'nova']
26 it 'does not create user and group' do
27 should_not contain_group('nova').with(
30 :before => 'User[nova]'
32 should_not contain_user('nova').with(
36 :home => '/var/lib/nova',
38 :shell => '/bin/false'
42 it 'creates various files and folders' do
43 should contain_file('/var/log/nova').with(
44 :ensure => 'directory',
47 :require => 'Package[nova-common]'
49 should contain_file('/etc/nova/nova.conf').with(
53 :require => 'Package[nova-common]'
57 it 'configures rootwrap' do
58 should contain_nova_config('DEFAULT/rootwrap_config').with_value('/etc/nova/rootwrap.conf')
61 it { should contain_exec('networking-refresh').with(
62 :command => '/sbin/ifdown -a ; /sbin/ifup -a',
66 it 'configures image service' do
67 should contain_nova_config('DEFAULT/image_service').with_value('nova.image.glance.GlanceImageService')
68 should contain_nova_config('glance/api_servers').with_value('localhost:9292')
71 it 'configures auth_strategy' do
72 should contain_nova_config('DEFAULT/auth_strategy').with_value('keystone')
73 should_not contain_nova_config('DEFAULT/use_deprecated_auth').with_value(false)
76 it 'configures rabbit' do
77 should contain_nova_config('DEFAULT/rpc_backend').with_value('rabbit')
78 should contain_nova_config('DEFAULT/rabbit_host').with_value('localhost')
79 should contain_nova_config('DEFAULT/rabbit_password').with_value('guest').with_secret(true)
80 should contain_nova_config('DEFAULT/rabbit_port').with_value('5672')
81 should contain_nova_config('DEFAULT/rabbit_userid').with_value('guest')
82 should contain_nova_config('DEFAULT/rabbit_virtual_host').with_value('/')
85 it 'configures various things' do
86 should contain_nova_config('DEFAULT/verbose').with_value(false)
87 should contain_nova_config('DEFAULT/debug').with_value(false)
88 should contain_nova_config('DEFAULT/log_dir').with_value('/var/log/nova')
89 should contain_nova_config('DEFAULT/state_path').with_value('/var/lib/nova')
90 should contain_nova_config('DEFAULT/lock_path').with_value(platform_params[:lock_path])
91 should contain_nova_config('DEFAULT/service_down_time').with_value('60')
92 should contain_nova_config('DEFAULT/rootwrap_config').with_value('/etc/nova/rootwrap.conf')
93 should contain_nova_config('DEFAULT/report_interval').with_value('10')
94 should contain_nova_config('DEFAULT/os_region_name').with_ensure('absent')
97 it 'installs utilities' do
98 should contain_class('nova::utilities')
101 it 'disables syslog' do
102 should contain_nova_config('DEFAULT/use_syslog').with_value(false)
106 context 'with overridden parameters' do
111 :log_dir => '/var/log/nova2',
112 :image_service => 'nova.image.local.LocalImageService',
113 :rabbit_host => 'rabbit',
114 :rabbit_userid => 'rabbit_user',
115 :rabbit_port => '5673',
116 :rabbit_password => 'password',
117 :rabbit_ha_queues => 'undef',
118 :lock_path => '/var/locky/path',
119 :state_path => '/var/lib/nova2',
120 :service_down_time => '120',
121 :auth_strategy => 'foo',
122 :ensure_package => '2012.1.1-15.el6',
123 :memcached_servers => ['memcached01:11211', 'memcached02:11211'],
124 :install_utilities => false,
125 :notification_driver => 'ceilometer.compute.nova_notifier',
126 :notification_topics => 'openstack',
127 :notify_api_faults => true,
128 :nova_user_id => '499',
129 :nova_group_id => '499',
130 :report_interval => '60',
131 :nova_shell => '/bin/bash',
132 :os_region_name => 'MyRegion' }
135 it 'creates user and group' do
136 should contain_group('nova').with(
137 :ensure => 'present',
140 :before => 'Package[nova-common]'
142 should contain_user('nova').with(
143 :ensure => 'present',
146 :home => '/var/lib/nova',
147 :managehome => false,
148 :shell => '/bin/bash',
151 :require => 'Group[nova]'
155 it 'installs packages' do
156 should contain_package('nova-common').with('ensure' => '2012.1.1-15.el6')
157 should contain_package('python-nova').with('ensure' => '2012.1.1-15.el6')
160 it 'configures image service' do
161 should contain_nova_config('DEFAULT/image_service').with_value('nova.image.local.LocalImageService')
162 should_not contain_nova_config('glance/api_servers')
165 it 'configures auth_strategy' do
166 should contain_nova_config('DEFAULT/auth_strategy').with_value('foo')
167 should_not contain_nova_config('DEFAULT/use_deprecated_auth').with_value(true)
170 it 'configures rabbit' do
171 should contain_nova_config('DEFAULT/rpc_backend').with_value('rabbit')
172 should contain_nova_config('DEFAULT/rabbit_host').with_value('rabbit')
173 should contain_nova_config('DEFAULT/rabbit_password').with_value('password').with_secret(true)
174 should contain_nova_config('DEFAULT/rabbit_port').with_value('5673')
175 should contain_nova_config('DEFAULT/rabbit_userid').with_value('rabbit_user')
176 should contain_nova_config('DEFAULT/rabbit_virtual_host').with_value('/')
179 it 'configures memcached_servers' do
180 should contain_nova_config('DEFAULT/memcached_servers').with_value('memcached01:11211,memcached02:11211')
183 it 'configures various things' do
184 should contain_nova_config('DEFAULT/verbose').with_value(true)
185 should contain_nova_config('DEFAULT/debug').with_value(true)
186 should contain_nova_config('DEFAULT/log_dir').with_value('/var/log/nova2')
187 should contain_nova_config('DEFAULT/state_path').with_value('/var/lib/nova2')
188 should contain_nova_config('DEFAULT/lock_path').with_value('/var/locky/path')
189 should contain_nova_config('DEFAULT/service_down_time').with_value('120')
190 should contain_nova_config('DEFAULT/notification_driver').with_value('ceilometer.compute.nova_notifier')
191 should contain_nova_config('DEFAULT/notification_topics').with_value('openstack')
192 should contain_nova_config('DEFAULT/notify_api_faults').with_value(true)
193 should contain_nova_config('DEFAULT/report_interval').with_value('60')
194 should contain_nova_config('DEFAULT/os_region_name').with_value('MyRegion')
197 context 'with multiple notification_driver' do
198 before { params.merge!( :notification_driver => ['ceilometer.compute.nova_notifier', 'nova.openstack.common.notifier.rpc_notifier']) }
200 it { should contain_nova_config('DEFAULT/notification_driver').with_value(
201 'ceilometer.compute.nova_notifier,nova.openstack.common.notifier.rpc_notifier'
205 it 'does not install utilities' do
206 should_not contain_class('nova::utilities')
209 context 'with logging directory disabled' do
210 before { params.merge!( :log_dir => false) }
212 it { should contain_nova_config('DEFAULT/log_dir').with_ensure('absent') }
216 context 'with wrong notify_on_state_change parameter' do
218 { :notify_on_state_change => 'vm_status' }
221 it 'configures database' do
222 should contain_nova_config('DEFAULT/notify_on_state_change').with_ensure('absent')
226 context 'with notify_on_state_change parameter' do
228 { :notify_on_state_change => 'vm_state' }
231 it 'configures database' do
232 should contain_nova_config('DEFAULT/notify_on_state_change').with_value('vm_state')
236 context 'with syslog enabled' do
238 { :use_syslog => 'true' }
241 it 'configures syslog' do
242 should contain_nova_config('DEFAULT/use_syslog').with_value(true)
243 should contain_nova_config('DEFAULT/syslog_log_facility').with_value('LOG_USER')
247 context 'with syslog enabled and log_facility parameter' do
249 { :use_syslog => 'true',
250 :log_facility => 'LOG_LOCAL0' }
253 it 'configures syslog' do
254 should contain_nova_config('DEFAULT/use_syslog').with_value(true)
255 should contain_nova_config('DEFAULT/syslog_log_facility').with_value('LOG_LOCAL0')
259 context 'with rabbit_hosts parameter' do
261 { :rabbit_hosts => ['rabbit:5673', 'rabbit2:5674'] }
264 it 'configures rabbit' do
265 should_not contain_nova_config('DEFAULT/rabbit_host')
266 should_not contain_nova_config('DEFAULT/rabbit_port')
267 should contain_nova_config('DEFAULT/rabbit_hosts').with_value('rabbit:5673,rabbit2:5674')
268 should contain_nova_config('DEFAULT/rabbit_ha_queues').with_value(true)
269 should contain_nova_config('DEFAULT/rabbit_use_ssl').with_value(false)
270 should contain_nova_config('DEFAULT/amqp_durable_queues').with_value(false)
271 should contain_nova_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
272 should contain_nova_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
273 should contain_nova_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
274 should contain_nova_config('DEFAULT/kombu_ssl_version').with_ensure('absent')
278 context 'with rabbit_hosts parameter (one server)' do
280 { :rabbit_hosts => ['rabbit:5673'] }
283 it 'configures rabbit' do
284 should_not contain_nova_config('DEFAULT/rabbit_host')
285 should_not contain_nova_config('DEFAULT/rabbit_port')
286 should contain_nova_config('DEFAULT/rabbit_hosts').with_value('rabbit:5673')
287 should contain_nova_config('DEFAULT/rabbit_ha_queues').with_value(true)
288 should contain_nova_config('DEFAULT/rabbit_use_ssl').with_value(false)
289 should contain_nova_config('DEFAULT/amqp_durable_queues').with_value(false)
293 context 'with rabbit_ha_queues set to true' do
295 { :rabbit_ha_queues => 'true' }
298 it 'configures rabbit' do
299 should contain_nova_config('DEFAULT/rabbit_ha_queues').with_value(true)
303 context 'with amqp_durable_queues parameter' do
305 { :rabbit_hosts => ['rabbit:5673'],
306 :amqp_durable_queues => 'true' }
309 it 'configures rabbit' do
310 should_not contain_nova_config('DEFAULT/rabbit_host')
311 should_not contain_nova_config('DEFAULT/rabbit_port')
312 should contain_nova_config('DEFAULT/rabbit_hosts').with_value('rabbit:5673')
313 should contain_nova_config('DEFAULT/rabbit_ha_queues').with_value(true)
314 should contain_nova_config('DEFAULT/rabbit_use_ssl').with_value(false)
315 should contain_nova_config('DEFAULT/amqp_durable_queues').with_value(true)
316 should contain_nova_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
317 should contain_nova_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
318 should contain_nova_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
319 should contain_nova_config('DEFAULT/kombu_ssl_version').with_ensure('absent')
323 context 'with rabbit ssl enabled with kombu' do
325 { :rabbit_hosts => ['rabbit:5673'],
326 :rabbit_use_ssl => 'true',
327 :kombu_ssl_ca_certs => '/etc/ca.cert',
328 :kombu_ssl_certfile => '/etc/certfile',
329 :kombu_ssl_keyfile => '/etc/key',
330 :kombu_ssl_version => 'TLSv1', }
333 it 'configures rabbit' do
334 should contain_nova_config('DEFAULT/rabbit_use_ssl').with_value(true)
335 should contain_nova_config('DEFAULT/kombu_ssl_ca_certs').with_value('/etc/ca.cert')
336 should contain_nova_config('DEFAULT/kombu_ssl_certfile').with_value('/etc/certfile')
337 should contain_nova_config('DEFAULT/kombu_ssl_keyfile').with_value('/etc/key')
338 should contain_nova_config('DEFAULT/kombu_ssl_version').with_value('TLSv1')
342 context 'with rabbit ssl enabled without kombu' do
344 { :rabbit_hosts => ['rabbit:5673'],
345 :rabbit_use_ssl => 'true', }
348 it 'configures rabbit' do
349 should contain_nova_config('DEFAULT/rabbit_use_ssl').with_value(true)
350 should contain_nova_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
351 should contain_nova_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
352 should contain_nova_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
353 should contain_nova_config('DEFAULT/kombu_ssl_version').with_value('TLSv1')
357 context 'with rabbit ssl disabled' do
360 :rabbit_password => 'pass',
361 :rabbit_use_ssl => false,
362 :kombu_ssl_version => 'TLSv1',
366 it 'configures rabbit' do
367 should contain_nova_config('DEFAULT/rabbit_use_ssl').with_value('false')
368 should contain_nova_config('DEFAULT/kombu_ssl_ca_certs').with_ensure('absent')
369 should contain_nova_config('DEFAULT/kombu_ssl_certfile').with_ensure('absent')
370 should contain_nova_config('DEFAULT/kombu_ssl_keyfile').with_ensure('absent')
371 should contain_nova_config('DEFAULT/kombu_ssl_version').with_ensure('absent')
375 context 'with qpid rpc_backend' do
377 { :rpc_backend => 'qpid' }
380 context 'with default parameters' do
381 it 'configures qpid' do
382 should contain_nova_config('DEFAULT/rpc_backend').with_value('qpid')
383 should contain_nova_config('DEFAULT/qpid_hostname').with_value('localhost')
384 should contain_nova_config('DEFAULT/qpid_port').with_value('5672')
385 should contain_nova_config('DEFAULT/qpid_username').with_value('guest')
386 should contain_nova_config('DEFAULT/qpid_password').with_value('guest').with_secret(true)
387 should contain_nova_config('DEFAULT/qpid_heartbeat').with_value('60')
388 should contain_nova_config('DEFAULT/qpid_protocol').with_value('tcp')
389 should contain_nova_config('DEFAULT/qpid_tcp_nodelay').with_value(true)
393 context 'with qpid_password parameter (without qpid_sasl_mechanisms)' do
395 params.merge!({ :qpid_password => 'guest' })
397 it { should contain_nova_config('DEFAULT/qpid_sasl_mechanisms').with_ensure('absent') }
400 context 'with qpid_password parameter (with qpid_sasl_mechanisms)' do
403 :qpid_password => 'guest',
404 :qpid_sasl_mechanisms => 'A'
407 it { should contain_nova_config('DEFAULT/qpid_sasl_mechanisms').with_value('A') }
410 context 'with qpid_password parameter (with array of qpid_sasl_mechanisms)' do
413 :qpid_password => 'guest',
414 :qpid_sasl_mechanisms => [ 'DIGEST-MD5', 'GSSAPI', 'PLAIN' ]
417 it { should contain_nova_config('DEFAULT/qpid_sasl_mechanisms').with_value('DIGEST-MD5 GSSAPI PLAIN') }
421 context 'with qpid rpc_backend with old parameter' do
423 { :rpc_backend => 'nova.openstack.common.rpc.impl_qpid' }
426 it { should contain_nova_config('DEFAULT/rpc_backend').with_value('nova.openstack.common.rpc.impl_qpid') }
429 context 'with rabbitmq rpc_backend with old parameter' do
431 { :rpc_backend => 'nova.openstack.common.rpc.impl_kombu' }
434 it { should contain_nova_config('DEFAULT/rpc_backend').with_value('nova.openstack.common.rpc.impl_kombu') }
437 context 'with ssh public key' do
440 :nova_public_key => {'type' => 'ssh-rsa',
445 it 'should install ssh public key' do
446 should contain_ssh_authorized_key('nova-migration-public-key').with(
447 :ensure => 'present',
454 context 'with ssh public key missing key type' do
457 :nova_public_key => {'type' => '',
462 it 'should raise an error' do
464 should contain_ssh_authorized_key('nova-migration-public-key').with(
465 :ensure => 'present',
469 }.to raise_error Puppet::Error, /You must provide both a key type and key data./
473 context 'with ssh public key missing key data' do
476 :nova_public_key => {'type' => 'ssh-rsa',
481 it 'should raise an error' do
483 should contain_ssh_authorized_key('nova-migration-public-key').with(
484 :ensure => 'present',
488 }.to raise_error Puppet::Error, /You must provide both a key type and key data./
492 context 'with ssh private key' do
495 :nova_private_key => {'type' => 'ssh-rsa',
500 it 'should install ssh private key' do
501 should contain_file('/var/lib/nova/.ssh/id_rsa').with(
502 :content => 'keydata'
507 context 'with ssh private key missing key type' do
510 :nova_private_key => {'type' => '',
515 it 'should raise an error' do
517 should contain_file('/var/lib/nova/.ssh/id_rsa').with(
518 :content => 'keydata'
520 }.to raise_error Puppet::Error, /You must provide both a key type and key data./
524 context 'with ssh private key having incorrect key type' do
527 :nova_private_key => {'type' => 'invalid',
532 it 'should raise an error' do
534 should contain_file('/var/lib/nova/.ssh/id_rsa').with(
535 :content => 'keydata'
537 }.to raise_error Puppet::Error, /Unable to determine name of private key file./
541 context 'with ssh private key missing key data' do
544 :nova_private_key => {'type' => 'ssh-rsa',
549 it 'should raise an error' do
551 should contain_file('/var/lib/nova/.ssh/id_rsa').with(
552 :content => 'keydata'
554 }.to raise_error Puppet::Error, /You must provide both a key type and key data./
558 context 'with SSL socket options set' do
562 :enabled_ssl_apis => ['ec2', 'osapi_compute'],
563 :cert_file => '/path/to/cert',
564 :ca_file => '/path/to/ca',
565 :key_file => '/path/to/key',
569 it { should contain_nova_config('DEFAULT/enabled_ssl_apis').with_value('ec2,osapi_compute') }
570 it { should contain_nova_config('DEFAULT/ssl_ca_file').with_value('/path/to/ca') }
571 it { should contain_nova_config('DEFAULT/ssl_cert_file').with_value('/path/to/cert') }
572 it { should contain_nova_config('DEFAULT/ssl_key_file').with_value('/path/to/key') }
575 context 'with SSL socket options set with wrong parameters' do
579 :enabled_ssl_apis => ['ec2'],
580 :ca_file => '/path/to/ca',
581 :key_file => '/path/to/key',
585 it_raises 'a Puppet::Error', /The cert_file parameter is required when use_ssl is set to true/
588 context 'with SSL socket options set to false' do
592 :enabled_ssl_apis => [],
599 it { should contain_nova_config('DEFAULT/enabled_ssl_apis').with_ensure('absent') }
600 it { should contain_nova_config('DEFAULT/ssl_ca_file').with_ensure('absent') }
601 it { should contain_nova_config('DEFAULT/ssl_cert_file').with_ensure('absent') }
602 it { should contain_nova_config('DEFAULT/ssl_key_file').with_ensure('absent') }
607 context 'on Debian platforms' do
609 { :osfamily => 'Debian',
610 :operatingsystem => 'Debian' }
613 let :platform_params do
614 { :nova_common_package => 'nova-common',
615 :lock_path => '/var/lock/nova' }
618 it_behaves_like 'nova'
619 it 'creates the log folder with the right group for Debian' do
620 should contain_file('/var/log/nova').with(:group => 'nova')
624 context 'on Ubuntu platforms' do
626 { :osfamily => 'Debian',
627 :operatingsystem => 'Ubuntu' }
630 let :platform_params do
631 { :nova_common_package => 'nova-common',
632 :lock_path => '/var/lock/nova' }
635 it_behaves_like 'nova'
636 it 'creates the log folder with the right group for Ubuntu' do
637 should contain_file('/var/log/nova').with(:group => 'adm')
641 context 'on RedHat platforms' do
643 { :osfamily => 'RedHat' }
646 let :platform_params do
647 { :nova_common_package => 'openstack-nova-common',
648 :lock_path => '/var/lib/nova/tmp' }
651 it_behaves_like 'nova'
653 it 'creates the log folder with the right group for RedHat' do
654 should contain_file('/var/log/nova').with(:group => 'nova')