Class: VagrantPlugins::HyperV::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-windows-hyperv/monkey_patch/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



18
19
20
21
# File 'lib/vagrant-windows-hyperv/monkey_patch/config.rb', line 18

def initialize
  @ip_address_timeout = UNSET_VALUE
  @customizations   = []
end

Instance Attribute Details

#customizationsObject (readonly)

Returns the value of attribute customizations.



16
17
18
# File 'lib/vagrant-windows-hyperv/monkey_patch/config.rb', line 16

def customizations
  @customizations
end

#ip_address_timeoutInteger

The timeout to wait for an IP address when booting the machine, in seconds.

Returns:

  • (Integer)


15
16
17
# File 'lib/vagrant-windows-hyperv/monkey_patch/config.rb', line 15

def ip_address_timeout
  @ip_address_timeout
end

Instance Method Details

#customize(*command) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/vagrant-windows-hyperv/monkey_patch/config.rb', line 23

def customize(*command)
  @customizations ||= []
  event   = command.first.is_a?(String) ? command.shift : "pre-boot"
  command = command[0]
  options = command[1]
  @customizations << [event, command, options]
end

#finalize!Object



31
32
33
34
35
# File 'lib/vagrant-windows-hyperv/monkey_patch/config.rb', line 31

def finalize!
  if @ip_address_timeout == UNSET_VALUE
    @ip_address_timeout = 120
  end
end

#validate(machine) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/vagrant-windows-hyperv/monkey_patch/config.rb', line 37

def validate(machine)
  errors = _detected_errors

  valid_events = ["pre-boot"]
  @customizations.each do |event, _|
    if !valid_events.include?(event)
      errors << "Invalid custom event #{event} use pre-boot"
    end
  end

  { "Hyper-V" => errors }
end