Class: Mulder::Connection
- Inherits:
-
Object
- Object
- Mulder::Connection
- Defined in:
- lib/mulder/connection.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #autoscaler ⇒ Object
- #compute ⇒ Object
- #group_by_id_regexp(id_regexp) ⇒ Object
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
- #instances_by_group(group) ⇒ Object
- #server_by_instance_id(instance_id) ⇒ Object
Constructor Details
#initialize(config) ⇒ Connection
Returns a new instance of Connection.
8 9 10 |
# File 'lib/mulder/connection.rb', line 8 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/mulder/connection.rb', line 6 def config @config end |
Instance Method Details
#autoscaler ⇒ Object
31 32 33 34 35 36 |
# File 'lib/mulder/connection.rb', line 31 def autoscaler @autoscaler ||= ::Fog::AWS::AutoScaling.new( :aws_access_key_id => @config.aws_access_key_id, :aws_secret_access_key => @config.aws_secret_access_key ) end |
#compute ⇒ Object
38 39 40 41 42 43 |
# File 'lib/mulder/connection.rb', line 38 def compute @compute ||= ::Fog::Compute::AWS.new( :aws_access_key_id => @config.aws_access_key_id, :aws_secret_access_key => @config.aws_secret_access_key ) end |
#group_by_id_regexp(id_regexp) ⇒ Object
12 13 14 15 16 |
# File 'lib/mulder/connection.rb', line 12 def group_by_id_regexp(id_regexp) autoscaler.groups.find_all do |group| group.id =~ id_regexp end.last end |
#instances_by_group(group) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/mulder/connection.rb', line 18 def instances_by_group(group) group.instances.collect do |instance| compute_instance = server_by_instance_id(instance.id) Mulder::Instance.new(compute_instance) end rescue [] end |
#server_by_instance_id(instance_id) ⇒ Object
27 28 29 |
# File 'lib/mulder/connection.rb', line 27 def server_by_instance_id(instance_id) compute.servers.get(instance_id) end |