diff --git a/manifests/api.pp b/manifests/api.pp index d7cca900..8a404cd6 100644 --- a/manifests/api.pp +++ b/manifests/api.pp @@ -72,6 +72,12 @@ # (optional) Factory to use for ratelimiting # Defaults to 'cinder.api.v1.limits:RateLimitingMiddleware.factory' # +# [*default_volume_type*] +# (optional) default volume type to use. +# This should contain the name of the default volume type to use. +# If not configured, it produces an error when creating a volume +# without specifying a type. +# Defaults to 'false'. class cinder::api ( $keystone_password, $keystone_enabled = true, @@ -89,6 +95,7 @@ class cinder::api ( $enabled = true, $manage_service = true, $ratelimits = undef, + $default_volume_type = false, $ratelimits_factory = 'cinder.api.v1.limits:RateLimitingMiddleware.factory' ) { @@ -187,4 +194,15 @@ class cinder::api ( } } } + + if $default_volume_type { + cinder_config { + 'DEFAULT/default_volume_type': value => $default_volume_type; + } + } else { + cinder_config { + 'DEFAULT/default_volume_type': ensure => absent; + } + } + } diff --git a/manifests/backends.pp b/manifests/backends.pp index eb417b96..7c697193 100644 --- a/manifests/backends.pp +++ b/manifests/backends.pp @@ -9,16 +9,10 @@ # This should contain names used in ceph::backend::* resources. # Example: ['volume1', 'volume2', 'sata3'] # -# [*default_volume_type*] -# (optional) default volume type to use. -# This should contain the name of the default volume type to use. -# If not configured, it produces an error when creating a volume -# without specifying a type. -# Defaults to 'false'. -# # Author: Andrew Woodward class cinder::backends ( $enabled_backends = undef, + # DEPRECATED $default_volume_type = false ){ @@ -28,13 +22,7 @@ class cinder::backends ( } if $default_volume_type { - cinder_config { - 'DEFAULT/default_volume_type': value => $default_volume_type; - } - } else { - cinder_config { - 'DEFAULT/default_volume_type': ensure => absent; - } + fail('The default_volume_type parameter is deprecated in this class, you should declare it in cinder::api.') } } diff --git a/spec/classes/cinder_api_spec.rb b/spec/classes/cinder_api_spec.rb index 640af215..f2797e40 100644 --- a/spec/classes/cinder_api_spec.rb +++ b/spec/classes/cinder_api_spec.rb @@ -26,6 +26,9 @@ describe 'cinder::api' do should contain_cinder_config('DEFAULT/osapi_volume_listen').with( :value => '0.0.0.0' ) + should contain_cinder_config('DEFAULT/default_volume_type').with( + :ensure => 'absent' + ) should contain_cinder_api_paste_ini('filter:authtoken/service_protocol').with( :value => 'http' ) @@ -77,6 +80,17 @@ describe 'cinder::api' do end end + describe 'with a default volume type' do + let :params do + req_params.merge({'default_volume_type' => 'foo'}) + end + it 'should configure the default volume type for cinder' do + should contain_cinder_config('DEFAULT/default_volume_type').with( + :value => 'foo' + ) + end + end + describe 'with custom auth_uri' do let :params do req_params.merge({'keystone_auth_uri' => 'http://foo.bar:8080/v2.0/'}) diff --git a/spec/classes/cinder_backends_spec.rb b/spec/classes/cinder_backends_spec.rb index a0f48c1b..de990d02 100644 --- a/spec/classes/cinder_backends_spec.rb +++ b/spec/classes/cinder_backends_spec.rb @@ -46,20 +46,19 @@ describe 'cinder::backends' do it 'configures cinder.conf with default params' do should contain_cinder_config('DEFAULT/enabled_backends').with_value(p[:enabled_backends].join(',')) - should contain_cinder_config('DEFAULT/default_volume_type').with_ensure('absent') end end context 'configure cinder with a default volume type' do before :each do params.merge!( - :enabled_backends => ['lowcost', 'regular', 'premium'], + :enabled_backends => ['foo', 'bar'], :default_volume_type => 'regular' ) end - it 'configures cinder.conf with default params' do - should contain_cinder_config('DEFAULT/default_volume_type').with_value('regular') + it 'should fail to configure default volume type' do + expect { subject }.to raise_error(Puppet::Error, /The default_volume_type parameter is deprecated in this class, you should declare it in cinder::api./) end end