Add support for setting the GUID of the partition to set

its correct type.

Previously, it was not possible to set the type of the partition via
the specific GUID. This commit adds support for adding the GUID into
the gtp_type of the partition description in hdds.json and this field
will be utilized in to code.
This commit is contained in:
Lukáš Růžička 2019-10-18 12:03:37 +02:00
parent a01d22f6ef
commit e63e8314f4
1 changed files with 9 additions and 3 deletions

View File

@ -147,9 +147,15 @@ class GuestfsImage(object):
# start and end sector numbers - more details in
# guestfs docs
gfs.part_add(disk, part['type'], int(part['start']), int(part['end']))
# identify the partition and format it
partn = gfs.list_partitions()[-1]
gfs.mkfs(part['filesystem'], partn, label=part.get('label'))
# identify the partition
partname = gfs.list_partitions()[-1]
partnum = gfs.part_list(disk)[-1]["part_num"]
# sometimes, we want to set the gpt type of the partition
gpt_type = part.get("gpt_type", None)
if gpt_type:
gfs.part_set_gpt_type(disk, partnum, gpt_type)
# format the partition
gfs.mkfs(part['filesystem'], partname, label=part.get('label'))
# do file 'writes' (create a file with a given string as
# its content)
for write in self.writes: