Merge pull request #752 from mwhudson/lp-1876874

round autoinstall partition sizes using percentages down to a megabyte boundary
This commit is contained in:
Michael Hudson-Doyle 2020-05-05 23:12:24 +12:00 committed by GitHub
commit 5d05a7b95e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -37,8 +37,8 @@ storage:
- {type: partition, device: disk-2, size: 1M, wipe: superblock, flag: bios_grub, number: 1, preserve: false, id: partition-grub-2}
- {type: partition, device: disk-1, size: 1G, wipe: superblock, number: 2, preserve: false, id: partition-boot-1}
- {type: partition, device: disk-2, size: 1G, wipe: superblock, number: 2, preserve: false, id: partition-boot-2}
- {type: partition, device: disk-1, size: 3G, wipe: superblock, number: 3, preserve: false, id: partition-system-1}
- {type: partition, device: disk-2, size: 3G, wipe: superblock, number: 3, preserve: false, id: partition-system-2}
- {type: partition, device: disk-1, size: 17%, wipe: superblock, number: 3, preserve: false, id: partition-system-1}
- {type: partition, device: disk-2, size: 17%, wipe: superblock, number: 3, preserve: false, id: partition-system-2}
- {type: raid, name: md0, raidlevel: raid1, devices: [partition-boot-1, partition-boot-2], preserve: false, id: raid-boot}
- {type: raid, name: md1, raidlevel: raid1, devices: [partition-system-1, partition-system-2], preserve: false, id: raid-system}
- {type: format, fstype: ext4, volume: raid-boot, preserve: false, id: format-boot}

View File

@ -14,6 +14,7 @@ class StorageChecker:
def _check_partition(self, action):
assert 'device' in action
assert 'size' in action
assert action['size'] % 512 == 0
assert 'number' in action
assert action['device'] in self.actions
assert 'ptable' in self.actions[action['device']]
@ -49,6 +50,7 @@ class StorageChecker:
assert 'name' in action
assert 'size' in action
assert isinstance(action['size'], str)
assert int(action['size'][:-1]) % 512 == 0
assert action['volgroup'] in self.actions
def check(self, action):

View File

@ -1375,7 +1375,8 @@ class FilesystemModel(object):
elif isinstance(p.size, str):
if p.size.endswith("%"):
percentage = int(p.size[:-1])
p.size = parent.available_for_partitions*percentage//100
p.size = align_down(
parent.available_for_partitions*percentage//100)
else:
p.size = dehumanize_size(p.size)