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.
|
||||
return false if !found
|
||||
|
||||
# If the environment doesn't contain the machine with this
|
||||
# name, then it is also false. At some point, we can remove
|
||||
# this limitation if we support destroying machines where
|
||||
# the Vagrantfile is moved.
|
||||
return false if !env.machine_names.find { |n| n == self.name.to_sym }
|
||||
# Get the machine
|
||||
machine = nil
|
||||
begin
|
||||
machine = env.machine(self.name.to_sym, self.provider.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
|
||||
end
|
||||
|
|
|
@ -73,15 +73,17 @@ module VagrantPlugins
|
|||
#
|
||||
# @return [Symbol]
|
||||
def state
|
||||
# XXX: What happens if we destroy the VM but the UUID is still
|
||||
# set here?
|
||||
|
||||
# Determine the ID of the state here.
|
||||
state_id = nil
|
||||
state_id = :not_created if !@driver.uuid
|
||||
state_id = @driver.read_state 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
|
||||
short = state_id.to_s.gsub("_", " ")
|
||||
long = I18n.t("vagrant.commands.status.#{state_id}")
|
||||
|
|
Loading…
Reference in New Issue