summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Roberts <chrisroberts.code@gmail.com>2012-10-03 12:46:44 -0700
committerBryan McLellan <btm@opscode.com>2012-10-15 14:13:02 -0700
commit04bdf7152d0fd88db7281d1675846b82bac66634 (patch)
tree2ff9fcbef591dff7b03381d2d0d36bd43e78594b
parentd95521e13615f6d394527ca6163e67851044cb93 (diff)
downloadchef-04bdf7152d0fd88db7281d1675846b82bac66634.tar.gz
Upfactor #run_chef_client into Chef::Application
-rw-r--r--chef/lib/chef/application.rb13
-rw-r--r--chef/lib/chef/application/client.rb12
-rw-r--r--chef/lib/chef/application/solo.rb17
-rw-r--r--chef/lib/chef/application/windows_service.rb14
4 files changed, 15 insertions, 41 deletions
diff --git a/chef/lib/chef/application.rb b/chef/lib/chef/application.rb
index 328a81a2eb..c9c436fa4f 100644
--- a/chef/lib/chef/application.rb
+++ b/chef/lib/chef/application.rb
@@ -127,6 +127,18 @@ class Chef::Application
raise Chef::Exceptions::Application, "#{self.to_s}: you must override run_application"
end
+ # Initializes Chef::Client instance and runs it
+ def run_chef_client
+ @chef_client = Chef::Client.new(
+ @chef_client_json,
+ :override_runlist => config[:override_runlist]
+ )
+ @chef_client_json = nil
+
+ @chef_client.run
+ @chef_client = nil
+ end
+
private
def apply_config(config_file_path)
@@ -134,7 +146,6 @@ class Chef::Application
Chef::Config.merge!(config)
end
-
class << self
def debug_stacktrace(e)
message = "#{e.class}: #{e}\n#{e.backtrace.join("\n")}"
diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb
index 2a226ca07f..9d407c87c3 100644
--- a/chef/lib/chef/application/client.rb
+++ b/chef/lib/chef/application/client.rb
@@ -313,18 +313,6 @@ class Chef::Application::Client < Chef::Application
private
- # Initializes Chef::Client instance and runs it
- def run_chef_client
- @chef_client = Chef::Client.new(
- @chef_client_json,
- :override_runlist => config[:override_runlist]
- )
- @chef_client_json = nil
-
- @chef_client.run
- @chef_client = nil
- end
-
def client_sleep(sec)
IO.select([ SELF_PIPE[0] ], nil, nil, sec) or return
SELF_PIPE[0].getc
diff --git a/chef/lib/chef/application/solo.rb b/chef/lib/chef/application/solo.rb
index 7b20e5dfbf..288729838c 100644
--- a/chef/lib/chef/application/solo.rb
+++ b/chef/lib/chef/application/solo.rb
@@ -149,8 +149,8 @@ class Chef::Application::Solo < Chef::Application
def initialize
super
- @chef_solo = nil
- @chef_solo_json = nil
+ @chef_client = nil
+ @chef_client_json = nil
end
def reconfigure
@@ -182,7 +182,7 @@ class Chef::Application::Solo < Chef::Application
end
begin
- @chef_solo_json = Chef::JSONCompat.from_json(json_io.read)
+ @chef_client_json = Chef::JSONCompat.from_json(json_io.read)
json_io.close unless json_io.closed?
rescue JSON::ParserError => error
Chef::Application.fatal!("Could not parse the provided JSON file (#{Chef::Config[:json_attribs]})!: " + error.message, 2)
@@ -247,15 +247,4 @@ class Chef::Application::Solo < Chef::Application
end
end
- private
-
- # Initializes Chef::Client instance and runs it
- def run_chef_client
- @chef_solo = Chef::Client.new(
- @chef_solo_json,
- :override_runlist => config[:override_runlist]
- )
- @chef_solo.run
- @chef_solo = nil
- end
end
diff --git a/chef/lib/chef/application/windows_service.rb b/chef/lib/chef/application/windows_service.rb
index bfcef44ec3..0d4a022fdf 100644
--- a/chef/lib/chef/application/windows_service.rb
+++ b/chef/lib/chef/application/windows_service.rb
@@ -219,20 +219,6 @@ class Chef
end
end
- private
-
- # Initializes Chef::Client instance and runs it
- def run_chef_client
- @chef_client = Chef::Client.new(
- @chef_client_json,
- :override_runlist => config[:override_runlist]
- )
- @chef_client_json = nil
-
- @chef_client.run
- @chef_client = nil
- end
-
end
end
end