Class: ProxyAPI::ForemanChef::ChefProxy
- Inherits:
-
Object
- Object
- ProxyAPI::ForemanChef::ChefProxy
- Defined in:
- app/lib/proxy_api/foreman_chef/chef_proxy.rb
Defined Under Namespace
Classes: Client, Environment, Node
Constant Summary collapse
- PREFIX =
'chef'
Instance Method Summary collapse
-
#create_client(key) ⇒ Object
Creates a Chef Client entry [
key] : String containing the client name Returns : Hash representation of client on chef server. -
#delete_client(key) ⇒ Object
Deletes a Chef Client entry [
key] : String containing the client name Returns : Boolean status. -
#delete_node(key) ⇒ Object
Deletes a Chef Node entry [
key] : String containing the hostname Returns : Boolean status. -
#initialize(args) ⇒ ChefProxy
constructor
A new instance of ChefProxy.
-
#list_environments ⇒ Object
List all Chef environments Returns : Hash representation of environments on chef server.
-
#show_client(key) ⇒ Object
Shows a Chef Client entry [
key] : String containing the client name Returns : Hash representation of client on chef server. -
#show_node(key) ⇒ Object
Shows a Chef Node entry [
key] : String containing the hostname Returns : Hash representation of node on chef server. -
#update_node(key, attributes) ⇒ Object
Updates a Chef Node entry [
key] : String containing the hostname [attributes] : Hash containing attributes Returns : Hash representation of node on chef server.
Constructor Details
#initialize(args) ⇒ ChefProxy
Returns a new instance of ChefProxy.
27 28 29 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 27 def initialize(args) @args = args end |
Instance Method Details
#create_client(key) ⇒ Object
Creates a Chef Client entry
key-
: String containing the client name
Returns : Hash representation of client on chef server
63 64 65 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 63 def create_client(key) Client.new(@args).send(:post, :client => {:name => key}) end |
#delete_client(key) ⇒ Object
Deletes a Chef Client entry
key-
: String containing the client name
Returns : Boolean status
70 71 72 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 70 def delete_client(key) Client.new(@args).send(:delete, key) end |
#delete_node(key) ⇒ Object
Deletes a Chef Node entry
key-
: String containing the hostname
Returns : Boolean status
49 50 51 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 49 def delete_node(key) Node.new(@args).send(:delete, key) end |
#list_environments ⇒ Object
List all Chef environments Returns : Hash representation of environments on chef server
76 77 78 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 76 def list_environments Environment.new(@args).send(:get) end |
#show_client(key) ⇒ Object
Shows a Chef Client entry
key-
: String containing the client name
Returns : Hash representation of client on chef server
56 57 58 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 56 def show_client(key) Client.new(@args).send(:get, key) end |
#show_node(key) ⇒ Object
Shows a Chef Node entry
key-
: String containing the hostname
Returns : Hash representation of node on chef server
34 35 36 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 34 def show_node(key) Node.new(@args).send(:get, key) end |
#update_node(key, attributes) ⇒ Object
Updates a Chef Node entry
key-
: String containing the hostname
attributes-
: Hash containing attributes
Returns : Hash representation of node on chef server
42 43 44 |
# File 'app/lib/proxy_api/foreman_chef/chef_proxy.rb', line 42 def update_node(key, attributes) Node.new(@args).send(:put, { :node => attributes }, key ) end |