2014-03-06 16:51:07 +00:00
|
|
|
|
2014-02-15 23:29:16 +00:00
|
|
|
require "log4r"
|
2014-02-16 00:28:11 +00:00
|
|
|
|
2014-02-15 23:29:16 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module HyperV
|
|
|
|
module Action
|
|
|
|
class ReadState
|
|
|
|
def initialize(app, env)
|
|
|
|
@app = app
|
|
|
|
@logger = Log4r::Logger.new("vagrant::hyperv::connection")
|
|
|
|
end
|
|
|
|
|
|
|
|
def call(env)
|
|
|
|
if env[:machine].id
|
2014-03-06 16:51:07 +00:00
|
|
|
response = env[:machine].provider.driver.get_current_state
|
2014-02-16 19:31:33 +00:00
|
|
|
env[:machine_state_id] = response["state"].downcase.to_sym
|
2014-02-26 19:20:53 +00:00
|
|
|
|
|
|
|
# If the machine isn't created, then our ID is stale, so just
|
|
|
|
# mark it as not created.
|
|
|
|
if env[:machine_state_id] == :not_created
|
|
|
|
env[:machine].id = nil
|
|
|
|
end
|
2014-02-15 23:29:16 +00:00
|
|
|
else
|
|
|
|
env[:machine_state_id] = :not_created
|
|
|
|
end
|
|
|
|
@app.call(env)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|