Sha256: e5c5e33219f0ed06be6909f86309f2fcf0b5d6d8eafedbd50a62f148ad70868f
Contents?: true
Size: 1.03 KB
Versions: 3
Compression:
Stored size: 1.03 KB
Contents
require "log4r" module VagrantPlugins module GQ module Action # This action reads the state of the machine and puts it in the # `:machine_state_id` key in the environment. class ReadState def initialize(app, env) @app = app @logger = Log4r::Logger.new("vagrant_gq::action::read_state") end def call(env) env[:machine_state_id] = read_state(env[:gq_compute], env[:machine]) @app.call(env) end def read_state(gq, machine) return :not_created if machine.id.nil? # Find the machine server = gq.servers.get(machine.id) if server.nil? || [:"shutting-down", :terminated].include?(server.state.to_sym) # The machine can't be found @logger.info("Machine not found or terminated, assuming it got destroyed.") machine.id = nil return :not_created end # Return the state return server.state.to_sym 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/read_state.rb |
vagrant-gq-0.1.1 | lib/vagrant-gq/action/read_state.rb |
vagrant-gq-0.1.0 | lib/vagrant-gq/action/read_state.rb |