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