diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index 81fe444a9..e3968eda2 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -31,15 +31,49 @@ # will be removed from nova.conf completely. # Defaults to an empty list # +# [*remove_unused_base_images*] +# (optional) Should unused base images be removed? +# If undef is specified, remove the line in nova.conf +# otherwise, use a boolean to remove or not the base images. +# Defaults to undef +# +# [*remove_unused_kernels*] +# (optional) Should unused kernel images be removed? +# This is only safe to enable if all compute nodes +# have been updated to support this option. +# If undef is specified, remove the line in nova.conf +# otherwise, use a boolean to remove or not the kernels. +# Defaults to undef +# +# [*remove_unused_resized_minimum_age_seconds*] +# (optional) Unused resized base images younger +# than this will not be removed +# If undef is specified, remove the line in nove.conf +# otherwise, use a integer or a string to define after +# how many seconds it will be removed. +# Defaults to undef +# +# [*remove_unused_original_minimum_age_seconds*] +# (optional) Unused unresized base images younger +# than this will not be removed +# If undef is specified, remove the line in nove.conf +# otherwise, use a integer or a string to define after +# how many seconds it will be removed. +# Defaults to undef +# class nova::compute::libvirt ( - $libvirt_virt_type = 'kvm', - $vncserver_listen = '127.0.0.1', - $migration_support = false, - $libvirt_cpu_mode = false, - $libvirt_disk_cachemodes = [], + $libvirt_virt_type = 'kvm', + $vncserver_listen = '127.0.0.1', + $migration_support = false, + $libvirt_cpu_mode = false, + $libvirt_disk_cachemodes = [], + $remove_unused_base_images = undef, + $remove_unused_kernels = undef, + $remove_unused_resized_minimum_age_seconds = undef, + $remove_unused_original_minimum_age_seconds = undef, # DEPRECATED PARAMETER - $libvirt_type = false + $libvirt_type = false ) { include nova::params @@ -121,4 +155,44 @@ class nova::compute::libvirt ( 'libvirt/disk_cachemodes': ensure => absent; } } + + if $remove_unused_kernels != undef { + nova_config { + 'libvirt/remove_unused_kernels': value => $remove_unused_kernels; + } + } else { + nova_config { + 'libvirt/remove_unused_kernels': ensure => absent; + } + } + + if $remove_unused_resized_minimum_age_seconds != undef { + nova_config { + 'libvirt/remove_unused_resized_minimum_age_seconds': value => $remove_unused_resized_minimum_age_seconds; + } + } else { + nova_config { + 'libvirt/remove_unused_resized_minimum_age_seconds': ensure => absent; + } + } + + if $remove_unused_base_images != undef { + nova_config { + 'DEFAULT/remove_unused_base_images': value => $remove_unused_base_images; + } + } else { + nova_config { + 'DEFAULT/remove_unused_base_images': ensure => absent; + } + } + + if $remove_unused_original_minimum_age_seconds != undef { + nova_config { + 'DEFAULT/remove_unused_original_minimum_age_seconds': value => $remove_unused_original_minimum_age_seconds; + } + } else { + nova_config { + 'DEFAULT/remove_unused_original_minimum_age_seconds': ensure => absent; + } + } } diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index 5386dc622..48897c8bd 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -38,14 +38,22 @@ describe 'nova::compute::libvirt' do it { should contain_nova_config('libvirt/cpu_mode').with_value('host-model')} it { should contain_nova_config('libvirt/disk_cachemodes').with_ensure('absent')} it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')} + it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_ensure('absent')} + it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_ensure('absent')} + it { should contain_nova_config('libvirt/remove_unused_kernels').with_ensure('absent')} + it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_ensure('absent')} end describe 'with params' do let :params do - { :libvirt_virt_type => 'qemu', - :vncserver_listen => '0.0.0.0', - :libvirt_cpu_mode => 'host-passthrough', - :libvirt_disk_cachemodes => ['file=directsync','block=none'] + { :libvirt_virt_type => 'qemu', + :vncserver_listen => '0.0.0.0', + :libvirt_cpu_mode => 'host-passthrough', + :libvirt_disk_cachemodes => ['file=directsync','block=none'], + :remove_unused_base_images => true, + :remove_unused_kernels => true, + :remove_unused_resized_minimum_age_seconds => 3600, + :remove_unused_original_minimum_age_seconds => 3600 } end @@ -53,6 +61,10 @@ describe 'nova::compute::libvirt' do it { should contain_nova_config('libvirt/cpu_mode').with_value('host-passthrough')} it { should contain_nova_config('libvirt/disk_cachemodes').with_value('file=directsync,block=none')} it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')} + it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)} + it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)} + it { should contain_nova_config('libvirt/remove_unused_kernels').with_value(true)} + it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value(3600)} end describe 'with deprecated params' do @@ -121,17 +133,29 @@ describe 'nova::compute::libvirt' do it { should contain_nova_config('DEFAULT/compute_driver').with_value('libvirt.LibvirtDriver')} it { should contain_nova_config('libvirt/virt_type').with_value('kvm')} it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('127.0.0.1')} + it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_ensure('absent')} + it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_ensure('absent')} + it { should contain_nova_config('libvirt/remove_unused_kernels').with_ensure('absent')} + it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_ensure('absent')} end describe 'with params' do let :params do - { :libvirt_virt_type => 'qemu', - :vncserver_listen => '0.0.0.0' + { :libvirt_virt_type => 'qemu', + :vncserver_listen => '0.0.0.0', + :remove_unused_base_images => true, + :remove_unused_kernels => true, + :remove_unused_resized_minimum_age_seconds => 3600, + :remove_unused_original_minimum_age_seconds => 3600 } end it { should contain_nova_config('libvirt/virt_type').with_value('qemu')} it { should contain_nova_config('DEFAULT/vncserver_listen').with_value('0.0.0.0')} + it { should contain_nova_config('DEFAULT/remove_unused_base_images').with_value(true)} + it { should contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value(3600)} + it { should contain_nova_config('libvirt/remove_unused_kernels').with_value(true)} + it { should contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value(3600)} end describe 'with deprecated params' do