diff options
author | nimisha <nimisha.sharad@msystechnologies.com> | 2017-03-15 17:13:45 +0530 |
---|---|---|
committer | nimisha <nimisha.sharad@msystechnologies.com> | 2017-03-31 20:47:10 +0530 |
commit | 47248829419bc68a4df28067a0382886c68f43b7 (patch) | |
tree | ec42b1195ac0d9a809cc953279b5a5dc78f18b79 /lib/chef/provider | |
parent | 7a2f9dcef5338b9ca9606bafaecfd90e0c07e97d (diff) | |
download | chef-47248829419bc68a4df28067a0382886c68f43b7.tar.gz |
Updated random_delay implementation and added execution_time_limit property
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
Diffstat (limited to 'lib/chef/provider')
-rw-r--r-- | lib/chef/provider/windows_task.rb | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb index 8a19bdde76..e32d285464 100644 --- a/lib/chef/provider/windows_task.rb +++ b/lib/chef/provider/windows_task.rb @@ -76,6 +76,7 @@ class Chef xml_options = []
xml_options << "cwd" if new_resource.cwd
xml_options << "random_delay" if new_resource.random_delay
+ xml_options << "execution_time_limit" if new_resource.execution_time_limit
update_task_xml(xml_options) unless xml_options.empty?
new_resource.updated_by_last_action true
@@ -93,7 +94,7 @@ class Chef Chef::Log.info "#{@new_resource} task ran"
end
else
- Chef::Log.debug "#{@new_resource} task doesn't exists - nothing to do"
+ Chef::Log.warn "#{@new_resource} task doesn't exists - nothing to do"
end
end
@@ -111,13 +112,13 @@ class Chef options['IT'] = '' if @new_resource.interactive_enabled
run_schtasks 'CHANGE', options
- xml_options = ["cwd", "random_delay"]
+ xml_options = ["cwd", "random_delay", "execution_time_limit"]
update_task_xml(xml_options)
new_resource.updated_by_last_action true
Chef::Log.info "Change #{@new_resource} task ran"
else
- Chef::Log.debug "#{@new_resource} task doesn't exists - nothing to do"
+ Chef::Log.warn "#{@new_resource} task doesn't exists - nothing to do"
end
end
@@ -128,7 +129,7 @@ class Chef new_resource.updated_by_last_action true
Chef::Log.info "#{@new_resource} task deleted"
else
- Chef::Log.debug "#{@new_resource} task doesn't exists - nothing to do"
+ Chef::Log.warn "#{@new_resource} task doesn't exists - nothing to do"
end
end
@@ -142,8 +143,7 @@ class Chef Chef::Log.info "#{@new_resource} task ended"
end
else
- Chef::Log.fatal "#{@new_resource} task doesn't exist - nothing to do"
- raise Errno::ENOENT, "#{@new_resource}: task does not exist, cannot end"
+ Chef::Log.warn "#{@new_resource} task doesn't exist - nothing to do"
end
end
@@ -169,10 +169,10 @@ class Chef @new_resource.updated_by_last_action true
Chef::Log.info "#{@new_resource} task disabled"
else
- Chef::Log.debug "#{@new_resource} already disabled - nothing to do"
+ Chef::Log.warn "#{@new_resource} already disabled - nothing to do"
end
else
- Chef::Log.debug "#{@new_resource} task doesn't exist - nothing to do"
+ Chef::Log.warn "#{@new_resource} task doesn't exist - nothing to do"
end
end
@@ -198,9 +198,20 @@ class Chef end
def update_task_xml(options = [])
+ # random_delay xml element is different for different frequencies
+ random_delay_xml_element = {
+ :minute => "Triggers/TimeTrigger/RandomDelay",
+ :hourly => "Triggers/TimeTrigger/RandomDelay",
+ :once => "Triggers/TimeTrigger/RandomDelay",
+ :daily => "Triggers/CalendarTrigger/RandomDelay",
+ :weekly => "Triggers/CalendarTrigger/RandomDelay",
+ :monthly => "Triggers/CalendarTrigger/RandomDelay",
+ }
+
xml_element_mapping = {
"cwd" => "Actions/Exec/WorkingDirectory",
- "random_delay" => "Triggers/TimeTrigger/RandomDelay"
+ "random_delay" => random_delay_xml_element[@new_resource.frequency],
+ "execution_time_limit" => "Settings/ExecutionTimeLimit"
}
Chef::Log.debug 'looking for existing tasks'
|