From e63e8314f4bc38cb63d96bf5cdb387574b2c0744 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20R=C5=AF=C5=BEi=C4=8Dka?= Date: Fri, 18 Oct 2019 12:03:37 +0200 Subject: [PATCH] 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. --- createhdds.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/createhdds.py b/createhdds.py index 3d858d9..626d9a5 100755 --- a/createhdds.py +++ b/createhdds.py @@ -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: