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

Slight improvement to code flow

parent 22e0f3b8
No related branches found
No related tags found
No related merge requests found
Pipeline #82359 failed
......@@ -11,3 +11,5 @@ Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
Metrics/MethodLength:
Max: 15
......@@ -15,20 +15,7 @@ module ForemanVmwareAdvanced
return unless vm
spec = {}
if vm.firmware == 'efi'
if SETTINGS[:vmware_secureboot] && args[:guest_id]&.start_with?('win')
spec[:bootOptions] = RbVmomi::VIM::VirtualMachineBootOptions.new(efiSecureBootEnabled: true)
end
if SETTINGS[:vmware_vtpm]
spec[:deviceChange] = [
{
operation: :add,
device: RbVmomi::VIM::VirtualTPM.new(key: -1)
}
]
end
end
spec.merge! build_efi_spec(args) if vm.firmware == 'efi'
return vm if spec.empty?
......@@ -40,5 +27,25 @@ module ForemanVmwareAdvanced
vm
end
private
def build_efi_spec(args)
spec = {}
spec[:bootOptions] = RbVmomi::VIM::VirtualMachineBootOptions.new(efiSecureBootEnabled: true) \
if SETTINGS[:vmware_secureboot] && args[:guest_id]&.start_with?('win')
if SETTINGS[:vmware_vtpm]
spec[:deviceChange] = [
{
operation: :add,
device: RbVmomi::VIM::VirtualTPM.new(key: -1)
}
]
end
spec
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment