Handle inaccessible VMs with "vagrant status"

This commit is contained in:
Mitchell Hashimoto 2011-08-28 20:17:25 -07:00
parent ed422e1151
commit 2efe1f9135
2 changed files with 16 additions and 2 deletions

View File

@ -3,10 +3,19 @@ module Vagrant
class StatusCommand < NamedBase
register "status", "Shows the status of the current Vagrant environment."
def route
def execute
state = nil
results = target_vms.collect do |vm|
state = vm.created? ? vm.vm.state.to_s : "not_created"
if vm.created?
if vm.vm.accessible?
state = vm.vm.state.to_s
else
state = "inaccessible"
end
else
state = "not_created"
end
"#{vm.name.to_s.ljust(25)}#{state.gsub("_", " ")}"
end

View File

@ -191,6 +191,11 @@ en:
stopped without properly closing the session. Run `vagrant up`
to resume this virtual machine. If any problems persist, you may
have to destroy and restart the virtual machine.
inaccessible: |-
The VM is inaccessible! This is a rare case which means that VirtualBox
can't find your VM configuration. This usually happens when upgrading
VirtualBox, moving to a new computer, etc. Please consult VirtualBox
for how to handle this issue.
output: |-
Current VM states: