Service Validation for Nova-API
As an option, validate Nova API service with a default or custom command, and if the service is up and running, create a Puppet Anchor. Change-Id: Ifec05a8409f1d6fabd62f2005478c3dca8104a27
This commit is contained in:
@@ -120,6 +120,26 @@
|
|||||||
# (optional) Enable or not Nova API v3
|
# (optional) Enable or not Nova API v3
|
||||||
# Defaults to false
|
# 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(
|
class nova::api(
|
||||||
$admin_password,
|
$admin_password,
|
||||||
$enabled = false,
|
$enabled = false,
|
||||||
@@ -149,6 +169,8 @@ class nova::api(
|
|||||||
$ratelimits = undef,
|
$ratelimits = undef,
|
||||||
$ratelimits_factory =
|
$ratelimits_factory =
|
||||||
'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory',
|
'nova.api.openstack.compute.limits:RateLimitingMiddleware.factory',
|
||||||
|
$validate = false,
|
||||||
|
$validation_options = {},
|
||||||
# DEPRECATED PARAMETER
|
# DEPRECATED PARAMETER
|
||||||
$workers = undef,
|
$workers = undef,
|
||||||
$conductor_workers = undef,
|
$conductor_workers = undef,
|
||||||
@@ -218,10 +240,11 @@ class nova::api(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if $auth_uri {
|
if $auth_uri {
|
||||||
nova_config { 'keystone_authtoken/auth_uri': value => $auth_uri; }
|
$auth_uri_real = $auth_uri
|
||||||
} else {
|
} 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 {
|
if $auth_version {
|
||||||
nova_config { 'keystone_authtoken/auth_version': value => $auth_version; }
|
nova_config { 'keystone_authtoken/auth_version': value => $auth_version; }
|
||||||
@@ -309,4 +332,14 @@ class nova::api(
|
|||||||
'filter:authtoken/auth_admin_prefix': ensure => absent;
|
'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]'})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ describe 'nova::api' do
|
|||||||
:ensure => 'present',
|
:ensure => 'present',
|
||||||
:notify => 'Service[nova-api]'
|
:notify => 'Service[nova-api]'
|
||||||
)
|
)
|
||||||
|
should_not contain_exec('validate_nova_api')
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'configures keystone_authtoken middleware' do
|
it 'configures keystone_authtoken middleware' do
|
||||||
@@ -182,6 +183,45 @@ describe 'nova::api' do
|
|||||||
end
|
end
|
||||||
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
|
context 'while not managing service state' do
|
||||||
before do
|
before do
|
||||||
params.merge!({
|
params.merge!({
|
||||||
|
|||||||
Reference in New Issue
Block a user