vagrant/plugins/guests/arch/cap/configure_networks.rb

31 lines
951 B
Ruby
Raw Normal View History

require "tempfile"
require "vagrant/util/template_renderer"
2013-04-04 18:39:58 +00:00
module VagrantPlugins
module GuestArch
module Cap
class ConfigureNetworks
include Vagrant::Util
2013-04-04 18:39:58 +00:00
def self.configure_networks(machine, networks)
networks.each do |network|
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]}")
2013-04-04 18:39:58 +00:00
end
end
end
end
end
end