Class: VagrantPlugins::ProfitBricks::Action::ListImages

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-profitbricks/action/list_images.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, _env) ⇒ ListImages

Returns a new instance of ListImages.



7
8
9
# File 'lib/vagrant-profitbricks/action/list_images.rb', line 7

def initialize(app, _env)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/vagrant-profitbricks/action/list_images.rb', line 11

def call(env)
  compute_service = env[:profitbricks_compute]
  env[:ui].info format('%-20s %-20s %s', 'ID', 'Name', 'Location')
  compute_service.images.sort_by(&:name).each do |server|
    env[:ui].info format('%-20s %-20s %s', server.id, server.name, server.location)
  end
  @app.call(env)
end