Sha256: 3740936706745e80f8e725b6a85efeb7b7a4b8ab2c593b57eb640bb8cff57a08

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

require "log4r"

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

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

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

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-cosmic-0.2.0 lib/vagrant-cosmic/action/stop_instance.rb
vagrant-cosmic-0.1.0 lib/vagrant-cosmic/action/stop_instance.rb