Class: Chef::Knife::BlueboxLbList

Inherits:
Chef::Knife show all
Defined in:
lib/chef/knife/bluebox_lb_list.rb

Instance Method Summary collapse

Instance Method Details

#hObject



34
35
36
# File 'lib/chef/knife/bluebox_lb_list.rb', line 34

def h
  @highline ||= HighLine.new
end

#runObject



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/chef/knife/bluebox_lb_list.rb', line 38

def run
  blb = Fog::Bluebox::BLB.new(
    :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
    :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
  )

  blb.lb_applications.each_with_index do |application, index|
    puts if index != 0
    lines = []

    lines << [ 'Application ID', 'Name', 'IP addresses'].map {|s| h.color(s, :bold)}
    lines << [ application.id, application.name, application.ip_v4, nil, nil, application.ip_v6 ]
    unless application.lb_services.empty?
      lines << [ 'Service ID', 'Service Type', 'Port'].map {|s| h.color(s, :bold)}
      application.lb_services.each do |service|
        lines << [ service.id, service.service_type, service.port.to_s ]
      end
    end
    lines.flatten!
    puts h.list(lines, :uneven_columns_across, 3)
  end

end