error for vagrant ssh on windows, error text, mario gem, still need doc pages for links in error.yml

This commit is contained in:
John Bender 2010-03-24 23:54:35 -07:00
parent 9ba3108cc3
commit 4e4d1a6978
10 changed files with 404 additions and 218 deletions

View File

@ -7,6 +7,7 @@ gem "net-scp", ">= 1.0.2"
gem "git-style-binaries", ">= 0.1.10" gem "git-style-binaries", ">= 0.1.10"
gem "json_pure", ">= 1.2.0" gem "json_pure", ">= 1.2.0"
gem "archive-tar-minitar", ">= 0.5.2" gem "archive-tar-minitar", ">= 0.5.2"
gem "mario, "= 0.0.6"
# Gems required for testing only. To install run # Gems required for testing only. To install run
# gem bundle test # gem bundle test

View File

@ -16,6 +16,7 @@ begin
gemspec.add_dependency('json_pure', '>= 1.2.0') gemspec.add_dependency('json_pure', '>= 1.2.0')
gemspec.add_dependency('git-style-binaries', '>= 0.1.10') gemspec.add_dependency('git-style-binaries', '>= 0.1.10')
gemspec.add_dependency('archive-tar-minitar', '= 0.5.2') gemspec.add_dependency('archive-tar-minitar', '= 0.5.2')
gemspec.add_dependency('mario', '= 0.0.6')
end end
Jeweler::GemcutterTasks.new Jeweler::GemcutterTasks.new
rescue LoadError rescue LoadError

View File

@ -8,3 +8,10 @@ If you're working with a team or company or with a custom box and
you want more secure SSH, you should create your own keypair you want more secure SSH, you should create your own keypair
and configure the private key in the Vagrantfile with and configure the private key in the Vagrantfile with
`config.ssh.private_key_path` `config.ssh.private_key_path`
# Putty
If you are using Vagrant on windows, the .ppk file contained here, in the keys directory,
has been generated from the private key and should be used to connect Putty to any VMs that
are leveraging the default key pair. See [TODO LINK]() in the documentation for more details on
using Putty with Vagrant.

26
keys/vagrant.ppk Normal file
View File

@ -0,0 +1,26 @@
PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: imported-openssh-key
Public-Lines: 6
AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+k
z4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1Y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YDQT9Jpx4TMss4PSavPaBH3RXow5Ohe+bYoQNE5O
gEXk2wVfZczCZpigBKbKZHNYcelXtTt/nP3rsCuGcM4h53s=
Private-MAC: bc710f345e67c736d57dd72aab10fe4625345dae

View File

@ -3,7 +3,7 @@ PROJECT_ROOT = File.join(libdir, '..') unless defined?(PROJECT_ROOT)
# The libs which must be loaded prior to the rest # The libs which must be loaded prior to the rest
%w{tempfile open-uri json pathname logger uri net/http virtualbox net/ssh archive/tar/minitar %w{tempfile open-uri json pathname logger uri net/http virtualbox net/ssh archive/tar/minitar
net/scp fileutils}.each do |lib| net/scp fileutils mario}.each do |lib|
require lib require lib
end end

View File

@ -17,6 +17,12 @@ module Vagrant
# process with an SSH process. This method optionally takes a hash # process with an SSH process. This method optionally takes a hash
# of options which override the configuration values. # of options which override the configuration values.
def connect(opts={}) def connect(opts={})
if Mario::Platform.windows?
error_and_exit(:ssh_unavailable_windows,
:key_path => env.config.ssh.private_key_path,
:ssh_port => port(opts))
end
options = {} options = {}
[:host, :username, :private_key_path].each do |param| [:host, :username, :private_key_path].each do |param|
options[param] = opts[param] || env.config.ssh.send(param) options[param] = opts[param] || env.config.ssh.send(param)

View File

@ -58,6 +58,12 @@
\npermissions on the following file to 0600 and then try running this command again: \npermissions on the following file to 0600 and then try running this command again:
\n<%= key_path %>" \n<%= key_path %>"
:ssh_unavailable_windows: "`vagrant ssh` isn't available on the Windows platform. The vagrant.ppk
\nfile is available at <%= key_path %>.ppk
\nfor use with Putty. To do this create a new Putty session for vagrant@localhost on
\nport <%= ssh_port %>, in the Connection>SSH>Auth configuration section navigate
\nto the vagrant.ppk file, select it, save the session for later use, and connect.
\nFor a more detailed guide please consult TODO LINK."
:virtualbox_import_failure: "The VM import failed! Try running `VBoxManage import` on the box file manually for more verbose error output." :virtualbox_import_failure: "The VM import failed! Try running `VBoxManage import` on the box file manually for more verbose error output."
:virtualbox_invalid_version: "Vagrant has detected that you have VirtualBox version <%= version %> installed! :virtualbox_invalid_version: "Vagrant has detected that you have VirtualBox version <%= version %> installed!
\nVagrant requires that you use at least VirtualBox version 3.1. Please install \nVagrant requires that you use at least VirtualBox version 3.1. Please install

117
templates/errors.yml~ Normal file
View File

