Class: Ridley::ClientResource

Inherits:
Resource
  • Object
show all
Defined in:
lib/ridley/resources/client_resource.rb

Overview

Author:

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#<=>, #==, all, #chef_id, chef_id, chef_json_class, chef_type, create, delete, delete_all, #eql?, find, find!, #hash, #initialize, #reload, resource_path, #save, set_chef_id, set_chef_json_class, set_chef_type, set_resource_path, #to_s, update, #update

Constructor Details

This class inherits a constructor from Ridley::Resource

Class Method Details

.regenerate_key(client, chef_client) ⇒ Ridley::ClientResource

Retrieves a client from the remote connection matching the given chef_id and regenerates it's private key. An instance of the updated object will be returned and have a value set for the 'private_key' accessor.

Parameters:

Returns:

Raises:


17
18
19
20
21
# File 'lib/ridley/resources/client_resource.rb', line 17

def regenerate_key(client, chef_client)
  obj = find!(client, chef_client)
  obj.regenerate_key
  obj
end

Instance Method Details

#regenerate_keyBoolean

Regenerates the private key of the instantiated client object. The new private key will be set to the value of the 'private_key' accessor of the instantiated client object.

Returns:

  • (Boolean)

    true for success and false for failure


61
62
63
64
# File 'lib/ridley/resources/client_resource.rb', line 61

def regenerate_key
  self.private_key = true
  self.save
end

#to_jsonObject

Override to_json to reflect to massage the returned attributes based on the type of connection. Only OHC/OPC requires the json_class attribute is not present.


68
69
70
71
72
73
74
# File 'lib/ridley/resources/client_resource.rb', line 68

def to_json
  if client.connection.hosted?
    to_hash.except(:json_class).to_json
  else
    super
  end
end