Failed SSH commands show output in error message. [closes GH-285]

This commit is contained in:
Mitchell Hashimoto 2011-02-08 22:47:36 -08:00
parent 41e98c97d6
commit c1373f4eca
3 changed files with 10 additions and 3 deletions

View File

@ -8,6 +8,7 @@
- Change sudo shell to use `bash` (configurable). [GH-301] - Change sudo shell to use `bash` (configurable). [GH-301]
- Can now set mac address of host only network. [GH-294] - Can now set mac address of host only network. [GH-294]
- NFS shared folders with spaces now work properly. [GH-293] - NFS shared folders with spaces now work properly. [GH-293]
- Failed SSH commands now show output in error message. [GH-285]
## 0.7.1 (January 28, 2011) ## 0.7.1 (January 28, 2011)

View File

@ -75,7 +75,7 @@ module Vagrant
options = { :error_check => true }.merge(options || {}) options = { :error_check => true }.merge(options || {})
block ||= Proc.new do |ch, type, data| block ||= Proc.new do |ch, type, data|
check_exit_status(data, command, options) if type == :exit_status && options[:error_check] check_exit_status(data, command, options, ch[:result]) if type == :exit_status && options[:error_check]
ch[:result] ||= "" ch[:result] ||= ""
ch[:result] << data if [:stdout, :stderr].include?(type) ch[:result] << data if [:stdout, :stderr].include?(type)
@ -99,12 +99,14 @@ module Vagrant
# Checks for an erroroneous exit status and raises an exception # Checks for an erroroneous exit status and raises an exception
# if so. # if so.
def check_exit_status(exit_status, commands, options=nil) def check_exit_status(exit_status, commands, options=nil, output=nil)
if exit_status != 0 if exit_status != 0
output ||= '[no output]'
options = { options = {
:_error_class => Errors::VagrantError, :_error_class => Errors::VagrantError,
:_key => :ssh_bad_exit_status, :_key => :ssh_bad_exit_status,
:command => [commands].flatten.join("\n") :command => [commands].flatten.join("\n"),
:output => output
}.merge(options || {}) }.merge(options || {})
raise options[:_error_class], options raise options[:_error_class], options

View File

@ -70,6 +70,10 @@ en:
Vagrant assumes that this means the command failed! Vagrant assumes that this means the command failed!
%{command} %{command}
The output of the command prior to failing is outputted below:
%{output}
ssh_connection_refused: |- ssh_connection_refused: |-
SSH connection was refused! This usually happens if the VM failed to SSH connection was refused! This usually happens if the VM failed to
boot properly. Some steps to try to fix this: First, try reloading your boot properly. Some steps to try to fix this: First, try reloading your