-
Notifications
You must be signed in to change notification settings - Fork 1k
VMware - Secure Boot & Virtual TPM #10225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
stejskalleos
wants to merge
2
commits into
theforeman:develop
from
stejskalleos:ls/vmware_secure_boot
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -206,8 +206,18 @@ def firmware_types | |||||||
| { | ||||||||
| "automatic" => N_("Automatic"), | ||||||||
| "bios" => N_("BIOS"), | ||||||||
| "efi" => N_("EFI"), | ||||||||
| } | ||||||||
| "uefi" => N_("UEFI"), | ||||||||
| "uefi_secure_boot" => N_("UEFI Secure Boot"), | ||||||||
| }.freeze | ||||||||
| end | ||||||||
|
|
||||||||
| # Returns the firmware type based on the VM object | ||||||||
| def firmware_type(vm_obj) | ||||||||
sbernhard marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| if vm_obj.firmware == 'efi' | ||||||||
| vm_obj.secure_boot ? "uefi_secure_boot" : "uefi" | ||||||||
| else | ||||||||
| vm_obj.firmware | ||||||||
| end | ||||||||
| end | ||||||||
|
|
||||||||
| def disk_mode_types | ||||||||
|
|
@@ -488,8 +498,24 @@ def parse_args(args) | |||||||
|
|
||||||||
| args.except!(:hardware_version) if args[:hardware_version] == 'Default' | ||||||||
|
|
||||||||
| firmware_type = args.delete(:firmware_type) | ||||||||
| args[:firmware] = firmware_mapping(firmware_type) if args[:firmware] == 'automatic' | ||||||||
| # This value comes from PxeLoaderSupport#firmware_type | ||||||||
| firmware_type = args.delete(:firmware_type).to_s | ||||||||
|
|
||||||||
| # automatic firmware type is determined by the PXE Loader | ||||||||
| # if no PXE Loader is set, we will set it to bios by default | ||||||||
| if args[:firmware] == 'automatic' | ||||||||
| args[:firmware] = (firmware_type == 'none' || firmware_type.empty?) ? 'bios' : firmware_type | ||||||||
| end | ||||||||
|
|
||||||||
| # Adjust firmware and secure_boot values for VMware compatibility | ||||||||
| args[:secure_boot] = true if args[:firmware] == 'uefi_secure_boot' | ||||||||
| # VMware expects the firmware type to be 'efi' | ||||||||
| args[:firmware] = 'efi' if args[:firmware]&.start_with?('uefi') | ||||||||
|
|
||||||||
| args[:virtual_tpm] = ActiveRecord::Type::Boolean.new.cast(args[:virtual_tpm]) | ||||||||
ekohl marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| if args[:firmware] == 'bios' && args[:virtual_tpm] | ||||||||
| errors.add :base, _('TPM is not compatible with BIOS firmware. Please change Firmware or disable TPM.') | ||||||||
| end | ||||||||
|
|
||||||||
| args.reject! { |k, v| v.nil? } | ||||||||
| args | ||||||||
|
|
@@ -522,7 +548,7 @@ def create_vm(args = { }) | |||||||
| clone_vm(args) | ||||||||
| else | ||||||||
| vm = new_vm(args) | ||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then you can raise the error here (probably with some message):
Suggested change
|
||||||||
| vm.firmware = 'bios' if vm.firmware == 'automatic' | ||||||||
| raise ArgumentError, errors.full_messages.join(';') if errors.any? | ||||||||
| vm.save | ||||||||
| end | ||||||||
| rescue Fog::Vsphere::Compute::NotFound => e | ||||||||
|
|
@@ -828,11 +854,6 @@ def vm_instance_defaults | |||||||
| ) | ||||||||
| end | ||||||||
|
|
||||||||
| def firmware_mapping(firmware_type) | ||||||||
| return 'efi' if firmware_type == :uefi | ||||||||
| 'bios' | ||||||||
| end | ||||||||
|
|
||||||||
| def set_vm_volumes_attributes(vm, vm_attrs) | ||||||||
| volumes = vm.volumes || [] | ||||||||
| vm_attrs[:volumes_attributes] = Hash[volumes.each_with_index.map { |volume, idx| [idx.to_s, volume.attributes.merge(:size_gb => volume.size_gb)] }] | ||||||||
|
|
||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.