Class: VagrantPlugins::Deltacloud::Action::WaitForServerToBeActive

Inherits:
AbstractAction
  • Object
show all
Defined in:
lib/vagrant-deltacloud-provider/action/wait_active.rb

Instance Method Summary collapse

Methods inherited from AbstractAction

#call

Constructor Details

#initialize(app, _env, retry_interval = 3, timeout = 200) ⇒ WaitForServerToBeActive

Returns a new instance of WaitForServerToBeActive.



11
12
13
14
15
16
# File 'lib/vagrant-deltacloud-provider/action/wait_active.rb', line 11

def initialize(app, _env, retry_interval = 3, timeout = 200)
  @app    = app
  @logger = Log4r::Logger.new('vagrant_deltacloud::action::start_server')
  @retry_interval = retry_interval
  @timeout = timeout
end

Instance Method Details

#execute(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/vagrant-deltacloud-provider/action/wait_active.rb', line 18

def execute(env)
  env[:deltacloud_client] = Deltacloud::DeltacloudClient.instance
  if env[:machine].id
    env[:ui].info(I18n.t('vagrant_deltacloud.waiting_start'))
    client = env[:deltacloud_client]
    timeout(@timeout, Errors::Timeout) do
      while client.get_instance_details(env, env[:machine].id).status != 'RUNNING'
        sleep @retry_interval
        @logger.info('Waiting for server to be active')
      end
    end
  end
  @app.call(env)
end