class Chef::Knife::ScalewayVolumeList

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/scaleway_volume_list.rb, line 22
def run
  $stdout.sync = true

  validate!

  image_list = [
    ui.color('ID',           :bold),
    ui.color('Name',         :bold),
    ui.color('Server',       :bold),
    ui.color('Size',         :bold)
  ]

  volumes = Scaleway::Volume.all

  volumes.each do |volume|
    server_name = volume.server ? volume.server.name : ''
    image_list << volume.id.to_s
    image_list << volume.name.to_s
    image_list << server_name
    image_list << "#{(volume.size.to_i / 1000 / 1000 / 1000)} GB"
  end

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