Class: VagrantPlugins::DigitalOcean::Actions::Reload

Inherits:
Object
  • Object
show all
Includes:
Helpers::Client
Defined in:
lib/vagrant-digitalocean/actions/reload.rb

Instance Method Summary collapse

Methods included from Helpers::Client

#client

Constructor Details

#initialize(app, env) ⇒ Reload

Returns a new instance of Reload.



9
10
11
12
13
14
# File 'lib/vagrant-digitalocean/actions/reload.rb', line 9

def initialize(app, env)
  @app = app
  @machine = env[:machine]
  @client = client
  @logger = Log4r::Logger.new('vagrant::digitalocean::reload')
end

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vagrant-digitalocean/actions/reload.rb', line 16

def call(env)
  # submit reboot droplet request
  result = @client.post("/v2/droplets/#{@machine.id}/actions", {
    :type => 'reboot'
  })

  # wait for request to complete
  env[:ui].info I18n.t('vagrant_digital_ocean.info.reloading')
  @client.wait_for_event(env, result['action']['id'])

  @app.call(env)
end