`vagrant ssh` now queries for the ssh forwarded port, rather than relying on config
This commit is contained in:
parent
cc0a1930d8
commit
0e4ae3530a
|
@ -122,8 +122,11 @@ module Vagrant
|
|||
return pnum if pnum
|
||||
|
||||
# Check if we have an SSH forwarded port
|
||||
pnum = env.config.vm.forwarded_ports[env.config.ssh.forwarded_port_key]
|
||||
return pnum[:hostport] if pnum
|
||||
pnum = env.vm.vm.forwarded_ports.detect do |fp|
|
||||
fp.name == env.config.ssh.forwarded_port_key
|
||||
end
|
||||
|
||||
return pnum.hostport if pnum
|
||||
|
||||
# Fall back to the default
|
||||
return env.config.ssh.port
|
||||
|
|
|
@ -29,6 +29,7 @@ class Test::Unit::TestCase
|
|||
config.ssh.username = "foo"
|
||||
config.ssh.password = "bar"
|
||||
config.ssh.host = "baz"
|
||||
config.ssh.port = 22
|
||||
config.ssh.forwarded_port_key = "ssh"
|
||||
config.ssh.max_tries = 10
|
||||
config.ssh.timeout = 10
|
||||
|
|
|
@ -6,6 +6,13 @@ class SshTest < Test::Unit::TestCase
|
|||
yield config if block_given?
|
||||
end
|
||||
|
||||
@forwarded_ports = []
|
||||
@vm = mock("vm")
|
||||
@vm.stubs(:forwarded_ports).returns(@forwarded_ports)
|
||||
|
||||
@env.stubs(:vm).returns(mock_vm(@env))
|
||||
@env.vm.stubs(:vm).returns(@vm)
|
||||
|
||||
@ssh = Vagrant::SSH.new(@env)
|
||||
end
|
||||
|
||||
|
@ -181,10 +188,17 @@ class SshTest < Test::Unit::TestCase
|
|||
context "getting the ssh port" do
|
||||
setup do
|
||||
mock_ssh
|
||||
|
||||
end
|
||||
|
||||
should "return the configured port by default" do
|
||||
assert_equal @env.config.vm.forwarded_ports[@env.config.ssh.forwarded_port_key][:hostport], @ssh.port
|
||||
port = 2222
|
||||
fp = mock("fp")
|
||||
fp.stubs(:name).returns(@env.config.ssh.forwarded_port_key)
|
||||
fp.stubs(:hostport).returns(port)
|
||||
@forwarded_ports << fp
|
||||
|
||||
assert_equal port, @ssh.port
|
||||
end
|
||||
|
||||
should "return the port given in options if it exists" do
|
||||
|
|
|
@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Mitchell Hashimoto", "John Bender"]
|
||||
s.date = %q{2010-05-26}
|
||||
s.date = %q{2010-05-27}
|
||||
s.default_executable = %q{vagrant}
|
||||
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"]
|
||||
|
|
Loading…
Reference in New Issue