def call(env)
result = @client.post("/v2/droplets/#{@machine.id}/actions", {
:type => 'rebuild',
:image => @machine.provider_config.image
})
env[:ui].info I18n.t('vagrant_digital_ocean.info.rebuilding')
@client.wait_for_event(env, result['action']['id'])
Provider.droplet(@machine, :refresh => true)
switch_user = @machine.provider_config.setup?
user = @machine.config.ssh.username
@machine.config.ssh.username = 'root' if switch_user
retryable(:tries => 120, :sleep => 10) do
next if env[:interrupted]
raise 'not ready' if !@machine.communicate.ready?
end
@machine.config.ssh.username = user
@app.call(env)
end