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
|
end
|
||||||
|
|
||||||
def configure_private_networks(env)
|
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
|
next if type.to_sym != :private_network
|
||||||
|
|
||||||
container_name = env[:machine].provider.driver.container_name
|
container_name = env[:machine].provider.driver.container_name
|
||||||
address_type = config[:type]
|
container_interface = config[:interface]
|
||||||
ip = config[:ip]
|
address_type = config[:type]
|
||||||
bridge_ip = config.fetch(:lxc__bridge_ip) { build_bridge_ip(ip) }
|
ip = config[:ip]
|
||||||
bridge = config.fetch(:lxc__bridge_name)
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,11 @@ module Vagrant
|
||||||
@cli.info(*command)
|
@cli.info(*command)
|
||||||
end
|
end
|
||||||
|
|
||||||
def configure_private_network(bridge_name, bridge_ip, container_name, address_type, ip)
|
def configure_private_network(bridge_name, bridge_ip, container_name, container_interface, address_type, ip)
|
||||||
@logger.info "Configuring network interface for #{container_name} using #{ip} and bridge #{bridge_name}"
|
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
|
if ip
|
||||||
ip += '/24'
|
ip += '/24'
|
||||||
end
|
end
|
||||||
|
@ -170,6 +173,8 @@ module Vagrant
|
||||||
cmd = [
|
cmd = [
|
||||||
Vagrant::LXC.source_root.join('scripts/pipework').to_s,
|
Vagrant::LXC.source_root.join('scripts/pipework').to_s,
|
||||||
bridge_name,
|
bridge_name,
|
||||||
|
"-i",
|
||||||
|
container_interface,
|
||||||
container_name,
|
container_name,
|
||||||
ip ||= "dhcp"
|
ip ||= "dhcp"
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue