Merge pull request #401 from cangeli/multiple-private-networks
This commit is contained in:
commit
3421d7eb0f
2 changed files with 15 additions and 9 deletions
|
@ -22,16 +22,17 @@ module Vagrant
|
|||
end
|
||||
|
||||
def configure_private_networks(env)
|
||||
env[:machine].config.vm.networks.find do |type, config|
|
||||
env[:machine].config.vm.networks.find_all.each do |type, config|
|
||||
next if type.to_sym != :private_network
|
||||
|
||||
container_name = env[:machine].provider.driver.container_name
|
||||
container_interface = config[:interface]
|
||||
address_type = config[:type]
|
||||
ip = config[:ip]
|
||||
bridge_ip = config.fetch(:lxc__bridge_ip) { build_bridge_ip(ip) }
|
||||
bridge = config.fetch(:lxc__bridge_name)
|
||||
|
||||
env[:machine].provider.driver.configure_private_network(bridge, bridge_ip, container_name, address_type, ip)
|
||||
env[:machine].provider.driver.configure_private_network(bridge, bridge_ip, container_name, container_interface, address_type, ip)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -130,8 +130,11 @@ module Vagrant
|
|||
@cli.info(*command)
|
||||
end
|
||||
|
||||
def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
|
||||
@logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}"
|
||||
def configure_private_network(bridge_name, bridge_ip, container_name, container_interface, address_type, ip)
|
||||
if ! container_interface
|
||||
container_interface = "eth1"
|
||||
end
|
||||
@logger.info "Configuring network interface #{container_interface} for #{container_name} using #{ip} and bridge #{bridge_name}"
|
||||
if ip
|
||||
ip += '/24'
|
||||
end
|
||||
|
@ -170,6 +173,8 @@ module Vagrant
|
|||
cmd = [
|
||||
Vagrant::LXC.source_root.join('scripts/pipework').to_s,
|
||||
bridge_name,
|
||||
"-i",
|
||||
container_interface,
|
||||
container_name,
|
||||
ip ||= "dhcp"
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue