Sha256: 6f7c2521aa01ca1998fe8fa4f89d8e62f5b7af34f8e162f7f04b6ce9d46ef0b6

Contents?: true

Size: 712 Bytes

Versions: 15

Compression:

Stored size: 712 Bytes

Contents

require "log4r"

module VagrantPlugins
  module Sakura
    module Action
      class Halt
        def initialize(app, env)
          @app    = app
          @logger = Log4r::Logger.new("vagrant_sakura::action::halt")
        end

        def call(env)
          api      = env[:sakura_api]
          serverid = env[:machine].id

          env[:ui].info(I18n.t("vagrant_sakura.power_off"))

          response = api.delete("/server/#{serverid}/power")
          sleep 3
          while true
            response = api.get("/server/#{serverid}/power")
            break if response["Instance"]["Status"] == "down"
            sleep 1
          end

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
vagrant-sakura-0.4.2 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.4.0 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.3.2 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.3.1 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.3.0 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.2.1 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.1.0 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.9 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.8 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.7 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.6 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.5 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.3 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.2 lib/vagrant-sakura/action/halt.rb
vagrant-sakura-0.0.1 lib/vagrant-sakura/action/halt.rb