core: Use Machine#state wherever possible so we update the index

This commit is contained in:
Mitchell Hashimoto 2014-03-14 16:34:14 -07:00
parent e14216da4e
commit 9a16af10ad
6 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@ module Vagrant
# Otherwise, periodically verify the VM isn't in a bad state. # Otherwise, periodically verify the VM isn't in a bad state.
while true while true
state = env[:machine].provider.state.id state = env[:machine].state.id
# Used to report invalid states # Used to report invalid states
Thread.current[:last_known_state] = state Thread.current[:last_known_state] = state

View File

@ -7,7 +7,7 @@ module VagrantPlugins
end end
def call(env) def call(env)
if env[:machine].provider.state.id == :saved if env[:machine].state.id == :saved
env[:ui].info I18n.t("vagrant.actions.vm.discard_state.discarding") env[:ui].info I18n.t("vagrant.actions.vm.discard_state.discarding")
env[:machine].provider.driver.discard_saved_state env[:machine].provider.driver.discard_saved_state
end end

View File

@ -12,7 +12,7 @@ module VagrantPlugins
@env = env @env = env
raise Vagrant::Errors::VMPowerOffToPackage if \ raise Vagrant::Errors::VMPowerOffToPackage if \
@env[:machine].provider.state.id != :poweroff @env[:machine].state.id != :poweroff
export export

View File

@ -33,7 +33,7 @@ module VagrantPlugins
end end
def recover(env) def recover(env)
if env[:machine].provider.state.id != :not_created if env[:machine].state.id != :not_created
return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError) return if env["vagrant.error"].is_a?(Vagrant::Errors::VagrantError)
# If we're not supposed to destroy on error then just return # If we're not supposed to destroy on error then just return

View File

@ -7,7 +7,7 @@ module VagrantPlugins
end end
def call(env) def call(env)
current_state = env[:machine].provider.state.id current_state = env[:machine].state.id
if current_state == :paused if current_state == :paused
env[:ui].info I18n.t("vagrant.actions.vm.resume.unpausing") env[:ui].info I18n.t("vagrant.actions.vm.resume.unpausing")

View File

@ -7,7 +7,7 @@ module VagrantPlugins
end end
def call(env) def call(env)
if env[:machine].provider.state.id == :running if env[:machine].state.id == :running
env[:ui].info I18n.t("vagrant.actions.vm.suspend.suspending") env[:ui].info I18n.t("vagrant.actions.vm.suspend.suspending")
env[:machine].provider.driver.suspend env[:machine].provider.driver.suspend
end end