summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@getchef.com>2014-09-03 14:11:29 -0700
committerChris Doherty <cdoherty@getchef.com>2014-09-10 16:34:17 -0700
commit32f7f6526e07053ba972129883eb016caf3ca731 (patch)
tree60488e59d5371fec44de3f3fe1aa81e1215133c0 /lib
parent494d2b5c32c7295fc4f0c95b0ca01af65f7c80c3 (diff)
downloadchef-32f7f6526e07053ba972129883eb016caf3ca731.tar.gz
'timeout' -> 'delay_mins'; add a run_context() shim for RebootPending.
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/provider/reboot.rb6
-rw-r--r--lib/chef/rebooter.rb12
-rw-r--r--lib/chef/resource/reboot.rb6
-rw-r--r--lib/chef/run_context.rb1
4 files changed, 15 insertions, 10 deletions
diff --git a/lib/chef/provider/reboot.rb b/lib/chef/provider/reboot.rb
index 3cfe576067..1890c4e8bc 100644
--- a/lib/chef/provider/reboot.rb
+++ b/lib/chef/provider/reboot.rb
@@ -35,7 +35,7 @@ class Chef
def load_current_resource
@current_resource ||= Chef::Resource::Reboot.new(@new_resource.name)
@current_resource.reason(@new_resource.reason)
- @current_resource.timeout(@new_resource.timeout)
+ @current_resource.delay_mins(@new_resource.delay_mins)
@current_resource.timestamp(@new_resource.timestamp)
@current_resource
end
@@ -43,8 +43,8 @@ class Chef
def action_request
Chef::Log.warn "Reboot requested:'#{@new_resource.name}'"
node.run_context.request_reboot(
- :reboot_timeout => @new_resource.timeout,
- :reboot_reason => @new_resource.reason,
+ :delay_mins => @new_resource.delay_mins,
+ :reason => @new_resource.reason,
:timestamp => Time.now,
:requested_by => @new_resource.name
)
diff --git a/lib/chef/rebooter.rb b/lib/chef/rebooter.rb
index 83bc40c7ad..ab3673c720 100644
--- a/lib/chef/rebooter.rb
+++ b/lib/chef/rebooter.rb
@@ -29,23 +29,27 @@ class Chef
include Chef::DSL::RebootPending
include Chef::Mixin::ShellOut
- attr_reader :node, :reboot_info
+ attr_reader :reboot_info
+
+ # shims for RebootPending.
+ attr_reader :node, :run_context
def initialize(node)
@node = node
+ @run_context = node.run_context
@reboot_info = node.run_context.reboot_info
end
def reboot!
Chef::Log.warn "Totally would have rebooted here. #{@reboot_info.inspect}"
cmd = if Chef::Platform.windows?
- "shutdown /r /t #{reboot_info[:timeout]} /c \"#{reboot_info[:reason]}\""
+ "shutdown /r /t #{reboot_info[:delay_mins]} /c \"#{reboot_info[:reason]}\""
else
- shutdown_time = reboot_info[:reboot_timeout] > 0 ? reboot_info[:reboot_timeout] : "now"
+ shutdown_time = reboot_info[:delay_mins] > 0 ? reboot_info[:reboot_timeout] : "now"
"shutdown -h #{shutdown_time}"
end
- # shell_out!(cmd)
Chef::Log.warn "Shutdown command: '#{cmd}'"
+ #shell_out!(cmd)
end
def self.reboot_if_needed!(node)
diff --git a/lib/chef/resource/reboot.rb b/lib/chef/resource/reboot.rb
index 4c683337d5..71c34be891 100644
--- a/lib/chef/resource/reboot.rb
+++ b/lib/chef/resource/reboot.rb
@@ -28,7 +28,7 @@ class Chef
@allowed_actions = [:request, :cancel]
@reason = "Reboot by Chef"
- @timeout = 0
+ @delay_mins = 0
# no default action just now.
end
@@ -37,8 +37,8 @@ class Chef
set_or_return(:reason, arg, :kind_of => String)
end
- def timeout(arg=nil)
- set_or_return(:timeout, arg, :kind_of => Fixnum)
+ def delay_mins(arg=nil)
+ set_or_return(:delay_mins, arg, :kind_of => Fixnum)
end
def timestamp(arg=nil)
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index c8eb5b8c85..b41173e12b 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -288,6 +288,7 @@ ERROR_MESSAGE
end
def cancel_reboot
+ Chef::Log::warn "Changing reboot status from #{@reboot_info.inspect} to {}"
@reboot_info = {}
end