Skip to content
Snippets Groups Projects
Verified Commit a5e5a3ea authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Add preliminary secure boot setup

parent ba39ecbe
No related branches found
No related tags found
No related merge requests found
......@@ -5,11 +5,7 @@ module ForemanVmwareAdvanced
def parse_args(inp_args)
args = super(inp_args)
args[:extra_config] = (args[:extra_config] || {}).merge(
'bios.bootOrder': 'ethernet0',
'disk.EnableUUID': 'TRUE',
'svga.autodetect': 'TRUE'
)
args[:extra_config] = (args[:extra_config] || {}).merge(SETTINGS[:vmware_advanced]) if SETTINGS[:vmware_advanced]
args
end
......@@ -18,21 +14,28 @@ module ForemanVmwareAdvanced
vm = super(args)
return unless vm
if SETTINGS[:vtpm_add] && vm.firmware == 'efi'
begin
spec = {
deviceChange: [
{
operation: :add,
device: RbVmomi::VIM::VirtualTPM.new(key: -1)
}
]
}
client.vm_reconfig_hardware 'instance_uuid' => vm.attributes[:instance_uuid], 'hardware_spec' => spec
rescue StandardError => e
logger.error "Failed to add vTPM - #{e.class}: #{e}"
spec = {}
if vm.firmeware == 'efi'
if SETTINGS[:vmware_secureboot] && args[:guest_id]&.start_with?('win')
spec[:bootOptions] = RbVmomi::VIM::VirtualMachineBootOptions.new(efiSecureBootEnabled: true)
end
if SETTINGS[:vtpm_add]
spec[:deviceChange] = [
{
operation: :add,
device: RbVmomi::VIM::VirtualTPM.new(key: -1)
}
]
end
end
return vm if spec.empty?
begin
client.vm_reconfig_hardware 'instance_uuid' => vm.attributes[:instance_uuid], 'hardware_spec' => spec
rescue StandardError => e
logger.error "Failed to add advanced VMWare options - #{e.class}: #{e}"
end
vm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment