Sha256: 393d6c6d90e3a8eacba7e06e08be25961e483c893f4782b1053ca9fa9c7258d1

Contents?: true

Size: 1 KB

Versions: 6

Compression:

Stored size: 1 KB

Contents

require 'log4r'
require 'vagrant-ovirt4/util/timer'
require 'vagrant/util/retryable'

module VagrantPlugins
  module OVirtProvider
    module Action
      class WaitTilSuspended
        include Vagrant::Util::Retryable

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

        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_id => env[:machine].id
            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

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vagrant-ovirt4-2.2.0 lib/vagrant-ovirt4/action/wait_til_suspended.rb
vagrant-ovirt4-2.1.3 lib/vagrant-ovirt4/action/wait_til_suspended.rb
vagrant-ovirt4-2.1.0 lib/vagrant-ovirt4/action/wait_til_suspended.rb
vagrant-ovirt4-2.0.0 lib/vagrant-ovirt4/action/wait_til_suspended.rb
vagrant-ovirt4-1.2.3 lib/vagrant-ovirt4/action/wait_til_suspended.rb
vagrant-ovirt4-1.2.2 lib/vagrant-ovirt4/action/wait_til_suspended.rb