ssh_config works with new machine abstraction

This commit is contained in:
Mitchell Hashimoto 2012-08-13 19:48:26 -07:00
parent 83b908f3d8
commit db11c16b79
2 changed files with 13 additions and 13 deletions

View File

@ -10,12 +10,11 @@ module VagrantPlugins
def execute
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: vagrant ssh-config [vm-name] [-h name]"
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant ssh-config [vm-name] [-h name]"
o.separator ""
opts.separator ""
opts.on("--host COMMAND", "Name the host for the config..") do |h|
o.on("--host COMMAND", "Name the host for the config..") do |h|
options[:host] = h
end
end
@ -23,13 +22,12 @@ module VagrantPlugins
argv = parse_options(opts)
return if !argv
with_target_vms(argv, :single_target => true) do |vm|
raise Vagrant::Errors::VMNotCreatedError if !vm.created?
raise Vagrant::Errors::VMInaccessible if !vm.state == :inaccessible
with_target_vms(argv, :single_target => true) do |machine|
ssh_info = machine.ssh_info
raise Vagrant::Errors::SSHNotReady if ssh_info.nil?
ssh_info = vm.ssh.info
variables = {
:host_key => options[:host] || vm.name || "vagrant",
:host_key => options[:host] || machine.name || "vagrant",
:ssh_host => ssh_info[:host],
:ssh_port => ssh_info[:port],
:ssh_user => ssh_info[:username],
@ -45,7 +43,7 @@ module VagrantPlugins
# Success, exit status 0
0
end
end
end
end
end

View File

@ -164,8 +164,10 @@ en:
The provider for this Vagrant-managed machine is reporting that it
is not yet ready for SSH. Depending on your provider this can carry
different meanings. Make sure your machine is created and running and
try again. If you continue to get this error message, please view the
documentation for the provider you're using.
try again. Additionally, check the output of `vagrant status` to verify
that the machine is in the state that you expect. If you continue to
get this error message, please view the documentation for the provider
you're using.
ssh_port_not_detected: |-
Vagrant couldn't determine the SSH port for your VM! Vagrant attempts to
automatically find a forwarded port that matches your `config.ssh.guest_port`