diff --git a/manifests/volume.pp b/manifests/volume.pp index cb6fd65e..0a3d7db6 100644 --- a/manifests/volume.pp +++ b/manifests/volume.pp @@ -14,10 +14,28 @@ # (Optional) Whether to start/stop the service. # Defaults to 'true'. # +# [*volume_clear*] +# (Optional) Method used to wipe old volumes. +# Defaults to $::os_service_default. +# +# [*volume_clear_size*] +# (Optional) Size in MiB to wipe at start of old volumes. +# Set to '0' means all. +# Defaults to $::os_service_default. +# +# [*volume_clear_ionice*] +# (Optional) The flag to pass to ionice to alter the i/o priority +# of the process used to zero a volume after deletion, +# for example "-c3" for idle only priority. +# Defaults to $::os_service_default. +# class cinder::volume ( - $package_ensure = 'present', - $enabled = true, - $manage_service = true + $package_ensure = 'present', + $enabled = true, + $manage_service = true, + $volume_clear = $::os_service_default, + $volume_clear_size = $::os_service_default, + $volume_clear_ionice = $::os_service_default, ) { include ::cinder::params @@ -52,4 +70,10 @@ class cinder::volume ( require => Package['cinder'], tag => 'cinder-service', } + + cinder_config { + 'DEFAULT/volume_clear': value => $volume_clear; + 'DEFAULT/volume_clear_size': value => $volume_clear_size; + 'DEFAULT/volume_clear_ionice': value => $volume_clear_ionice; + } } diff --git a/spec/classes/cinder_volume_spec.rb b/spec/classes/cinder_volume_spec.rb index e84c2b26..aaed49ff 100644 --- a/spec/classes/cinder_volume_spec.rb +++ b/spec/classes/cinder_volume_spec.rb @@ -15,6 +15,9 @@ describe 'cinder::volume' do 'hasstatus' => true, 'tag' => 'cinder-service', )} + it { is_expected.to contain_cinder_config('DEFAULT/volume_clear').with_value('') } + it { is_expected.to contain_cinder_config('DEFAULT/volume_clear_size').with_value('') } + it { is_expected.to contain_cinder_config('DEFAULT/volume_clear_ionice').with_value('') } describe 'with manage_service false' do let :params do @@ -24,4 +27,19 @@ describe 'cinder::volume' do is_expected.to contain_service('cinder-volume').without_ensure end end + + describe 'with volume_clear parameters' do + let :params do + { + 'volume_clear' => 'none', + 'volume_clear_size' => '10', + 'volume_clear_ionice' => '-c3', + } + end + it 'should set volume_clear parameters' do + is_expected.to contain_cinder_config('DEFAULT/volume_clear').with_value('none') + is_expected.to contain_cinder_config('DEFAULT/volume_clear_size').with_value('10') + is_expected.to contain_cinder_config('DEFAULT/volume_clear_ionice').with_value('-c3') + end + end end