Merge pull request #1384 from dbungert/fsobj-ids-v2

filesystem: part ids are not part nums
This commit is contained in:
Dan Bungert 2022-08-09 17:26:04 -06:00 committed by GitHub
commit b2510de9a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 3 deletions

View File

@ -23,6 +23,7 @@ import math
import os
import pathlib
import platform
import random
import tempfile
from curtin import storage_config
@ -42,12 +43,15 @@ GiB = 1024 * 1024 * 1024
def _set_backlinks(obj):
if obj.id is None:
base = obj.type
i = 0
num = len(obj._m._all_ids) + 1
while True:
val = "%s-%s" % (base, i)
# Create a semireadable id.
# The number on the end is not particularly meaningful,
# notably on a partition it is (usually) not the partition number.
rand = random.randint(0, 16**2 - 1)
val = f'{base}-{rand:02x}-{num}'
if val not in obj._m._all_ids:
break
i += 1
obj.id = val
obj._m._all_ids.add(obj.id)
for field in attr.fields(type(obj)):