Class: VagrantPlugins::ProfitBricks::Command::ListDatacenters

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

Instance Method Summary collapse

Methods included from Utils

#display_table, #fog_pb

Instance Method Details

#executeObject



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

def execute
  opts = OptionParser.new do |o|
    o.banner = 'Usage: vagrant profitbricks datacenters [options]'
  end

  argv = parse_options(opts)
  return unless argv

  compute = fog_pb(argv[0])

  rows = []

  compute.datacenters.sort_by(&:id).each do |dc|
    rows << [
      dc.id,
      dc.name
    ]
  end

  display_table(@env, %w[ID Name], rows)
end