add command_options to glance::cache::[cleaner|pruner]
The parameter command_options allows to add options (like config file to use) to the cron job command. This makes it also possible to redirect the output. Extend tests, to support different operating systems and test parameters. Change-Id: I12a76e742db7279eafa3f3ec3c92947ff551b782
This commit is contained in:
parent
246842f13c
commit
b8a59c7706
18
manifests/cache/cleaner.pp
vendored
18
manifests/cache/cleaner.pp
vendored
@ -19,18 +19,24 @@
|
||||
# [*weekday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*command_options*]
|
||||
# command options to add to the cronjob
|
||||
# (eg. point to config file, or redirect output)
|
||||
# (optional) Defaults to ''.
|
||||
#
|
||||
class glance::cache::cleaner (
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
$minute = 1,
|
||||
$hour = 0,
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
$command_options = '',
|
||||
) {
|
||||
|
||||
include glance::params
|
||||
|
||||
cron { 'glance-cache-cleaner':
|
||||
command => $glance::params::cache_cleaner_command,
|
||||
command => "${glance::params::cache_cleaner_command} ${command_options}",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
user => 'glance',
|
||||
minute => $minute,
|
||||
|
18
manifests/cache/pruner.pp
vendored
18
manifests/cache/pruner.pp
vendored
@ -19,18 +19,24 @@
|
||||
# [*weekday*]
|
||||
# (optional) Defaults to '*'.
|
||||
#
|
||||
# [*command_options*]
|
||||
# command options to add to the cronjob
|
||||
# (eg. point to config file, or redirect output)
|
||||
# (optional) Defaults to ''.
|
||||
#
|
||||
class glance::cache::pruner (
|
||||
$minute = '*/30',
|
||||
$hour = '*',
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
$minute = '*/30',
|
||||
$hour = '*',
|
||||
$monthday = '*',
|
||||
$month = '*',
|
||||
$weekday = '*',
|
||||
$command_options = '',
|
||||
) {
|
||||
|
||||
include glance::params
|
||||
|
||||
cron { 'glance-cache-pruner':
|
||||
command => $glance::params::cache_pruner_command,
|
||||
command => "${glance::params::cache_pruner_command} ${command_options}",
|
||||
environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
user => 'glance',
|
||||
minute => $minute,
|
||||
|
@ -2,21 +2,64 @@ require 'spec_helper'
|
||||
|
||||
describe 'glance::cache::cleaner' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
shared_examples_for 'glance cache cleaner' do
|
||||
|
||||
context 'when default parameters' do
|
||||
|
||||
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
|
||||
|
||||
context 'when overriding parameters' do
|
||||
let :params do
|
||||
{
|
||||
:minute => 59,
|
||||
:hour => 23,
|
||||
:monthday => '1',
|
||||
:month => '2',
|
||||
:weekday => '3',
|
||||
:command_options => '--config-dir /etc/glance/',
|
||||
}
|
||||
end
|
||||
it 'configures a cron' do
|
||||
should contain_cron('glance-cache-cleaner').with(
|
||||
:command => 'glance-cache-cleaner --config-dir /etc/glance/',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
:user => 'glance',
|
||||
:minute => 59,
|
||||
:hour => 23,
|
||||
:monthday => '1',
|
||||
:month => '2',
|
||||
:weekday => '3'
|
||||
)
|
||||
end
|
||||
end
|
||||
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 => '*',
|
||||
:require => 'Package[glance-api]'
|
||||
)
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
include_examples 'glance cache cleaner'
|
||||
it { should contain_cron('glance-cache-cleaner').with(:require => 'Package[glance-api]')}
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
include_examples 'glance cache cleaner'
|
||||
it { should contain_cron('glance-cache-cleaner').with(:require => 'Package[openstack-glance]')}
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -2,21 +2,64 @@ require 'spec_helper'
|
||||
|
||||
describe 'glance::cache::pruner' do
|
||||
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
shared_examples_for 'glance cache pruner' do
|
||||
|
||||
context 'when default parameters' do
|
||||
|
||||
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
|
||||
|
||||
context 'when overriding parameters' do
|
||||
let :params do
|
||||
{
|
||||
:minute => 59,
|
||||
:hour => 23,
|
||||
:monthday => '1',
|
||||
:month => '2',
|
||||
:weekday => '3',
|
||||
:command_options => '--config-dir /etc/glance/',
|
||||
}
|
||||
end
|
||||
it 'configures a cron' do
|
||||
should contain_cron('glance-cache-pruner').with(
|
||||
:command => 'glance-cache-pruner --config-dir /etc/glance/',
|
||||
:environment => 'PATH=/bin:/usr/bin:/usr/sbin',
|
||||
:user => 'glance',
|
||||
:minute => 59,
|
||||
:hour => 23,
|
||||
:monthday => '1',
|
||||
:month => '2',
|
||||
:weekday => '3'
|
||||
)
|
||||
end
|
||||
end
|
||||
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 => '*',
|
||||
:require => 'Package[glance-api]'
|
||||
)
|
||||
context 'on Debian platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'Debian' }
|
||||
end
|
||||
include_examples 'glance cache pruner'
|
||||
it { should contain_cron('glance-cache-pruner').with(:require => 'Package[glance-api]')}
|
||||
end
|
||||
|
||||
context 'on RedHat platforms' do
|
||||
let :facts do
|
||||
{ :osfamily => 'RedHat' }
|
||||
end
|
||||
include_examples 'glance cache pruner'
|
||||
it { should contain_cron('glance-cache-pruner').with(:require => 'Package[openstack-glance]')}
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user