Add a refreshonly parameter to service_validation

This will allow to run the service_validation on demand when required
from a notification, for example.

Change-Id: I18ea45f39cd7f4930de4916d658653d22d8530b3
This commit is contained in:
David Moreau-Simard
2016-09-27 10:45:42 -04:00
parent adf3ce3d1d
commit 48a89dfeea
2 changed files with 40 additions and 31 deletions

View File

@@ -37,6 +37,10 @@
# The provider to use for the exec command; # The provider to use for the exec command;
# string; optional; default to 'shell' # string; optional; default to 'shell'
# #
# [*refreshonly*]
# If the service validation should only occur on a refresh/notification;
# boolean; optional; default to false
#
# [*timeout*] # [*timeout*]
# The maximum time the command should take; # The maximum time the command should take;
# string; optional; default to '60' # string; optional; default to '60'
@@ -62,11 +66,12 @@ define openstacklib::service_validation(
$service_name = $name, $service_name = $name,
$path = '/usr/bin:/bin:/usr/sbin:/sbin', $path = '/usr/bin:/bin:/usr/sbin:/sbin',
$provider = shell, $provider = shell,
$refreshonly = false,
$timeout = '60',
$tries = '10', $tries = '10',
$try_sleep = '2', $try_sleep = '2',
$onlyif = undef, $onlyif = undef,
$unless = undef, $unless = undef,
$timeout = '60',
) { ) {
if $onlyif and $unless { if $onlyif and $unless {
@@ -74,15 +79,16 @@ define openstacklib::service_validation(
} }
exec { "execute ${service_name} validation": exec { "execute ${service_name} validation":
path => $path, command => $command,
provider => $provider, path => $path,
command => $command, provider => $provider,
timeout => $timeout, refreshonly => $refreshonly,
tries => $tries, timeout => $timeout,
try_sleep => $try_sleep, tries => $tries,
onlyif => $onlyif, try_sleep => $try_sleep,
unless => $unless, onlyif => $onlyif,
logoutput => 'on_failure', unless => $unless,
logoutput => 'on_failure',
} }
anchor { "create ${service_name} anchor": anchor { "create ${service_name} anchor":

View File

@@ -33,13 +33,14 @@ describe 'openstacklib::service_validation' do
end end
it { is_expected.to contain_exec("execute #{title} validation").with( it { is_expected.to contain_exec("execute #{title} validation").with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin', :path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell', :provider => 'shell',
:command => 'nova list', :command => 'nova list',
:timeout => '60', :refreshonly => false,
:tries => '10', :timeout => '60',
:try_sleep => '2', :tries => '10',
:logoutput => 'on_failure', :try_sleep => '2',
:logoutput => 'on_failure',
)} )}
it { is_expected.to contain_anchor("create #{title} anchor").with( it { is_expected.to contain_anchor("create #{title} anchor").with(
@@ -54,13 +55,14 @@ describe 'openstacklib::service_validation' do
end end
it { is_expected.to contain_exec("execute #{title} validation").with( it { is_expected.to contain_exec("execute #{title} validation").with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin', :path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell', :provider => 'shell',
:command => 'nova list', :command => 'nova list',
:timeout => '60', :refreshonly => false,
:tries => '10', :timeout => '60',
:try_sleep => '2', :tries => '10',
:unless => 'pwd', :try_sleep => '2',
:unless => 'pwd',
)} )}
it { is_expected.to contain_anchor("create #{title} anchor").with( it { is_expected.to contain_anchor("create #{title} anchor").with(
@@ -75,13 +77,14 @@ describe 'openstacklib::service_validation' do
end end
it { is_expected.to contain_exec("execute #{title} validation").with( it { is_expected.to contain_exec("execute #{title} validation").with(
:path => '/usr/bin:/bin:/usr/sbin:/sbin', :path => '/usr/bin:/bin:/usr/sbin:/sbin',
:provider => 'shell', :provider => 'shell',
:command => 'nova list', :command => 'nova list',
:timeout => '60', :refreshonly => false,
:tries => '10', :timeout => '60',
:try_sleep => '2', :tries => '10',
:onlyif => 'pwd', :try_sleep => '2',
:onlyif => 'pwd',
)} )}
it { is_expected.to contain_anchor("create #{title} anchor").with( it { is_expected.to contain_anchor("create #{title} anchor").with(