diff options
author | Chris Doherty <cdoherty@getchef.com> | 2014-09-08 16:34:10 -0700 |
---|---|---|
committer | Chris Doherty <cdoherty@getchef.com> | 2014-09-10 16:34:31 -0700 |
commit | 6d3aa8327224e25d6011b46b8873cab5e7a56031 (patch) | |
tree | e51748930df65a9b87f7535a8685b38be5280b92 /lib | |
parent | 2456f0c47df72268e1c73c9c5109771a59f10938 (diff) | |
download | chef-6d3aa8327224e25d6011b46b8873cab5e7a56031.tar.gz |
Add #reboot! to Rebooter for immediate rebooting; make Rebooter stateless;
add specs.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/platform/rebooter.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/chef/platform/rebooter.rb b/lib/chef/platform/rebooter.rb index 75213b3fc7..08224b4d77 100644 --- a/lib/chef/platform/rebooter.rb +++ b/lib/chef/platform/rebooter.rb @@ -26,9 +26,10 @@ class Chef extend Chef::Mixin::ShellOut class << self - attr_reader :node, :reboot_info - def reboot! + def reboot!(node) + reboot_info = node.run_context.reboot_info + cmd = if Chef::Platform.windows? "shutdown /r /t #{reboot_info[:delay_mins]} /c \"#{reboot_info[:reason]}\"" else @@ -36,15 +37,13 @@ class Chef "shutdown -r +#{reboot_info[:delay_mins]} \"#{reboot_info[:reason]}\"" end + Chef::Log.warn "Rebooting server at a recipe's request. Details: #{reboot_info.inspect}" shell_out!(cmd) end - def reboot_if_needed!(this_node) - @node = this_node - @reboot_info = node.run_context.reboot_info - + def reboot_if_needed!(node) if node.run_context.reboot_requested? - reboot! + reboot!(node) end end end |