Sha256: f15b94fa0786cb6af7f2e2a889d8da84ef3fd380de9744e19d60b19e3b1848a7

Contents?: true

Size: 711 Bytes

Versions: 3

Compression:

Stored size: 711 Bytes

Contents

require "log4r"

module VagrantPlugins
  module GQ
    module Action
      # This stops the running instance.
      class StopInstance
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_gq::action::stop_instance")
        end

        def call(env)
          server = env[:gq_compute].servers.get(env[:machine].id)

          if env[:machine].state.id == :stopped
            env[:ui].info(I18n.t("vagrant_gq.already_status", :status => env[:machine].state.id))
          else
            env[:ui].info(I18n.t("vagrant_gq.stopping"))
            server.stop(!!env[:force_halt])
          end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-gq-0.1.2 lib/vagrant-gq/action/stop_instance.rb
vagrant-gq-0.1.1 lib/vagrant-gq/action/stop_instance.rb
vagrant-gq-0.1.0 lib/vagrant-gq/action/stop_instance.rb