Class: VagrantPlugins::OVirtProvider::Action::WaitTilSuspended

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

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ WaitTilSuspended

Returns a new instance of WaitTilSuspended.



11
12
13
14
# File 'lib/vagrant-ovirt4/action/wait_til_suspended.rb', line 11

def initialize(app, env)
  @logger = Log4r::Logger.new("vagrant_ovirt4::action::wait_til_suspended")
  @app = app
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-ovirt4/action/wait_til_suspended.rb', line 16

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

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

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

  if not ready
    raise Errors::WaitForShutdownVmTimeout
  end

  
  @app.call(env)
end