Class: Kelbim::Exporter

Inherits:
Object
  • Object
show all
Defined in:
lib/kelbim/exporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(elb, options = {}) ⇒ Exporter

of class methods



12
13
14
15
# File 'lib/kelbim/exporter.rb', line 12

def initialize(elb, options = {})
  @elb = elb
  @options = options
end

Class Method Details

.export(elb, options = {}) ⇒ Object



7
8
9
# File 'lib/kelbim/exporter.rb', line 7

def export(elb, options = {})
  self.new(elb, options).export
end

Instance Method Details

#exportObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/kelbim/exporter.rb', line 17

def export
  result = {}
  lbs = @elb.load_balancers

  ec2s = @options[:ec2s]
  elb_names = @options[:elb_names]

  if ec2s or elb_names
    lbs = lbs.select do |lb|
      (ec2s.nil? or ec2s.include?(lb.vpc_id || 'classic')) &&
      (elb_names.nil? or elb_names.include?(lb.name))
    end
  end

  lbs.each do |lb|
    result[lb.vpc_id] ||= {}
    result[lb.vpc_id][lb.name] = export_load_balancer(lb)
  end

  return result
end