2013-08-14 14:10:18 +00:00
|
|
|
# A general Vagrant system implementation for "solaris 11".
|
|
|
|
#
|
|
|
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
|
|
|
|
|
|
|
module VagrantPlugins
|
|
|
|
module GuestSolaris11
|
|
|
|
module Cap
|
|
|
|
class ConfigureNetworks
|
|
|
|
def self.configure_networks(machine, networks)
|
|
|
|
networks.each do |network|
|
|
|
|
device = "#{machine.config.solaris11.device}#{network[:interface]}"
|
|
|
|
su_cmd = machine.config.solaris11.suexec_cmd
|
|
|
|
mask = "#{network[:netmask]}"
|
|
|
|
cidr = mask.split(".").map { |e| e.to_i.to_s(2).rjust(8, "0") }.join.count("1").to_s
|
|
|
|
#ifconfig_cmd = "#{su_cmd} /sbin/ifconfig #{device}"
|
|
|
|
#machine.communicate.execute("#{ifconfig_cmd} plumb")
|
|
|
|
if network[:type].to_sym == :static
|
|
|
|
#machine.communicate.execute("#{ifconfig_cmd} inet #{network[:ip]} netmask #{network[:netmask]}")
|
|
|
|
#machine.communicate.execute("#{ifconfig_cmd} up")
|
|
|
|
#machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"")
|
|
|
|
# ipadm create-addr -T static -a local=172.16.10.15/24 net2/v4
|
2014-10-10 20:49:45 +00:00
|
|
|
if machine.communicate.test("ipadm | grep #{device}/v4")
|
|
|
|
machine.communicate.execute("#{su_cmd} ipadm delete-addr #{device}/v4")
|
2014-10-10 18:09:42 +00:00
|
|
|
end
|
2014-10-10 20:42:13 +00:00
|
|
|
machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4")
|
2013-08-14 14:10:18 +00:00
|
|
|
elsif network[:type].to_sym == :dhcp
|
|
|
|
#machine.communicate.execute("#{ifconfig_cmd} dhcp start")
|
2014-05-21 22:21:05 +00:00
|
|
|
if machine.communicate.test("ipadm show-if -o all | grep #{device} | tr -s ' ' | cut -d ' ' -f 6 | grep '4\|6'")
|
|
|
|
machine.communicate.execute("#{su_cmd} ipadm create-addr -T addrconf #{device}/v4")
|
|
|
|
end
|
2013-08-14 14:10:18 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|