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 Guest
|
||||
class Gentoo < Linux
|
||||
def prepare_host_only_network(net_options=nil)
|
||||
# Remove any previous host only network additions to the
|
||||
# interface file.
|
||||
vm.ssh.execute do |ssh|
|
||||
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 configure_networks(networks)
|
||||
# Remove any previous host only network additions to the interface file
|
||||
vm.channel.sudo("sed -e '/^#VAGRANT-BEGIN/,/^#VAGRANT-END/ d' /etc/conf.d/net > /tmp/vagrant-network-interfaces")
|
||||
vm.channel.sudo("cat /tmp/vagrant-network-interfaces > /etc/conf.d/net")
|
||||
|
||||
def enable_host_only_network(net_options)
|
||||
entry = TemplateRenderer.render('guests/gentoo/network_hostonly',
|
||||
:net_options => net_options)
|
||||
vm.ssh.upload!(StringIO.new(entry), "/tmp/vagrant-network-entry")
|
||||
# Configure each network interface
|
||||
networks.each do |network|
|
||||
entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
|
||||
:options => network)
|
||||
|
||||
vm.ssh.execute do |ssh|
|
||||
ssh.exec!("sudo ln -fs /etc/init.d/net.lo /etc/init.d/net.eth#{net_options[:adapter]}")
|
||||
ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} stop 2> /dev/null")
|
||||
ssh.exec!("sudo su -c 'cat /tmp/vagrant-network-entry >> /etc/conf.d/net'")
|
||||
ssh.exec!("sudo /etc/init.d/net.eth#{net_options[:adapter]} start")
|
||||
# Upload the entry to a temporary location
|
||||
temp = Tempfile.new("vagrant")
|
||||
temp.write(entry)
|
||||
temp.close
|
||||
|
||||
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
|
||||
|
|
|
@ -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