Sha256: 69079b3107b42c10aa5bbe50374f25195a07cb9b045119b357527f1261528b37

Contents?: true

Size: 792 Bytes

Versions: 2

Compression:

Stored size: 792 Bytes

Contents

require "log4r"

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

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

          if env[:machine].state.id == :stopped
            env[:ui].info(I18n.t("vagrant_cloudstack.already_status", :status => env[:machine].state.id))
          else
            env[:ui].info(I18n.t("vagrant_cloudstack.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-cloudstack-1.3.0 lib/vagrant-cloudstack/action/stop_instance.rb
vagrant-cloudstack-1.2.0 lib/vagrant-cloudstack/action/stop_instance.rb