summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Doherty <cdoherty@getchef.com>2014-09-05 15:58:31 -0700
committerChris Doherty <cdoherty@getchef.com>2014-09-10 16:34:28 -0700
commite1cb4798d79b857da01ae964abd95eae88fee476 (patch)
treebdcec42c166f10189ab92009c33ac28e9e8c739a
parent5f0d5d63ec6a30ff90b10bf01782e698a34ffbfa (diff)
downloadchef-e1cb4798d79b857da01ae964abd95eae88fee476.tar.gz
Chef::Rebooter -> Chef::Platform::Rebooter
-rw-r--r--lib/chef/client.rb4
-rw-r--r--lib/chef/platform/rebooter.rb (renamed from lib/chef/rebooter.rb)44
-rw-r--r--spec/functional/rebooter_spec.rb7
3 files changed, 28 insertions, 27 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 4aeecd03c2..dbd26b26c0 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -44,7 +44,7 @@ require 'chef/resource_reporter'
require 'chef/run_lock'
require 'chef/policy_builder'
require 'chef/request_id'
-require 'chef/rebooter'
+require 'chef/platform/rebooter'
require 'ohai'
require 'rbconfig'
@@ -438,7 +438,7 @@ class Chef
@events.run_completed(node)
# rebooting has to be the last thing we do, no exceptions.
- Chef::Rebooter.reboot_if_needed!(node)
+ Chef::Platform::Rebooter.reboot_if_needed!(node)
true
rescue Exception => e
diff --git a/lib/chef/rebooter.rb b/lib/chef/platform/rebooter.rb
index f88276694c..d471b3838e 100644
--- a/lib/chef/rebooter.rb
+++ b/lib/chef/platform/rebooter.rb
@@ -22,32 +22,34 @@ require 'chef/platform'
# this has whatever's needed to reboot the server, on whichever platform.
class Chef
- module Rebooter
- extend Chef::Mixin::ShellOut
+ class Platform
+ module Rebooter
+ extend Chef::Mixin::ShellOut
- class << self
- attr_reader :node, :reboot_info
+ class << self
+ attr_reader :node, :reboot_info
- def reboot!
- cmd = if Chef::Platform.windows?
- "shutdown /r /t #{reboot_info[:delay_mins]} /c \"#{reboot_info[:reason]}\""
- else
- shutdown_time = reboot_info[:delay_mins] > 0 ? reboot_info[:reboot_timeout] : "now"
- "shutdown -r #{shutdown_time}"
- end
- Chef::Log.warn "Shutdown command (not running): '#{cmd}'"
+ def reboot!
+ cmd = if Chef::Platform.windows?
+ "shutdown /r /t #{reboot_info[:delay_mins]} /c \"#{reboot_info[:reason]}\""
+ else
+ shutdown_time = reboot_info[:delay_mins] > 0 ? reboot_info[:reboot_timeout] : "now"
+ "shutdown -r #{shutdown_time}"
+ end
+ Chef::Log.warn "Shutdown command (not running): '#{cmd}'"
- shell_out!(cmd)
- end
+ shell_out!(cmd)
+ end
- def reboot_if_needed!(this_node)
- @node = this_node
- @reboot_info = node.run_context.reboot_info
+ def reboot_if_needed!(this_node)
+ @node = this_node
+ @reboot_info = node.run_context.reboot_info
- if node.run_context.reboot_requested?
- reboot!
+ if node.run_context.reboot_requested?
+ reboot!
+ end
end
- end
- end # end class instance stuff.
+ end # end class instance stuff.
+ end
end
end
diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb
index 24356b90aa..c6140caeff 100644
--- a/spec/functional/rebooter_spec.rb
+++ b/spec/functional/rebooter_spec.rb
@@ -18,7 +18,7 @@
require 'spec_helper'
-describe Chef::Rebooter do
+describe Chef::Platform::Rebooter do
let(:reboot_info) do
{
@@ -41,12 +41,11 @@ describe Chef::Rebooter do
Chef::RunContext.new(node, {}, events)
end
- let(:rebooter) { Chef::Rebooter }
-
- let(:sheller) { Chef::Rebooter }
+ let(:rebooter) { Chef::Platform::Rebooter }
describe '#reboot_if_needed!' do
+ # test that it's producing the correct commands.
it 'should call #shell_out! when reboot has been requested' do
run_context.request_reboot(reboot_info)