Class: Kelbim::Exporter

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::Helper

#matched_elb?

Constructor Details

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

of class methods



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

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

Class Method Details

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



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

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

Instance Method Details

#exportObject



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

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

  ec2s = @options[:ec2s]

  if ec2s or @options[:elb_name] or @options[:exclude_elb_name]
    lbs = lbs.select do |lb|
      (ec2s.nil? or ec2s.include?(lb.vpc_id || 'classic')) &&
      matched_elb?(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