Class: Fog::Hyperv::Compute::Firmware

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

Overview

UEFI firmware settings for 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

#boot_orderArray<String> (readonly)

TODO:

should be mapped to VM models; HDD/NIC/DVD, needs additional work

Returns the boot order of the VM.

Returns:

  • (Array<String>)

    the boot order of the VM



18
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 18

attribute :boot_order

#computer_nameString (readonly)

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

Returns:

  • (String)

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



13
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 13

attribute :computer_name

#console_mode:Default, ...

Returns where the console output should be directed.

Returns:

  • (:Default, :COM1, :COM2, :None)

    where the console output should be directed



21
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 21

attribute :console_mode, type: :hypervenum, values: %i[Default COM1 COM2 None]

#pause_after_boot_failure:On, :Off

Returns if the VM should pause after failing boot.

Returns:

  • (:On, :Off)

    if the VM should pause after failing boot



38
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 38

attribute :pause_after_boot_failure, type: :hypervenum, values: Fog::Hyperv::ON_OFF_STATE_ENUM_VALUES

#preferred_network_boot_protocol:IPv4, :IPv6

Returns the preferred IP protocol for PXE.

Returns:

  • (:IPv4, :IPv6)

    the preferred IP protocol for PXE



24
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 24

attribute :preferred_network_boot_protocol, type: :hypervenum, values: %i[IPv4 IPv6]

#secure_boot:On, :Off

Returns if secure boot should be enabled.

Returns:

  • (:On, :Off)

    if secure boot should be enabled



27
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 27

attribute :secure_boot, type: :hypervenum, values: Fog::Hyperv::ON_OFF_STATE_ENUM_VALUES

#secure_boot_templateString

Returns the template to use for the secure boot configuration.

Returns:

  • (String)

    the template to use for the secure boot configuration

See Also:



31
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 31

attribute :secure_boot_template

#secure_boot_template_idString (readonly)

Returns the template id to use for the secure boot configuration.

Returns:

  • (String)

    the template id to use for the secure boot configuration

See Also:



35
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 35

attribute :secure_boot_template_id

#vm_idString (readonly)

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

Returns:

  • (String)

    the GUID of the VM this UEFI configuration is attached to



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

identity :vm_id

Instance Method Details

#reloadObject

Reload attributes from Hyper-V



64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 64

def reload
  requires :vm_id

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

    _return_fields: self.class.attributes
  )
  return unless data

  merge_attributes(data)
end

#updateObject

Save any modifications to Hyper-V



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/fog/hyperv/compute/models/firmware.rb', line 41

def update
  requires :vm_id

  changes = {
    enable_secure_boot: changed!(:secure_boot),
    secure_boot_template: changed!(:secure_boot_template),
    preferred_network_boot_protocol: changed!(:preferred_network_boot_protocol),
    console_mode: changed!(:console_mode),
    pause_after_boot_failure: changed!(:pause_after_boot_failure)
  }.compact
  return self unless changes.any?

  merge_attributes(
    service.set_vm_firmware(
      computer_name:,
      vm_id:,

      _return_fields: self.class.attributes
    )
  )
end