class Chef::Knife::ScalewayIpList

Public Instance Methods

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

  validate!

  ip_list = [
    ui.color('ID',           :bold),
    ui.color('Address',      :bold),
    ui.color('Server',       :bold),
  ]

  ips = Scaleway::Ip.all

  ips.each do |ip|
    server_name = ip.server ? ip.server.name : ''
    ip_list << ip.id.to_s
    ip_list << ip.address.to_s
    ip_list << server_name
  end

  puts ui.list(ip_list, :uneven_columns_across, 3)
end