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 ...@@ -5,11 +5,7 @@ module ForemanVmwareAdvanced
def parse_args(inp_args) def parse_args(inp_args)
args = super(inp_args) args = super(inp_args)
args[:extra_config] = (args[:extra_config] || {}).merge( args[:extra_config] = (args[:extra_config] || {}).merge(SETTINGS[:vmware_advanced]) if SETTINGS[:vmware_advanced]
'bios.bootOrder': 'ethernet0',
'disk.EnableUUID': 'TRUE',
'svga.autodetect': 'TRUE'
)
args args
end end
...@@ -18,21 +14,28 @@ module ForemanVmwareAdvanced ...@@ -18,21 +14,28 @@ module ForemanVmwareAdvanced
vm = super(args) vm = super(args)
return unless vm return unless vm
if SETTINGS[:vtpm_add] && vm.firmware == 'efi' spec = {}
begin if vm.firmeware == 'efi'
spec = { if SETTINGS[:vmware_secureboot] && args[:guest_id]&.start_with?('win')
deviceChange: [ spec[:bootOptions] = RbVmomi::VIM::VirtualMachineBootOptions.new(efiSecureBootEnabled: true)
{
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}"
end 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 end
vm vm
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment