Class: VagrantPlugins::AVF::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant_provider_avf/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



6
7
8
9
10
11
12
13
14
15
# File 'lib/vagrant_provider_avf/config.rb', line 6

def initialize
  @cpus = UNSET_VALUE
  @memory_mb = UNSET_VALUE
  @disk_gb = UNSET_VALUE
  @headless = UNSET_VALUE
  @guest = UNSET_VALUE
  @kernel_path = UNSET_VALUE
  @initrd_path = UNSET_VALUE
  @disk_image_path = UNSET_VALUE
end

Instance Attribute Details

#cpusObject

Returns the value of attribute cpus.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def cpus
  @cpus
end

#disk_gbObject

Returns the value of attribute disk_gb.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def disk_gb
  @disk_gb
end

#disk_image_pathObject

Returns the value of attribute disk_image_path.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def disk_image_path
  @disk_image_path
end

#guestObject

Returns the value of attribute guest.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def guest
  @guest
end

#headlessObject

Returns the value of attribute headless.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def headless
  @headless
end

#initrd_pathObject

Returns the value of attribute initrd_path.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def initrd_path
  @initrd_path
end

#kernel_pathObject

Returns the value of attribute kernel_path.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def kernel_path
  @kernel_path
end

#memory_mbObject

Returns the value of attribute memory_mb.



4
5
6
# File 'lib/vagrant_provider_avf/config.rb', line 4

def memory_mb
  @memory_mb
end

Instance Method Details

#boot_configObject



45
46
47
48
49
50
51
52
# File 'lib/vagrant_provider_avf/config.rb', line 45

def boot_config
  Model::BootConfig.new(
    guest: @guest,
    kernel_path: @kernel_path,
    initrd_path: @initrd_path,
    disk_image_path: @disk_image_path
  )
end

#finalize!Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/vagrant_provider_avf/config.rb', line 17

def finalize!
  @cpus = nil if @cpus == UNSET_VALUE
  @memory_mb = nil if @memory_mb == UNSET_VALUE
  @disk_gb = nil if @disk_gb == UNSET_VALUE
  @headless = true if @headless == UNSET_VALUE
  @guest = :linux if @guest == UNSET_VALUE
  @kernel_path = nil if @kernel_path == UNSET_VALUE
  @initrd_path = nil if @initrd_path == UNSET_VALUE
  @disk_image_path = nil if @disk_image_path == UNSET_VALUE
end

#machine_requirementsObject



36
37
38
39
40
41
42
43
# File 'lib/vagrant_provider_avf/config.rb', line 36

def machine_requirements
  Model::MachineRequirements.new(
    cpus: @cpus,
    memory_mb: @memory_mb,
    disk_gb: @disk_gb,
    headless: @headless
  )
end

#validate(_machine) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/vagrant_provider_avf/config.rb', line 28

def validate(_machine)
  errors = _detected_errors + machine_requirements.errors + boot_config.errors

  return {} if errors.empty?

  { "AVF provider" => errors }
end