SSH gives proper error if VM is not running [closes GH-167]

This commit is contained in:
Mitchell Hashimoto 2010-09-29 23:37:24 -07:00
parent 990908c3ed
commit c30b5f4093
4 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,6 @@
## 0.6.4 (unreleased)
- SSH gives proper error message if VM is not running. [GH-167]
- Fix some issues with undefined constants in command errors.
- Replaced `Kernel#system` calls with custom `Vagrant::Util::Sh` method to
fix strange error issues.

View File

@ -25,6 +25,7 @@ module Vagrant
def ssh_connect
raise Errors::VMNotCreatedError.new if !ssh_vm.created?
raise Errors::VMNotRunningError.new if !ssh_vm.vm.running?
ssh_vm.ssh.connect
end

View File

@ -293,6 +293,11 @@ module Vagrant
error_key(:vm_not_found)
end
class VMNotRunningError < VagrantError
status_code(44)
error_key(:vm_not_running)
end
class VMPowerOffToPackage < VagrantError
status_code(24)
error_key(:power_off, "vagrant.actions.vm.export")

View File

@ -88,8 +88,9 @@ en:
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
If VirtualBox is installed, it may be an incorrect version. Vagrant currently
requires VirtualBox 3.2.x. Please install the proper version to continue.
vm_creation_required: VM must be created before running this command. Run `vagrant up` first.
vm_not_found: A VM by the name of %{name} was not found.
vm_creation_required: "VM must be created before running this command. Run `vagrant up` first."
vm_not_found: "A VM by the name of %{name} was not found."
vm_not_running: "VM must be running to open SSH connection."
#-------------------------------------------------------------------------------
# Translations for config validation errors