SSH gets port from proper place in 3.2.x

This commit is contained in:
Mitchell Hashimoto 2010-06-17 22:31:01 -07:00
parent 26b837f427
commit d257703496
4 changed files with 24 additions and 6 deletions

View File

@ -132,8 +132,20 @@ module Vagrant
return pnum if pnum
# Check if we have an SSH forwarded port
pnum = env.vm.vm.forwarded_ports.detect do |fp|
fp.name == env.config.ssh.forwarded_port_key
if VirtualBox.version =~ /^3\.1\./
pnum = env.vm.vm.forwarded_ports.detect do |fp|
fp.name == env.config.ssh.forwarded_port_key
end
else
# VirtualBox 3.2 specific
pnum = nil
env.vm.vm.network_adapters.each do |na|
pnum = na.nat_engine.forwarded_ports.detect do |fp|
fp.name == env.config.ssh.forwarded_port_key
end
break if pnum
end
end
return pnum.hostport if pnum

View File

@ -1,6 +1,6 @@
require File.join(File.dirname(__FILE__), '..', 'test_helper')
class SshTest < Test::Unit::TestCase
class SshSessionTest < Test::Unit::TestCase
setup do
@session = mock("session")

View File

@ -16,6 +16,10 @@ class SshTest < Test::Unit::TestCase
@ssh = Vagrant::SSH.new(@env)
end
setup do
VirtualBox.stubs(:version).returns("3.1.4")
end
context "connecting to external SSH" do
setup do
mock_ssh
@ -93,6 +97,7 @@ class SshTest < Test::Unit::TestCase
setup do
mock_ssh
@ssh.stubs(:check_key_permissions)
@ssh.stubs(:port).returns(80)
end
should "check key permissions then attempt to start connection" do
@ -206,10 +211,11 @@ class SshTest < Test::Unit::TestCase
context "getting the ssh port" do
setup do
mock_ssh
end
should "return the configured port by default" do
should "return the configured port by default in VB 3.1.x" do
VirtualBox.stubs(:version).returns("3.1.4")
port = 2222
fp = mock("fp")
fp.stubs(:name).returns(@env.config.ssh.forwarded_port_key)

View File

@ -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-06-15}
s.date = %q{2010-06-17}
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"]