Merge "Service Validation for Glance-API"

This commit is contained in:
Jenkins 2014-12-23 03:37:35 +00:00 committed by Gerrit Code Review
commit 390cd7787e
2 changed files with 76 additions and 0 deletions

View File

@ -157,6 +157,27 @@
# [*os_region_name*]
# (optional) Sets the keystone region to use.
# Defaults to 'RegionOne'.
#
# [*validate*]
# (optional) Whether to validate the service is working after any service refreshes
# Defaults to false
#
# [*validation_options*]
# (optional) Service validation options
# Should be a hash of options defined in openstacklib::service_validation
# If empty, defaults values are taken from openstacklib function.
# Default command list images.
# Require validate set at True.
# Example:
# glance::api::validation_options:
# glance-api:
# command: check_glance-api.py
# path: /usr/bin:/bin:/usr/sbin:/sbin
# provider: shell
# tries: 5
# try_sleep: 10
# Defaults to {}
#
class glance::api(
$keystone_password,
$verbose = false,
@ -194,6 +215,8 @@ class glance::api(
$database_idle_timeout = 3600,
$image_cache_dir = '/var/lib/glance/image-cache',
$os_region_name = 'RegionOne',
$validate = false,
$validation_options = {},
# DEPRECATED PARAMETERS
$mysql_module = undef,
) inherits glance {
@ -429,4 +452,15 @@ class glance::api(
hasstatus => true,
hasrestart => true,
}
if $validate {
$defaults = {
'glance-api' => {
'command' => "glance --os-auth-url ${auth_url} --os-tenant-name ${keystone_tenant} --os-username ${keystone_user} --os-password ${keystone_password} image-list",
}
}
$validation_options_hash = merge ($defaults, $validation_options)
create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Service[glance-api]'})
}
}

View File

@ -90,6 +90,8 @@ describe 'glance::api' do
'hasrestart' => true
) }
it { should_not contain_exec('validate_nova_api') }
it 'should lay down default api config' do
[
'verbose',
@ -157,6 +159,7 @@ describe 'glance::api' do
end
end
end
end
describe 'with disabled service managing' do
@ -337,6 +340,45 @@ describe 'glance::api' do
it { should contain_glance_api_config('glance_store/stores').with_value("glance.store.filesystem.Store,glance.store.http.Store") }
end
describe 'while validating the service with default command' do
let :params do
default_params.merge({
:validate => true,
})
end
it { should contain_exec('execute glance-api validation').with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell',
:tries => '10',
:try_sleep => '2',
:command => 'glance --os-auth-url http://localhost:5000/v2.0 --os-tenant-name services --os-username glance --os-password ChangeMe image-list',
)}
it { should contain_anchor('create glance-api anchor').with(
:require => 'Exec[execute glance-api validation]',
)}
end
describe 'while validating the service with custom command' do
let :params do
default_params.merge({
:validate => true,
:validation_options => { 'glance-api' => { 'command' => 'my-script' } }
})
end
it { should contain_exec('execute glance-api validation').with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell',
:tries => '10',
:try_sleep => '2',
:command => 'my-script',
)}
it { should contain_anchor('create glance-api anchor').with(
:require => 'Exec[execute glance-api validation]',
)}
end
describe 'on Debian platforms' do
let :facts do
{ :osfamily => 'Debian' }