Class: Chef::Knife::TerremarkServerList

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

Instance Method Summary collapse

Instance Method Details

#hObject



49
50
51
# File 'lib/chef/knife/terremark_server_list.rb', line 49

def h
  @highline ||= HighLine.new
end

#runObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/chef/knife/terremark_server_list.rb', line 53

def run 
  server_name = @name_args[0]

  terremark = Fog::Terremark.new(
    :terremark_username => Chef::Config[:knife][:terremark_username],
    :terremark_password => Chef::Config[:knife][:terremark_password],
    :terremark_service  => Chef::Config[:knife][:terremark_service] || :vcloud
  )

  $stdout.sync = true

  server_list = [ h.color('ID', :bold), h.color('Name', :bold) ]
  terremark.servers.all.each do |server|
    server_list << server.id.to_s
    server_list << server.name
  end
  puts h.list(server_list, :columns_across, 2)

end