2012-12-23 06:47:06 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module ProviderVirtualBox
|
|
|
|
class Config < Vagrant.plugin("2", :config)
|
2013-01-31 05:03:02 +00:00
|
|
|
# Vagrant by default will make "smart" decisions to enable/disable
|
|
|
|
# the NAT DNS proxy. If this is set to `true`, then the DNS proxy
|
|
|
|
# will not be enabled, and it is up to the end user to do it.
|
|
|
|
#
|
|
|
|
# @return [Boolean]
|
|
|
|
attr_accessor :auto_nat_dns_proxy
|
|
|
|
|
2013-01-11 22:16:00 +00:00
|
|
|
# An array of customizations to make on the VM prior to booting it.
|
|
|
|
#
|
|
|
|
# @return [Array]
|
2012-12-23 06:47:06 +00:00
|
|
|
attr_reader :customizations
|
|
|
|
|
2012-12-25 17:00:06 +00:00
|
|
|
# If set to `true`, then VirtualBox will be launched with a GUI.
|
2013-01-11 22:16:00 +00:00
|
|
|
#
|
|
|
|
# @return [Boolean]
|
2012-12-25 17:00:06 +00:00
|
|
|
attr_accessor :gui
|
|
|
|
|
2013-01-31 07:03:21 +00:00
|
|
|
# This should be set to the name of the machine in the VirtualBox
|
|
|
|
# GUI.
|
|
|
|
#
|
|
|
|
# @return [String]
|
|
|
|
attr_accessor :name
|
|
|
|
|
2013-01-11 22:16:00 +00:00
|
|
|
# The defined network adapters.
|
|
|
|
#
|
|
|
|
# @return [Hash]
|
|
|
|
attr_reader :network_adapters
|
|
|
|
|
2012-12-23 06:47:06 +00:00
|
|
|
def initialize
|
2013-01-31 05:03:02 +00:00
|
|
|
@auto_nat_dns_proxy = UNSET_VALUE
|
2013-01-11 22:16:00 +00:00
|
|
|
@customizations = []
|
2013-01-31 07:03:21 +00:00
|
|
|
@name = UNSET_VALUE
|
2013-01-11 22:16:00 +00:00
|
|
|
@network_adapters = {}
|
|
|
|
@gui = UNSET_VALUE
|
|
|
|
|
|
|
|
# We require that network adapter 1 is a NAT device.
|
|
|
|
network_adapter(1, :nat)
|
2012-12-23 06:47:06 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# Customize the VM by calling `VBoxManage` with the given
|
|
|
|
# arguments.
|
|
|
|
#
|
|
|
|
# When called multiple times, the customizations will be applied
|
|
|
|
# in the order given.
|
|
|
|
#
|
|
|
|
# The special `:name` parameter in the command will be replaced with
|
|
|
|
# the unique ID or name of the virtual machine. This is useful for
|
|
|
|
# parameters to `modifyvm` and the like.
|
|
|
|
#
|
|
|
|
# @param [Array] command An array of arguments to pass to
|
|
|
|
# VBoxManage.
|
|
|
|
def customize(command)
|
|
|
|
@customizations << command
|
|
|
|
end
|
2012-12-25 17:18:47 +00:00
|
|
|
|
2013-01-11 22:16:00 +00:00
|
|
|
# This defines a network adapter that will be added to the VirtualBox
|
|
|
|
# virtual machine in the given slot.
|
|
|
|
#
|
|
|
|
# @param [Integer] slot The slot for this network adapter.
|
|
|
|
# @param [Symbol] type The type of adapter.
|
|
|
|
def network_adapter(slot, type, *args)
|
|
|
|
@network_adapters[slot] = [type, args]
|
|
|
|
end
|
|
|
|
|
2012-12-25 17:18:47 +00:00
|
|
|
# This is the hook that is called to finalize the object before it
|
|
|
|
# is put into use.
|
|
|
|
def finalize!
|
2013-01-31 05:03:02 +00:00
|
|
|
# Default is to auto the DNS proxy
|
|
|
|
@auto_nat_dns_proxy = true if @auto_nat_dns_proxy == UNSET_VALUE
|
|
|
|
|
2012-12-25 17:18:47 +00:00
|
|
|
# Default is to not show a GUI
|
|
|
|
@gui = false if @gui == UNSET_VALUE
|
2013-01-31 07:03:21 +00:00
|
|
|
|
|
|
|
# The default name is just nothing, and we default it
|
|
|
|
@name = nil if @name == UNSET_VALUE
|
2012-12-25 17:18:47 +00:00
|
|
|
end
|
2012-12-23 06:47:06 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|