diff --git a/CHANGELOG.md b/CHANGELOG.md index 81a918e09..f10baf631 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/lib/vagrant/command/ssh.rb b/lib/vagrant/command/ssh.rb index 6770870d5..eec55009d 100644 --- a/lib/vagrant/command/ssh.rb +++ b/lib/vagrant/command/ssh.rb @@ -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 diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index db0b44926..f91a914ec 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -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") diff --git a/templates/locales/en.yml b/templates/locales/en.yml index eb2c4a937..c0a747294 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -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