2014-02-15 23:29:16 +00:00
|
|
|
require "vagrant"
|
2014-02-15 23:38:11 +00:00
|
|
|
|
2014-02-15 23:29:16 +00:00
|
|
|
module VagrantPlugins
|
|
|
|
module HyperV
|
|
|
|
class Config < Vagrant.plugin("2", :config)
|
2016-03-01 15:23:38 +00:00
|
|
|
|
2015-03-30 16:17:29 +00:00
|
|
|
attr_accessor :ip_address_timeout # Time to wait for an IP address when booting, in seconds @return [Integer]
|
|
|
|
attr_accessor :memory # Memory size in mb @return [Integer]
|
|
|
|
attr_accessor :maxmemory # Maximal memory size in mb enables dynamical memory allocation @return [Integer]
|
|
|
|
attr_accessor :cpus # Number of cpu's @return [Integer]
|
|
|
|
attr_accessor :vmname # Name that will be shoen in Hyperv Manager @return [String]
|
|
|
|
attr_accessor :vlan_id # VLAN ID for network interface for the virtual machine. @return [Integer]
|
2015-09-22 10:35:55 +00:00
|
|
|
attr_accessor :mac # MAC address for network interface for the virtual machine. @return [String]
|
2016-03-01 15:23:38 +00:00
|
|
|
attr_accessor :differencing_disk # Create differencing disk instead of cloning whole VHD [Boolean]
|
2016-07-26 12:41:01 +00:00
|
|
|
attr_accessor :auto_start_action #action on automatic start of VM. Values: Nothing, StartIfRunning, Start
|
2016-07-26 12:56:20 +00:00
|
|
|
attr_accessor :auto_stop_action #action on automatic stop of VM. Values: ShutDown, TurnOff, Save
|
2017-03-15 17:09:18 +00:00
|
|
|
attr_accessor :vm_integration_service # Options for VMServiceIntegration
|
2015-03-30 14:37:29 +00:00
|
|
|
|
2014-02-26 19:12:24 +00:00
|
|
|
def initialize
|
|
|
|
@ip_address_timeout = UNSET_VALUE
|
2015-01-14 14:59:01 +00:00
|
|
|
@memory = UNSET_VALUE
|
|
|
|
@maxmemory = UNSET_VALUE
|
|
|
|
@cpus = UNSET_VALUE
|
|
|
|
@vmname = UNSET_VALUE
|
2017-03-15 17:09:18 +00:00
|
|
|
@vlan_id = UNSET_VALUE
|
|
|
|
@mac = UNSET_VALUE
|
2016-03-01 15:23:38 +00:00
|
|
|
@differencing_disk = UNSET_VALUE
|
2016-07-26 12:41:01 +00:00
|
|
|
@auto_start_action = UNSET_VALUE
|
2016-07-26 12:56:20 +00:00
|
|
|
@auto_stop_action = UNSET_VALUE
|
2017-03-15 17:09:18 +00:00
|
|
|
@vm_integration_service = {
|
|
|
|
guest_service_interface: UNSET_VALUE,
|
|
|
|
heartbeat: UNSET_VALUE,
|
|
|
|
key_value_pair_exchange: UNSET_VALUE,
|
|
|
|
shutdown: UNSET_VALUE,
|
|
|
|
vss: UNSET_VALUE,
|
|
|
|
time_synchronization: UNSET_VALUE
|
|
|
|
}
|
2014-02-15 23:29:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def finalize!
|
2014-02-26 19:12:24 +00:00
|
|
|
if @ip_address_timeout == UNSET_VALUE
|
|
|
|
@ip_address_timeout = 120
|
|
|
|
end
|
2015-01-14 14:59:01 +00:00
|
|
|
@memory = nil if @memory == UNSET_VALUE
|
|
|
|
@maxmemory = nil if @maxmemory == UNSET_VALUE
|
2016-03-01 15:23:38 +00:00
|
|
|
@cpus = nil if @cpus == UNSET_VALUE
|
2015-01-14 14:59:01 +00:00
|
|
|
@vmname = nil if @vmname == UNSET_VALUE
|
2015-03-30 16:17:29 +00:00
|
|
|
@vlan_id = nil if @vlan_id == UNSET_VALUE
|
2015-09-22 10:35:55 +00:00
|
|
|
@mac = nil if @mac == UNSET_VALUE
|
2016-03-01 15:23:38 +00:00
|
|
|
@differencing_disk = false if @differencing_disk == UNSET_VALUE
|
2016-07-26 12:41:01 +00:00
|
|
|
@auto_start_action = nil if @auto_start_action == UNSET_VALUE
|
2016-07-26 12:56:20 +00:00
|
|
|
@auto_stop_action = nil if @auto_stop_action == UNSET_VALUE
|
2017-03-15 17:09:18 +00:00
|
|
|
|
|
|
|
@vm_integration_service.each { |key, value|
|
|
|
|
@vm_integration_service[key] = nil if value == UNSET_VALUE
|
|
|
|
}
|
2014-02-15 23:29:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def validate(machine)
|
|
|
|
errors = _detected_errors
|
2014-02-27 07:13:09 +00:00
|
|
|
|
2017-03-15 17:09:18 +00:00
|
|
|
{"Hyper-V" => errors}
|
2014-02-15 23:29:16 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|