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

View File

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