Class: VagrantPlugins::OVirtProvider::Action::WaitTillDown

Inherits:
Object
  • Object
show all
Includes:
Vagrant::Util::Retryable
Defined in:
lib/vagrant-ovirt4/action/wait_till_down.rb

Overview

Wait till VM is stopped

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ WaitTillDown

Returns a new instance of WaitTillDown.



13
14
15
16
# File 'lib/vagrant-ovirt4/action/wait_till_down.rb', line 13

def initialize(app, env)
  @logger = Log4r::Logger.new("vagrant_ovirt4::action::wait_till_down")
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-ovirt4/action/wait_till_down.rb', line 18

def call(env)
  vm_service = env[:vms_service].vm_service(env[:machine].id)

  env[:ui].info(I18n.t("vagrant_ovirt4.wait_till_down"))
  for i in 1..300
    ready = true
    if vm_service.get == nil
      raise NoVMError, :vm_name => ''
    end

    if vm_service.get.status.to_sym != :down
      ready = false
    end
    break if ready
    sleep 2
  end

  if not ready
    raise Errors::WaitForShutdownVmTimeout
  end

  
  @app.call(env)
end