Scope SSH errors to proper exception classes

This commit is contained in:
Mitchell Hashimoto 2010-09-01 10:47:34 -07:00
parent e7f06d7fb7
commit ae6e42dbbc
5 changed files with 18 additions and 43 deletions

View File

@ -12,7 +12,7 @@ module Vagrant
vm.ssh.execute do |ssh|
# Checks for the existence of chef binary and error if it
# doesn't exist.
ssh.exec!("which #{binary}", :error_key => :chef_not_detected, :error_data => {:binary => binary})
ssh.exec!("which #{binary}", :error_class => ChefError, :_key => :chef_not_detected, :binary => binary)
end
end

View File

@ -68,7 +68,7 @@ module Vagrant
# interface file.
vm.ssh.execute do |ssh|
# Verify debian/ubuntu
ssh.exec!("cat /etc/debian_version", :error_key => :network_not_debian)
ssh.exec!("cat /etc/debian_version", :error_class => LinuxError, :_key => :network_not_debian)
# Clear out any previous entries
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/network/interfaces > /tmp/vagrant-network-interfaces")

View File

@ -308,6 +308,11 @@ en:
running_client: "Running chef-client..."
running_solo: "Running chef-solo..."
invalid_provisioner: "Vagrant::Provisioners::Chef is not a valid provisioner! Use ChefSolo or ChefServer instead."
not_detected: |-
The `%{binary}` binary appears to not be in the PATH of the guest. This
could be because the PATH is not properly setup or perhaps chef is not
installed on this guest. Chef provisioning can not continue without
chef properly installed.
server_url_required: |-
Chef server provisioning requires that the `config.chef.chef_server_url` be set to the
URL of your chef server. Examples include "http://12.12.12.12:4000" and
@ -324,3 +329,13 @@ en:
linux:
attempting_halt: "Attempting graceful shutdown of linux..."
mount_fail: "Failed to mount shared folders. `vboxsf` was not available."
network_not_debian: |-
Host only networking is only supported for Debian/Ubuntu by the built-in
"Linux" system. If you're using some other distro and want to implement
host only networking, please subclass the `Vagrant::Systems::Linux` class
and implement the `prepare_host_only_network` and `enable_host_only_network`
methods.
Otherwise, please report your distro and how to modify network interfaces
to the Vagrant mailing list or IRC and we'll probably be glad to add it
to the internal systems.

View File

@ -7,33 +7,6 @@
#---------------------------------------------------------------------
# CATEGORY: Error Messages
#---------------------------------------------------------------------
:box_file_exists: |-
The specified output file for packaging already exists. Please move
the file or modify the output filename parameter then try to package
again.
Specified output file: <%= output_file %>
:box_remove_doesnt_exist: |-
The box you're attempting to remove does not exist!
:box_repackage_doesnt_exist: |-
The box you're attempting to repackage does not exist. Please check the
name you specified and try again. As a reminder, the repackage
command is for repackaging boxes which have been added through `vagrant box add`
but the box has been lost.
:chef_not_detected: |-
The `<%= binary %>` binary appears to not be in the PATH of the guest. This
could be because the PATH is not properly setup or perhaps chef is not
installed on this guest. Chef provisioning can not continue without
chef properly installed.
:command_box_invalid: |-
Please specify a valid action to take on the boxes, either
`add` or `remove`. Examples:
vagrant box add name uri
vagrant box remove name
vagrant box list
:package_requires_export: |-
Package must be used in conjunction with export.
:system_invalid_class: |-
The specified system does not inherit from `Vagrant::Systems::Base`. The
specified system class must inherit from this class.
@ -45,16 +18,3 @@
:system_unspecified: |-
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.
#---------------------------------------------------------------------
# CATEGORY: Error Messages for Linux System
#---------------------------------------------------------------------
:network_not_debian: |-
Host only networking is only supported for Debian/Ubuntu by the built-in
"Linux" system. If you're using some other distro and want to implement
host only networking, please subclass the `Vagrant::Systems::Linux` class
and implement the `prepare_host_only_network` and `enable_host_only_network`
methods.
Otherwise, please report your distro and how to modify network interfaces
to the Vagrant mailing list or IRC and we'll probably be glad to add it
to the internal systems.

View File

@ -73,7 +73,7 @@ class ChefProvisionerTest < Test::Unit::TestCase
should "verify binary exists" do
binary = "foo"
@ssh.expects(:exec!).with("which #{binary}", :error_key => :chef_not_detected, :error_data => { :binary => binary }).once
@ssh.expects(:exec!).with("which #{binary}", anything)
@action.verify_binary(binary)
end
end