| 56 | |
| 57 | @dataclass |
| 58 | class DiskLayoutConfiguration(SubConfig): |
| 59 | config_type: DiskLayoutType |
| 60 | device_modifications: list[DeviceModification] = field(default_factory=list) |
| 61 | lvm_config: LvmConfiguration | None = None |
| 62 | disk_encryption: DiskEncryption | None = None |
| 63 | btrfs_options: BtrfsOptions | None = None |
| 64 | |
| 65 | # used for pre-mounted config |
| 66 | mountpoint: Path | None = None |
| 67 | |
| 68 | @override |
| 69 | def json(self) -> _DiskLayoutConfigurationSerialization: |
| 70 | if self.config_type == DiskLayoutType.Pre_mount: |
| 71 | return { |
| 72 | 'config_type': self.config_type.value, |
| 73 | 'mountpoint': str(self.mountpoint), |
| 74 | } |
| 75 | else: |
| 76 | config: _DiskLayoutConfigurationSerialization = { |
| 77 | 'config_type': self.config_type.value, |
| 78 | 'device_modifications': [mod.json() for mod in self.device_modifications], |
| 79 | } |
| 80 | |
| 81 | if self.lvm_config: |
| 82 | config['lvm_config'] = self.lvm_config.json() |
| 83 | |
| 84 | if self.disk_encryption: |
| 85 | config['disk_encryption'] = self.disk_encryption.json() |
| 86 | |
| 87 | if self.btrfs_options: |
| 88 | config['btrfs_options'] = self.btrfs_options.json() |
| 89 | |
| 90 | return config |
| 91 | |
| 92 | @override |
| 93 | def summary(self) -> list[str]: |
| 94 | out = [tr('{} layout').format(self.config_type.short_msg())] |
| 95 | |
| 96 | devices = set(mod.device_path for mod in self.device_modifications) |
| 97 | |
| 98 | if devices: |
| 99 | dev_str = ', '.join(str(d) for d in devices) |
| 100 | out.append(tr('Devices {}').format(dev_str)) |
| 101 | |
| 102 | if self.lvm_config is not None: |
| 103 | out.append(tr('LVM set up')) |
| 104 | |
| 105 | if self.disk_encryption is not None: |
| 106 | out.append(tr('{} encryption').format(self.disk_encryption.encryption_type.type_to_text())) |
| 107 | |
| 108 | if self.btrfs_options is not None: |
| 109 | if self.btrfs_options.snapshot_config: |
| 110 | out.append(tr('Btrfs snapshot "{}"').format(self.btrfs_options.snapshot_config.snapshot_type)) |
| 111 | |
| 112 | return out |
| 113 | |
| 114 | @classmethod |
| 115 | def parse_arg( |
no outgoing calls