diff options
author | Matt Wrock <matt@mattwrock.com> | 2015-12-22 12:56:08 -0800 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2015-12-22 12:56:08 -0800 |
commit | 7983e70b7d80ac5063fd7b9182d6fd41ff39c5c3 (patch) | |
tree | 53501d8ee5dc4837e3fb15a7f93944ee48f6a21f /lib/chef/api_client | |
parent | e41ae9e7f407e8fa139bb154813805b46c0b5d1f (diff) | |
download | chef-7983e70b7d80ac5063fd7b9182d6fd41ff39c5c3.tar.gz |
no longer wait on node search to refresh vault but pass created ApiClient instead
Diffstat (limited to 'lib/chef/api_client')
-rw-r--r-- | lib/chef/api_client/registration.rb | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/chef/api_client/registration.rb b/lib/chef/api_client/registration.rb index 7875afde0f..bc941d5bfa 100644 --- a/lib/chef/api_client/registration.rb +++ b/lib/chef/api_client/registration.rb @@ -53,8 +53,9 @@ class Chef def run assert_destination_writable! retries = Config[:client_registration_retries] || 5 + client = nil begin - create_or_update + client = api_client(create_or_update) rescue Net::HTTPFatalError => e # HTTPFatalError implies 5xx. raise if retries <= 0 @@ -64,6 +65,7 @@ class Chef retry end write_key + client end def assert_destination_writable! @@ -106,6 +108,28 @@ class Chef response end + def api_client(response) + return response if response.is_a?(Chef::ApiClient) + + client = Chef::ApiClient.new + client.name(name) + client.public_key(api_client_key(response, "public_key")) + client.private_key(api_client_key(response, "private_key")) + client + end + + def api_client_key(response, key_name) + if response[key_name] + if response[key_name].respond_to?(:to_pem) + response[key_name].to_pem + else + response[key_name] + end + elsif response["chef_key"] + response["chef_key"][key_name] + end + end + def put_data base_put_data = { :name => name, :admin => false } if self_generate_keys? |