Update Gentoo guest to new networks API
This commit is contained in:
parent
13760e81de
commit
3a2546907e
|
@ -1,25 +1,30 @@
|
||||||
|
require 'tempfile'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module Guest
|
module Guest
|
||||||
class Gentoo < Linux
|
class Gentoo < Linux
|
||||||
def prepare_host_only_network(net_options=nil)
|
def configure_networks(networks)
|
||||||
# Remove any previous host only network additions to the
|
# Remove any previous host only network additions to the interface file
|
||||||
# interface file.
|
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
||||||
vm.ssh.execute do |ssh|
|
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
||||||
ssh.exec!("sudo sed -e '/^#VAGRANT-BEGIN-HOSTONLY/,/^#VAGRANT-END-HOSTONLY/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
|
||||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-interfaces > /etc/conf.d/net'")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def enable_host_only_network(net_options)
|
# Configure each network interface
|
||||||
entry = TemplateRenderer.render('guests/gentoo/network_hostonly',
|
networks.each do |network|
|
||||||
:net_options => net_options)
|
entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
|
||||||
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
:options => network)
|
||||||
|
|
||||||
vm.ssh.execute do |ssh|
|
# Upload the entry to a temporary location
|
||||||
ssh.exec!("sudo ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{net_options[:adapter]}")
|
temp = Tempfile.new("vagrant")
|
||||||
ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} stop 2> /dev/null")
|
temp.write(entry)
|
||||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/conf.d/net'")
|
temp.close
|
||||||
ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} start")
|
|
||||||
|
vm.channel.upload(temp.path, "/tmp/vagrant-network-entry")
|
||||||
|
|
||||||
|
# Configure the interface
|
||||||
|
vm.channel.sudo("ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{network[:interface]}")
|
||||||
|
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} stop 2> /dev/null")
|
||||||
|
vm.channel.sudo("cat /tmp/vagrant-network-entry >> /etc/conf.d/net")
|
||||||
|
vm.channel.sudo("/etc/init.d/net.eth#{network[:interface]} start")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
|
config_eth<%= options[:interface] %>="dhcp"
|
||||||
|
#VAGRANT-END
|
|
@ -1,4 +0,0 @@
|
||||||
#VAGRANT-BEGIN-HOSTONLY
|
|
||||||
# The contents below are automatically generated by Vagrant. Do not modify.
|
|
||||||
config_eth<%= net_options[:adapter] %>=("<%= net_options[:ip] %> netmask <%= net_options[:netmask] %>")
|
|
||||||
#VAGRANT-END-HOSTONLY
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#VAGRANT-BEGIN
|
||||||
|
# The contents below are automatically generated by Vagrant. Do not modify.
|
||||||
|
config_eth<%= options[:interface] %>=("<%= options[:ip] %> netmask <%= options[:netmask] %>")
|
||||||
|
#VAGRANT-END
|
Loading…
Reference in New Issue