Class: Cloudfinder::EC2::Clusterfinder

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudfinder-ec2/clusterfinder.rb

Instance Method Summary collapse

Instance Method Details

#find(query) ⇒ Cloudfinder::EC2::Cluster

Find all the running instances for a named cluster and build them into a cluster object, grouped by role.

Parameters:

  • query (Hash)

Options Hash (query):

  • :cluster_name (string)

    find instances tagged with this cluster name

  • :region (string)

    EC2 region to search

Returns:



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/cloudfinder-ec2/clusterfinder.rb', line 12

def find(query)
  validate_arguments(query)
  @cluster_name = query[:cluster_name]
  instances     = []

  each_running_instance(query[:region]) do |instance_data|
    if in_cluster?(instance_data) && has_role?(instance_data)
      instances << new_instance(instance_data)
    end
  end

  Cloudfinder::EC2::Cluster.new(
      cluster_name: @cluster_name,
      instances:    instances
  )
end