Refactor partition type GUID (#2890)

This commit is contained in:
codefiles 2024-11-19 17:41:27 -05:00 committed by GitHub
parent 20cc124a6d
commit 4f704b8501
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 8 deletions

View File

@ -4,7 +4,6 @@ import json
import logging
import os
import time
import uuid
from collections.abc import Iterable
from pathlib import Path
from typing import Any, Literal
@ -29,6 +28,7 @@ from .device_model import (
LvmVolumeGroup,
LvmVolumeInfo,
ModificationStatus,
PartitionGUID,
PartitionModification,
PartitionTable,
SectorSize,
@ -544,8 +544,7 @@ class DeviceHandler:
raise DiskError(f'Unable to add partition, most likely due to overlapping sectors: {ex}') from ex
if disk.type == PartitionTable.GPT.value and part_mod.is_root():
linux_root_x86_64 = "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709"
partition.type_uuid = uuid.UUID(linux_root_x86_64).bytes
partition.type_uuid = PartitionGUID.LINUX_ROOT_X86_64.bytes
# the partition has a path now that it has been added
part_mod.dev_path = Path(partition.path)

View File

@ -585,11 +585,15 @@ class PartitionFlag(Enum):
ESP = parted.PARTITION_ESP
# class PartitionGUIDs(Enum):
# """
# A list of Partition type GUIDs (lsblk -o+PARTTYPE) can be found here: https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
# """
# XBOOTLDR = 'bc13c2ff-59e6-4262-a352-b275fd6f7172'
class PartitionGUID(Enum):
"""
A list of Partition type GUIDs (lsblk -o+PARTTYPE) can be found here: https://en.wikipedia.org/wiki/GUID_Partition_Table#Partition_type_GUIDs
"""
LINUX_ROOT_X86_64 = "4F68BCE3-E8CD-4DB1-96E7-FBCAF984B709"
@property
def bytes(self) -> bytes:
return uuid.UUID(self.value).bytes
class FilesystemType(Enum):