| 1437 | |
| 1438 | |
| 1439 | class EncryptionType(StrEnum): |
| 1440 | NO_ENCRYPTION = auto() |
| 1441 | LUKS = auto() |
| 1442 | LVM_ON_LUKS = auto() |
| 1443 | LUKS_ON_LVM = auto() |
| 1444 | |
| 1445 | @classmethod |
| 1446 | def _encryption_type_mapper(cls) -> dict[str, Self]: |
| 1447 | return { |
| 1448 | tr('No Encryption'): cls.NO_ENCRYPTION, |
| 1449 | tr('LUKS'): cls.LUKS, |
| 1450 | tr('LVM on LUKS'): cls.LVM_ON_LUKS, |
| 1451 | tr('LUKS on LVM'): cls.LUKS_ON_LVM, |
| 1452 | } |
| 1453 | |
| 1454 | @classmethod |
| 1455 | def text_to_type(cls, text: str) -> Self: |
| 1456 | mapping = cls._encryption_type_mapper() |
| 1457 | return mapping[text] |
| 1458 | |
| 1459 | def type_to_text(self) -> str: |
| 1460 | mapping = self._encryption_type_mapper() |
| 1461 | type_to_text = {enctype: text for text, enctype in mapping.items()} |
| 1462 | return type_to_text[self] |
| 1463 | |
| 1464 | |
| 1465 | class _DiskEncryptionSerialization(TypedDict): |