@ -0,0 +1,117 @@
:box_already_exists: "This box appears to already exist! Please call `vagrant box remove <%= box_name %>`
\nand then try to add it again."
:box_add_already_exists: "A box with the name '<%= box_name %>' already exists, please use another name or use `vagrant box remove <%= box_name %>`"
:box_download_unknown_type: "Unknown URI type for box download."
: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!
\nThe box must be added through the `vagrant box add` command. Please view
\nthe 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
\nfor every vagrant virtual machine. Please specify one in your Vagrantfile
\nusing `config.vm.box`"
:chef_base_invalid_provisioner: "Vagrant::Provisioners::Chef is not a valid provisioner! Use ChefSolo or ChefServer instead."
:chef_server_url_required: "Chef server provisioning requires that the `config.chef.chef_server_url` be set to the
\nURL of your chef server. Examples include \"http://12.12.12.12:4000\" and
\n\"http://myserver.com:4000\" (the port of course can be different, but 4000 is the default)"
:chef_server_validation_key_required: "Chef server provisioning requires that the `config.chef.validation_key_path` configuration
\nbe set to a path on your local machine of the validation key used to register the
\nVM with the chef server."
:chef_server_validation_key_doesnt_exist: "The validation key set for `config.chef.validation_key_path` does not exist! This
\nfile needs to exist so it can be uploaded to the virtual machine. It is
\ncurrently set to \"<%= Vagrant.config.chef.validation_key_path %>\""
:command_box_invalid: "Please specify a valid action to take on the boxes, either
\n`add` or `remove`. Examples:
\nvagrant box add name uri
\nvagrant box remove name
\nvagrant box list"
:dotfile_error: "The dotfile which Vagrant uses to store the UUID of the project's
\nvirtual machine already exists and is not a file! The dotfile is
\ncurrently configured to be `<%= env.dotfile_path %>`
\nTo change this value, please see `config.vagrant.dotfile_name`
\nThis often exists if you're trying to create a Vagrant virtual
\nenvironment from your home directory. To resolve this, you can either
\nmodify the configuration a bit, or simply use a different directory."
:downloader_file_doesnt_exist: "The given box does not exist on the file system:\n
\n<%= source_url %>"
:environment_not_created: "The task you're trying to run requires that the vagrant environment
\nalready be created, but unfortunately this vagrant still appears to
\nhave no box! You can setup the environment by setting up your
\n<%= Vagrant::Environment::ROOTFILE_NAME %> and running `vagrant up`"
:package_include_file_doesnt_exist: "File specified to include: '<%= filename %>' does not exist!"
:package_requires_export: "Package must be used in conjunction with export."
:provisioner_invalid_class: "Provisioners must be an instance of Vagrant::Provisioners::Base"
:provisioner_unknown_type: "Unknown provisioner type: <%= provisioner %>"
:rootfile_already_exists: "It looks like this directory is already setup for vagrant! (A <%= Vagrant::Environment::ROOTFILE_NAME %>
\nalready exists.)"
:rootfile_not_found: "A `<%= Vagrant::Environment::ROOTFILE_NAME %>` was not found! This file is required for vagrant to run
\nsince it describes the expected environment that vagrant is supposed
\nto manage. Please create a `<%= Vagrant::Environment::ROOTFILE_NAME %>` and place it in your project
\nroot."
:ssh_bad_permissions: "The private key to connect to this box via SSH has invalid permissions
\nset on it. The permissions of the private key should be set to 0600, otherwise SSH will
\nignore the key. Vagrant tried to do this automatically for you but failed. Please set the
\npermissions on the following file to 0600 and then try running this command again:
\n<%= key_path %>"
:virtualbox_import_failure: "The VM import failed! Try running `VBoxManage import` on the box file manually for more verbose error output."
:virtualbox_invalid_version: "Vagrant has detected that you have VirtualBox version <%= version %> installed!
\nVagrant requires that you use at least VirtualBox version 3.1. Please install
\na more recent version of VirtualBox to continue."
:virtualbox_not_detected: "Vagrant could not detect VirtualBox! Make sure VirtualBox is properly installed.
\nIf VirtualBox is installed, you may need to tweak the paths to the `VBoxManage`
\napplication which ships with VirtualBox and the path to the global XML configuration
\nwhich VirtualBox typically stores somewhere in your home directory.
\nThe following shows how to configure VirtualBox. This can be done in the
\nVagrantfile. Note that 90% of the time, you shouldn't need to do this if VirtualBox
\nis installed. Please use the various Vagrant support lines to request more information
\nif you can't get this working.
\nVirtualBox::Command.vboxmanage = \"/path/to/my/VBoxManage\"
\nVirtualBox::Global.vboxconfig = \"~/path/to/VirtualBox.xml\""
:virtualbox_xml_not_detected: "Vagrant couldn't find your global VirtualBox.xml file!
\nIf you just recently installed VirtualBox, make sure you've launched
\nit at least once, since the initial launch will typically create this
\nfile.
\nOtherwise, you may need to set the path to the VirtualBox.xml file
\nmanually. Note that 90% of people should never have to do this, so
\ndon't be afraid to use the various Vagrant support lines to ask for
\nhelp. To set the path manually:
\nVirtualBox::Global.vboxconfig = \"/path/to/VirtualBox.xml\""
:vm_failed_to_boot: "Failed to connect to VM! Failed to boot?"
:vm_not_running: "VM is not running! Nothing to shut down!"
:vm_not_running_for_suspend: "The vagrant virtual environment you are trying to suspend must be running to be suspended."
:vm_not_suspended: "The vagrant virtual environment you are trying to resume is not in a suspended state."
:vm_port_collision: "Vagrant cannot forward the specified ports on this VM, since they
\nwould collide with another VirtualBox virtual machine's forwarded
\nports! The \"<%= name %>\" forwarded port (<%= hostport %>) is already in use on the host
\nmachine.
\nTo fix this, modify your current projects Vagrantfile to use another
\nport. Example, where '1234' would be replaced by a unique host port:
\nconfig.vm.forward_port(\"<%= name %>\", <%= guestport %>, 1234)"
: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_mount_fail: "Failed to mount shared folders. vboxsf was not available."
:vm_ssh_auth_failed: "SSH authentication failed! While this could be due to a variety of reasons,
\nthe two most common are: private key path is incorrect or you're using a box
\nwhich was built for Vagrant 0.1.x.
\nVagrant 0.2.x dropped support for password-based authentication. If you're
\ntring to `vagrant up` a box which does not support Vagrant's private/public
\nkeypair, then this error will be raised. To resolve this, read the guide
\non converting base boxes from password-based to keypairs here:
\nhttp://vagrantup.com/docs/converting_password_to_key_ssh.html
\nIf the box was built for 0.2.x and contains a custom public key, perhaps
\nthe path to the private key is incorrect. Check your `config.ssh.private_key_path`."

View File

@ -17,6 +17,8 @@ class SshTest < Test::Unit::TestCase
setup do setup do
mock_ssh mock_ssh
@ssh.stubs(:check_key_permissions) @ssh.stubs(:check_key_permissions)
@ssh.stubs(:error_and_exit)
Kernel.stubs(:exec)
end end
should "check key permissions prior to exec" do should "check key permissions prior to exec" do
@ -40,6 +42,22 @@ class SshTest < Test::Unit::TestCase
@ssh.connect(args) @ssh.connect(args)
end end
context "cheching windows" do
should "error and exit if the platform is windows" do
Mario::Platform.expects(:windows?).returns(true)
@ssh.expects(:error_and_exit).with do |error_name, opts|
opts[:key_path] && opts[:ssh_port]
end
@ssh.connect
end
should "not error and exit if the platform is anything other that windows" do
Mario::Platform.expects(:windows?).returns(false)
@ssh.expects(:error_and_exit).never
@ssh.connect
end
end
def ssh_exec_expect(port, key_path, uname, host) def ssh_exec_expect(port, key_path, uname, host)
Kernel.expects(:exec).with() do |arg| Kernel.expects(:exec).with() do |arg|
assert arg =~ /^ssh/ assert arg =~ /^ssh/

View File

@ -1,6 +1,6 @@
# Generated by jeweler # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY # DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
Gem::Specification.new do |s| Gem::Specification.new do |s|
@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Mitchell Hashimoto", "John Bender"] s.authors = ["Mitchell Hashimoto", "John Bender"]
s.date = %q{2010-03-20} s.date = %q{2010-03-24}
s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.} s.description = %q{Vagrant is a tool for building and distributing virtualized development environments.}
s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"] s.email = ["mitchell.hashimoto@gmail.com", "john.m.bender@gmail.com"]
s.executables = ["vagrant", "vagrant-box", "vagrant-down", "vagrant-halt", "vagrant-init", "vagrant-package", "vagrant-reload", "vagrant-resume", "vagrant-ssh", "vagrant-status", "vagrant-suspend", "vagrant-up"] s.executables = ["vagrant", "vagrant-box", "vagrant-down", "vagrant-halt", "vagrant-init", "vagrant-package", "vagrant-reload", "vagrant-resume", "vagrant-ssh", "vagrant-status", "vagrant-suspend", "vagrant-up"]
@ -40,6 +40,7 @@ Gem::Specification.new do |s|
"config/default.rb", "config/default.rb",
"keys/README.md", "keys/README.md",
"keys/vagrant", "keys/vagrant",
"keys/vagrant.ppk",
"keys/vagrant.pub", "keys/vagrant.pub",
"lib/vagrant.rb", "lib/vagrant.rb",
"lib/vagrant/actions/base.rb", "lib/vagrant/actions/base.rb",
@ -196,6 +197,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"]) s.add_runtime_dependency(%q<json_pure>, [">= 1.2.0"])
s.add_runtime_dependency(%q<git-style-binaries>, [">= 0.1.10"]) s.add_runtime_dependency(%q<git-style-binaries>, [">= 0.1.10"])
s.add_runtime_dependency(%q<archive-tar-minitar>, ["= 0.5.2"]) s.add_runtime_dependency(%q<archive-tar-minitar>, ["= 0.5.2"])
s.add_runtime_dependency(%q<mario>, ["= 0.0.6"])
else else
s.add_dependency(%q<virtualbox>, [">= 0.5.4"]) s.add_dependency(%q<virtualbox>, [">= 0.5.4"])
s.add_dependency(%q<net-ssh>, [">= 2.0.19"]) s.add_dependency(%q<net-ssh>, [">= 2.0.19"])
@ -203,6 +205,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<json_pure>, [">= 1.2.0"]) s.add_dependency(%q<json_pure>, [">= 1.2.0"])
s.add_dependency(%q<git-style-binaries>, [">= 0.1.10"]) s.add_dependency(%q<git-style-binaries>, [">= 0.1.10"])
s.add_dependency(%q<archive-tar-minitar>, ["= 0.5.2"]) s.add_dependency(%q<archive-tar-minitar>, ["= 0.5.2"])
s.add_dependency(%q<mario>, ["= 0.0.6"])
end end
else else
s.add_dependency(%q<virtualbox>, [">= 0.5.4"]) s.add_dependency(%q<virtualbox>, [">= 0.5.4"])
@ -211,6 +214,7 @@ Gem::Specification.new do |s|
s.add_dependency(%q<json_pure>, [">= 1.2.0"]) s.add_dependency(%q<json_pure>, [">= 1.2.0"])
s.add_dependency(%q<git-style-binaries>, [">= 0.1.10"]) s.add_dependency(%q<git-style-binaries>, [">= 0.1.10"])
s.add_dependency(%q<archive-tar-minitar>, ["= 0.5.2"]) s.add_dependency(%q<archive-tar-minitar>, ["= 0.5.2"])
s.add_dependency(%q<mario>, ["= 0.0.6"])
end end
end end