Class: Chef::Knife::ProfitbricksImageList

Inherits:
Chef::Knife
  • Object
show all
Includes:
ProfitbricksBase
Defined in:
lib/chef/knife/profitbricks_image_list.rb

Instance Method Summary collapse

Methods included from ProfitbricksBase

#connection, #error_and_exit, #get_image, included, #msg_pair, #validate_required_params

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/chef/knife/profitbricks_image_list.rb', line 10

def run
  $stdout.sync = true
  image_list = [
    ui.color('ID', :bold),
    ui.color('Name', :bold),
    ui.color('Description', :bold),
    ui.color('Location', :bold),
    ui.color('Size', :bold),
    ui.color('Public', :bold)
  ]

  connection
  ProfitBricks::Image.list.each do |image|
    image_list << image.id
    image_list << image.properties['name']
    image_list << image.properties['description']
    image_list << image.properties['location']
    image_list << image.properties['size'].to_s
    image_list << image.properties['public'].to_s
  end

  puts ui.list(image_list, :uneven_columns_across, 6)
end