Skip to content

Commit

Permalink
boot: extend bootable raid for poweredge devices
Browse files Browse the repository at this point in the history
  • Loading branch information
dbungert committed Jul 26, 2023
1 parent f3dbda1 commit fe66e0a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
22 changes: 14 additions & 8 deletions subiquity/common/filesystem/boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@

import attr

from subiquity.common.dmidecode import dmidecode_get
from subiquity.common.filesystem import gaps, sizes
from subiquity.models.filesystem import Bootloader, Disk, Partition, Raid, align_up

log = logging.getLogger("subiquity.common.filesystem.boot")


def bootable_raid(raid: Raid):
if raid._m.bootloader != Bootloader.UEFI:
return False
if raid.container is not None and raid.container.metadata == "imsm":
return True
if "poweredge" in dmidecode_get("system-product-name").lower():
# LP: #1961079 - all poweredge devices assumed to support raid UEFI boot
return True
return False


@functools.singledispatch
def is_boot_device(device):
"""Is `device` a boot device?"""
Expand All @@ -45,10 +57,7 @@ def _is_boot_device_disk(disk):

@is_boot_device.register(Raid)
def _is_boot_device_raid(raid):
bl = raid._m.bootloader
if bl != Bootloader.UEFI:
return False
if not raid.container or raid.container.metadata != "imsm":
if not bootable_raid(raid):
return False
return any(p.grub_device for p in raid._partitions)

Expand Down Expand Up @@ -344,10 +353,7 @@ def _can_be_boot_device_disk(disk, *, resize_partition=None, with_reformatting=F

@can_be_boot_device.register(Raid)
def _can_be_boot_device_raid(raid, *, resize_partition=None, with_reformatting=False):
bl = raid._m.bootloader
if bl != Bootloader.UEFI:
return False
if not raid.container or raid.container.metadata != "imsm":
if not bootable_raid(raid):
return False
if with_reformatting:
return True
Expand Down
24 changes: 21 additions & 3 deletions subiquity/common/filesystem/tests/test_boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import unittest
from unittest.mock import Mock
from unittest.mock import Mock, patch

from subiquity.common.filesystem import boot
from subiquity.models.filesystem import Bootloader
Expand All @@ -26,7 +26,9 @@ def test_bios(self):
raid = make_raid(make_model(Bootloader.BIOS))
self.assertFalse(boot.can_be_boot_device(raid))

def test_UEFI_no_container(self):
@patch("subiquity.common.filesystem.boot.dmidecode_get")
def test_UEFI_no_container(self, dmi_get):
dmi_get.return_value = ""
raid = make_raid(make_model(Bootloader.UEFI))
raid.container = None
self.assertFalse(boot.can_be_boot_device(raid))
Expand All @@ -37,8 +39,24 @@ def test_UEFI_container_imsm(self):
raid.container.metadata = "imsm"
self.assertTrue(boot.can_be_boot_device(raid))

def test_UEFI_container_non_imsm(self):
@patch("subiquity.common.filesystem.boot.dmidecode_get")
def test_UEFI_container_non_imsm(self, dmi_get):
dmi_get.return_value = ""
raid = make_raid(make_model(Bootloader.UEFI))
raid.container = Mock()
raid.container.metadata = "something else"
self.assertFalse(boot.can_be_boot_device(raid))

@patch("subiquity.common.filesystem.boot.dmidecode_get")
def test_UEFI_spn_poweredge(self, dmi_get):
dmi_get.return_value = "CompanyName PowerEdge 1234"
raid = make_raid(make_model(Bootloader.UEFI))
raid.container = None
self.assertTrue(boot.can_be_boot_device(raid))

@patch("subiquity.common.filesystem.boot.dmidecode_get")
def test_UEFI_spn_other(self, dmi_get):
dmi_get.return_value = "CompanyName ProductName 1227"
raid = make_raid(make_model(Bootloader.UEFI))
raid.container = None
self.assertFalse(boot.can_be_boot_device(raid))

0 comments on commit fe66e0a

Please sign in to comment.