Merge pull request #1774 from dbungert/lp-2033244-capability-order

filesystem: capability flags in a specific order
This commit is contained in:
Dan Bungert 2023-08-28 19:35:07 -06:00 committed by GitHub
commit 3a2044593c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 1 deletions

View File

@ -38,3 +38,6 @@ class TestCapabilities(unittest.TestCase):
def test_is_zfs(self):
self.assertTrue(GuidedCapability.ZFS.is_zfs())
def test_order(self):
self.assertLess(GuidedCapability.DIRECT, GuidedCapability.CORE_BOOT_ENCRYPTED)

View File

@ -340,6 +340,8 @@ class Disk:
class GuidedCapability(enum.Enum):
# The order listed here is the order they will be presented as options
MANUAL = enum.auto()
DIRECT = enum.auto()
LVM = enum.auto()
@ -354,6 +356,9 @@ class GuidedCapability(enum.Enum):
DD = enum.auto()
def __lt__(self, other) -> bool:
return self.value < other.value
def is_lvm(self) -> bool:
return self in [GuidedCapability.LVM, GuidedCapability.LVM_LUKS]

View File

@ -128,6 +128,8 @@ class CapabilityInfo:
new_disallowed.append(disallowed_cap)
seen_disallowed.add(disallowed_cap.capability)
self.disallowed = new_disallowed
self.allowed.sort()
self.disallowed.sort()
@attr.s(auto_attribs=True)
@ -967,7 +969,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
continue
if not info.is_core_boot_classic():
classic_capabilities.update(info.capability_info.allowed)
return sorted(classic_capabilities, key=lambda x: x.name)
return sorted(classic_capabilities)
async def v2_guided_GET(self, wait: bool = False) -> GuidedStorageResponseV2:
"""Acquire a list of possible guided storage configuration scenarios.

View File

@ -349,6 +349,7 @@ class TestFlow(TestAPI):
resp = await inst.get("/storage/v2/guided?wait=true")
[reformat, manual] = resp["targets"]
self.assertEqual("DIRECT", reformat["allowed"][0])
await inst.post(
"/storage/v2/guided",
{