Sha256: 4eb9b59924529fab0bcfb25ccf887716b9a900fe02667e96a9e6b64afd5531e9

Contents?: true

Size: 934 Bytes

Versions: 15

Compression:

Stored size: 934 Bytes

Contents

require "log4r"
require 'json'

require 'vagrant-skytap/util/timer'
require 'vagrant-skytap/api/environment'

require 'net/https'
require 'uri'
require 'base64'
require 'json'
require 'timeout'

module VagrantPlugins
  module Skytap
    module Action
      # Stops the Skytap VM and waits until stopped.
      class StopVm
        attr_reader :env

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

        def call(env)
          vm = env[:environment].current_vm
          if env[:force_halt]
            vm.poweroff!
          else
            begin
              vm.stop!
            rescue Errors::InstanceReadyTimeout
              @logger.info(I18n.t("vagrant_skytap.graceful_halt_vm_failed"))
              vm.poweroff!
            end
          end
          @app.call(env)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vagrant-skytap-0.2.3 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.2.2 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.2.1 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.2.0 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.11 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.10 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.9 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.8 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.7 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.6 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.5 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.4 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.3 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.2 lib/vagrant-skytap/action/stop_vm.rb
vagrant-skytap-0.1.1a lib/vagrant-skytap/action/stop_vm.rb