Class: Fog::Hyperv::Compute::Bios

Inherits:
Model
  • Object
show all
Defined in:
lib/fog/hyperv/compute/models/bios.rb

Overview

Configuration for the BIOS settings of a VM

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#initialize, #merge_attributes

Methods included from ModelExtends

#collection

Methods included from ModelIncludes

#cluster, #computer, #dirty, #dirty?, #vm

Constructor Details

This class inherits a constructor from Fog::Hyperv::Model

Instance Attribute Details

#computer_nameString (readonly)

Returns the name of the computer running the VM that this BIOS configuration is attached to.

Returns:

  • (String)

    the name of the computer running the VM that this BIOS configuration is attached to



14
# File 'lib/fog/hyperv/compute/models/bios.rb', line 14

attribute :computer_name, type: :string

#num_lock_enabledBoolean

Returns if num-lock should be enabled on boot.

Returns:

  • (Boolean)

    if num-lock should be enabled on boot



19
# File 'lib/fog/hyperv/compute/models/bios.rb', line 19

attribute :num_lock_enabled, type: :boolean

#startup_orderArray<Symbol>

Note:

Hyper-V only really allows reordering these entries, not adding/removing from the list

Returns the boot order of the VM.

Examples:

Set legacy net boot as default - if possible

netboot = bios.startup_order.delete :LegacyNetworkAdapter
bios.startup_order.unshift netboot if netboot
bios.save

Returns:

  • (Array<Symbol>)

    the boot order of the VM

See Also:



28
# File 'lib/fog/hyperv/compute/models/bios.rb', line 28

attribute :startup_order, type: :hypervenumarray, values: Fog::Hyperv::BOOT_DEVICE_ENUM_VALUES

#vm_idString (readonly)

Returns the GUID of the VM this BIOS configuration is attached to.

Returns:

  • (String)

    the GUID of the VM this BIOS configuration is attached to



10
# File 'lib/fog/hyperv/compute/models/bios.rb', line 10

identity :vm_id, type: :string

Instance Method Details

#reloadObject

Reload attributes from Hyper-V



56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/fog/hyperv/compute/models/bios.rb', line 56

def reload
  requires :vm_id

  data = service.get_vm_bios(
    computer_name:,
    vm_id:,

    _return_fields: self.class.attributes
  )
  return unless data

  merge_attributes(data)
end

#updateObject

Save any modifications to Hyper-V



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fog/hyperv/compute/models/bios.rb', line 31

def update
  requires :vm_id

  # raise ArgumentError, 'Startup order can only be rearranged, not modified' \
  #   if changed?(:startup_order) && startup_order.sort != old.startup_order.sort

  changes = {
    startup_order: changed!(:startup_order)
  }.compact
  changes[num_lock_enabled ? :enable_num_lock : :disable_num_lock] = true if changed?(:num_lock_enabled)
  return self unless changes.any?

  data = service.set_vm_bios(
    computer_name:,
    vm_id:,

    **changes,

    _return_fields: self.class.attributes
  )

  merge_attributes(data)
end