SSH no longer raises ActionException. Raises VagrantError
This commit is contained in:
parent
786a0f443a
commit
364233527e
|
@ -222,13 +222,12 @@ module Vagrant
|
||||||
def check_exit_status(exit_status, command, options=nil)
|
def check_exit_status(exit_status, command, options=nil)
|
||||||
if exit_status != 0
|
if exit_status != 0
|
||||||
options = {
|
options = {
|
||||||
:error_key => :ssh_bad_exit_status,
|
:_error_class => Errors::VagrantError,
|
||||||
:error_data => {
|
:_key => :ssh_bad_exit_status,
|
||||||
:command => command
|
:command => command
|
||||||
}
|
|
||||||
}.merge(options || {})
|
}.merge(options || {})
|
||||||
|
|
||||||
raise Action::ActionException.new(options[:error_key], options[:error_data])
|
raise options[:_error_class].new(options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,7 +106,7 @@ module Vagrant
|
||||||
break unless result
|
break unless result
|
||||||
|
|
||||||
attempts += 1
|
attempts += 1
|
||||||
raise Action::ActionException.new(:vm_mount_fail) if attempts >= 10
|
raise LinuxError.new(:mount_fail) if attempts >= 10
|
||||||
sleep sleeptime
|
sleep sleeptime
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -115,5 +115,11 @@ module Vagrant
|
||||||
vm.env.config
|
vm.env.config
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class Linux < Base
|
||||||
|
class LinuxError < Errors::VagrantError
|
||||||
|
error_namespace("vagrant.systems.linux")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,11 @@ en:
|
||||||
keypair for the SSH user not being properly set on the guest VM. Please
|
keypair for the SSH user not being properly set on the guest VM. Please
|
||||||
verify that the guest VM is setup with the proper public key, and that
|
verify that the guest VM is setup with the proper public key, and that
|
||||||
the private key path for Vagrant is setup propery as well.
|
the private key path for Vagrant is setup propery as well.
|
||||||
|
ssh_bad_exit_status: |-
|
||||||
|
The following SSH command responded with a non-zero exit status.
|
||||||
|
Vagrant assumes that this means the command failed!
|
||||||
|
|
||||||
|
%{command}
|
||||||
ssh_key_bad_permissions: |-
|
ssh_key_bad_permissions: |-
|
||||||
The private key to connect to this box via SSH has invalid permissions
|
The private key to connect to this box via SSH has invalid permissions
|
||||||
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
|
set on it. The permissions of the private key should be set to 0600, otherwise SSH will
|
||||||
|
@ -318,3 +323,4 @@ en:
|
||||||
systems:
|
systems:
|
||||||
linux:
|
linux:
|
||||||
attempting_halt: "Attempting graceful shutdown of linux..."
|
attempting_halt: "Attempting graceful shutdown of linux..."
|
||||||
|
mount_fail: "Failed to mount shared folders. `vboxsf` was not available."
|
||||||
|
|
|
@ -34,11 +34,6 @@
|
||||||
vagrant box list
|
vagrant box list
|
||||||
:package_requires_export: |-
|
:package_requires_export: |-
|
||||||
Package must be used in conjunction with export.
|
Package must be used in conjunction with export.
|
||||||
:ssh_bad_exit_status: |-
|
|
||||||
The following SSH command responded with a non-zero exit status.
|
|
||||||
Vagrant assumes that this means the command failed!
|
|
||||||
|
|
||||||
<%= command %>
|
|
||||||
:system_invalid_class: |-
|
:system_invalid_class: |-
|
||||||
The specified system does not inherit from `Vagrant::Systems::Base`. The
|
The specified system does not inherit from `Vagrant::Systems::Base`. The
|
||||||
specified system class must inherit from this class.
|
specified system class must inherit from this class.
|
||||||
|
@ -50,8 +45,6 @@
|
||||||
:system_unspecified: |-
|
:system_unspecified: |-
|
||||||
A VM system type must be specified! This is done via the `config.vm.system`
|
A VM system type must be specified! This is done via the `config.vm.system`
|
||||||
configuration value. Please read the documentation online for more information.
|
configuration value. Please read the documentation online for more information.
|
||||||
:vm_mount_fail: |-
|
|
||||||
Failed to mount shared folders. vboxsf was not available.
|
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
# CATEGORY: Error Messages for Linux System
|
# CATEGORY: Error Messages for Linux System
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
|
|
|
@ -19,21 +19,14 @@ class SshSessionTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "checking exit status" do
|
context "checking exit status" do
|
||||||
should "raise an ActionException if its non-zero" do
|
should "raise an ActionException if its non-zero" do
|
||||||
assert_raises(Vagrant::Action::ActionException) {
|
assert_raises(Vagrant::Errors::VagrantError) {
|
||||||
@instance.check_exit_status(1, "foo")
|
@instance.check_exit_status(1, "foo")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
should "raise the given exception if specified" do
|
should "raise the given exception if specified" do
|
||||||
options = {
|
assert_raises(Vagrant::Errors::BaseVMNotFound) {
|
||||||
:error_key => :foo,
|
@instance.check_exit_status(1, "foo", :_error_class => Vagrant::Errors::BaseVMNotFound)
|
||||||
:error_data => {}
|
|
||||||
}
|
|
||||||
result = Exception.new
|
|
||||||
Vagrant::Action::ActionException.expects(:new).with(options[:error_key], options[:error_data]).once.returns(result)
|
|
||||||
|
|
||||||
assert_raises(Exception) {
|
|
||||||
@instance.check_exit_status(1, "foo", options)
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ class LinuxSystemTest < Test::Unit::TestCase
|
||||||
should "raise an ActionException if the command fails constantly" do
|
should "raise an ActionException if the command fails constantly" do
|
||||||
@ssh.expects(:exec!).times(@limit).returns(!@success_return)
|
@ssh.expects(:exec!).times(@limit).returns(!@success_return)
|
||||||
|
|
||||||
assert_raises(Vagrant::Action::ActionException) {
|
assert_raises(Vagrant::Systems::Linux::LinuxError) {
|
||||||
mount_folder
|
mount_folder
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue