Skip to content

Commit

Permalink
Secure Boot & Virtual TPM
Browse files Browse the repository at this point in the history
  • Loading branch information
stejskalleos committed Jun 27, 2024
1 parent 4a7f4e7 commit 97a27f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/fog/vsphere/models/compute/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Server < Fog::Compute::Server
attribute :cpuHotAddEnabled
attribute :memoryHotAddEnabled
attribute :firmware
attribute :secure_boot
attribute :virtual_tpm
attribute :boot_order
attribute :annotation
attribute :extra_config
Expand Down
14 changes: 14 additions & 0 deletions lib/fog/vsphere/requests/compute/create_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ def device_change(attributes)
if (cdroms = attributes[:cdroms])
devices << cdroms.map { |cdrom| create_cdrom(cdrom, cdroms.index(cdrom)) }
end

devices << create_virtual_tpm if attributes[:virtual_tpm]

devices.flatten
end

Expand All @@ -166,6 +169,10 @@ def boot_options(attributes, vm_cfg)
options[:bootRetryDelay] = attributes[:boot_retry]
end

if attributes[:secure_boot]
options[:efiSecureBootEnabled] = true
end

options.empty? ? nil : RbVmomi::VIM::VirtualMachineBootOptions.new(options)
end

Expand Down Expand Up @@ -326,6 +333,13 @@ def create_cdrom(cdrom, index = 0, operation = :add, controller_key = 200)
}
end

def create_virtual_tpm
{
operation: :add,
device: RbVmomi::VIM::VirtualTPM.new(key: -1)
}
end

def extra_config(attributes)
extra_config = attributes[:extra_config] || { 'bios.bootOrder' => 'ethernet0' }
extra_config.map { |k, v| { key: k, value: v.to_s } }
Expand Down

0 comments on commit 97a27f0

Please sign in to comment.