Sha256: 1eb366ee7535e939bd0c7d2edd47372ac31376f774fc2e3d30a25a406b7f1b3e

Contents?: true

Size: 1.36 KB

Versions: 6

Compression:

Stored size: 1.36 KB

Contents

require 'tempfile'

require 'vagrant/util/template_renderer'

module Vagrant
  module Guest
    class Gentoo < Linux
      # Make the TemplateRenderer top-level
      include Vagrant::Util

      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")

        # Configure each network interface
        networks.each do |network|
          entry = TemplateRenderer.render("guests/gentoo/network_#{network[:type]}",
                                          :options => network)

          # Upload the entry to a temporary location
          temp = Tempfile.new("vagrant")
          temp.binmode
          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
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
vagrantup-1.0.1 lib/vagrant/guest/gentoo.rb
vagrantup-1.0.0 lib/vagrant/guest/gentoo.rb
vagrantup-0.9.99.2 lib/vagrant/guest/gentoo.rb
vagrantup-0.9.99.1 lib/vagrant/guest/gentoo.rb
vagrant-1.0.1 lib/vagrant/guest/gentoo.rb
vagrant-1.0.0 lib/vagrant/guest/gentoo.rb