Update Arch guest to the new networks API
This commit is contained in:
parent
3a2546907e
commit
f4ea1f800c
|
@ -1,3 +1,6 @@
|
||||||
|
require 'set'
|
||||||
|
require 'tempfile'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Guest
|
module Guest
|
||||||
class Arch < Linux
|
class Arch < Linux
|
||||||
|
@ -10,23 +13,34 @@ module Vagrant
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Convert these to the new format
|
def configure_networks(networks)
|
||||||
def prepare_host_only_network(net_options=nil)
|
# Remove previous Vagrant-managed network interfaces
|
||||||
vm.ssh.execute do |ssh|
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
|
||||||
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/rc.conf > /tmp/vagrant-network-interfaces")
|
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/rc.conf")
|
||||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/rc.conf'")
|
|
||||||
|
# Configure the network interfaces
|
||||||
|
interfaces = Set.new
|
||||||
|
entries = []
|
||||||
|
networks.each do |network|
|
||||||
|
interfaces.add(network[:interface])
|
||||||
|
entries << TemplateRenderer.render("guests/arch/network_#{network[:type]}",
|
||||||
|
:options => network)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def enable_host_only_network(net_options)
|
# Perform the careful dance necessary to reconfigure
|
||||||
entry = TemplateRenderer.render('guests/arch/network_hostonly',
|
# the network interfaces
|
||||||
:net_options => net_options)
|
temp = Tempfile.new("vagrant")
|
||||||
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
temp.write(entries.join("\n"))
|
||||||
|
temp.close
|
||||||
|
|
||||||
vm.ssh.execute do |ssh|
|
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")
|
||||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/rc.conf'")
|
|
||||||
ssh.exec!("sudo /etc/rc.d/network restart")
|
# Reconfigure the network interfaces
|
||||||
ssh.exec!("sudo su -c 'dhcpcd -k eth0 && dhcpcd eth0 & sleep 3'")
|
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/rc.conf")
|
||||||
|
vm.channel.sudo("/etc/rc.d/network restart")
|
||||||
|
|
||||||
|
interfaces.each do |interface|
|
||||||
|
vm.channel.sudo("dhcpcd -k eth#{interface} && dhcpcd eth#{interface} && sleep 3")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
|
interface=eth<%= options[:interface] %>
|
||||||
|
address=
|
||||||
|
netmask=
|
||||||
|
gateway=
|
||||||
|
#VAGRANT-END
|
|
@ -1,7 +0,0 @@
|
||||||
#VAGRANT-BEGIN-HOSTONLY
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
interface=eth<%= net_options[:adapter] %>
|
|
||||||
address=<%= net_options[:ip]%>
|
|
||||||
netmask=<%= net_options[:netmask] %>
|
|
||||||
gateway=
|
|
||||||
#VAGRANT-END-HOSTONLY
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
|
interface=eth<%= options[:interface] %>
|
||||||
|
address=<%= options[:ip]%>
|
||||||
|
netmask=<%= options[:netmask] %>
|
||||||
|
gateway=
|
||||||
|
#VAGRANT-END
|
Loading…
Reference in New Issue