Sha256: dc1eca8294cf082e3cab35c7c79c6711d3d0b57e2aeeb91dd6340cfacb79fb8a

Contents?: true

Size: 863 Bytes

Versions: 4

Compression:

Stored size: 863 Bytes

Contents

require 'log4r'

module VagrantPlugins
  module OVirtProvider
    module Action
      class HaltVM
        def initialize(app, env)
          @logger = Log4r::Logger.new("vagrant_ovirt4::action::halt_vm")
          @app = app
        end

        def call(env)
          env[:ui].info(I18n.t("vagrant_ovirt4.halt_vm"))

          # Halt via OS capability
          begin
            if env[:machine].guest.capability?(:halt)
              env[:machine].guest.capability(:halt)
              # Give the VM a chance to shutdown gracefully..."
              sleep 10
            end
          rescue
            env[:ui].info("Failed to shutdown guest gracefully.")
          end

          machine = env[:vms_service].vm_service(env[:machine].id)
          machine.stop rescue nil #todo dont rescue

          @app.call(env)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vagrant-ovirt4-2.2.0 lib/vagrant-ovirt4/action/halt_vm.rb
vagrant-ovirt4-2.1.3 lib/vagrant-ovirt4/action/halt_vm.rb
vagrant-ovirt4-2.1.0 lib/vagrant-ovirt4/action/halt_vm.rb
vagrant-ovirt4-2.0.0 lib/vagrant-ovirt4/action/halt_vm.rb