Commit 04bdf715 authored by Chris Roberts's avatar Chris Roberts Committed by Bryan McLellan
Browse files

Upfactor #run_chef_client into Chef::Application

parent d95521e1
......@@ -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")}"
......
......@@ -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
......
......@@ -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
......@@ -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
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment