Merge pull request #2052 from janth/solaris11-guest
guests/solaris11: Added solaris11 guest plugin
This commit is contained in:
commit
5a18be1827
|
@ -0,0 +1,25 @@
|
||||||
|
# A general Vagrant system implementation for "solaris 11".
|
||||||
|
#
|
||||||
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
module Cap
|
||||||
|
class ChangeHostName
|
||||||
|
def self.change_host_name(machine, name)
|
||||||
|
su_cmd = machine.config.solaris11.suexec_cmd
|
||||||
|
|
||||||
|
# Only do this if the hostname is not already set
|
||||||
|
if !machine.communicate.test("/usr/sbin/svccfg -s system/identity:node listprop config/nodename | /usr/bin/grep '#{name}'")
|
||||||
|
#machine.communicate.execute("#{su_cmd} sh -c \"echo '#{name}' > /etc/nodename\"")
|
||||||
|
#machine.communicate.execute("#{su_cmd} uname -S #{name}")
|
||||||
|
machine.communicate.execute("#{su_cmd} /usr/sbin/svccfg -s system/identity:node setprop config/nodename=\"#{name}\"")
|
||||||
|
machine.communicate.execute("#{su_cmd} /usr/sbin/svccfg -s system/identity:node setprop config/loopback=\"#{name}\"")
|
||||||
|
machine.communicate.execute("#{su_cmd} /usr/sbin/svccfg -s system/identity:node refresh ")
|
||||||
|
machine.communicate.execute("#{su_cmd} /usr/sbin/svcadm restart system/identity:node ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,32 @@
|
||||||
|
# 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
|
||||||
|
machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4")
|
||||||
|
elsif network[:type].to_sym == :dhcp
|
||||||
|
#machine.communicate.execute("#{ifconfig_cmd} dhcp start")
|
||||||
|
machine.communicate.execute("#{su_cmd} ipadm create-addr -T addrconf #{device}/v4")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,26 @@
|
||||||
|
# A general Vagrant system implementation for "solaris 11".
|
||||||
|
#
|
||||||
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
module Cap
|
||||||
|
class Halt
|
||||||
|
def self.halt(machine)
|
||||||
|
# There should be an exception raised if the line
|
||||||
|
#
|
||||||
|
# vagrant::::profiles=Primary Administrator
|
||||||
|
#
|
||||||
|
# does not exist in /etc/user_attr. TODO
|
||||||
|
begin
|
||||||
|
machine.communicate.execute(
|
||||||
|
"#{machine.config.solaris11.suexec_cmd} /usr/sbin/shutdown -y -i5 -g0")
|
||||||
|
rescue IOError
|
||||||
|
# Ignore, this probably means connection closed because it
|
||||||
|
# shut down.
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,32 @@
|
||||||
|
# A general Vagrant system implementation for "solaris 11".
|
||||||
|
#
|
||||||
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
module Cap
|
||||||
|
class MountVirtualBoxSharedFolder
|
||||||
|
def self.mount_virtualbox_shared_folder(machine, name, guestpath, options)
|
||||||
|
# These are just far easier to use than the full options syntax
|
||||||
|
owner = options[:owner]
|
||||||
|
group = options[:group]
|
||||||
|
|
||||||
|
# Create the shared folder
|
||||||
|
machine.communicate.execute("#{machine.config.solaris11.suexec_cmd} mkdir -p #{guestpath}")
|
||||||
|
|
||||||
|
# We have to use this `id` command instead of `/usr/bin/id` since this
|
||||||
|
# one accepts the "-u" and "-g" flags.
|
||||||
|
id_cmd = "/usr/xpg4/bin/id"
|
||||||
|
|
||||||
|
# Mount the folder with the proper owner/group
|
||||||
|
mount_options = "-o uid=`#{id_cmd} -u #{owner}`,gid=`#{id_cmd} -g #{group}`"
|
||||||
|
mount_options += ",#{options[:extra]}" if options[:extra]
|
||||||
|
machine.communicate.execute("#{machine.config.solaris11.suexec_cmd} /sbin/mount -F vboxfs #{mount_options} #{name} #{guestpath}")
|
||||||
|
|
||||||
|
# chown the folder to the proper owner/group
|
||||||
|
machine.communicate.execute("#{machine.config.solaris11.suexec_cmd} chown `#{id_cmd} -u #{owner}`:`#{id_cmd} -g #{group}` #{guestpath}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,22 @@
|
||||||
|
# A general Vagrant system implementation for "solaris 11".
|
||||||
|
#
|
||||||
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
class Config < Vagrant.plugin("2", :config)
|
||||||
|
attr_accessor :halt_timeout
|
||||||
|
attr_accessor :halt_check_interval
|
||||||
|
# This sets the command to use to execute items as a superuser. sudo is default
|
||||||
|
attr_accessor :suexec_cmd
|
||||||
|
attr_accessor :device
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@halt_timeout = 30
|
||||||
|
@halt_check_interval = 1
|
||||||
|
@suexec_cmd = 'sudo'
|
||||||
|
@device = "net"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,15 @@
|
||||||
|
# A general Vagrant system implementation for "solaris 11".
|
||||||
|
#
|
||||||
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
||||||
|
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
class Guest < Vagrant.plugin("2", :guest)
|
||||||
|
def detect?(machine)
|
||||||
|
machine.communicate.test("uname -s | grep SunOS")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,44 @@
|
||||||
|
# A general Vagrant system implementation for "solaris 11".
|
||||||
|
#
|
||||||
|
# Contributed by Jan Thomas Moldung <janth@moldung.no>
|
||||||
|
|
||||||
|
require "vagrant"
|
||||||
|
|
||||||
|
module VagrantPlugins
|
||||||
|
module GuestSolaris11
|
||||||
|
class Plugin < Vagrant.plugin("2")
|
||||||
|
name "Solaris 11 guest."
|
||||||
|
description "Solaris 11 guest support."
|
||||||
|
|
||||||
|
config("solaris11") do
|
||||||
|
require File.expand_path("../config", __FILE__)
|
||||||
|
Config
|
||||||
|
end
|
||||||
|
|
||||||
|
guest("solaris11") do
|
||||||
|
require File.expand_path("../guest", __FILE__)
|
||||||
|
Guest
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("solaris11", "change_host_name") do
|
||||||
|
require_relative "cap/change_host_name"
|
||||||
|
Cap::ChangeHostName
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("solaris11", "configure_networks") do
|
||||||
|
require_relative "cap/configure_networks"
|
||||||
|
Cap::ConfigureNetworks
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("solaris11", "halt") do
|
||||||
|
require_relative "cap/halt"
|
||||||
|
Cap::Halt
|
||||||
|
end
|
||||||
|
|
||||||
|
guest_capability("solaris11", "mount_virtualbox_shared_folder") do
|
||||||
|
require_relative "cap/mount_virtualbox_shared_folder"
|
||||||
|
Cap::MountVirtualBoxSharedFolder
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue