summaryrefslogtreecommitdiff
path: root/lib/chef/resource
diff options
context:
space:
mode:
authornimisha <nimisha.sharad@msystechnologies.com>2017-03-20 19:12:38 +0530
committernimisha <nimisha.sharad@msystechnologies.com>2017-03-31 20:47:15 +0530
commitb8a019f9e0e1ad2665c5f356bae002e544ddd56f (patch)
treed87184974bf1e99890e34af02022375e065078ba /lib/chef/resource
parentc1b5a5b0631a27c0f2e56b141d8523cc5f78200c (diff)
downloadchef-b8a019f9e0e1ad2665c5f356bae002e544ddd56f.tar.gz
Fixed Idempotency check
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
Diffstat (limited to 'lib/chef/resource')
-rw-r--r--lib/chef/resource/windows_task.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/chef/resource/windows_task.rb b/lib/chef/resource/windows_task.rb
index ee2ba92fc9..2317cddb58 100644
--- a/lib/chef/resource/windows_task.rb
+++ b/lib/chef/resource/windows_task.rb
@@ -58,12 +58,13 @@ class Chef
property :months, String
property :idle_time, Integer
property :random_delay, String
- property :execution_time_limit, String
+ property :execution_time_limit, String, default: "PT72H"
attr_accessor :exists, :status, :enabled
def after_created
validate_random_delay(random_delay, frequency) if random_delay
+ validate_start_time(start_time) if frequency == :once
validate_start_day(start_day, frequency) if start_day
validate_user_and_password(user,password)
validate_interactive_setting(interactive_enabled, password)
@@ -77,7 +78,7 @@ class Chef
def validate_random_delay(random_delay, frequency)
if [:once, :on_logon, :onstart, :on_idle].include? frequency
- raise ArgumentError, "`start_day` property is not supported with frequency: #{frequency}"
+ raise ArgumentError, "`random_delay` property is not supported with frequency: #{frequency}"
end
end
@@ -87,6 +88,10 @@ class Chef
end
end
+ def validate_start_time(start_time)
+ raise ArgumentError,"`start_time` needs to be provided with `frequency :once`" unless start_time
+ end
+
SYSTEM_USERS = ['NT AUTHORITY\SYSTEM', 'SYSTEM', 'NT AUTHORITY\LOCALSERVICE', 'NT AUTHORITY\NETWORKSERVICE'].freeze
def validate_user_and_password(user,password)
@@ -137,8 +142,8 @@ class Chef
end
def validate_create_day(day, frequency)
- unless [:weekly, :monthly].include?(frequency)
- raise 'day attribute is only valid for tasks that run weekly or monthly'
+ unless [:weekly].include?(frequency)
+ raise 'day attribute is only valid for tasks that run weekly'
end
if day.is_a?(String) && day.to_i.to_s != day
days = day.split(',')