Sha256: a34e9a6b8d9995b6e5f72e3c1f2fcbe5755e2e15f5b5154677aacb165260ec56
Contents?: true
Size: 906 Bytes
Versions: 11
Compression:
Stored size: 906 Bytes
Contents
require "log4r" module VagrantPlugins module Shell 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_shell::action::read_state") end def call(env) env[:machine_state_id] = read_state(env[:machine]) @app.call(env) end def read_state(machine) return :not_created if machine.id.nil? # Return the state output = %x{ #{machine.provider_config.script} read-state #{machine.id} } if $?.to_i > 0 raise Errors::ShellError, :message => "Failure: #{env[:machine].provider_config.script} read-state #{machine.id}" end output.strip end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems