Class: Chef::Knife::BlueboxImageList

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

Instance Method Summary collapse

Instance Method Details

#highlineObject



33
34
35
# File 'lib/chef/knife/bluebox_image_list.rb', line 33

def highline
  @highline ||= HighLine.new
end

#runObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/chef/knife/bluebox_image_list.rb', line 37

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

  images  = bluebox.images.inject({}) { |h,i| h[i.id] = i.description; h }

  image_list = [ highline.color('ID', :bold), highline.color('Name', :bold) ]

  bluebox.images.each do |image|
    image_list << image.id.to_s
    image_list << image.description
  end
  puts highline.list(image_list, :columns_across, 2)

end