2012-01-17 19:25:40 +00:00
|
|
|
require 'set'
|
|
|
|
require 'tempfile'
|
|
|
|
|
2012-05-23 22:57:43 +00:00
|
|
|
require "vagrant"
|
2012-02-11 02:14:51 +00:00
|
|
|
require 'vagrant/util/template_renderer'
|
|
|
|
|
2012-05-23 22:57:43 +00:00
|
|
|
require Vagrant.source_root.join("plugins/guests/linux/guest")
|
|
|
|
|
2012-04-19 04:23:25 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module GuestArch
|
|
|
|
class Guest < VagrantPlugins::GuestLinux::Guest
|
2012-02-11 02:14:51 +00:00
|
|
|
# Make the TemplateRenderer top-level
|
|
|
|
include Vagrant::Util
|
|
|
|
|
2011-07-27 21:24:27 +00:00
|
|
|
def change_host_name(name)
|
2012-01-07 04:03:56 +00:00
|
|
|
# Only do this if the hostname is not already set
|
2012-09-02 17:00:11 +00:00
|
|
|
if !vm.communicate.test("sudo hostname | grep '#{name}'")
|
|
|
|
vm.communicate.sudo("sed -i 's/\\(HOSTNAME=\\).*/\\1#{name}/' /etc/rc.conf")
|
|
|
|
vm.communicate.sudo("hostname #{name}")
|
|
|
|
vm.communicate.sudo("sed -i 's@^\\(127[.]0[.]0[.]1[[:space:]]\\+\\)@\\1#{name} @' /etc/hosts")
|
2011-07-27 21:24:27 +00:00
|
|
|
end
|
|
|
|
end
|
2011-07-29 14:20:54 +00:00
|
|
|
|
2012-01-17 19:25:40 +00:00
|
|
|
def configure_networks(networks)
|
|
|
|
networks.each do |network|
|
2012-06-01 12:26:34 +00:00
|
|
|
entry = TemplateRenderer.render("guests/arch/network_#{network[:type]}",
|
|
|
|
:options => network)
|
2012-01-17 19:25:40 +00:00
|
|
|
|
2012-05-29 17:45:28 +00:00
|
|
|
temp = Tempfile.new("vagrant")
|
|
|
|
temp.binmode
|
|
|
|
temp.write(entry)
|
|
|
|
temp.close
|
2011-07-29 14:20:54 +00:00
|
|
|
|
2012-09-02 17:00:11 +00:00
|
|
|
vm.communicate.upload(temp.path, "/tmp/vagrant_network")
|
|
|
|
vm.communicate.sudo("mv /tmp/vagrant_network /etc/network.d/interfaces/eth#{network[:interface]}")
|
|
|
|
vm.communicate.sudo("netcfg interfaces/eth#{network[:interface]}")
|
2011-07-29 14:20:54 +00:00
|
|
|
end
|
|
|
|
end
|
2011-07-27 21:24:27 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|