Sha256: afb760f578390328653056399b92caad0923fbeb3dacad4490a604fab1312d45

Contents?: true

Size: 916 Bytes

Versions: 11

Compression:

Stored size: 916 Bytes

Contents

module VagrantWindows
  module Guest
    module Cap
      class Halt
        def self.halt(machine)
          # Fix defect 129, if there's an existing scheduled reboot cancel it so shutdown succeeds
          machine.communicate.execute("shutdown -a", :error_check => false)
          
          # Force shutdown the machine now
          machine.communicate.execute("shutdown /s /t 1 /c \"Vagrant Halt\" /f /d p:4:1")

          # Wait until the VM's state is actually powered off. If this doesn't
          # occur within a reasonable amount of time (15 seconds by default),
          # then simply return and allow Vagrant to kill the machine.
          count = 0
          while machine.state != :poweroff
            count += 1

            return if count >= machine.config.windows.halt_timeout
            sleep machine.config.windows.halt_check_interval
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vagrant-windows-1.7.0.pre.2 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.7.0.pre.1 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.6.0 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.6.0.pre.1 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.5.1 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.5.0 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.4.0 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.3.2 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.3.1 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.3.0 lib/vagrant-windows/guest/cap/halt.rb
vagrant-windows-1.3.0.pre.3 lib/vagrant-windows/guest/cap/halt.rb