Skip to content

Commit

Permalink
Optimize secure boot support and firmware handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nofaralfasi authored and chris1984 committed Jul 29, 2024
1 parent 2bf75a7 commit 4de65fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions lib/fog/vsphere/compute.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ module Shared
parent: 'parent',
hostname: 'summary.guest.hostName',
operatingsystem: 'summary.guest.guestFullName',
virtual_tpm: 'summary.config.tpmPresent',
ipaddress: 'guest.ipAddress',
power_state: 'runtime.powerState',
connection_state: 'runtime.connectionState',
Expand All @@ -173,6 +174,7 @@ module Shared
cpuHotAddEnabled: 'config.cpuHotAddEnabled',
memoryHotAddEnabled: 'config.memoryHotAddEnabled',
firmware: 'config.firmware',
secure_boot: 'config.bootOptions.efiSecureBootEnabled',
boot_order: 'config.bootOptions.bootOrder',
annotation: 'config.annotation',
extra_config: 'config.extraConfig'
Expand Down
8 changes: 4 additions & 4 deletions lib/fog/vsphere/requests/compute/create_vm.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Fog
module Vsphere
class Compute
# rubocop:disable Metrics/ClassLength
class Real
def create_vm(attributes = {})
# build up vm configuration
Expand All @@ -22,7 +23,7 @@ def create_vm(attributes = {})
vm_cfg[:cpuHotAddEnabled] = attributes[:cpuHotAddEnabled] if attributes.key?(:cpuHotAddEnabled)
vm_cfg[:memoryHotAddEnabled] = attributes[:memoryHotAddEnabled] if attributes.key?(:memoryHotAddEnabled)
vm_cfg[:firmware] = attributes[:firmware] if attributes.key?(:firmware)
vm_cfg[:bootOptions] = boot_options(attributes, vm_cfg) if attributes.key?(:boot_order) || attributes.key?(:boot_retry)
vm_cfg[:bootOptions] = boot_options(attributes, vm_cfg)
resource_pool = if attributes[:resource_pool] && attributes[:resource_pool] != 'Resources'
get_raw_resource_pool(attributes[:resource_pool], attributes[:cluster], attributes[:datacenter])
else
Expand Down Expand Up @@ -173,9 +174,7 @@ def boot_options(attributes, vm_cfg)
options[:bootRetryDelay] = attributes[:boot_retry]
end

if attributes[:secure_boot]
options[:efiSecureBootEnabled] = true
end
options[:efiSecureBootEnabled] = attributes[:secure_boot] if attributes.key?(:secure_boot)

options.empty? ? nil : RbVmomi::VIM::VirtualMachineBootOptions.new(options)
end
Expand Down Expand Up @@ -353,6 +352,7 @@ def extra_config(attributes)
end
end

# rubocop:enable Metrics/ClassLength
class Mock
def create_vm(attributes = {})
id = SecureRandom.uuid
Expand Down

0 comments on commit 4de65fc

Please sign in to comment.