Merge "Service Validation for Nova-API"
This commit is contained in:
@@ -120,6 +120,26 @@
|
||||
# (optional) Enable or not Nova API v3
|
||||
# Defaults to false
|
||||
#
|
||||
# [*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 nova flavors.
|
||||
# Require validate set at True.
|
||||
# Example:
|
||||
# nova::api::validation_options:
|
||||
# nova-api:
|
||||
# command: check_nova.py
|
||||
# path: /usr/bin:/bin:/usr/sbin:/sbin
|
||||
# provider: shell
|
||||
# tries: 5
|
||||
# try_sleep: 10
|
||||
# Defaults to {}
|
||||
#
|
||||
class nova::api(
|
||||
$admin_password,
|
||||
$enabled = false,
|
||||
@@ -149,6 +169,8 @@ class nova::api(
|
||||
$ratelimits = undef,
|
||||
$ratelimits_factory =
|
||||
'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory',
|
||||
$validate = false,
|
||||
$validation_options = {},
|
||||
# DEPRECATED PARAMETER
|
||||
$workers = undef,
|
||||
$conductor_workers = undef,
|
||||
@@ -221,10 +243,11 @@ class nova::api(
|
||||
}
|
||||
|
||||
if $auth_uri {
|
||||
nova_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
||||
$auth_uri_real = $auth_uri
|
||||
} else {
|
||||
nova_config { 'keystone_authtoken/auth_uri': value => "${auth_protocol}://${auth_host}:5000/"; }
|
||||
$auth_uri_real = "${auth_protocol}://${auth_host}:5000/"
|
||||
}
|
||||
nova_config { 'keystone_authtoken/auth_uri': value => $auth_uri_real; }
|
||||
|
||||
if $auth_version {
|
||||
nova_config { 'keystone_authtoken/auth_version': value => $auth_version; }
|
||||
@@ -312,4 +335,14 @@ class nova::api(
|
||||
'filter:authtoken/auth_admin_prefix': ensure => absent;
|
||||
}
|
||||
|
||||
if $validate {
|
||||
$defaults = {
|
||||
'nova-api' => {
|
||||
'command' => "nova --os-auth-url ${auth_uri_real} --os-tenant-name ${admin_tenant_name} --os-username ${admin_user} --os-password ${admin_password} flavor-list",
|
||||
}
|
||||
}
|
||||
$validation_options_hash = merge ($defaults, $validation_options)
|
||||
create_resources('openstacklib::service_validation', $validation_options_hash, {'subscribe' => 'Service[nova-api]'})
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ describe 'nova::api' do
|
||||
:notify => 'Service[nova-api]',
|
||||
:tag => ['openstack', 'nova']
|
||||
)
|
||||
should_not contain_exec('validate_nova_api')
|
||||
end
|
||||
|
||||
it 'configures keystone_authtoken middleware' do
|
||||
@@ -184,6 +185,45 @@ describe 'nova::api' do
|
||||
end
|
||||
end
|
||||
|
||||
context 'while validating the service with default command' do
|
||||
before do
|
||||
params.merge!({
|
||||
:validate => true,
|
||||
})
|
||||
end
|
||||
it { should contain_exec('execute nova-api validation').with(
|
||||
:path => '/usr/bin:/bin:/usr/sbin:/sbin',
|
||||
:provider => 'shell',
|
||||
:tries => '10',
|
||||
:try_sleep => '2',
|
||||
:command => 'nova --os-auth-url http://127.0.0.1:5000/ --os-tenant-name services --os-username nova --os-password passw0rd flavor-list',
|
||||
)}
|
||||
|
||||
it { should contain_anchor('create nova-api anchor').with(
|
||||
:require => 'Exec[execute nova-api validation]',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'while validating the service with custom command' do
|
||||
before do
|
||||
params.merge!({
|
||||
:validate => true,
|
||||
:validation_options => { 'nova-api' => { 'command' => 'my-script' } }
|
||||
})
|
||||
end
|
||||
it { should contain_exec('execute nova-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 nova-api anchor').with(
|
||||
:require => 'Exec[execute nova-api validation]',
|
||||
)}
|
||||
end
|
||||
|
||||
context 'while not managing service state' do
|
||||
before do
|
||||
params.merge!({
|
||||
|
Reference in New Issue
Block a user