Class: VagrantPlugins::DigitalOcean::Actions::Rebuild
- Inherits:
-
Object
- Object
- VagrantPlugins::DigitalOcean::Actions::Rebuild
- Includes:
- Helpers::Client
- Defined in:
- lib/vagrant-digitalocean/actions/rebuild.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Rebuild
constructor
A new instance of Rebuild.
Methods included from Helpers::Client
Constructor Details
#initialize(app, env) ⇒ Rebuild
Returns a new instance of Rebuild.
9 10 11 12 13 14 |
# File 'lib/vagrant-digitalocean/actions/rebuild.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::digitalocean::rebuild') end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-digitalocean/actions/rebuild.rb', line 16 def call(env) # look up image id image_id = @client .request('/images', { :filter => 'global' }) .find_id(:images, :name => @machine.provider_config.image) # submit rebuild request result = @client.request("/droplets/#{@machine.id}/rebuild", { :image_id => image_id }) # wait for request to complete env[:ui].info I18n.t('vagrant_digital_ocean.info.rebuilding') @client.wait_for_event(env, result['event_id']) @app.call(env) end |