Class: VagrantPlugins::OneAndOne::Command::ListServers

Inherits:
Object
  • Object
show all
Includes:
Utils
Defined in:
lib/vagrant-oneandone/command/list_servers.rb

Instance Method Summary collapse

Methods included from Utils

#display_table, #fog_oneandone

Instance Method Details

#executeObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/vagrant-oneandone/command/list_servers.rb', line 9

def execute
  options = OptionParser.new do |o|
    o.banner = I18n.t('vagrant_1and1.command.list_servers')
    o.separator ''
    o.separator 'Usage: vagrant oneandone servers [<api_key>]'
    o.separator ''
  end

  argv = parse_options(options)
  return unless argv

  compute = fog_oneandone(argv[0])

  rows = []
  compute.servers.all.each do |s|
    rows << [s.id, s.name, s.status['state'], s.datacenter['country_code']]
  end

  display_table(@env, ['ID', 'Name', 'State', 'Data Center'], rows)
end