Merge pull request #8577 from chrisroberts/fix/dhcp-assigned-route
Fetch first network device and pass to template for rendering
This commit is contained in:
commit
1bf09520d3
|
@ -15,11 +15,12 @@ module VagrantPlugins
|
||||||
entries = []
|
entries = []
|
||||||
interfaces = machine.guest.capability(:network_interfaces)
|
interfaces = machine.guest.capability(:network_interfaces)
|
||||||
|
|
||||||
|
root_device = interfaces.first
|
||||||
networks.each do |network|
|
networks.each do |network|
|
||||||
network[:device] = interfaces[network[:interface]]
|
network[:device] = interfaces[network[:interface]]
|
||||||
|
|
||||||
entry = TemplateRenderer.render("guests/debian/network_#{network[:type]}",
|
entry = TemplateRenderer.render("guests/debian/network_#{network[:type]}",
|
||||||
options: network,
|
options: network.merge(:root_device => root_device),
|
||||||
)
|
)
|
||||||
entries << entry
|
entries << entry
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ iface <%= options[:device] %> inet dhcp
|
||||||
post-up route del default dev $IFACE || true
|
post-up route del default dev $IFACE || true
|
||||||
<% else %>
|
<% else %>
|
||||||
# We need to disable eth0, see GH-2648
|
# We need to disable eth0, see GH-2648
|
||||||
post-up route del default dev $IFACE || true
|
post-up route del default dev <%= options[:root_device] %> || true
|
||||||
post-up dhclient $IFACE
|
post-up dhclient $IFACE
|
||||||
pre-down route add default dev $IFACE
|
pre-down route add default dev <%= options[:root_device] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
|
|
|
@ -23,6 +23,7 @@ describe "templates/guests/debian/network_dhcp" do
|
||||||
it "renders the template" do
|
it "renders the template" do
|
||||||
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
result = Vagrant::Util::TemplateRenderer.render(template, options: {
|
||||||
device: "eth1",
|
device: "eth1",
|
||||||
|
root_device: "eth0",
|
||||||
use_dhcp_assigned_default_route: true,
|
use_dhcp_assigned_default_route: true,
|
||||||
})
|
})
|
||||||
expect(result).to eq <<-EOH.gsub(/^ {8}/, "")
|
expect(result).to eq <<-EOH.gsub(/^ {8}/, "")
|
||||||
|
@ -31,9 +32,9 @@ describe "templates/guests/debian/network_dhcp" do
|
||||||
auto eth1
|
auto eth1
|
||||||
iface eth1 inet dhcp
|
iface eth1 inet dhcp
|
||||||
# We need to disable eth0, see GH-2648
|
# We need to disable eth0, see GH-2648
|
||||||
post-up route del default dev $IFACE || true
|
post-up route del default dev eth0 || true
|
||||||
post-up dhclient $IFACE
|
post-up dhclient $IFACE
|
||||||
pre-down route add default dev $IFACE
|
pre-down route add default dev eth0
|
||||||
#VAGRANT-END
|
#VAGRANT-END
|
||||||
EOH
|
EOH
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue