From b141609990fa4f7305443ee6ea6fe8796604c539 Mon Sep 17 00:00:00 2001 From: Daniel Girtler Date: Sun, 24 Sep 2023 19:47:38 +1000 Subject: Fix 1669 | Refactor display of sizes in tables (#2100) * Use sector as default display * Display tables in sector size * Refactor size * Update * Update * fix flake8 --------- Co-authored-by: Daniel Girtler --- examples/config-sample.json | 17 +++-------------- examples/full_automated_installation.py | 15 +++++++++------ 2 files changed, 12 insertions(+), 20 deletions(-) (limited to 'examples') diff --git a/examples/config-sample.json b/examples/config-sample.json index ed1cc38e..d43f7ea6 100644 --- a/examples/config-sample.json +++ b/examples/config-sample.json @@ -17,9 +17,8 @@ "Boot" ], "fs_type": "fat32", - "length": { + "size": { "sector_size": null, - "total_size": null, "unit": "MiB", "value": 512 }, @@ -28,7 +27,6 @@ "obj_id": "2c3fa2d5-2c79-4fab-86ec-22d0ea1543c0", "start": { "sector_size": null, - "total_size": null, "unit": "MiB", "value": 1 }, @@ -39,9 +37,8 @@ "btrfs": [], "flags": [], "fs_type": "ext4", - "length": { + "size": { "sector_size": null, - "total_size": null, "unit": "GiB", "value": 20 }, @@ -50,7 +47,6 @@ "obj_id": "3e7018a0-363b-4d05-ab83-8e82d13db208", "start": { "sector_size": null, - "total_size": null, "unit": "MiB", "value": 513 }, @@ -61,14 +57,8 @@ "btrfs": [], "flags": [], "fs_type": "ext4", - "length": { + "size": { "sector_size": null, - "total_size": { - "sector_size": null, - "total_size": null, - "unit": "B", - "value": 250148290560 - }, "unit": "Percent", "value": 100 }, @@ -77,7 +67,6 @@ "obj_id": "ce58b139-f041-4a06-94da-1f8bad775d3f", "start": { "sector_size": null, - "total_size": null, "unit": "GiB", "value": 20 }, diff --git a/examples/full_automated_installation.py b/examples/full_automated_installation.py index 79e85348..d25575d4 100644 --- a/examples/full_automated_installation.py +++ b/examples/full_automated_installation.py @@ -23,8 +23,8 @@ device_modification = disk.DeviceModification(device, wipe=True) boot_partition = disk.PartitionModification( status=disk.ModificationStatus.Create, type=disk.PartitionType.Primary, - start=disk.Size(1, disk.Unit.MiB), - length=disk.Size(512, disk.Unit.MiB), + start=disk.Size(1, disk.Unit.MiB, device.device_info.sector_size), + length=disk.Size(512, disk.Unit.MiB, device.device_info.sector_size), mountpoint=Path('/boot'), fs_type=disk.FilesystemType.Fat32, flags=[disk.PartitionFlag.Boot] @@ -35,20 +35,23 @@ device_modification.add_partition(boot_partition) root_partition = disk.PartitionModification( status=disk.ModificationStatus.Create, type=disk.PartitionType.Primary, - start=disk.Size(513, disk.Unit.MiB), - length=disk.Size(20, disk.Unit.GiB), + start=disk.Size(513, disk.Unit.MiB, device.device_info.sector_size), + length=disk.Size(20, disk.Unit.GiB, device.device_info.sector_size), mountpoint=None, fs_type=fs_type, mount_options=[], ) device_modification.add_partition(root_partition) +start_home = root_partition.length +length_home = device.device_info.total_size - start_home + # create a new home partition home_partition = disk.PartitionModification( status=disk.ModificationStatus.Create, type=disk.PartitionType.Primary, - start=root_partition.length, - length=disk.Size(100, disk.Unit.Percent, total_size=device.device_info.total_size), + start=start_home, + length=length_home, mountpoint=Path('/home'), fs_type=fs_type, mount_options=[] -- cgit v1.2.3-70-g09d2