diff --git a/manifests/cache/cleaner.pp b/manifests/cache/cleaner.pp new file mode 100644 index 00000000..181c627e --- /dev/null +++ b/manifests/cache/cleaner.pp @@ -0,0 +1,42 @@ +# == Class: glance::cache::cleaner +# +# Installs a cron job to run glance-cache-cleaner. +# +# === Parameters +# +# [*minute*] +# (optional) Defaults to '1'. +# +# [*hour*] +# (optional) Defaults to '0'. +# +# [*monthday*] +# (optional) Defaults to '*'. +# +# [*month*] +# (optional) Defaults to '*'. +# +# [*weekday*] +# (optional) Defaults to '*'. +# +class glance::cache::cleaner ( + $minute = 1, + $hour = 0, + $monthday = '*', + $month = '*', + $weekday = '*', +) { + + include glance::params + + cron { 'glance-cache-cleaner': + command => $glance::params::cache_cleaner_command, + environment => 'PATH=/bin:/usr/bin:/usr/sbin', + user => 'glance', + minute => $minute, + hour => $hour, + monthday => $monthday, + month => $month, + weekday => $weekday + } +} diff --git a/manifests/cache/pruner.pp b/manifests/cache/pruner.pp new file mode 100644 index 00000000..9c3811a9 --- /dev/null +++ b/manifests/cache/pruner.pp @@ -0,0 +1,42 @@ +# == Class: glance::cache::pruner +# +# Installs a cron job to run glance-cache-pruner. +# +# === Parameters +# +# [*minute*] +# (optional) Defaults to '*/30'. +# +# [*hour*] +# (optional) Defaults to '*'. +# +# [*monthday*] +# (optional) Defaults to '*'. +# +# [*month*] +# (optional) Defaults to '*'. +# +# [*weekday*] +# (optional) Defaults to '*'. +# +class glance::cache::pruner ( + $minute = '*/30', + $hour = '*', + $monthday = '*', + $month = '*', + $weekday = '*', +) { + + include glance::params + + cron { 'glance-cache-pruner': + command => $glance::params::cache_pruner_command, + environment => 'PATH=/bin:/usr/bin:/usr/sbin', + user => 'glance', + minute => $minute, + hour => $hour, + monthday => $monthday, + month => $month, + weekday => $weekday + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 5b6a6ec5..5ba0e927 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -5,6 +5,9 @@ class glance::params { $client_package_name = 'python-glanceclient' $pyceph_package_name = 'python-ceph' + $cache_cleaner_command = 'glance-cache-cleaner' + $cache_pruner_command = 'glance-cache-pruner' + case $::osfamily { 'RedHat': { $package_name = 'openstack-glance' diff --git a/spec/classes/glance_cache_cleaner_spec.rb b/spec/classes/glance_cache_cleaner_spec.rb new file mode 100644 index 00000000..8b8bbe48 --- /dev/null +++ b/spec/classes/glance_cache_cleaner_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe 'glance::cache::cleaner' do + + let :facts do + { :osfamily => 'Debian' } + end + + it 'configures a cron' do + should contain_cron('glance-cache-cleaner').with( + :command => 'glance-cache-cleaner', + :environment => 'PATH=/bin:/usr/bin:/usr/sbin', + :user => 'glance', + :minute => 1, + :hour => 0, + :monthday => '*', + :month => '*', + :weekday => '*' + ) + end +end diff --git a/spec/classes/glance_cache_pruner_spec.rb b/spec/classes/glance_cache_pruner_spec.rb new file mode 100644 index 00000000..5bcf7cd2 --- /dev/null +++ b/spec/classes/glance_cache_pruner_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe 'glance::cache::pruner' do + + let :facts do + { :osfamily => 'Debian' } + end + + it 'configures a cron' do + should contain_cron('glance-cache-pruner').with( + :command => 'glance-cache-pruner', + :environment => 'PATH=/bin:/usr/bin:/usr/sbin', + :user => 'glance', + :minute => '*/30', + :hour => '*', + :monthday => '*', + :month => '*', + :weekday => '*' + ) + end +end