-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Secure Boot Support and Firmware Handling
- Renamed firmware-related attributes to align with VMware conventions. - Accurately report firmware type and Secure Boot status to Foreman.
- Loading branch information
1 parent
a4fb77c
commit 6422a10
Showing
3 changed files
with
28 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -48,6 +48,22 @@ def boot_order xml | |
xml_elements(xml, "domain/os/boot", "dev") | ||
end | ||
|
||
# Foreman expects the firmware to be 'uefi_sb' if SB is enabled | ||
def firmware(xml) | ||
firmware_type = xml_elements(xml, "domain/os", "firmware").first || 'bios' | ||
return 'uefi_sb' if firmware_type == 'efi' && secure_boot_enabled?(xml) | ||
|
||
firmware_type | ||
end | ||
|
||
def secure_boot_enabled?(xml) | ||
Check warning on line 59 in lib/fog/libvirt/requests/compute/list_domains.rb GitHub Actions / runner / rubocop
|
||
enabled_features = xml_elements(xml, "domain/os/firmware/feature[@enabled='yes']") | ||
.map { |feature| feature[:name] } | ||
|
||
required_features = ['secure-boot', 'enrolled-keys'] | ||
required_features.all? { |feature| enabled_features.include?(feature) } | ||
end | ||
|
||
def domain_interfaces xml | ||
ifs = xml_elements(xml, "domain/devices/interface") | ||
ifs.map { |i| | ||
|
@@ -78,6 +94,7 @@ def domain_to_attributes(dom) | |
:active => dom.active?, | ||
:display => domain_display(dom.xml_desc), | ||
:boot_order => boot_order(dom.xml_desc), | ||
:firmware => firmware(dom.xml_desc), | ||
:nics => domain_interfaces(dom.xml_desc), | ||
:volumes_path => domain_volumes(dom.xml_desc), | ||
:state => states[dom.info.state] | ||
|
This file contains 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