All errors now go through the errors.yml files
This commit is contained in:
parent
ac6c3a4892
commit
3c2e1bd80a
|
@ -21,10 +21,7 @@ module Vagrant
|
|||
|
||||
def setup_box_dir
|
||||
if File.directory?(box_dir)
|
||||
error_and_exit(<<-msg)
|
||||
This box appears to already exist! Please call `vagrant box remove #{@runner.name}`
|
||||
and then try to add it again.
|
||||
msg
|
||||
error_and_exit(:box_already_exists, :box_name => @runner.name)
|
||||
end
|
||||
|
||||
FileUtils.mkdir_p(box_dir)
|
||||
|
|
|
@ -14,9 +14,7 @@ module Vagrant
|
|||
# Wait for it to complete booting, or error if we could
|
||||
# never detect it booted up successfully
|
||||
if !wait_for_boot
|
||||
error_and_exit(<<-error)
|
||||
Failed to connect to VM! Failed to boot?
|
||||
error
|
||||
error_and_exit(:vm_failed_to_boot)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,9 +4,7 @@ module Vagrant
|
|||
class MoveHardDrive < Base
|
||||
def execute!
|
||||
unless @runner.powered_off?
|
||||
error_and_exit(<<-error)
|
||||
The virtual machine must be powered off to move its disk.
|
||||
error
|
||||
error_and_exit(:vm_power_off_to_move_hd)
|
||||
return
|
||||
end
|
||||
|
||||
|
|
|
@ -14,10 +14,7 @@ module Vagrant
|
|||
def init(default_box=nil)
|
||||
rootfile_path = File.join(Dir.pwd, Env::ROOTFILE_NAME)
|
||||
if File.exist?(rootfile_path)
|
||||
error_and_exit(<<-error)
|
||||
It looks like this directory is already setup for vagrant! (A #{Env::ROOTFILE_NAME}
|
||||
already exists.)
|
||||
error
|
||||
error_and_exit(:rootfile_already_exists, :rootfile => Env::ROOTFILE_NAME)
|
||||
end
|
||||
|
||||
# Copy over the rootfile template into this directory
|
||||
|
@ -162,9 +159,7 @@ msg
|
|||
def package(out_path=nil, include_files=[])
|
||||
Env.load!
|
||||
Env.require_persisted_vm
|
||||
error_and_exit(<<-error) unless Env.persisted_vm.powered_off?
|
||||
The vagrant virtual environment you are trying to package must be powered off
|
||||
error
|
||||
error_and_exit(:vm_power_off_to_package) unless Env.persisted_vm.powered_off?
|
||||
|
||||
Env.persisted_vm.package(out_path, include_files)
|
||||
end
|
||||
|
@ -179,14 +174,7 @@ error
|
|||
sub_commands = ["list", "add", "remove"]
|
||||
|
||||
if !sub_commands.include?(argv[0])
|
||||
error_and_exit(<<-error)
|
||||
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
|
||||
error
|
||||
error_and_exit(:command_box_invalid)
|
||||
end
|
||||
|
||||
send("box_#{argv[0]}", *argv[1..-1])
|
||||
|
@ -217,9 +205,7 @@ error
|
|||
def box_remove(name)
|
||||
box = Box.find(name)
|
||||
if box.nil?
|
||||
error_and_exit(<<-error)
|
||||
The box you're attempting to remove does not exist!
|
||||
error
|
||||
error_and_exit(:box_remove_doesnt_exist)
|
||||
return # for tests
|
||||
end
|
||||
|
||||
|
|
|
@ -32,43 +32,13 @@ module Vagrant
|
|||
def check_virtualbox!
|
||||
version = VirtualBox::Command.version
|
||||
if version.nil?
|
||||
error_and_exit(<<-msg)
|
||||
Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
|
||||
If VirtualBox is installed, you may need to tweak the paths to the `VBoxManage`
|
||||
application which ships with VirtualBox and the path to the global XML configuration
|
||||
which VirtualBox typically stores somewhere in your home directory.
|
||||
|
||||
The following shows how to configure VirtualBox. This can be done in the
|
||||
Vagrantfile. Note that 90% of the time, you shouldn't need to do this if VirtualBox
|
||||
is installed. Please use the various Vagrant support lines to request more information
|
||||
if you can't get this working.
|
||||
|
||||
VirtualBox::Command.vboxmanage = "/path/to/my/VBoxManage"
|
||||
VirtualBox::Global.vboxconfig = "~/path/to/VirtualBox.xml"
|
||||
msg
|
||||
error_and_exit(:virtualbox_not_detected)
|
||||
elsif version.to_f < 3.1
|
||||
error_and_exit(<<-msg)
|
||||
Vagrant has detected that you have VirtualBox version #{version} installed!
|
||||
Vagrant requires that you use at least VirtualBox version 3.1. Please install
|
||||
a more recent version of VirtualBox to continue.
|
||||
msg
|
||||
error_and_exit(:virtualbox_invalid_version, :version => version.to_s)
|
||||
end
|
||||
|
||||
if !VirtualBox::Global.vboxconfig?
|
||||
error_and_exit(<<-msg)
|
||||
Vagrant couldn't find your global VirtualBox.xml file!
|
||||
|
||||
If you just recently installed VirtualBox, make sure you've launched
|
||||
it at least once, since the initial launch will typically create this
|
||||
file.
|
||||
|
||||
Otherwise, you may need to set the path to the VirtualBox.xml file
|
||||
manually. Note that 90% of people should never have to do this, so
|
||||
don't be afraid to use the various Vagrant support lines to ask for
|
||||
help. To set the path manually:
|
||||
|
||||
VirtualBox::Global.vboxconfig = "/path/to/VirtualBox.xml"
|
||||
msg
|
||||
error_and_exit(:virtualbox_xml_not_detected)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -158,12 +128,7 @@ msg
|
|||
|
||||
def require_root_path
|
||||
if !root_path
|
||||
error_and_exit(<<-msg)
|
||||
A `#{ROOTFILE_NAME}` was not found! This file is required for vagrant to run
|
||||
since it describes the expected environment that vagrant is supposed
|
||||
to manage. Please create a #{ROOTFILE_NAME} and place it in your project
|
||||
root.
|
||||
msg
|
||||
error_and_exit(:rootfile_not_found, :rootfile => ROOTFILE_NAME)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -172,18 +137,9 @@ msg
|
|||
|
||||
if !box
|
||||
if !Vagrant.config.vm.box
|
||||
error_and_exit(<<-msg)
|
||||
No base box was specified! A base box is required as a staring point
|
||||
for every vagrant virtual machine. Please specify one in your Vagrantfile
|
||||
using `config.vm.box`
|
||||
msg
|
||||
error_and_exit(:box_not_specified)
|
||||
else
|
||||
error_and_exit(<<-msg)
|
||||
Specified box `#{Vagrant.config.vm.box}` does not exist!
|
||||
|
||||
The box must be added through the `vagrant box add` command. Please view
|
||||
the documentation associated with the command for more information.
|
||||
msg
|
||||
error_and_exit(:box_specified_doesnt_exist, :box_name => Vagrant.config.vm.box)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -192,13 +148,7 @@ msg
|
|||
require_root_path
|
||||
|
||||
if !persisted_vm
|
||||
error_and_exit(<<-error)
|
||||
The task you're trying to run requires that the vagrant environment
|
||||
already be created, but unfortunately this vagrant still appears to
|
||||
have no box! You can setup the environment by setting up your
|
||||
#{ROOTFILE_NAME} and running `vagrant up`
|
||||
error
|
||||
return
|
||||
error_and_exit(:environment_not_created)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -43,21 +43,7 @@ module Vagrant
|
|||
check_thread.join(Vagrant.config.ssh.timeout)
|
||||
return check_thread[:result]
|
||||
rescue Net::SSH::AuthenticationFailed
|
||||
error_and_exit(<<-msg)
|
||||
SSH authentication failed! While this could be due to a variety of reasons,
|
||||
the two most common are: private key path is incorrect or you're using a box
|
||||
which was built for Vagrant 0.1.x.
|
||||
|
||||
Vagrant 0.2.x dropped support for password-based authentication. If you're
|
||||
tring to `vagrant up` a box which does not support Vagrant's private/public
|
||||
keypair, then this error will be raised. To resolve this, read the guide
|
||||
on converting base boxes from password-based to keypairs here:
|
||||
|
||||
http://vagrantup.com/docs/converting_password_to_key_ssh.html
|
||||
|
||||
If the box was built for 0.2.x and contains a custom public key, perhaps
|
||||
the path to the private key is incorrect. Check your `config.ssh.private_key_path`.
|
||||
msg
|
||||
error_and_exit(:vm_ssh_auth_failed)
|
||||
end
|
||||
|
||||
def port(opts={})
|
||||
|
|
|
@ -10,12 +10,12 @@ module Vagrant
|
|||
puts "====================================================================="
|
||||
end
|
||||
|
||||
def error_and_exit(error)
|
||||
def error_and_exit(key, data = {})
|
||||
abort <<-error
|
||||
=====================================================================
|
||||
Vagrant experienced an error!
|
||||
|
||||
#{error.chomp}
|
||||
#{Errors.error_string(key, data).chomp}
|
||||
=====================================================================
|
||||
error
|
||||
end
|
||||
|
|
|
@ -8,6 +8,8 @@ module Vagrant
|
|||
@@errors = nil
|
||||
|
||||
class <<self
|
||||
# Resets the internal errors hash to nil, forcing a reload on the next
|
||||
# access of {errors}.
|
||||
def reset!
|
||||
@@errors = nil
|
||||
end
|
||||
|
|
|
@ -1 +1,69 @@
|
|||
:foo: bar
|
||||
:box_already_exists: "This box appears to already exist! Please call `vagrant box remove <%= box_name %>`
|
||||
and then try to add it again."
|
||||
:box_remove_doesnt_exist: "The box you're attempting to remove does not exist!"
|
||||
:box_specified_doesnt_exist: "Specified box `<%= box_name %>` does not exist!
|
||||
|
||||
The box must be added through the `vagrant box add` command. Please view
|
||||
the documentation associated with the command for more information."
|
||||
:box_not_specified: "No base box was specified! A base box is required as a staring point
|
||||
for every vagrant virtual machine. Please specify one in your Vagrantfile
|
||||
using `config.vm.box`"
|
||||
: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"
|
||||
:environment_not_created: "The task you're trying to run requires that the vagrant environment
|
||||
already be created, but unfortunately this vagrant still appears to
|
||||
have no box! You can setup the environment by setting up your
|
||||
<%= Vagrant::Env::ROOTFILE_NAME %> and running `vagrant up`"
|
||||
:rootfile_already_exists: "It looks like this directory is already setup for vagrant! (A <%= rootfile %>
|
||||
already exists.)"
|
||||
:rootfile_not_found: "A `<%= rootfile %>` was not found! This file is required for vagrant to run
|
||||
since it describes the expected environment that vagrant is supposed
|
||||
to manage. Please create a `<%= rootfile %>` and place it in your project
|
||||
root."
|
||||
:virtualbox_invalid_version: "Vagrant has detected that you have VirtualBox version <%= version %> installed!
|
||||
Vagrant requires that you use at least VirtualBox version 3.1. Please install
|
||||
a more recent version of VirtualBox to continue."
|
||||
:virtualbox_not_detected: "Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
|
||||
If VirtualBox is installed, you may need to tweak the paths to the `VBoxManage`
|
||||
application which ships with VirtualBox and the path to the global XML configuration
|
||||
which VirtualBox typically stores somewhere in your home directory.
|
||||
|
||||
The following shows how to configure VirtualBox. This can be done in the
|
||||
Vagrantfile. Note that 90% of the time, you shouldn't need to do this if VirtualBox
|
||||
is installed. Please use the various Vagrant support lines to request more information
|
||||
if you can't get this working.
|
||||
|
||||
VirtualBox::Command.vboxmanage = \"/path/to/my/VBoxManage\"
|
||||
VirtualBox::Global.vboxconfig = \"~/path/to/VirtualBox.xml\""
|
||||
:virtualbox_xml_not_detected: "Vagrant couldn't find your global VirtualBox.xml file!
|
||||
|
||||
If you just recently installed VirtualBox, make sure you've launched
|
||||
it at least once, since the initial launch will typically create this
|
||||
file.
|
||||
|
||||
Otherwise, you may need to set the path to the VirtualBox.xml file
|
||||
manually. Note that 90% of people should never have to do this, so
|
||||
don't be afraid to use the various Vagrant support lines to ask for
|
||||
help. To set the path manually:
|
||||
|
||||
VirtualBox::Global.vboxconfig = \"/path/to/VirtualBox.xml\""
|
||||
:vm_failed_to_boot: "Failed to connect to VM! Failed to boot?"
|
||||
:vm_power_off_to_move_hd: "The virtual machine must be powered off to move its disk."
|
||||
:vm_power_off_to_package: "The vagrant virtual environment you are trying to package must be powered off."
|
||||
:vm_ssh_auth_failed: "SSH authentication failed! While this could be due to a variety of reasons,
|
||||
the two most common are: private key path is incorrect or you're using a box
|
||||
which was built for Vagrant 0.1.x.
|
||||
|
||||
Vagrant 0.2.x dropped support for password-based authentication. If you're
|
||||
tring to `vagrant up` a box which does not support Vagrant's private/public
|
||||
keypair, then this error will be raised. To resolve this, read the guide
|
||||
on converting base boxes from password-based to keypairs here:
|
||||
|
||||
http://vagrantup.com/docs/converting_password_to_key_ssh.html
|
||||
|
||||
If the box was built for 0.2.x and contains a custom public key, perhaps
|
||||
the path to the private key is incorrect. Check your `config.ssh.private_key_path`."
|
|
@ -389,16 +389,13 @@ class EnvTest < Test::Unit::TestCase
|
|||
Vagrant::Env.require_box
|
||||
end
|
||||
|
||||
should "error and exit if no box is found" do
|
||||
should "error and exit if no box is specified" do
|
||||
mock_config do |config|
|
||||
config.vm.box = nil
|
||||
end
|
||||
|
||||
Vagrant::Env.expects(:box).returns(nil)
|
||||
Vagrant::Env.expects(:error_and_exit).once.with() do |msg|
|
||||
assert msg =~ /no base box was specified/i
|
||||
true
|
||||
end
|
||||
Vagrant::Env.expects(:error_and_exit).once.with(:box_not_specified)
|
||||
Vagrant::Env.require_box
|
||||
end
|
||||
|
||||
|
@ -408,10 +405,7 @@ class EnvTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
Vagrant::Env.expects(:box).returns(nil)
|
||||
Vagrant::Env.expects(:error_and_exit).once.with() do |msg|
|
||||
assert msg =~ /does not exist/i
|
||||
true
|
||||
end
|
||||
Vagrant::Env.expects(:error_and_exit).once.with(:box_specified_doesnt_exist, :box_name => "foo")
|
||||
Vagrant::Env.require_box
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue