core: MachineIndex#valid? checks state and ID again
This commit is contained in:
parent
bc4d91fb73
commit
d526dd54fe
|
@ -435,11 +435,19 @@ module Vagrant
|
||||||
# found, it is already false.
|
# found, it is already false.
|
||||||
return false if !found
|
return false if !found
|
||||||
|
|
||||||
# If the environment doesn't contain the machine with this
|
# Get the machine
|
||||||
# name, then it is also false. At some point, we can remove
|
machine = nil
|
||||||
# this limitation if we support destroying machines where
|
begin
|
||||||
# the Vagrantfile is moved.
|
machine = env.machine(self.name.to_sym, self.provider.to_sym)
|
||||||
return false if !env.machine_names.find { |n| n == self.name.to_sym }
|
rescue Errors::MachineNotFound
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
# Refresh the machine state
|
||||||
|
machine.state
|
||||||
|
|
||||||
|
# If the machine doesn't have an ID, it is invalid
|
||||||
|
return false if !machine.id
|
||||||
|
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -73,15 +73,17 @@ module VagrantPlugins
|
||||||
#
|
#
|
||||||
# @return [Symbol]
|
# @return [Symbol]
|
||||||
def state
|
def state
|
||||||
# XXX: What happens if we destroy the VM but the UUID is still
|
|
||||||
# set here?
|
|
||||||
|
|
||||||
# Determine the ID of the state here.
|
# Determine the ID of the state here.
|
||||||
state_id = nil
|
state_id = nil
|
||||||
state_id = :not_created if !@driver.uuid
|
state_id = :not_created if !@driver.uuid
|
||||||
state_id = @driver.read_state if !state_id
|
state_id = @driver.read_state if !state_id
|
||||||
state_id = :unknown if !state_id
|
state_id = :unknown if !state_id
|
||||||
|
|
||||||
|
# If we're not created, then reset the ID to nil
|
||||||
|
if state_id == :not_created
|
||||||
|
@machine.id = nil
|
||||||
|
end
|
||||||
|
|
||||||
# Translate into short/long descriptions
|
# Translate into short/long descriptions
|
||||||
short = state_id.to_s.gsub("_", " ")
|
short = state_id.to_s.gsub("_", " ")
|
||||||
long = I18n.t("vagrant.commands.status.#{state_id}")
|
long = I18n.t("vagrant.commands.status.#{state_id}")
|
||||||
|
|
Loading…
Reference in New Issue