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



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

def self.configure_networks(machine, networks)
  networks.each do |network|
    # we use arch templates here, since TemplateRenderer has hardcoded
    # paths and arch already uses systemd + netctl
    entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}",
                                    :options => network)

    temp = Tempfile.new("vagrant")
    temp.binmode
    temp.write(entry)
    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