Class: VagrantPlugins::SimpleCloud::Actions::Reload
- Inherits:
-
Object
- Object
- VagrantPlugins::SimpleCloud::Actions::Reload
- Includes:
- Helpers::Client
- Defined in:
- lib/vagrant-simple_cloud/actions/reload.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Reload
constructor
A new instance of Reload.
Methods included from Helpers::Client
Constructor Details
#initialize(app, env) ⇒ Reload
Returns a new instance of Reload.
9 10 11 12 13 14 |
# File 'lib/vagrant-simple_cloud/actions/reload.rb', line 9 def initialize(app, env) @app = app @machine = env[:machine] @client = client @logger = Log4r::Logger.new('vagrant::simple_cloud::reload') end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-simple_cloud/actions/reload.rb', line 16 def call(env) # submit reboot droplet request result = @client.post("/v2/vps/#{@machine.id}/actions", { :type => 'reboot' }) # wait for request to complete env[:ui].info I18n.t('vagrant_simple_cloud.info.reloading') @client.wait_for_event(env, result['action']['id']) # wait for ssh to be ready 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 |