3 describe 'nova::api' do
10 { :admin_password => 'passw0rd' }
14 { :processorcount => 5 }
17 shared_examples 'nova-api' do
19 context 'with default parameters' do
21 it 'installs nova-api package and service' do
22 should contain_service('nova-api').with(
23 :name => platform_params[:nova_api_service],
28 should contain_package('nova-api').with(
29 :name => platform_params[:nova_api_package],
31 :notify => 'Service[nova-api]',
32 :tag => ['openstack', 'nova']
34 should_not contain_exec('validate_nova_api')
37 it 'configures keystone_authtoken middleware' do
38 should contain_nova_config(
39 'keystone_authtoken/auth_host').with_value('127.0.0.1')
40 should contain_nova_config(
41 'keystone_authtoken/auth_port').with_value('35357')
42 should contain_nova_config(
43 'keystone_authtoken/auth_protocol').with_value('http')
44 should contain_nova_config(
45 'keystone_authtoken/auth_uri').with_value('http://127.0.0.1:5000/')
46 should contain_nova_config(
47 'keystone_authtoken/auth_admin_prefix').with_ensure('absent')
48 should contain_nova_config(
49 'keystone_authtoken/auth_version').with_ensure('absent')
50 should contain_nova_config(
51 'keystone_authtoken/admin_tenant_name').with_value('services')
52 should contain_nova_config(
53 'keystone_authtoken/admin_user').with_value('nova')
54 should contain_nova_config(
55 'keystone_authtoken/admin_password').with_value('passw0rd').with_secret(true)
58 it 'configures various stuff' do
59 should contain_nova_config('DEFAULT/ec2_listen').with('value' => '0.0.0.0')
60 should contain_nova_config('DEFAULT/osapi_compute_listen').with('value' => '0.0.0.0')
61 should contain_nova_config('DEFAULT/metadata_listen').with('value' => '0.0.0.0')
62 should contain_nova_config('DEFAULT/osapi_volume_listen').with('value' => '0.0.0.0')
63 should contain_nova_config('DEFAULT/osapi_compute_workers').with('value' => '5')
64 should contain_nova_config('DEFAULT/ec2_workers').with('value' => '5')
65 should contain_nova_config('DEFAULT/metadata_workers').with('value' => '5')
68 it 'do not configure v3 api' do
69 should contain_nova_config('osapi_v3/enabled').with('value' => false)
72 it 'unconfigures neutron_metadata proxy' do
73 should contain_nova_config('neutron/service_metadata_proxy').with(:value => false)
74 should contain_nova_config('neutron/metadata_proxy_shared_secret').with(:ensure => 'absent')
78 context 'with deprecated parameters' do
84 it 'configures various stuff' do
85 should contain_nova_config('DEFAULT/osapi_compute_workers').with('value' => '1')
89 context 'with overridden parameters' do
93 :ensure_package => '2012.1-2',
94 :auth_host => '10.0.0.1',
96 :auth_protocol => 'https',
97 :auth_admin_prefix => '/keystone/admin',
98 :auth_uri => 'https://10.0.0.1:9999/',
99 :auth_version => 'v3.0',
100 :admin_tenant_name => 'service2',
101 :admin_user => 'nova2',
102 :admin_password => 'passw0rd2',
103 :api_bind_address => '192.168.56.210',
104 :metadata_listen => '127.0.0.1',
105 :volume_api_class => 'nova.volume.cinder.API',
106 :use_forwarded_for => false,
107 :ratelimits => '(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)',
108 :neutron_metadata_proxy_shared_secret => 'secrete',
109 :osapi_compute_workers => 1,
110 :metadata_workers => 2,
112 :keystone_ec2_url => 'https://example.com:5000/v2.0/ec2tokens',
113 :pci_alias => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\",\"name\":\"graphic_card\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"name\":\"network_card\"}]"
117 it 'installs nova-api package and service' do
118 should contain_package('nova-api').with(
119 :name => platform_params[:nova_api_package],
120 :ensure => '2012.1-2',
121 :tag => ['openstack', 'nova']
123 should contain_service('nova-api').with(
124 :name => platform_params[:nova_api_service],
125 :ensure => 'running',
131 it 'configures keystone_authtoken middleware' do
132 should contain_nova_config(
133 'keystone_authtoken/auth_host').with_value('10.0.0.1')
134 should contain_nova_config(
135 'keystone_authtoken/auth_port').with_value('1234')
136 should contain_nova_config(
137 'keystone_authtoken/auth_protocol').with_value('https')
138 should contain_nova_config(
139 'keystone_authtoken/auth_admin_prefix').with_value('/keystone/admin')
140 should contain_nova_config(
141 'keystone_authtoken/auth_uri').with_value('https://10.0.0.1:9999/')
142 should contain_nova_config(
143 'keystone_authtoken/auth_version').with_value('v3.0')
144 should contain_nova_config(
145 'keystone_authtoken/admin_tenant_name').with_value('service2')
146 should contain_nova_config(
147 'keystone_authtoken/admin_user').with_value('nova2')
148 should contain_nova_config(
149 'keystone_authtoken/admin_password').with_value('passw0rd2').with_secret(true)
150 should contain_nova_paste_api_ini(
151 'filter:ratelimit/limits').with_value('(GET, "*", .*, 100, MINUTE);(POST, "*", .*, 200, MINUTE)')
154 it 'configures various stuff' do
155 should contain_nova_config('DEFAULT/ec2_listen').with('value' => '192.168.56.210')
156 should contain_nova_config('DEFAULT/osapi_compute_listen').with('value' => '192.168.56.210')
157 should contain_nova_config('DEFAULT/metadata_listen').with('value' => '127.0.0.1')
158 should contain_nova_config('DEFAULT/osapi_volume_listen').with('value' => '192.168.56.210')
159 should contain_nova_config('DEFAULT/use_forwarded_for').with('value' => false)
160 should contain_nova_config('DEFAULT/osapi_compute_workers').with('value' => '1')
161 should contain_nova_config('DEFAULT/metadata_workers').with('value' => '2')
162 should contain_nova_config('neutron/service_metadata_proxy').with('value' => true)
163 should contain_nova_config('neutron/metadata_proxy_shared_secret').with('value' => 'secrete')
164 should contain_nova_config('DEFAULT/keystone_ec2_url').with('value' => 'https://example.com:5000/v2.0/ec2tokens')
167 it 'configure nova api v3' do
168 should contain_nova_config('osapi_v3/enabled').with('value' => true)
171 it 'configures nova pci_alias entries' do
172 should contain_nova_config('DEFAULT/pci_alias').with(
173 'value' => "[{\"vendor_id\":\"8086\",\"product_id\":\"0126\",\"name\":\"graphic_card\"},{\"vendor_id\":\"9096\",\"product_id\":\"1520\",\"name\":\"network_card\"}]"
185 ].each do |auth_admin_prefix|
186 context "with auth_admin_prefix_containing incorrect value #{auth_admin_prefix}" do
188 params.merge!({ :auth_admin_prefix => auth_admin_prefix })
190 it { expect { should contain_nova_config('keystone_authtoken/auth_admin_prefix') }.to \
191 raise_error(Puppet::Error, /validate_re\(\): "#{auth_admin_prefix}" does not match/) }
195 context 'while validating the service with default command' do
201 it { should contain_exec('execute nova-api validation').with(
202 :path => '/usr/bin:/bin:/usr/sbin:/sbin',
203 :provider => 'shell',
206 :command => 'nova --os-auth-url http://127.0.0.1:5000/ --os-tenant-name services --os-username nova --os-password passw0rd flavor-list',
209 it { should contain_anchor('create nova-api anchor').with(
210 :require => 'Exec[execute nova-api validation]',
214 context 'while validating the service with custom command' do
218 :validation_options => { 'nova-api' => { 'command' => 'my-script' } }
221 it { should contain_exec('execute nova-api validation').with(
222 :path => '/usr/bin:/bin:/usr/sbin:/sbin',
223 :provider => 'shell',
226 :command => 'my-script',
229 it { should contain_anchor('create nova-api anchor').with(
230 :require => 'Exec[execute nova-api validation]',
234 context 'while not managing service state' do
238 :manage_service => false,
242 it { should contain_service('nova-api').without_ensure }
245 context 'with default database parameters' do
246 let :pre_condition do
250 it { should_not contain_nova_config('database/connection') }
251 it { should_not contain_nova_config('database/slave_connection') }
252 it { should_not contain_nova_config('database/idle_timeout').with_value('3600') }
255 context 'with overridden database parameters' do
256 let :pre_condition do
258 database_connection => 'mysql://user:pass@db/db',
259 slave_connection => 'mysql://user:pass@slave/db',
260 database_idle_timeout => '30',
265 it { should contain_nova_config('database/connection').with_value('mysql://user:pass@db/db').with_secret(true) }
266 it { should contain_nova_config('database/slave_connection').with_value('mysql://user:pass@slave/db').with_secret(true) }
267 it { should contain_nova_config('database/idle_timeout').with_value('30') }
272 context 'on Debian platforms' do
274 facts.merge!( :osfamily => 'Debian' )
277 let :platform_params do
278 { :nova_api_package => 'nova-api',
279 :nova_api_service => 'nova-api' }
282 it_behaves_like 'nova-api'
285 context 'on RedHat platforms' do
287 facts.merge!( :osfamily => 'RedHat' )
290 let :platform_params do
291 { :nova_api_package => 'openstack-nova-api',
292 :nova_api_service => 'openstack-nova-api' }
295 it_behaves_like 'nova-api'