Skip to content

Commit

Permalink
Secure Boot & Virtual TPM
Browse files Browse the repository at this point in the history
  • Loading branch information
stejskalleos authored and chris1984 committed Jul 29, 2024
1 parent 62fb4b9 commit 2bf75a7
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 @@ -53,6 +53,8 @@ class Server < Fog::Compute::Server # rubocop:disable Metrics/ClassLength
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 @@ -153,6 +153,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 @@ -170,6 +173,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 @@ -333,6 +340,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 2bf75a7

Please sign in to comment.