Class: BrohamNode
- Inherits:
-
RightAws::ActiveSdb::Base
- Object
- RightAws::ActiveSdb::Base
- BrohamNode
- Defined in:
- lib/broham/cluster.rb
Overview
This actually reaches into the settings hash and supplies
(it’s written like this so that chef
Instance Attribute Summary collapse
-
#settings ⇒ Object
Returns the value of attribute settings.
Class Method Summary collapse
Instance Method Summary collapse
-
#broham_attr(attr) ⇒ Object
retrieve a simple scalar value from the broham info.
-
#broham_info ⇒ Object
Return cached copy of the broham registration, if any.
- #establish_connection ⇒ Object
-
#initialize(settings) ⇒ BrohamNode
constructor
- Settings hash must contain * ‘aws’
- a hash with keys ‘access_key’ and ‘secret_access_key’ holding your AWS credentsials * ‘cluster_name’
- name of the cluster * ‘cluster_role’
-
role within that cluster.
- #set_cluster_info! ⇒ Object
Constructor Details
#initialize(settings) ⇒ BrohamNode
Settings hash must contain
- ‘aws’
-
a hash with keys ‘access_key’ and ‘secret_access_key’ holding your AWS credentsials
- ‘cluster_name’
-
name of the cluster
- ‘cluster_role’
-
role within that cluster
Method will set values for
-
‘cluster_role_index’
-
‘node_name’
26 27 28 |
# File 'lib/broham/cluster.rb', line 26 def initialize settings self.settings = settings end |
Instance Attribute Details
#settings ⇒ Object
Returns the value of attribute settings.
8 9 10 |
# File 'lib/broham/cluster.rb', line 8 def settings @settings end |
Class Method Details
.set_cluster_info!(settings) ⇒ Object
10 11 12 13 14 |
# File 'lib/broham/cluster.rb', line 10 def self.set_cluster_info! settings node = new(settings) node.set_cluster_info! node.settings end |
Instance Method Details
#broham_attr(attr) ⇒ Object
retrieve a simple scalar value from the broham info
35 36 37 |
# File 'lib/broham/cluster.rb', line 35 def broham_attr attr [ broham_info[attr] ].flatten.first end |
#broham_info ⇒ Object
Return cached copy of the broham registration, if any
41 42 43 44 45 |
# File 'lib/broham/cluster.rb', line 41 def broham_info return @broham_info if @broham_info establish_connection @broham_info ||= Broham.register_as_next("#{settings["cluster_name"]}-#{settings["cluster_role"]}") end |
#establish_connection ⇒ Object
47 48 49 50 |
# File 'lib/broham/cluster.rb', line 47 def establish_connection raise "Need to supply an AWS credentials hash with keys 'access_key' and 'secret_access_key'" if settings["aws"].blank? Broham.establish_connection(:access_key => settings["aws"]["access_key"], :secret_access_key => settings["aws"]["secret_access_key"]) end |
#set_cluster_info! ⇒ Object
30 31 32 |
# File 'lib/broham/cluster.rb', line 30 def set_cluster_info! settings['cluster_role_index'] ||= broham_attr('idx') end |