diff options
author | John Keiser <jkeiser@opscode.com> | 2013-09-12 16:06:40 -0700 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2013-10-02 11:57:50 -0700 |
commit | 14174da833af9cdd34e93161cc7d6232e6e4fa6c (patch) | |
tree | 30b9a575964d3f3036ca10850a5afce31251fbda /lib/chef/application.rb | |
parent | 6801b07c9a4b66984c3a45754502770fc2d835e7 (diff) | |
download | chef-14174da833af9cdd34e93161cc7d6232e6e4fa6c.tar.gz |
Support start_chef_zero parameter in knife and chef-client
Diffstat (limited to 'lib/chef/application.rb')
-rw-r--r-- | lib/chef/application.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/chef/application.rb b/lib/chef/application.rb index fd562d07ba..eb0488db1f 100644 --- a/lib/chef/application.rb +++ b/lib/chef/application.rb @@ -172,8 +172,35 @@ class Chef::Application raise Chef::Exceptions::Application, "#{self.to_s}: you must override run_application" end + def self.setup_server_connectivity + if Chef::Config.start_chef_zero + destroy_server_connectivity + + require 'chef_zero/server' + require 'chef/chef_fs/chef_fs_data_store' + require 'chef/chef_fs/config' + server_options = {} + server_options[:data_store] = Chef::ChefFS::ChefFSDataStore.new(Chef::ChefFS::Config.new.local_fs) + server_options[:log_level] = Chef::Log.level + server_options[:port] = Chef::Config.chef_zero_port + Chef::Log.info("Starting chef-zero on port #{Chef::Config.chef_zero_port} with repository at #{server_options[:data_store]}") + @chef_zero_server = ChefZero::Server.new(server_options) + @chef_zero_server.start_background + Chef::Config.chef_server_url = @chef_zero_server.url + end + end + + def self.destroy_server_connectivity + if @chef_zero_server + @chef_zero_server.stop + @chef_zero_server = nil + end + end + # Initializes Chef::Client instance and runs it def run_chef_client + Chef::Application.setup_server_connectivity + @chef_client = Chef::Client.new( @chef_client_json, :override_runlist => config[:override_runlist] @@ -182,6 +209,8 @@ class Chef::Application @chef_client.run @chef_client = nil + + Chef::Application.destroy_server_connectivity end private |