Sha256: 63360bc4694a9c8b7ae7b9d32ed0d61e8837472825ae8c7dd8e313b3fbbd4214

Contents?: true

Size: 799 Bytes

Versions: 10

Compression:

Stored size: 799 Bytes

Contents

module Vagrant
  class Action
    module VM
      class Halt
        include ExceptionCatcher

        def initialize(app, env, options=nil)
          @app = app
          env.merge!(options || {})
        end

        def call(env)
          if env["vm"].vm.running?
            if !env["force"]
              catch_action_exception(env) { env["vm"].system.halt }
              return if env.error?
            end

            if env["vm"].vm.state(true) != :powered_off
              env.logger.info "Forcing shutdown of VM..."
              env["vm"].vm.stop
            end

            # Sleep for a second to verify that the VM properly
            # cleans itself up
            sleep 1 if !env["vagrant.test"]
          end

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

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
vagrantup-0.5.4 lib/vagrant/action/vm/halt.rb
vagrantup-0.5.3 lib/vagrant/action/vm/halt.rb
vagrantup-0.5.2 lib/vagrant/action/vm/halt.rb
vagrantup-0.5.1 lib/vagrant/action/vm/halt.rb
vagrantup-0.5.0 lib/vagrant/action/vm/halt.rb
vagrant-0.5.4 lib/vagrant/action/vm/halt.rb
vagrant-0.5.3 lib/vagrant/action/vm/halt.rb
vagrant-0.5.2 lib/vagrant/action/vm/halt.rb
vagrant-0.5.1 lib/vagrant/action/vm/halt.rb
vagrant-0.5.0 lib/vagrant/action/vm/halt.rb