Remove config.ssh.port, it actually never did anything
This commit is contained in:
parent
66bf56a073
commit
9673b7eaee
|
@ -5,7 +5,6 @@ Vagrant::Config.run do |config|
|
|||
|
||||
config.ssh.username = "vagrant"
|
||||
config.ssh.host = "localhost"
|
||||
config.ssh.port = 22
|
||||
config.ssh.forwarded_port_key = "ssh"
|
||||
config.ssh.max_tries = 10
|
||||
config.ssh.timeout = 30
|
||||
|
|
|
@ -5,7 +5,6 @@ module Vagrant
|
|||
|
||||
attr_accessor :username
|
||||
attr_accessor :host
|
||||
attr_accessor :port
|
||||
attr_accessor :forwarded_port_key
|
||||
attr_accessor :max_tries
|
||||
attr_accessor :timeout
|
||||
|
@ -18,7 +17,7 @@ module Vagrant
|
|||
end
|
||||
|
||||
def validate(errors)
|
||||
[:username, :host, :port, :forwarded_port_key, :max_tries, :timeout, :private_key_path].each do |field|
|
||||
[:username, :host, :forwarded_port_key, :max_tries, :timeout, :private_key_path].each do |field|
|
||||
errors.add(I18n.t("vagrant.config.common.error_empty", :field => field)) if !instance_variable_get("@#{field}".to_sym)
|
||||
end
|
||||
|
||||
|
|
|
@ -245,6 +245,11 @@ module Vagrant
|
|||
error_key(:ssh_key_bad_permissions)
|
||||
end
|
||||
|
||||
class SSHPortNotDetected < VagrantError
|
||||
status_code(50)
|
||||
error_key(:ssh_port_not_detected)
|
||||
end
|
||||
|
||||
class SSHUnavailable < VagrantError
|
||||
status_code(45)
|
||||
error_key(:ssh_unavailable)
|
||||
|
|
|
@ -142,8 +142,7 @@ module Vagrant
|
|||
|
||||
# Returns the port which is either given in the options hash or taken from
|
||||
# the config by finding it in the forwarded ports hash based on the
|
||||
# `config.ssh.forwarded_port_key` or use the default port given by `config.ssh.port`
|
||||
# when port forwarding isn't used.
|
||||
# `config.ssh.forwarded_port_key`.
|
||||
def port(opts={})
|
||||
# Check if port was specified in options hash
|
||||
pnum = opts[:port]
|
||||
|
@ -161,8 +160,8 @@ module Vagrant
|
|||
|
||||
return pnum.hostport if pnum
|
||||
|
||||
# Fall back to the default
|
||||
return env.config.ssh.port
|
||||
# This should NEVER happen.
|
||||
raise Errors::SSHPortNotDetected
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -84,6 +84,10 @@ en:
|
|||
permissions on the following file to 0600 and then try running this command again:
|
||||
|
||||
%{key_path}
|
||||
ssh_port_not_detected: |-
|
||||
Vagrant couldn't determine the SSH port for your VM! This is a rare,
|
||||
exceptional event, and a bug should be filed. Please try recreating your
|
||||
VM (vagrant destroy, then vagrant up). Sorry!
|
||||
ssh_unavailable: "`ssh` binary could not be found. Is an SSH client installed?"
|
||||
ssh_unavailable_windows: |-
|
||||
`vagrant ssh` isn't available on the Windows platform. The
|
||||
|
|
|
@ -19,6 +19,7 @@ class SshTest < Test::Unit::TestCase
|
|||
setup do
|
||||
mock_ssh
|
||||
@ssh.stubs(:check_key_permissions)
|
||||
@ssh.stubs(:port).returns(2222)
|
||||
Kernel.stubs(:exec)
|
||||
Kernel.stubs(:system).returns(true)
|
||||
|
||||
|
@ -53,8 +54,8 @@ class SshTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
should "call exec with supplied params" do
|
||||
args = {:username => 'bar', :private_key_path => 'baz', :host => 'bak', :port => 'bag'}
|
||||
ssh_exec_expect(args[:port], args[:private_key_path], args[:username], args[:host])
|
||||
args = {:username => 'bar', :private_key_path => 'baz', :host => 'bak'}
|
||||
ssh_exec_expect(@ssh.port, args[:private_key_path], args[:username], args[:host])
|
||||
@ssh.connect(args)
|
||||
end
|
||||
|
||||
|
@ -116,10 +117,10 @@ class SshTest < Test::Unit::TestCase
|
|||
|
||||
def ssh_exec_expect(port, key_path, uname, host)
|
||||
Kernel.expects(:exec).with() do |arg|
|
||||
assert arg =~ /^ssh/
|
||||
assert arg =~ /-p #{port}/
|
||||
assert arg =~ /-i #{key_path}/
|
||||
assert arg =~ /#{uname}@#{host}/
|
||||
assert arg =~ /^ssh/, "ssh command expected"
|
||||
assert arg =~ /-p #{port}/, "-p #{port} expected"
|
||||
assert arg =~ /-i #{key_path}/, "-i #{key_path} expected"
|
||||
assert arg =~ /#{uname}@#{host}/, "#{uname}@{host} expected"
|
||||
yield arg if block_given?
|
||||
true
|
||||
end
|
||||
|
@ -198,6 +199,7 @@ class SshTest < Test::Unit::TestCase
|
|||
setup do
|
||||
mock_ssh
|
||||
@ssh.stubs(:check_key_permissions)
|
||||
@ssh.stubs(:port).returns(2222)
|
||||
end
|
||||
|
||||
should "return true if SSH connection works" do
|
||||
|
|
Loading…
Reference in New Issue