A VM can now have a host only network on multiple adapters

This commit is contained in:
Mitchell Hashimoto 2010-06-03 11:50:29 -07:00
parent bb7a309cab
commit 4e806ae325
3 changed files with 15 additions and 10 deletions

View File

@ -11,12 +11,15 @@ module Vagrant
logger.info "Enabling host only network..."
runner.system.prepare_host_only_network
runner.system.enable_host_only_network(runner.env.config.vm.network_options)
runner.env.config.vm.network_options.compact.each do |network_options|
runner.system.enable_host_only_network(network_options)
end
end
end
def enable_network?
!runner.env.config.vm.network_options.nil?
!runner.env.config.vm.network_options.compact.empty?
end
# Enables and assigns the host only network to the proper
@ -24,12 +27,13 @@ module Vagrant
def assign_network
logger.info "Preparing host only network..."
network_options = runner.env.config.vm.network_options
adapter = runner.vm.network_adapters[network_options[:adapter]]
adapter.enabled = true
adapter.attachment_type = :host_only
adapter.host_interface = network_name(network_options)
adapter.save
runner.env.config.vm.network_options.compact.each do |network_options|
adapter = runner.vm.network_adapters[network_options[:adapter]]
adapter.enabled = true
adapter.attachment_type = :host_only
adapter.host_interface = network_name(network_options)
adapter.save
end
end
# Returns the name of the proper host only network, or creates

View File

@ -102,7 +102,7 @@ module Vagrant
@forwarded_ports = {}
@shared_folders = {}
@provisioner = nil
@network_options = nil
@network_options = []
end
def forward_port(name, guestport, hostport, options=nil)
@ -140,7 +140,7 @@ module Vagrant
:name => nil
}.merge(options || {})
@network_options = options
@network_options[options[:adapter]] = options
end
def hd_location=(val)

View File

@ -25,6 +25,7 @@ class NetworkTest < Test::Unit::TestCase
context "after boot" do
setup do
@runner.env.config.vm.network("foo")
@action.stubs(:enable_network?).returns(true)
end