From 48a89dfeea1be8a5ec9c2f7a873bf4b8b31eaa9e Mon Sep 17 00:00:00 2001 From: David Moreau-Simard Date: Tue, 27 Sep 2016 10:45:42 -0400 Subject: [PATCH] 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 --- manifests/service_validation.pp | 26 ++++++----- .../openstacklib_service_validation_spec.rb | 45 ++++++++++--------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/manifests/service_validation.pp b/manifests/service_validation.pp index 11147393..4528a452 100644 --- a/manifests/service_validation.pp +++ b/manifests/service_validation.pp @@ -37,6 +37,10 @@ # The provider to use for the exec command; # string; optional; default to 'shell' # +# [*refreshonly*] +# If the service validation should only occur on a refresh/notification; +# boolean; optional; default to false +# # [*timeout*] # The maximum time the command should take; # string; optional; default to '60' @@ -62,11 +66,12 @@ define openstacklib::service_validation( $service_name = $name, $path = '/usr/bin:/bin:/usr/sbin:/sbin', $provider = shell, + $refreshonly = false, + $timeout = '60', $tries = '10', $try_sleep = '2', $onlyif = undef, $unless = undef, - $timeout = '60', ) { if $onlyif and $unless { @@ -74,15 +79,16 @@ define openstacklib::service_validation( } exec { "execute ${service_name} validation": - path => $path, - provider => $provider, - command => $command, - timeout => $timeout, - tries => $tries, - try_sleep => $try_sleep, - onlyif => $onlyif, - unless => $unless, - logoutput => 'on_failure', + command => $command, + path => $path, + provider => $provider, + refreshonly => $refreshonly, + timeout => $timeout, + tries => $tries, + try_sleep => $try_sleep, + onlyif => $onlyif, + unless => $unless, + logoutput => 'on_failure', } anchor { "create ${service_name} anchor": diff --git a/spec/defines/openstacklib_service_validation_spec.rb b/spec/defines/openstacklib_service_validation_spec.rb index 26be77ff..fe68edaa 100644 --- a/spec/defines/openstacklib_service_validation_spec.rb +++ b/spec/defines/openstacklib_service_validation_spec.rb @@ -33,13 +33,14 @@ describe 'openstacklib::service_validation' do end it { is_expected.to contain_exec("execute #{title} validation").with( - :path => '/usr/bin:/bin:/usr/sbin:/sbin', - :provider => 'shell', - :command => 'nova list', - :timeout => '60', - :tries => '10', - :try_sleep => '2', - :logoutput => 'on_failure', + :path => '/usr/bin:/bin:/usr/sbin:/sbin', + :provider => 'shell', + :command => 'nova list', + :refreshonly => false, + :timeout => '60', + :tries => '10', + :try_sleep => '2', + :logoutput => 'on_failure', )} it { is_expected.to contain_anchor("create #{title} anchor").with( @@ -54,13 +55,14 @@ describe 'openstacklib::service_validation' do end it { is_expected.to contain_exec("execute #{title} validation").with( - :path => '/usr/bin:/bin:/usr/sbin:/sbin', - :provider => 'shell', - :command => 'nova list', - :timeout => '60', - :tries => '10', - :try_sleep => '2', - :unless => 'pwd', + :path => '/usr/bin:/bin:/usr/sbin:/sbin', + :provider => 'shell', + :command => 'nova list', + :refreshonly => false, + :timeout => '60', + :tries => '10', + :try_sleep => '2', + :unless => 'pwd', )} it { is_expected.to contain_anchor("create #{title} anchor").with( @@ -75,13 +77,14 @@ describe 'openstacklib::service_validation' do end it { is_expected.to contain_exec("execute #{title} validation").with( - :path => '/usr/bin:/bin:/usr/sbin:/sbin', - :provider => 'shell', - :command => 'nova list', - :timeout => '60', - :tries => '10', - :try_sleep => '2', - :onlyif => 'pwd', + :path => '/usr/bin:/bin:/usr/sbin:/sbin', + :provider => 'shell', + :command => 'nova list', + :refreshonly => false, + :timeout => '60', + :tries => '10', + :try_sleep => '2', + :onlyif => 'pwd', )} it { is_expected.to contain_anchor("create #{title} anchor").with(