Class: VagrantPlugins::GuestSystemd::Cap::ConfigureNetworks

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-systemd.rb

Class Method Summary collapse

Class Method Details

.configure_networks(machine, networks) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vagrant-systemd.rb', line 31

def self.configure_networks(machine, networks)
  networks.each do |network|
    template_path = File.expand_path("../../templates/network_#{network[:type]}.erb", __FILE__)
    template = File.read(template_path)

    temp = Tempfile.new("vagrant")
    temp.binmode
    temp.write(Erubis::Eruby.new(template, :trim => true).result(binding))
    temp.close

    machine.communicate.upload(temp.path, "/tmp/vagrant_network")
    machine.communicate.sudo("ln -sf /dev/null /etc/udev/rules.d/80-net-name-slot.rules")
    machine.communicate.sudo("mv /tmp/vagrant_network /etc/netctl/eth#{network[:interface]}")
    machine.communicate.sudo("netctl start eth#{network[:interface]}")
  end
end